diff options
Diffstat (limited to 'src/mesa/pipe/softpipe/sp_state_derived.c')
-rw-r--r-- | src/mesa/pipe/softpipe/sp_state_derived.c | 73 |
1 files changed, 48 insertions, 25 deletions
diff --git a/src/mesa/pipe/softpipe/sp_state_derived.c b/src/mesa/pipe/softpipe/sp_state_derived.c index 74d34c50a8..d399868f24 100644 --- a/src/mesa/pipe/softpipe/sp_state_derived.c +++ b/src/mesa/pipe/softpipe/sp_state_derived.c @@ -33,6 +33,22 @@ #include "sp_state.h" +static int +find_vs_output(const struct pipe_shader_state *vs, + uint semantic_name, + uint semantic_index) +{ + uint i; + for (i = 0; i < vs->num_outputs; i++) { + if (vs->output_semantic_name[i] == semantic_name && + vs->output_semantic_index[i] == semantic_index) + return i; + } + return -1; +} + + + /** * Determine which post-transform / pre-rasterization vertex attributes * we need. @@ -46,6 +62,7 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) = softpipe->rasterizer->flatshade ? INTERP_CONSTANT : INTERP_LINEAR; struct vertex_info *vinfo = &softpipe->vertex_info; uint i; + int src; memset(vinfo, 0, sizeof(*vinfo)); @@ -56,6 +73,11 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) draw_emit_vertex_attr(vinfo, FORMAT_HEADER, INTERP_LINEAR, 0); } + /* always emit pos for softpipe rasterization */ + src = find_vs_output(vs, TGSI_SEMANTIC_POSITION, 0); + assert(src >= 0); + draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_LINEAR, src); + /* * XXX I think we need to reconcile the vertex shader outputs with * the fragment shader inputs here to make sure the slots line up. @@ -63,42 +85,36 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) * Or maybe do that in the state tracker? */ - for (i = 0; i < vs->num_outputs; i++) { - switch (vs->output_semantic_name[i]) { + for (i = 0; i < fs->num_inputs; i++) { + switch (fs->input_semantic_name[i]) { case TGSI_SEMANTIC_POSITION: - draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_LINEAR, i); + /* handled above */ break; case TGSI_SEMANTIC_COLOR: - if (vs->output_semantic_index[i] == 0) { - draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp, i); - } - else { - assert(vs->output_semantic_index[i] == 1); - draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp, i); - } - break; - - case TGSI_SEMANTIC_BCOLOR: - /* no-op */ + src = find_vs_output(vs, TGSI_SEMANTIC_COLOR, + fs->input_semantic_index[i]); + assert(src >= 0); + draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp, src); break; case TGSI_SEMANTIC_FOG: - draw_emit_vertex_attr(vinfo, FORMAT_1F, INTERP_PERSPECTIVE, i); - break; - - case TGSI_SEMANTIC_PSIZE: - /* XXX only emit if drawing points or front/back polygon mode - * is point mode - */ - softpipe->psize_slot - = draw_emit_vertex_attr(vinfo, FORMAT_1F, INTERP_CONSTANT, i); + src = find_vs_output(vs, TGSI_SEMANTIC_FOG, 0); +#if 1 + if (src < 0) /* XXX temp hack, try demos/fogcoord.c with this */ + src = 0; +#endif + assert(src >= 0); + draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_PERSPECTIVE, src); break; case TGSI_SEMANTIC_GENERIC: /* this includes texcoords and varying vars */ - draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_PERSPECTIVE, i); + src = find_vs_output(vs, TGSI_SEMANTIC_GENERIC, + fs->input_semantic_index[i]); + assert(src >= 0); + draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_PERSPECTIVE, src); break; default: @@ -106,6 +122,13 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) } } + src = find_vs_output(vs, TGSI_SEMANTIC_PSIZE, 0); + if (src >= 0) { + softpipe->psize_slot = src; + draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_CONSTANT, src); + } + + draw_compute_vertex_size(vinfo); softpipe->nr_frag_attrs = fs->num_inputs; @@ -152,7 +175,7 @@ compute_cliprect(struct softpipe_context *sp) */ void softpipe_update_derived( struct softpipe_context *softpipe ) { - if (softpipe->dirty & (SP_NEW_RASTERIZER | SP_NEW_FS)) + if (softpipe->dirty & (SP_NEW_RASTERIZER | SP_NEW_FS | SP_NEW_VS)) calculate_vertex_layout( softpipe ); if (softpipe->dirty & (SP_NEW_SCISSOR | |