r600_pipe.h revision 58c243905b0cfcbf1b0299a0f7f0ea90755e36cc
18d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt/* 28d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Copyright 2010 Jerome Glisse <glisse@freedesktop.org> 38d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * 48d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Permission is hereby granted, free of charge, to any person obtaining a 5c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt * copy of this software and associated documentation files (the "Software"), 6c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt * to deal in the Software without restriction, including without limitation 78d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * on the rights to use, copy, modify, merge, publish, distribute, sub 88d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * license, and/or sell copies of the Software, and to permit persons to whom 98d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * the Software is furnished to do so, subject to the following conditions: 108d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * 118d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * The above copyright notice and this permission notice (including the next 128d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * paragraph) shall be included in all copies or substantial portions of the 138d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Software. 148d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * 158d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 168d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 178d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 188d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, 198d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 208d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 218d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * USE OR OTHER DEALINGS IN THE SOFTWARE. 228d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * 238d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Authors: 248d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Jerome Glisse 258d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt */ 268d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#ifndef R600_PIPE_H 278d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#define R600_PIPE_H 288d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 2961d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidtenum r600_pipe_state_id { 308d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt R600_PIPE_STATE_BLEND = 0, 318d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt R600_PIPE_STATE_BLEND_COLOR, 328d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt R600_PIPE_STATE_CONFIG, 338d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt R600_PIPE_STATE_CLIP, 348d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt R600_PIPE_STATE_SCISSOR, 358d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt R600_PIPE_STATE_VIEWPORT, 368d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt R600_PIPE_STATE_RASTERIZER, 378d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt R600_PIPE_STATE_VGT, 388d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt R600_PIPE_STATE_FRAMEBUFFER, 398d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt R600_PIPE_STATE_DSA, 408d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt R600_PIPE_STATE_STENCIL_REF, 418d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt R600_PIPE_STATE_PS_SHADER, 428d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt R600_PIPE_STATE_VS_SHADER, 438d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt R600_PIPE_STATE_CONSTANT, 448d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt R600_PIPE_STATE_SAMPLER, 458d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt R600_PIPE_STATE_RESOURCE, 468d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt R600_PIPE_NSTATES 478d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}; 4834af306c42b7ccf956508e7cd23f0ba90606e360Dmitry Shmidt 498d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtstruct r600_screen { 508d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt struct pipe_screen screen; 51 struct radeon *radeon; 52}; 53 54struct r600_pipe_sampler_view { 55 struct pipe_sampler_view base; 56 struct r600_pipe_state state; 57}; 58 59struct r600_pipe_rasterizer { 60 struct r600_pipe_state rstate; 61 bool flatshade; 62 unsigned sprite_coord_enable; 63 float offset_units; 64 float offset_scale; 65}; 66 67struct r600_pipe_blend { 68 struct r600_pipe_state rstate; 69 unsigned cb_target_mask; 70}; 71 72struct r600_pipe_shader { 73 struct r600_shader shader; 74 struct r600_pipe_state rstate; 75 struct radeon_ws_bo *bo; 76}; 77 78struct r600_vertex_element 79{ 80 unsigned count; 81 unsigned refcount; 82 struct pipe_vertex_element elements[32]; 83}; 84 85struct r600_pipe_context { 86 struct pipe_context context; 87 struct r600_screen *screen; 88 struct radeon *radeon; 89 struct blitter_context *blitter; 90 struct r600_pipe_state *states[R600_PIPE_NSTATES]; 91 struct r600_context ctx; 92 struct r600_vertex_element *vertex_elements; 93 struct pipe_framebuffer_state framebuffer; 94 struct pipe_index_buffer index_buffer; 95 struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS]; 96 unsigned nvertex_buffer; 97 unsigned cb_target_mask; 98 /* for saving when using blitter */ 99 struct pipe_stencil_ref stencil_ref; 100 struct pipe_viewport_state viewport; 101 struct pipe_clip_state clip; 102 unsigned vs_nconst; 103 unsigned ps_nconst; 104 struct r600_pipe_state vs_const[256]; 105 struct r600_pipe_state ps_const[256]; 106 struct r600_pipe_state vs_resource[160]; 107 struct r600_pipe_state ps_resource[160]; 108 struct r600_pipe_state config; 109 struct r600_pipe_shader *ps_shader; 110 struct r600_pipe_shader *vs_shader; 111 struct r600_pipe_state vs_const_buffer; 112 struct r600_pipe_state ps_const_buffer; 113 struct r600_pipe_rasterizer *rasterizer; 114 /* shader information */ 115 unsigned sprite_coord_enable; 116 bool flatshade; 117 struct u_upload_mgr *upload_vb; 118 struct u_upload_mgr *upload_ib; 119 enum radeon_family family; 120 unsigned any_user_vbs; 121}; 122 123struct r600_drawl { 124 struct pipe_context *ctx; 125 unsigned mode; 126 unsigned min_index; 127 unsigned max_index; 128 unsigned index_bias; 129 unsigned start; 130 unsigned count; 131 unsigned index_size; 132 unsigned index_buffer_offset; 133 struct pipe_resource *index_buffer; 134}; 135 136uint32_t r600_translate_texformat(enum pipe_format format, 137 const unsigned char *swizzle_view, 138 uint32_t *word4_p, uint32_t *yuv_format_p); 139 140/* r600_state2.c */ 141int r600_pipe_shader_update2(struct pipe_context *ctx, struct r600_pipe_shader *shader); 142int r600_pipe_shader_create2(struct pipe_context *ctx, struct r600_pipe_shader *shader, const struct tgsi_token *tokens); 143int r600_upload_index_buffer2(struct r600_pipe_context *rctx, struct r600_drawl *draw); 144int r600_upload_user_buffers2(struct r600_pipe_context *rctx); 145void r600_translate_index_buffer2(struct r600_pipe_context *r600, 146 struct pipe_resource **index_buffer, 147 unsigned *index_size, 148 unsigned *start, unsigned count); 149 150/* evergreen_state.c */ 151void evergreen_init_state_functions2(struct r600_pipe_context *rctx); 152void evergreen_init_config2(struct r600_pipe_context *rctx); 153void evergreen_draw(struct pipe_context *ctx, const struct pipe_draw_info *info); 154void evergreen_pipe_shader_ps(struct pipe_context *ctx, struct r600_pipe_shader *shader); 155void evergreen_pipe_shader_vs(struct pipe_context *ctx, struct r600_pipe_shader *shader); 156 157static INLINE u32 S_FIXED(float value, u32 frac_bits) 158{ 159 return value * (1 << frac_bits); 160} 161#define ALIGN_DIVUP(x, y) (((x) + (y) - 1) / (y)) 162 163#endif 164