r300: remove depth offset exits in favour of rrb depth changes
authorDave Airlie <airlied@redhat.com>
Thu, 26 Feb 2009 04:04:38 +0000 (14:04 +1000)
committerDave Airlie <airlied@redhat.com>
Fri, 27 Feb 2009 04:04:03 +0000 (14:04 +1000)
src/mesa/drivers/dri/r300/r300_cmdbuf.c
src/mesa/drivers/dri/r300/r300_state.c

index 068a9f978bac573060c5839c533602d5579c3ac9..231576fed89fc671a185214a5896528a18344406 100644 (file)
@@ -263,6 +263,33 @@ static void emit_zb_offset(GLcontext *ctx, struct radeon_state_atom * atom)
        END_BATCH();
 }
 
+static void emit_zstencil_format(GLcontext *ctx, struct radeon_state_atom * atom)
+{
+       r300ContextPtr r300 = R300_CONTEXT(ctx);
+       BATCH_LOCALS(&r300->radeon);
+       struct radeon_renderbuffer *rrb;
+       uint32_t zbpitch;
+       uint32_t format;
+
+       rrb = radeon_get_depthbuffer(&r300->radeon);
+       if (!rrb)
+         format = 0;
+       else {
+         if (rrb->cpp == 2)
+           format = R300_DEPTHFORMAT_16BIT_INT_Z;
+         else if (rrb->cpp == 4)
+           format = R300_DEPTHFORMAT_24BIT_INT_Z_8BIT_STENCIL;
+       }
+
+       OUT_BATCH(atom->cmd[0]);
+       atom->cmd[1] &= ~(3 << 0);
+       atom->cmd[1] |= format;
+       OUT_BATCH(atom->cmd[1]);
+       OUT_BATCH(atom->cmd[2]);
+       OUT_BATCH(atom->cmd[3]);
+       OUT_BATCH(atom->cmd[4]);
+}
+
 static int check_always(GLcontext *ctx, struct radeon_state_atom *atom)
 {
        return atom->cmd_size;
@@ -521,9 +548,12 @@ void r300InitCmdBuf(r300ContextPtr r300)
        ALLOC_STATE(zs, always, R300_ZS_CMDSIZE, 0);
        r300->hw.zs.cmd[R300_ZS_CMD_0] =
            cmdpacket0(r300->radeon.radeonScreen, R300_ZB_CNTL, 3);
+
        ALLOC_STATE(zstencil_format, always, 5, 0);
        r300->hw.zstencil_format.cmd[0] =
            cmdpacket0(r300->radeon.radeonScreen, R300_ZB_FORMAT, 4);
+       r300->hw.zstencil_format.emit = emit_zstencil_format;
+
        ALLOC_STATE(zb, always, R300_ZB_CMDSIZE, 0);
        r300->hw.zb.emit = emit_zb_offset;
        ALLOC_STATE(zb_depthclearvalue, always, 2, 0);
index ba1deee23ec884e5c120fdfc7624f484ec2cdeff..59728a07e5c3d618abc2e5447a85d88b59e3fb04 100644 (file)
@@ -2367,18 +2367,6 @@ static void r300ResetHwState(r300ContextPtr r300)
 
        r300->hw.zb_depthclearvalue.cmd[1] = 0;
 
-       switch (ctx->Visual.depthBits) {
-       case 16:
-               r300->hw.zstencil_format.cmd[1] = R300_DEPTHFORMAT_16BIT_INT_Z;
-               break;
-       case 24:
-               r300->hw.zstencil_format.cmd[1] = R300_DEPTHFORMAT_24BIT_INT_Z_8BIT_STENCIL;
-               break;
-       default:
-               fprintf(stderr, "Error: Unsupported depth %d... exiting\n", ctx->Visual.depthBits);
-               _mesa_exit(-1);
-       }
-
        r300->hw.zstencil_format.cmd[2] = R300_ZTOP_DISABLE;
        r300->hw.zstencil_format.cmd[3] = 0x00000003;
        r300->hw.zstencil_format.cmd[4] = 0x00000000;
@@ -2683,21 +2671,6 @@ void r300InitState(r300ContextPtr r300)
        GLcontext *ctx = r300->radeon.glCtx;
        GLuint depth_fmt;
 
-       switch (ctx->Visual.depthBits) {
-       case 16:
-               r300->radeon.state.depth.scale = 1.0 / (GLfloat) 0xffff;
-               depth_fmt = R300_DEPTHFORMAT_16BIT_INT_Z;
-               break;
-       case 24:
-               r300->radeon.state.depth.scale = 1.0 / (GLfloat) 0xffffff;
-               depth_fmt = R300_DEPTHFORMAT_24BIT_INT_Z_8BIT_STENCIL;
-               break;
-       default:
-               fprintf(stderr, "Error: Unsupported depth %d... exiting\n",
-                       ctx->Visual.depthBits);
-               _mesa_exit(-1);
-       }
-
        /* Only have hw stencil when depth buffer is 24 bits deep */
        r300->radeon.state.stencil.hwBuffer = (ctx->Visual.stencilBits > 0 &&
                                               ctx->Visual.depthBits == 24);