st/mesa: fix glDrawPixels(GL_DEPTH_COMPONENT) color output
authorBrian Paul <brianp@vmware.com>
Fri, 8 Jun 2012 20:26:53 +0000 (14:26 -0600)
committerBrian Paul <brianp@vmware.com>
Thu, 14 Jun 2012 20:37:31 +0000 (14:37 -0600)
When drawing a depth image the fragment shader also needs to emit the
current raster color.

The new piglit drawpix-z test exercises this.

NOTE: This is a candiate for the 8.0 branch.

src/mesa/state_tracker/st_cb_drawpixels.c

index 9a3f22465c6dd5418043185cb8bdd867bc356f07..d3f8d1368955e4b71bb73ce3f8375cd46dec3d26 100644 (file)
@@ -217,7 +217,7 @@ st_make_drawpix_z_stencil_program(struct st_context *st,
    if (!p)
       return NULL;
 
-   p->NumInstructions = write_depth ? 2 : 1;
+   p->NumInstructions = write_depth ? 3 : 1;
    p->NumInstructions += write_stencil ? 1 : 0;
 
    p->Instructions = _mesa_alloc_instructions(p->NumInstructions);
@@ -238,6 +238,13 @@ st_make_drawpix_z_stencil_program(struct st_context *st,
       p->Instructions[ic].TexSrcUnit = 0;
       p->Instructions[ic].TexSrcTarget = TEXTURE_2D_INDEX;
       ic++;
+      /* MOV result.color, fragment.color; */
+      p->Instructions[ic].Opcode = OPCODE_MOV;
+      p->Instructions[ic].DstReg.File = PROGRAM_OUTPUT;
+      p->Instructions[ic].DstReg.Index = FRAG_RESULT_COLOR;
+      p->Instructions[ic].SrcReg[0].File = PROGRAM_INPUT;
+      p->Instructions[ic].SrcReg[0].Index = FRAG_ATTRIB_COL0;
+      ic++;
    }
 
    if (write_stencil) {
@@ -260,8 +267,10 @@ st_make_drawpix_z_stencil_program(struct st_context *st,
 
    p->InputsRead = FRAG_BIT_TEX0 | FRAG_BIT_COL0;
    p->OutputsWritten = 0;
-   if (write_depth)
+   if (write_depth) {
       p->OutputsWritten |= BITFIELD64_BIT(FRAG_RESULT_DEPTH);
+      p->OutputsWritten |= BITFIELD64_BIT(FRAG_RESULT_COLOR);
+   }
    if (write_stencil)
       p->OutputsWritten |= BITFIELD64_BIT(FRAG_RESULT_STENCIL);