nouveau: avoid using uninitialised TexSrcUnit.
authorBen Skeggs <skeggsb@gmail.com>
Sun, 18 Mar 2007 13:08:45 +0000 (00:08 +1100)
committerBen Skeggs <skeggsb@gmail.com>
Sun, 18 Mar 2007 13:13:41 +0000 (00:13 +1100)
src/mesa/drivers/dri/nouveau/nouveau_shader_0.c

index 73c1f7c2a538b393e98796bcce4c7a97ec5347f7..211483dc027e6681eaf37a589d7d277596abd8c0 100644 (file)
@@ -263,6 +263,23 @@ pass0_make_mask(GLuint mesa_mask)
        return mask;
 }
 
+static GLboolean
+pass0_opcode_is_tex(enum prog_opcode op)
+{
+       switch (op) {
+       case OPCODE_TEX:
+       case OPCODE_TXB:
+       case OPCODE_TXD:
+       case OPCODE_TXL:
+       case OPCODE_TXP:
+               return GL_TRUE;
+       default:
+               break;
+       }
+
+       return GL_FALSE;
+}
+
 static nvsTexTarget
 pass0_make_tex_target(GLuint mesa)
 {
@@ -721,7 +738,11 @@ pass0_translate_arith(nouveauShader *nvs, struct gl_program *prog,
                                (inst->SaturateMode != SATURATE_OFF),
                                src[0], src[1], src[2]);
                nvsinst->tex_unit   = inst->TexSrcUnit;
-               nvsinst->tex_target = pass0_make_tex_target(inst->TexSrcTarget);
+               if (pass0_opcode_is_tex(inst->Opcode))
+                       nvsinst->tex_target =
+                               pass0_make_tex_target(inst->TexSrcTarget);
+               else
+                       nvsinst->tex_target = NVS_TEX_TARGET_UNKNOWN;
 
                ret = GL_TRUE;
        } else