i965: Fix source depth reg setting for FSes reading and writing to depth.
authorEric Anholt <eric@anholt.net>
Thu, 6 Aug 2009 03:12:15 +0000 (20:12 -0700)
committerEric Anholt <eric@anholt.net>
Fri, 4 Sep 2009 21:12:36 +0000 (14:12 -0700)
For some IZ setups, we'd forget to account for the source depth register
being present, so we'd both read the wrong reg, and write output depth to
the wrong reg.

Bug #22603.
(cherry picked from commit f44916414ecd2b888c8a680d56b7467ccdff6886)

src/mesa/drivers/dri/i965/brw_wm.c
src/mesa/drivers/dri/i965/brw_wm.h
src/mesa/drivers/dri/i965/brw_wm_iz.c

index 8a3b7df9c7892e07be8368c51463118a4074364b..d4e22d593967727a4844cad6a936252f2315d182 100644 (file)
@@ -202,6 +202,7 @@ static void brw_wm_populate_key( struct brw_context *brw,
    /* BRW_NEW_FRAGMENT_PROGRAM */
    const struct brw_fragment_program *fp = 
       (struct brw_fragment_program *)brw->fragment_program;
+   GLboolean uses_depth = (fp->program.Base.InputsRead & (1 << FRAG_ATTRIB_WPOS)) != 0;
    GLuint lookup = 0;
    GLuint line_aa;
    GLuint i;
@@ -263,6 +264,7 @@ static void brw_wm_populate_key( struct brw_context *brw,
         
    brw_wm_lookup_iz(line_aa,
                    lookup,
+                   uses_depth,
                    key);
 
 
index 295fed851bb609d13294f1be1ce75d69e9afe749..307b5e59ddecb349ab43e118c9f59ee9fccc8a8d 100644 (file)
@@ -286,6 +286,7 @@ void brw_wm_print_program( struct brw_wm_compile *c,
 
 void brw_wm_lookup_iz( GLuint line_aa,
                       GLuint lookup,
+                      GLboolean ps_uses_depth,
                       struct brw_wm_prog_key *key );
 
 GLboolean brw_wm_is_glsl(const struct gl_fragment_program *fp);
index bd60ac9b3159542012e953d824057031a9318499..7e2b1c79dedf1293604f533919ae0fa590be39d4 100644 (file)
@@ -118,6 +118,7 @@ const struct {
 
 void brw_wm_lookup_iz( GLuint line_aa,
                       GLuint lookup,
+                      GLboolean ps_uses_depth,
                       struct brw_wm_prog_key *key )
 {
    GLuint reg = 2;
@@ -127,7 +128,7 @@ void brw_wm_lookup_iz( GLuint line_aa,
    if (lookup & IZ_PS_COMPUTES_DEPTH_BIT)
       key->computes_depth = 1;
 
-   if (wm_iz_table[lookup].sd_present) {
+   if (wm_iz_table[lookup].sd_present || ps_uses_depth) {
       key->source_depth_reg = reg;
       reg += 2;
    }