radeonsi: move CB_TARGET_MASK into fb/blend state
authorChristian König <deathsimple@vodafone.de>
Wed, 18 Jul 2012 09:36:28 +0000 (11:36 +0200)
committerChristian König <deathsimple@vodafone.de>
Tue, 24 Jul 2012 10:29:30 +0000 (12:29 +0200)
Signed-off-by: Christian König <deathsimple@vodafone.de>
src/gallium/drivers/radeonsi/evergreen_hw_context.c
src/gallium/drivers/radeonsi/r600_state_common.c
src/gallium/drivers/radeonsi/si_state.c
src/gallium/drivers/radeonsi/si_state.h

index eedc61a83708a8fe1f929169f4e6491684392be9..9bd547f5477b89fa3ff34814896f2b6b7df29d04 100644 (file)
@@ -51,7 +51,6 @@ static const struct r600_reg si_context_reg_list[] = {
        {R_028080_TA_BC_BASE_ADDR, REG_FLAG_NEED_BO},
        {GROUP_FORCE_NEW_BLOCK, 0},
        {R_028234_PA_SU_HARDWARE_SCREEN_OFFSET, 0},
-       {R_028238_CB_TARGET_MASK, 0},
        {GROUP_FORCE_NEW_BLOCK, 0},
        {R_028400_VGT_MAX_VTX_INDX, 0},
        {R_028404_VGT_MIN_VTX_INDX, 0},
index aa8b23d470be775737adf096578c4974724fecf0..a123f09d0815e61fa643d5cef2560779802ff132 100644 (file)
@@ -554,10 +554,9 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *dinfo)
        struct pipe_draw_info info = *dinfo;
        struct r600_draw rdraw = {};
        struct pipe_index_buffer ib = {};
-       unsigned prim, mask, ls_mask = 0;
+       unsigned prim, ls_mask = 0;
        struct r600_block *dirty_block = NULL, *next_block = NULL;
        struct r600_atom *state = NULL, *next_state = NULL;
-       struct si_state_blend *blend;
        int i;
 
        if ((!info.count && (info.indexed || !info.count_from_stream_output)) ||
@@ -569,11 +568,6 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *dinfo)
        if (!rctx->ps_shader || !rctx->vs_shader)
                return;
 
-       /* only temporary */
-       if (!rctx->queued.named.blend)
-               return;
-       blend = rctx->queued.named.blend;
-
        si_update_derived_state(rctx);
 
        r600_vertex_buffer_update(rctx);
@@ -617,13 +611,10 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *dinfo)
 
        rctx->vs_shader_so_strides = rctx->vs_shader->so_strides;
 
-       mask = (1ULL << ((unsigned)rctx->framebuffer.nr_cbufs * 4)) - 1;
-
        if (rctx->vgt.id != R600_PIPE_STATE_VGT) {
                rctx->vgt.id = R600_PIPE_STATE_VGT;
                rctx->vgt.nregs = 0;
                r600_pipe_state_add_reg(&rctx->vgt, R_008958_VGT_PRIMITIVE_TYPE, prim, NULL, 0);
-               r600_pipe_state_add_reg(&rctx->vgt, R_028238_CB_TARGET_MASK, blend->cb_target_mask & mask, NULL, 0);
                r600_pipe_state_add_reg(&rctx->vgt, R_028400_VGT_MAX_VTX_INDX, ~0, NULL, 0);
                r600_pipe_state_add_reg(&rctx->vgt, R_028404_VGT_MIN_VTX_INDX, 0, NULL, 0);
                r600_pipe_state_add_reg(&rctx->vgt, R_028408_VGT_INDX_OFFSET, info.index_bias, NULL, 0);
@@ -641,7 +632,6 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *dinfo)
 
        rctx->vgt.nregs = 0;
        r600_pipe_state_mod_reg(&rctx->vgt, prim);
-       r600_pipe_state_mod_reg(&rctx->vgt, blend->cb_target_mask & mask);
        r600_pipe_state_mod_reg(&rctx->vgt, ~0);
        r600_pipe_state_mod_reg(&rctx->vgt, 0);
        r600_pipe_state_mod_reg(&rctx->vgt, info.index_bias);
index 4d3f63422e9679cb721bdf72cb8d6faf2b3b0322..1c0fc8a5cd9e1770a1590354858853c56e4ebba9 100644 (file)
 #include "si_state.h"
 #include "sid.h"
 
+/*
+ * inferred framebuffer and blender state
+ */
+static void si_update_fb_blend_state(struct r600_context *rctx)
+{
+       struct si_pm4_state *pm4 = CALLOC_STRUCT(si_pm4_state);
+       struct si_state_blend *blend = rctx->queued.named.blend;
+       uint32_t mask;
+
+       if (pm4 == NULL || blend == NULL)
+               return;
+
+       mask = (1ULL << ((unsigned)rctx->framebuffer.nr_cbufs * 4)) - 1;
+       mask &= blend->cb_target_mask;
+       si_pm4_set_reg(pm4, R_028238_CB_TARGET_MASK, mask);
+
+       si_pm4_set_state(rctx, fb_blend, pm4);
+}
+
 /*
  * Blender functions
  */
@@ -169,6 +188,7 @@ static void si_bind_blend_state(struct pipe_context *ctx, void *state)
 {
        struct r600_context *rctx = (struct r600_context *)ctx;
        si_pm4_bind_state(rctx, blend, (struct si_state_blend *)state);
+       si_update_fb_blend_state(rctx);
 }
 
 static void si_delete_blend_state(struct pipe_context *ctx, void *state)
@@ -1267,6 +1287,7 @@ static void si_set_framebuffer_state(struct pipe_context *ctx,
 
        si_pm4_set_state(rctx, framebuffer, pm4);
        si_update_fb_rs_state(rctx);
+       si_update_fb_blend_state(rctx);
 }
 
 void si_init_state_functions(struct r600_context *rctx)
index 306b45a9818a475604b9571af7875693132b8aef..4034f5514e242b09a8a12a3407642b589f5af785 100644 (file)
@@ -72,6 +72,7 @@ union si_state {
                struct si_state_rasterizer      *rasterizer;
                struct si_state_dsa             *dsa;
                struct si_pm4_state             *fb_rs;
+               struct si_pm4_state             *fb_blend;
                struct si_pm4_state             *dsa_stencil_ref;
        } named;
        struct si_pm4_state     *array[0];