r5xx: Enable depth write emission.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Sun, 1 Jun 2008 18:45:30 +0000 (11:45 -0700)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Sun, 1 Jun 2008 18:45:30 +0000 (11:45 -0700)
Thanks to nh for the r3xx version.

src/mesa/drivers/dri/r300/r300_context.h
src/mesa/drivers/dri/r300/r300_state.c
src/mesa/drivers/dri/r300/r500_fragprog.c

index 817f783dffbfae8b3e49e6928467aa8f19e4593b..a5ec5ee46e24071213868fb97dec5fbadaba2351 100644 (file)
@@ -833,6 +833,8 @@ struct r500_fragment_program {
 
        int max_temp_idx;
 
+       GLboolean writes_depth;
+
        GLuint optimization;
 };
 
index f0a5176949d80d4fd164ba426b5cac7b9310113c..550f71085423df6bcd58eeb069c4b34983881253 100644 (file)
@@ -411,7 +411,10 @@ static GLboolean current_fragment_program_writes_depth(GLcontext* ctx)
                        (char *)ctx->FragmentProgram._Current;
                return (fp && fp->WritesDepth);
        } else {
-               return GL_FALSE; /* TODO: Verify depth writing works on R5xx */
+               struct r500_fragment_program* fp =
+                       (struct r500_fragment_program*)(char*)
+                       ctx->FragmentProgram._Current;
+               return (fp && fp->writes_depth);
        }
 }
 
index a2312187a69cc825522439175814eb931d900b9d..d5ae4a5f749b7584a610d59498ab88ec0377d47d 100644 (file)
@@ -365,7 +365,9 @@ static void emit_alu(struct r500_fragment_program *fp, int counter, struct prog_
                        fp->inst[counter].inst0 |= (fpi->DstReg.WriteMask << 15);
 
                if (fpi->DstReg.Index == FRAG_RESULT_DEPR)
-                       fp->inst[counter].inst4 = R500_ALPHA_W_OMASK;
+                       fp->inst[counter].inst4 |= R500_ALPHA_W_OMASK;
+                       /* Notify the state emission! */
+                       fp->writes_depth = GL_TRUE;
        } else {
                fp->inst[counter].inst0 = R500_INST_TYPE_ALU
                        /* pixel_mask */
@@ -1251,6 +1253,8 @@ static void init_program(r300ContextPtr r300, struct r500_fragment_program *fp)
        fp->max_temp_idx = 1;
        /* Temp register offset. */
        fp->temp_reg_offset = 0;
+       /* Whether or not we perform any depth writing. */
+       fp->writes_depth = GL_FALSE;
 
        _mesa_memset(cs, 0, sizeof(*fp->cs));
        for (i = 0; i < PFS_MAX_ALU_INST; i++) {