From: Brian Date: Fri, 15 Feb 2008 02:18:09 +0000 (-0700) Subject: gallium: remove some debug assertions in vertex format validation X-Git-Tag: android-x86-1.6~16^2~1465^2~390^2~2618^2~15 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=663f4aaae618a8f031fa1a6b5292ddc57698741c;p=android-x86%2Fexternal-mesa.git gallium: remove some debug assertions in vertex format validation If a fragment shader references an input for which there's no vertex shader output (ex: texcoord3), use vertex output 0 by default. Basically, the attribute's value will be undefined. The shader writer should never rely on undefined fragment shader inputs anyway. --- diff --git a/src/mesa/pipe/softpipe/sp_state_derived.c b/src/mesa/pipe/softpipe/sp_state_derived.c index 9e4c35e696f..372597869f3 100644 --- a/src/mesa/pipe/softpipe/sp_state_derived.c +++ b/src/mesa/pipe/softpipe/sp_state_derived.c @@ -34,6 +34,15 @@ #include "sp_state.h" +/** + * Search vertex program's outputs to find a match for the given + * semantic name/index. Return the index of the output slot. + * + * Return 0 if not found. This will cause the fragment program to use + * vertex attrib 0 (position) in the cases where the fragment program + * attempts to use a missing vertex program output. This is an undefined + * condition that users shouldn't hit anyway. + */ static int find_vs_output(const struct pipe_shader_state *vs, uint semantic_name, @@ -45,7 +54,7 @@ find_vs_output(const struct pipe_shader_state *vs, vs->output_semantic_index[i] == semantic_index) return i; } - return -1; + return 0; } @@ -103,26 +112,17 @@ softpipe_get_vertex_info(struct softpipe_context *softpipe) switch (fs->input_semantic_name[i]) { case TGSI_SEMANTIC_POSITION: src = find_vs_output(vs, TGSI_SEMANTIC_POSITION, 0); - assert(src >= 0); draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_POS, src); break; case TGSI_SEMANTIC_COLOR: src = find_vs_output(vs, TGSI_SEMANTIC_COLOR, fs->input_semantic_index[i]); - if (src < 0) - src = 0; - assert(src >= 0); draw_emit_vertex_attr(vinfo, EMIT_4F, colorInterp, src); break; case TGSI_SEMANTIC_FOG: 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, EMIT_4F, INTERP_PERSPECTIVE, src); break; @@ -130,7 +130,6 @@ softpipe_get_vertex_info(struct softpipe_context *softpipe) /* this includes texcoords and varying vars */ src = find_vs_output(vs, TGSI_SEMANTIC_GENERIC, fs->input_semantic_index[i]); - assert(src >= 0); draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, src); break; @@ -140,7 +139,7 @@ softpipe_get_vertex_info(struct softpipe_context *softpipe) } softpipe->psize_slot = find_vs_output(vs, TGSI_SEMANTIC_PSIZE, 0); - if (softpipe->psize_slot >= 0) { + if (softpipe->psize_slot > 0) { draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_CONSTANT, softpipe->psize_slot); }