From c44de3097925e0d7b4f310432448a62a681189d5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sat, 29 Aug 2015 15:05:53 +0200 Subject: [PATCH] radeonsi: convert blend color state into an atom MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Alex Deucher Acked-by: Christian König --- src/gallium/drivers/radeonsi/si_hw_context.c | 1 + src/gallium/drivers/radeonsi/si_pipe.h | 6 ++++++ src/gallium/drivers/radeonsi/si_state.c | 20 ++++++++++++-------- src/gallium/drivers/radeonsi/si_state.h | 2 +- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_hw_context.c b/src/gallium/drivers/radeonsi/si_hw_context.c index c706d75c161..99aa039a0f4 100644 --- a/src/gallium/drivers/radeonsi/si_hw_context.c +++ b/src/gallium/drivers/radeonsi/si_hw_context.c @@ -193,6 +193,7 @@ void si_begin_new_cs(struct si_context *ctx) si_mark_atom_dirty(ctx, &ctx->msaa_sample_locs); si_mark_atom_dirty(ctx, &ctx->msaa_config); si_mark_atom_dirty(ctx, &ctx->sample_mask.atom); + si_mark_atom_dirty(ctx, &ctx->blend_color.atom); si_mark_atom_dirty(ctx, &ctx->db_render_state); si_mark_atom_dirty(ctx, &ctx->b.streamout.enable_atom); si_all_descriptors_begin_new_cs(ctx); diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h index 4d479e0990e..60124ea5cb5 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.h +++ b/src/gallium/drivers/radeonsi/si_pipe.h @@ -93,6 +93,11 @@ struct si_screen { struct r600_common_screen b; }; +struct si_blend_color { + struct r600_atom atom; + struct pipe_blend_color state; +}; + struct si_sampler_view { struct pipe_sampler_view base; struct list_head list; @@ -192,6 +197,7 @@ struct si_context { struct r600_resource *border_color_table; unsigned border_color_offset; + struct si_blend_color blend_color; struct si_scissors scissors; struct si_viewports viewports; struct si_clip_state clip_state; diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c index 80c7bde6db0..df1a13c6692 100644 --- a/src/gallium/drivers/radeonsi/si_state.c +++ b/src/gallium/drivers/radeonsi/si_state.c @@ -452,17 +452,20 @@ static void si_set_blend_color(struct pipe_context *ctx, const struct pipe_blend_color *state) { struct si_context *sctx = (struct si_context *)ctx; - struct si_pm4_state *pm4 = CALLOC_STRUCT(si_pm4_state); - if (pm4 == NULL) - return; + if (memcmp(&sctx->blend_color.state, state, sizeof(*state)) == 0) + return; - si_pm4_set_reg(pm4, R_028414_CB_BLEND_RED, fui(state->color[0])); - si_pm4_set_reg(pm4, R_028418_CB_BLEND_GREEN, fui(state->color[1])); - si_pm4_set_reg(pm4, R_02841C_CB_BLEND_BLUE, fui(state->color[2])); - si_pm4_set_reg(pm4, R_028420_CB_BLEND_ALPHA, fui(state->color[3])); + sctx->blend_color.state = *state; + si_mark_atom_dirty(sctx, &sctx->blend_color.atom); +} + +static void si_emit_blend_color(struct si_context *sctx, struct r600_atom *atom) +{ + struct radeon_winsys_cs *cs = sctx->b.rings.gfx.cs; - si_pm4_set_state(sctx, blend_color, pm4); + r600_write_context_reg_seq(cs, R_028414_CB_BLEND_RED, 4); + radeon_emit_array(cs, (uint32_t*)sctx->blend_color.state.color, 4); } /* @@ -3061,6 +3064,7 @@ void si_init_state_functions(struct si_context *sctx) si_init_atom(sctx, &sctx->db_render_state, &sctx->atoms.s.db_render_state, si_emit_db_render_state, 10); si_init_atom(sctx, &sctx->msaa_config, &sctx->atoms.s.msaa_config, si_emit_msaa_config, 10); si_init_atom(sctx, &sctx->sample_mask.atom, &sctx->atoms.s.sample_mask, si_emit_sample_mask, 4); + si_init_atom(sctx, &sctx->blend_color.atom, &sctx->atoms.s.blend_color, si_emit_blend_color, 6); si_init_atom(sctx, &sctx->clip_regs, &sctx->atoms.s.clip_regs, si_emit_clip_regs, 6); si_init_atom(sctx, &sctx->clip_state.atom, &sctx->atoms.s.clip_state, si_emit_clip_state, 2+6*4); si_init_atom(sctx, &sctx->scissors.atom, &sctx->atoms.s.scissors, si_emit_scissors, 16*4); diff --git a/src/gallium/drivers/radeonsi/si_state.h b/src/gallium/drivers/radeonsi/si_state.h index 77c4dd118dc..68a7cf9c3b4 100644 --- a/src/gallium/drivers/radeonsi/si_state.h +++ b/src/gallium/drivers/radeonsi/si_state.h @@ -78,7 +78,6 @@ struct si_vertex_element union si_state { struct { struct si_state_blend *blend; - struct si_pm4_state *blend_color; struct si_state_rasterizer *rasterizer; struct si_state_dsa *dsa; struct si_pm4_state *fb_rs; @@ -108,6 +107,7 @@ union si_state_atoms { struct r600_atom *db_render_state; struct r600_atom *msaa_config; struct r600_atom *sample_mask; + struct r600_atom *blend_color; struct r600_atom *clip_regs; struct r600_atom *clip_state; struct r600_atom *shader_userdata; -- 2.11.0