r600g: atomize blend color
authorMarek Olšák <maraeo@gmail.com>
Mon, 10 Sep 2012 17:41:39 +0000 (19:41 +0200)
committerMarek Olšák <maraeo@gmail.com>
Thu, 13 Sep 2012 18:18:44 +0000 (20:18 +0200)
Reviewed-by: Jerome Glisse <jglisse@redhat.com>
src/gallium/drivers/r600/evergreen_hw_context.c
src/gallium/drivers/r600/evergreen_state.c
src/gallium/drivers/r600/r600_hw_context.c
src/gallium/drivers/r600/r600_pipe.h
src/gallium/drivers/r600/r600_state.c
src/gallium/drivers/r600/r600_state_common.c

index 2fa9cc6889ebf3e0d6f3db2668904af1c3d8c580..24c504dc2e18672c2fb3608403671f5166a86a2e 100644 (file)
@@ -73,10 +73,6 @@ static const struct r600_reg evergreen_context_reg_list[] = {
        {R_02840C_VGT_MULTI_PRIM_IB_RESET_INDX, 0, 0},
        {R_028A94_VGT_MULTI_PRIM_IB_RESET_EN, 0, 0},
        {GROUP_FORCE_NEW_BLOCK, 0, 0},
-       {R_028414_CB_BLEND_RED, 0, 0},
-       {R_028418_CB_BLEND_GREEN, 0, 0},
-       {R_02841C_CB_BLEND_BLUE, 0, 0},
-       {R_028420_CB_BLEND_ALPHA, 0, 0},
        {R_0285BC_PA_CL_UCP0_X, 0, 0},
        {R_0285C0_PA_CL_UCP0_Y, 0, 0},
        {R_0285C4_PA_CL_UCP0_Z, 0, 0},
@@ -396,10 +392,6 @@ static const struct r600_reg cayman_context_reg_list[] = {
        {R_02840C_VGT_MULTI_PRIM_IB_RESET_INDX, 0, 0},
        {R_028A94_VGT_MULTI_PRIM_IB_RESET_EN, 0, 0},
        {GROUP_FORCE_NEW_BLOCK, 0, 0},
-       {R_028414_CB_BLEND_RED, 0, 0},
-       {R_028418_CB_BLEND_GREEN, 0, 0},
-       {R_02841C_CB_BLEND_BLUE, 0, 0},
-       {R_028420_CB_BLEND_ALPHA, 0, 0},
        {R_0285BC_PA_CL_UCP0_X, 0, 0},
        {R_0285C0_PA_CL_UCP0_Y, 0, 0},
        {R_0285C4_PA_CL_UCP0_Z, 0, 0},
index 95d70c8e9a0046b3dfd326024b0a637f175f580b..01c84adcd5c7c871f85fc02f4f86b343673258d3 100644 (file)
@@ -2187,8 +2187,9 @@ void evergreen_init_state_functions(struct r600_context *rctx)
        }
        rctx->sample_mask.sample_mask = ~0;
 
-       r600_init_atom(rctx, &rctx->cb_misc_state.atom, id++, evergreen_emit_cb_misc_state, 0);
        r600_init_atom(rctx, &rctx->alphatest_state.atom, id++, r600_emit_alphatest_state, 6);
+       r600_init_atom(rctx, &rctx->blend_color.atom, id++, r600_emit_blend_color, 6);
+       r600_init_atom(rctx, &rctx->cb_misc_state.atom, id++, evergreen_emit_cb_misc_state, 0);
        r600_init_atom(rctx, &rctx->db_misc_state.atom, id++, evergreen_emit_db_misc_state, 7);
        r600_init_atom(rctx, &rctx->stencil_ref.atom, id++, r600_emit_stencil_ref, 4);
        r600_init_atom(rctx, &rctx->viewport.atom, id++, r600_emit_viewport_state, 8);
index 207ccc3d85380435b63a1d93fecebb20ccddc896..fa6c867c271578ccef43335a0beef9516b899c89 100644 (file)
@@ -328,10 +328,6 @@ static const struct r600_reg r600_context_reg_list[] = {
        {R_028124_CB_CLEAR_GREEN, 0, 0},
        {R_028128_CB_CLEAR_BLUE, 0, 0},
        {R_02812C_CB_CLEAR_ALPHA, 0, 0},
-       {R_028414_CB_BLEND_RED, 0, 0},
-       {R_028418_CB_BLEND_GREEN, 0, 0},
-       {R_02841C_CB_BLEND_BLUE, 0, 0},
-       {R_028420_CB_BLEND_ALPHA, 0, 0},
        {R_028424_CB_FOG_RED, 0, 0},
        {R_028428_CB_FOG_GREEN, 0, 0},
        {R_02842C_CB_FOG_BLUE, 0, 0},
@@ -1040,6 +1036,7 @@ void r600_begin_new_cs(struct r600_context *ctx)
 
        /* Re-emit states. */
        r600_atom_dirty(ctx, &ctx->alphatest_state.atom);
+       r600_atom_dirty(ctx, &ctx->blend_color.atom);
        r600_atom_dirty(ctx, &ctx->cb_misc_state.atom);
        r600_atom_dirty(ctx, &ctx->db_misc_state.atom);
        r600_atom_dirty(ctx, &ctx->sample_mask.atom);
index 199b0f05fef5bec0072ba724aaeae2c89099d80f..88db6d4a97f8e2d82de1913a985d20ef03c89c95 100644 (file)
@@ -35,7 +35,7 @@
 #include "r600_resource.h"
 #include "evergreen_compute.h"
 
-#define R600_NUM_ATOMS 22
+#define R600_NUM_ATOMS 23
 
 #define R600_MAX_CONST_BUFFERS 2
 #define R600_MAX_CONST_BUFFER_SIZE 4096
@@ -92,6 +92,11 @@ struct r600_alphatest_state {
        bool cb0_export_16bpc; /* from set_framebuffer_state */
 };
 
+struct r600_blend_color {
+       struct r600_atom atom;
+       struct pipe_blend_color state;
+};
+
 struct r600_cs_shader_state {
        struct r600_atom atom;
        struct r600_pipe_compute *shader;
@@ -122,7 +127,6 @@ struct r600_viewport_state {
 
 enum r600_pipe_state_id {
        R600_PIPE_STATE_BLEND = 0,
-       R600_PIPE_STATE_BLEND_COLOR,
        R600_PIPE_STATE_CLIP,
        R600_PIPE_STATE_SCISSOR,
        R600_PIPE_STATE_RASTERIZER,
@@ -374,6 +378,7 @@ struct r600_context {
        struct r600_command_buffer      start_compute_cs_cmd;
        /* Register states. */
        struct r600_alphatest_state     alphatest_state;
+       struct r600_blend_color         blend_color;
        struct r600_cb_misc_state       cb_misc_state;
        struct r600_db_misc_state       db_misc_state;
        struct r600_seamless_cube_map   seamless_cube_map;
@@ -580,6 +585,7 @@ void r600_translate_index_buffer(struct r600_context *r600,
 /* r600_state_common.c */
 void r600_init_common_state_functions(struct r600_context *rctx);
 void r600_emit_alphatest_state(struct r600_context *rctx, struct r600_atom *atom);
+void r600_emit_blend_color(struct r600_context *rctx, struct r600_atom *atom);
 void r600_emit_stencil_ref(struct r600_context *rctx, struct r600_atom *atom);
 void r600_emit_viewport_state(struct r600_context *rctx, struct r600_atom *atom);
 void r600_init_atom(struct r600_context *rctx, struct r600_atom *atom, unsigned id,
index 0e395d79cf90aa0b546dcc37c37fae55d7562dca..b0af8c47099eacc6186fae78a1ab4d748797c5f9 100644 (file)
@@ -2068,8 +2068,9 @@ void r600_init_state_functions(struct r600_context *rctx)
        r600_init_atom(rctx, &rctx->sample_mask.atom, id++, r600_emit_sample_mask, 3);
        rctx->sample_mask.sample_mask = ~0;
 
-       r600_init_atom(rctx, &rctx->cb_misc_state.atom, id++, r600_emit_cb_misc_state, 0);
        r600_init_atom(rctx, &rctx->alphatest_state.atom, id++, r600_emit_alphatest_state, 6);
+       r600_init_atom(rctx, &rctx->blend_color.atom, id++, r600_emit_blend_color, 6);
+       r600_init_atom(rctx, &rctx->cb_misc_state.atom, id++, r600_emit_cb_misc_state, 0);
        r600_init_atom(rctx, &rctx->db_misc_state.atom, id++, r600_emit_db_misc_state, 4);
        r600_init_atom(rctx, &rctx->stencil_ref.atom, id++, r600_emit_stencil_ref, 4);
        r600_init_atom(rctx, &rctx->viewport.atom, id++, r600_emit_viewport_state, 8);
index 2c8241ed8d2a1be65e17cd3e6d95442f40829eac..a205ffda72d9a38d9f091d31df2b187f292db1d8 100644 (file)
@@ -177,20 +177,21 @@ static void r600_set_blend_color(struct pipe_context *ctx,
                                 const struct pipe_blend_color *state)
 {
        struct r600_context *rctx = (struct r600_context *)ctx;
-       struct r600_pipe_state *rstate = CALLOC_STRUCT(r600_pipe_state);
 
-       if (rstate == NULL)
-               return;
+       rctx->blend_color.state = *state;
+       r600_atom_dirty(rctx, &rctx->blend_color.atom);
+}
 
-       rstate->id = R600_PIPE_STATE_BLEND_COLOR;
-       r600_pipe_state_add_reg(rstate, R_028414_CB_BLEND_RED, fui(state->color[0]));
-       r600_pipe_state_add_reg(rstate, R_028418_CB_BLEND_GREEN, fui(state->color[1]));
-       r600_pipe_state_add_reg(rstate, R_02841C_CB_BLEND_BLUE, fui(state->color[2]));
-       r600_pipe_state_add_reg(rstate, R_028420_CB_BLEND_ALPHA, fui(state->color[3]));
+void r600_emit_blend_color(struct r600_context *rctx, struct r600_atom *atom)
+{
+       struct radeon_winsys_cs *cs = rctx->cs;
+       struct pipe_blend_color *state = &rctx->blend_color.state;
 
-       free(rctx->states[R600_PIPE_STATE_BLEND_COLOR]);
-       rctx->states[R600_PIPE_STATE_BLEND_COLOR] = rstate;
-       r600_context_pipe_state_set(rctx, rstate);
+       r600_write_context_reg_seq(cs, R_028414_CB_BLEND_RED, 4);
+       r600_write_value(cs, fui(state->color[0])); /* R_028414_CB_BLEND_RED */
+       r600_write_value(cs, fui(state->color[1])); /* R_028418_CB_BLEND_GREEN */
+       r600_write_value(cs, fui(state->color[2])); /* R_02841C_CB_BLEND_BLUE */
+       r600_write_value(cs, fui(state->color[3])); /* R_028420_CB_BLEND_ALPHA */
 }
 
 static void r600_set_stencil_ref(struct pipe_context *ctx,