Go to the source code of this file.
Functions | |
static void | calculate_vertex_layout (struct cell_context *cell) |
Determine how to map vertex program outputs to fragment program inputs. | |
void | cell_update_derived (struct cell_context *cell) |
Update derived state, send current state to SPUs prior to rendering. |
static void calculate_vertex_layout | ( | struct cell_context * | cell | ) | [static] |
Determine how to map vertex program outputs to fragment program inputs.
Basically, this will be used when computing the triangle interpolation coefficients from the post-transform vertex attributes.
Definition at line 44 of file cell_state_derived.c.
References assert, CELL_NEW_VERTEX_INFO, cell_context::dirty, cell_context::draw, draw_compute_vertex_size(), draw_emit_vertex_attr(), draw_find_vs_output(), EMIT_1F, EMIT_4F, pipe_rasterizer_state::flatshade, cell_context::fs, cell_fragment_shader_state::info, tgsi_shader_info::input_semantic_index, tgsi_shader_info::input_semantic_name, INTERP_CONSTANT, INTERP_LINEAR, INTERP_NONE, INTERP_PERSPECTIVE, INTERP_POS, vertex_info::num_attribs, tgsi_shader_info::num_inputs, cell_context::rasterizer, vertex_info::size, TGSI_SEMANTIC_COLOR, TGSI_SEMANTIC_FOG, TGSI_SEMANTIC_GENERIC, TGSI_SEMANTIC_POSITION, cell_context::vbuf, and cell_context::vertex_info.
00045 { 00046 const struct cell_fragment_shader_state *fs = cell->fs; 00047 const enum interp_mode colorInterp 00048 = cell->rasterizer->flatshade ? INTERP_CONSTANT : INTERP_LINEAR; 00049 struct vertex_info *vinfo = &cell->vertex_info; 00050 uint i; 00051 int src; 00052 00053 #if 0 00054 if (cell->vbuf) { 00055 /* if using the post-transform vertex buffer, tell draw_vbuf to 00056 * simply emit the whole post-xform vertex as-is: 00057 */ 00058 struct vertex_info *vinfo_vbuf = &cell->vertex_info_vbuf; 00059 vinfo_vbuf->num_attribs = 0; 00060 draw_emit_vertex_attr(vinfo_vbuf, EMIT_ALL, INTERP_NONE, 0); 00061 vinfo_vbuf->size = 4 * vs->num_outputs + sizeof(struct vertex_header)/4; 00062 } 00063 #endif 00064 00065 /* reset vinfo */ 00066 vinfo->num_attribs = 0; 00067 00068 /* we always want to emit vertex pos */ 00069 src = draw_find_vs_output(cell->draw, TGSI_SEMANTIC_POSITION, 0); 00070 assert(src >= 0); 00071 draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_POS, src); 00072 00073 00074 /* 00075 * Loop over fragment shader inputs, searching for the matching output 00076 * from the vertex shader. 00077 */ 00078 for (i = 0; i < fs->info.num_inputs; i++) { 00079 switch (fs->info.input_semantic_name[i]) { 00080 case TGSI_SEMANTIC_POSITION: 00081 /* already done above */ 00082 break; 00083 00084 case TGSI_SEMANTIC_COLOR: 00085 src = draw_find_vs_output(cell->draw, TGSI_SEMANTIC_COLOR, 00086 fs->info.input_semantic_index[i]); 00087 assert(src >= 0); 00088 draw_emit_vertex_attr(vinfo, EMIT_4F, colorInterp, src); 00089 break; 00090 00091 case TGSI_SEMANTIC_FOG: 00092 src = draw_find_vs_output(cell->draw, TGSI_SEMANTIC_FOG, 0); 00093 #if 1 00094 if (src < 0) /* XXX temp hack, try demos/fogcoord.c with this */ 00095 src = 0; 00096 #endif 00097 assert(src >= 0); 00098 draw_emit_vertex_attr(vinfo, EMIT_1F, INTERP_PERSPECTIVE, src); 00099 break; 00100 00101 case TGSI_SEMANTIC_GENERIC: 00102 /* this includes texcoords and varying vars */ 00103 src = draw_find_vs_output(cell->draw, TGSI_SEMANTIC_GENERIC, 00104 fs->info.input_semantic_index[i]); 00105 assert(src >= 0); 00106 draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, src); 00107 break; 00108 00109 default: 00110 assert(0); 00111 } 00112 } 00113 00114 draw_compute_vertex_size(vinfo); 00115 00116 /* XXX only signal this if format really changes */ 00117 cell->dirty |= CELL_NEW_VERTEX_INFO; 00118 }
void cell_update_derived | ( | struct cell_context * | cell | ) |
Update derived state, send current state to SPUs prior to rendering.
Definition at line 152 of file cell_state_derived.c.
00154 { 00155 if (cell->dirty & (CELL_NEW_RASTERIZER | 00156 CELL_NEW_FS | 00157 CELL_NEW_VS)) 00158 calculate_vertex_layout( cell ); 00159 00160 #if 0 00161 if (cell->dirty & (CELL_NEW_SCISSOR | 00162 CELL_NEW_DEPTH_STENCIL_ALPHA | 00163 CELL_NEW_FRAMEBUFFER)) 00164 compute_cliprect(cell); 00165 #endif 00166 00167 cell_emit_state(cell); 00168 00169 cell->dirty = 0;