From 74aa64876b54bc2d0088bc9ed2d390eaa2b73349 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 sample mask 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_blit.c | 5 +---- src/gallium/drivers/radeonsi/si_hw_context.c | 1 + src/gallium/drivers/radeonsi/si_pipe.c | 2 ++ src/gallium/drivers/radeonsi/si_pipe.h | 6 +++++ src/gallium/drivers/radeonsi/si_state.c | 23 ++++++++++++-------- src/gallium/drivers/radeonsi/si_state.h | 7 +----- 6 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_blit.c b/src/gallium/drivers/radeonsi/si_blit.c index d1486bd822d..08828ac8446 100644 --- a/src/gallium/drivers/radeonsi/si_blit.c +++ b/src/gallium/drivers/radeonsi/si_blit.c @@ -61,10 +61,7 @@ static void si_blitter_begin(struct pipe_context *ctx, enum si_blitter_op op) util_blitter_save_tesseval_shader(sctx->blitter, sctx->tes_shader); util_blitter_save_vertex_shader(sctx->blitter, sctx->vs_shader); util_blitter_save_vertex_elements(sctx->blitter, sctx->vertex_elements); - if (sctx->queued.named.sample_mask) { - util_blitter_save_sample_mask(sctx->blitter, - sctx->queued.named.sample_mask->sample_mask); - } + util_blitter_save_sample_mask(sctx->blitter, sctx->sample_mask.sample_mask); util_blitter_save_viewport(sctx->blitter, &sctx->viewports.states[0]); util_blitter_save_scissor(sctx->blitter, &sctx->scissors.states[0]); util_blitter_save_vertex_buffer_slot(sctx->blitter, sctx->vertex_buffer); diff --git a/src/gallium/drivers/radeonsi/si_hw_context.c b/src/gallium/drivers/radeonsi/si_hw_context.c index 689f8166b65..c706d75c161 100644 --- a/src/gallium/drivers/radeonsi/si_hw_context.c +++ b/src/gallium/drivers/radeonsi/si_hw_context.c @@ -192,6 +192,7 @@ void si_begin_new_cs(struct si_context *ctx) si_mark_atom_dirty(ctx, &ctx->clip_state.atom); 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->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.c b/src/gallium/drivers/radeonsi/si_pipe.c index f6f77534b93..da774789525 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.c +++ b/src/gallium/drivers/radeonsi/si_pipe.c @@ -151,6 +151,8 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, goto fail; sctx->blitter->draw_rectangle = r600_draw_rectangle; + sctx->sample_mask.sample_mask = 0xffff; + /* these must be last */ si_begin_new_cs(sctx); r600_query_init_backend_mask(&sctx->b); /* this emits commands and must be last */ diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h index 829acf735f6..4d479e0990e 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.h +++ b/src/gallium/drivers/radeonsi/si_pipe.h @@ -136,6 +136,11 @@ struct si_clip_state { struct pipe_clip_state state; }; +struct si_sample_mask { + struct r600_atom atom; + uint16_t sample_mask; +}; + struct si_scissors { struct r600_atom atom; unsigned dirty_mask; @@ -191,6 +196,7 @@ struct si_context { struct si_viewports viewports; struct si_clip_state clip_state; struct r600_atom clip_regs; + struct si_sample_mask sample_mask; struct r600_atom msaa_sample_locs; struct r600_atom msaa_config; int ps_iter_samples; diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c index d3e05b5e024..80c7bde6db0 100644 --- a/src/gallium/drivers/radeonsi/si_state.c +++ b/src/gallium/drivers/radeonsi/si_state.c @@ -2819,18 +2819,22 @@ static void si_bind_sampler_states(struct pipe_context *ctx, unsigned shader, static void si_set_sample_mask(struct pipe_context *ctx, unsigned sample_mask) { struct si_context *sctx = (struct si_context *)ctx; - struct si_state_sample_mask *state = CALLOC_STRUCT(si_state_sample_mask); - struct si_pm4_state *pm4 = &state->pm4; - uint16_t mask = sample_mask; - if (state == NULL) - return; + if (sctx->sample_mask.sample_mask == (uint16_t)sample_mask) + return; - state->sample_mask = mask; - si_pm4_set_reg(pm4, R_028C38_PA_SC_AA_MASK_X0Y0_X1Y0, mask | (mask << 16)); - si_pm4_set_reg(pm4, R_028C3C_PA_SC_AA_MASK_X0Y1_X1Y1, mask | (mask << 16)); + sctx->sample_mask.sample_mask = sample_mask; + si_mark_atom_dirty(sctx, &sctx->sample_mask.atom); +} + +static void si_emit_sample_mask(struct si_context *sctx, struct r600_atom *atom) +{ + struct radeon_winsys_cs *cs = sctx->b.rings.gfx.cs; + unsigned mask = sctx->sample_mask.sample_mask; - si_pm4_set_state(sctx, sample_mask, state); + r600_write_context_reg_seq(cs, R_028C38_PA_SC_AA_MASK_X0Y0_X1Y0, 2); + radeon_emit(cs, mask | (mask << 16)); + radeon_emit(cs, mask | (mask << 16)); } static void si_delete_sampler_state(struct pipe_context *ctx, void *state) @@ -3056,6 +3060,7 @@ void si_init_state_functions(struct si_context *sctx) si_init_atom(sctx, &sctx->msaa_sample_locs, &sctx->atoms.s.msaa_sample_locs, si_emit_msaa_sample_locs, 18); 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->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 a8a22eb5dfc..77c4dd118dc 100644 --- a/src/gallium/drivers/radeonsi/si_state.h +++ b/src/gallium/drivers/radeonsi/si_state.h @@ -43,11 +43,6 @@ struct si_state_blend { bool dual_src_blend; }; -struct si_state_sample_mask { - struct si_pm4_state pm4; - uint16_t sample_mask; -}; - struct si_state_rasterizer { struct si_pm4_state pm4; bool flatshade; @@ -84,7 +79,6 @@ union si_state { struct { struct si_state_blend *blend; struct si_pm4_state *blend_color; - struct si_state_sample_mask *sample_mask; struct si_state_rasterizer *rasterizer; struct si_state_dsa *dsa; struct si_pm4_state *fb_rs; @@ -113,6 +107,7 @@ union si_state_atoms { struct r600_atom *msaa_sample_locs; struct r600_atom *db_render_state; struct r600_atom *msaa_config; + struct r600_atom *sample_mask; struct r600_atom *clip_regs; struct r600_atom *clip_state; struct r600_atom *shader_userdata; -- 2.30.2