r300: fix vertex program bug
authorMaciej Cencora <m.cencora@gmail.com>
Fri, 5 Jun 2009 16:32:05 +0000 (18:32 +0200)
committerMaciej Cencora <m.cencora@gmail.com>
Thu, 11 Jun 2009 21:24:25 +0000 (23:24 +0200)
If the vertex program didn't write position attribute, the position invariant function would add necessary instructions, but the vertex position would be overwritten by artificial outputs insts added to satisfy fragment program requirements.

Fixes "whole screen is gray" problem for HW TCL path in sauerbraten when shaders are enabled, and whole slew of wine d3d9 tests.

src/mesa/drivers/dri/r300/r300_vertprog.c

index 66750b1c659bc7836f6a2486623178bcf15bd898..c41a8fdd621a373f3288febfea349268982ad8de 100644 (file)
@@ -1456,7 +1456,12 @@ void r300SelectVertexShader(r300ContextPtr r300)
                wpos_idx = i;
        }
 
-       add_outputs(&wanted_key, VERT_RESULT_HPOS);
+       if (vpc->mesa_program.IsPositionInvariant) {
+               wanted_key.InputsRead |= (1 << VERT_ATTRIB_POS);
+               wanted_key.OutputsWritten |= (1 << VERT_RESULT_HPOS);
+       } else {
+               add_outputs(&wanted_key, VERT_RESULT_HPOS);
+       }
 
        if (InputsRead & FRAG_BIT_COL0) {
                add_outputs(&wanted_key, VERT_RESULT_COL0);
@@ -1466,17 +1471,16 @@ void r300SelectVertexShader(r300ContextPtr r300)
                add_outputs(&wanted_key, VERT_RESULT_COL1);
        }
 
+       if (InputsRead & FRAG_BIT_FOGC) {
+               add_outputs(&wanted_key, VERT_RESULT_FOGC);
+       }
+
        for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
                if (InputsRead & (FRAG_BIT_TEX0 << i)) {
                        add_outputs(&wanted_key, VERT_RESULT_TEX0 + i);
                }
        }
 
-       if (vpc->mesa_program.IsPositionInvariant) {
-               /* we wan't position don't we ? */
-               wanted_key.InputsRead |= (1 << VERT_ATTRIB_POS);
-       }
-
        for (vp = vpc->progs; vp; vp = vp->next)
                if (_mesa_memcmp(&vp->key, &wanted_key, sizeof(wanted_key))
                    == 0) {