Fix stencil clears that have caused problems with redbook/stencil, tests/stencilwrap...
authorAapo Tahkola <aet@rasterburn.org>
Tue, 27 Jun 2006 01:46:11 +0000 (01:46 +0000)
committerAapo Tahkola <aet@rasterburn.org>
Tue, 27 Jun 2006 01:46:11 +0000 (01:46 +0000)
src/mesa/drivers/dri/r300/r300_ioctl.c

index 2a2eef58120a209bf79edc8144a62d8327fb5f6b..a05a29b7e1b66310c086c178574f592a89ef2dcd 100644 (file)
@@ -218,32 +218,18 @@ static void r300ClearBuffer(r300ContextPtr r300, int flags, int buffer)
        r300->hw.vpi.cmd[8] = 0;
 
        R300_STATECHANGE(r300, zs);
+       r300->hw.zs.cmd[R300_ZS_CNTL_0] = 0;
+       r300->hw.zs.cmd[R300_ZS_CNTL_1] = 0;
        if (flags & CLEARBUFFER_DEPTH) {
-               r300->hw.zs.cmd[R300_ZS_CNTL_0] &= R300_RB3D_STENCIL_ENABLE;
-               r300->hw.zs.cmd[R300_ZS_CNTL_0] |= 0x6; // test and write
-               r300->hw.zs.cmd[R300_ZS_CNTL_1] &= ~(R300_ZS_MASK << R300_RB3D_ZS1_DEPTH_FUNC_SHIFT);
+               r300->hw.zs.cmd[R300_ZS_CNTL_0] |= R300_RB3D_Z_WRITE_ONLY;
                r300->hw.zs.cmd[R300_ZS_CNTL_1] |= (R300_ZS_ALWAYS<<R300_RB3D_ZS1_DEPTH_FUNC_SHIFT);
-/*
-               R300_STATECHANGE(r300, zb);
-               r300->hw.zb.cmd[R300_ZB_OFFSET] =
-                       1024*4*300 +
-                       r300->radeon.radeonScreen->frontOffset +
-                       r300->radeon.radeonScreen->fbLocation;
-               r300->hw.zb.cmd[R300_ZB_PITCH] =
-                       r300->radeon.radeonScreen->depthPitch;
-*/
        } else {
-               r300->hw.zs.cmd[R300_ZS_CNTL_0] &= R300_RB3D_STENCIL_ENABLE;
                r300->hw.zs.cmd[R300_ZS_CNTL_0] |= R300_RB3D_Z_DISABLED_1; // disable
-               r300->hw.zs.cmd[R300_ZS_CNTL_1] &= ~(R300_ZS_MASK << R300_RB3D_ZS1_DEPTH_FUNC_SHIFT);
        }
        
        R300_STATECHANGE(r300, zs);
        if (flags & CLEARBUFFER_STENCIL) {
-               r300->hw.zs.cmd[R300_ZS_CNTL_0] &= ~R300_RB3D_STENCIL_ENABLE;
                r300->hw.zs.cmd[R300_ZS_CNTL_0] |= R300_RB3D_STENCIL_ENABLE;
-               r300->hw.zs.cmd[R300_ZS_CNTL_1] &= 
-                   ~((R300_ZS_MASK << R300_RB3D_ZS1_FRONT_FUNC_SHIFT) | (R300_ZS_MASK << R300_RB3D_ZS1_BACK_FUNC_SHIFT));
                r300->hw.zs.cmd[R300_ZS_CNTL_1] |= 
                    (R300_ZS_ALWAYS<<R300_RB3D_ZS1_FRONT_FUNC_SHIFT) | 
                    (R300_ZS_REPLACE<<R300_RB3D_ZS1_FRONT_FAIL_OP_SHIFT) |
@@ -299,37 +285,18 @@ static void r300ClearBuffer(r300ContextPtr r300, int flags, int buffer)
        {
        uint32_t t1, t2;
        
-       t1 = r300->hw.zs.cmd[R300_ZS_CNTL_0];
-       t2 = r300->hw.zs.cmd[R300_ZS_CNTL_1];
+       t1 = 0x0;
+       t2 = 0x0;
        
        if (flags & CLEARBUFFER_DEPTH) {
-               t1 &= R300_RB3D_STENCIL_ENABLE;
-               t1 |= 0x6; // test and write
-               
-               t2 &= ~(R300_ZS_MASK << R300_RB3D_ZS1_DEPTH_FUNC_SHIFT);
-               t2 |= (R300_ZS_ALWAYS<<R300_RB3D_ZS1_DEPTH_FUNC_SHIFT);
-/*
-               R300_STATECHANGE(r300, zb);
-               r300->hw.zb.cmd[R300_ZB_OFFSET] =
-                       1024*4*300 +
-                       r300->radeon.radeonScreen->frontOffset +
-                       r300->radeon.radeonScreen->fbLocation;
-               r300->hw.zb.cmd[R300_ZB_PITCH] =
-                       r300->radeon.radeonScreen->depthPitch;
-*/
+               t1 |= R300_RB3D_Z_WRITE_ONLY;
+               t2 |= (R300_ZS_ALWAYS << R300_RB3D_ZS1_DEPTH_FUNC_SHIFT);
        } else {
-               t1 &= R300_RB3D_STENCIL_ENABLE;
                t1 |= R300_RB3D_Z_DISABLED_1; // disable
-               
-               t2 &= ~(R300_ZS_MASK << R300_RB3D_ZS1_DEPTH_FUNC_SHIFT);
        }
        
        if (flags & CLEARBUFFER_STENCIL) {
-               t1 &= ~R300_RB3D_STENCIL_ENABLE;
                t1 |= R300_RB3D_STENCIL_ENABLE;
-               
-               t2 &= 
-                   ~((R300_ZS_MASK << R300_RB3D_ZS1_FRONT_FUNC_SHIFT) | (R300_ZS_MASK << R300_RB3D_ZS1_BACK_FUNC_SHIFT));
                t2 |= 
                    (R300_ZS_ALWAYS<<R300_RB3D_ZS1_FRONT_FUNC_SHIFT) | 
                    (R300_ZS_REPLACE<<R300_RB3D_ZS1_FRONT_FAIL_OP_SHIFT) |