r600g: always derive alphatest state from the first colorbuffer
authorMarek Olšák <maraeo@gmail.com>
Wed, 18 Jul 2012 02:17:11 +0000 (04:17 +0200)
committerMarek Olšák <maraeo@gmail.com>
Wed, 18 Jul 2012 02:17:11 +0000 (04:17 +0200)
src/gallium/drivers/r600/evergreen_state.c
src/gallium/drivers/r600/r600_pipe.h
src/gallium/drivers/r600/r600_state.c
src/gallium/drivers/r600/r600_state_common.c

index a62d18e..d90ef3c 100644 (file)
@@ -1397,10 +1397,13 @@ void evergreen_cb(struct r600_context *rctx, struct r600_pipe_state *rstate,
                blend_bypass = 1;
        }
 
-       alphatest_bypass = ntype == V_028C70_NUMBER_UINT || ntype == V_028C70_NUMBER_SINT;
-       if (rctx->alphatest_state.bypass != alphatest_bypass) {
-               rctx->alphatest_state.bypass = alphatest_bypass;
-               r600_atom_dirty(rctx, &rctx->alphatest_state.atom);
+       /* Alpha-test is done on the first colorbuffer only. */
+       if (cb == 0) {
+               alphatest_bypass = ntype == V_028C70_NUMBER_UINT || ntype == V_028C70_NUMBER_SINT;
+               if (rctx->alphatest_state.bypass != alphatest_bypass) {
+                       rctx->alphatest_state.bypass = alphatest_bypass;
+                       r600_atom_dirty(rctx, &rctx->alphatest_state.atom);
+               }
        }
 
        color_info |= S_028C70_FORMAT(format) |
@@ -1435,6 +1438,12 @@ void evergreen_cb(struct r600_context *rctx, struct r600_pipe_state *rstate,
                rctx->export_16bpc = false;
        }
 
+       /* Alpha-test is done on the first colorbuffer only. */
+       if (cb == 0 && rctx->alphatest_state.cb0_export_16bpc != rctx->export_16bpc) {
+               rctx->alphatest_state.cb0_export_16bpc = rctx->export_16bpc;
+               r600_atom_dirty(rctx, &rctx->alphatest_state.atom);
+       }
+
        /* for possible dual-src MRT */
        if (cb == 0 && rctx->framebuffer.nr_cbufs == 1 && !rtex->is_rat) {
                r600_pipe_state_add_reg_bo(rstate,
@@ -1681,10 +1690,6 @@ static void evergreen_set_framebuffer_state(struct pipe_context *ctx,
                rctx->cb_misc_state.nr_cbufs = state->nr_cbufs;
                r600_atom_dirty(rctx, &rctx->cb_misc_state.atom);
        }
-       if (rctx->alphatest_state.export_16bpc != rctx->export_16bpc) {
-               rctx->alphatest_state.export_16bpc = rctx->export_16bpc;
-               r600_atom_dirty(rctx, &rctx->alphatest_state.atom);
-       }
 }
 
 static void evergreen_emit_cb_misc_state(struct r600_context *rctx, struct r600_atom *atom)
index 063d9d3..2f16ff6 100644 (file)
@@ -97,7 +97,7 @@ struct r600_alphatest_state {
        unsigned sx_alpha_test_control; /* this comes from dsa state */
        unsigned sx_alpha_ref; /* this comes from dsa state */
        bool bypass;
-       bool export_16bpc; /* from set_framebuffer_state */
+       bool cb0_export_16bpc; /* from set_framebuffer_state */
 };
 
 enum r600_pipe_state_id {
index 4644034..269198b 100644 (file)
@@ -1426,10 +1426,13 @@ static void r600_cb(struct r600_context *rctx, struct r600_pipe_state *rstate,
                blend_bypass = 1;
        }
 
-       alphatest_bypass = ntype == V_0280A0_NUMBER_UINT || ntype == V_0280A0_NUMBER_SINT;
-       if (rctx->alphatest_state.bypass != alphatest_bypass) {
-               rctx->alphatest_state.bypass = alphatest_bypass;
-               r600_atom_dirty(rctx, &rctx->alphatest_state.atom);
+       /* Alpha-test is done on the first colorbuffer only. */
+       if (cb == 0) {
+               alphatest_bypass = ntype == V_0280A0_NUMBER_UINT || ntype == V_0280A0_NUMBER_SINT;
+               if (rctx->alphatest_state.bypass != alphatest_bypass) {
+                       rctx->alphatest_state.bypass = alphatest_bypass;
+                       r600_atom_dirty(rctx, &rctx->alphatest_state.atom);
+               }
        }
 
        color_info |= S_0280A0_FORMAT(format) |
index 6aff57a..89549f9 100644 (file)
@@ -92,7 +92,7 @@ static void r600_emit_alphatest_state(struct r600_context *rctx, struct r600_ato
        struct r600_alphatest_state *a = (struct r600_alphatest_state*)atom;
        unsigned alpha_ref = a->sx_alpha_ref;
 
-       if (rctx->chip_class >= EVERGREEN && a->export_16bpc) {
+       if (rctx->chip_class >= EVERGREEN && a->cb0_export_16bpc) {
                alpha_ref &= ~0x1FFF;
        }