mesa: Don't append fog code for programs that don't output color.
authorJosé Fonseca <jfonseca@vmware.com>
Wed, 11 May 2011 13:01:17 +0000 (14:01 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Wed, 11 May 2011 13:04:08 +0000 (14:04 +0100)
Fixes fdo 36919.

NOTE: This is a candidate for the stable branches.

It should be cherry-picked to the sames branches that
3aa21f93dc1329c6f956277f2746c2a0bdae5446 was.

src/mesa/program/programopt.c

index a239da2..c72dfb2 100644 (file)
@@ -267,6 +267,11 @@ _mesa_append_fog_code(struct gl_context *ctx,
       return;
    }
 
+   if (!(fprog->Base.OutputsWritten & (1 << FRAG_RESULT_COLOR))) {
+      /* program doesn't output color, so nothing to do */
+      return;
+   }
+
    /* Alloc storage for new instructions */
    newInst = _mesa_alloc_instructions(newLen);
    if (!newInst) {
@@ -407,6 +412,7 @@ _mesa_append_fog_code(struct gl_context *ctx,
    fprog->Base.Instructions = newInst;
    fprog->Base.NumInstructions = inst - newInst;
    fprog->Base.InputsRead |= FRAG_BIT_FOGC;
+   assert(fprog->Base.OutputsWritten & (1 << FRAG_RESULT_COLOR));
 }