[Mesa-dev] [PATCH 19/42] radeonsi: convert clip state into an atom
Marek Olšák
maraeo at gmail.com
Sun Aug 30 12:11:49 PDT 2015
From: Marek Olšák <marek.olsak at amd.com>
Reducing calloc overhead.
---
src/gallium/drivers/radeonsi/si_hw_context.c | 1 +
src/gallium/drivers/radeonsi/si_pipe.h | 6 ++++++
src/gallium/drivers/radeonsi/si_state.c | 24 +++++++++++-------------
src/gallium/drivers/radeonsi/si_state.h | 2 +-
4 files changed, 19 insertions(+), 14 deletions(-)
diff --git a/src/gallium/drivers/radeonsi/si_hw_context.c b/src/gallium/drivers/radeonsi/si_hw_context.c
index 5613781..689f816 100644
--- a/src/gallium/drivers/radeonsi/si_hw_context.c
+++ b/src/gallium/drivers/radeonsi/si_hw_context.c
@@ -189,6 +189,7 @@ void si_begin_new_cs(struct si_context *ctx)
si_mark_atom_dirty(ctx, &ctx->framebuffer.atom);
si_mark_atom_dirty(ctx, &ctx->clip_regs);
+ 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->db_render_state);
diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h
index 9be4aa7..829acf7 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.h
+++ b/src/gallium/drivers/radeonsi/si_pipe.h
@@ -131,6 +131,11 @@ struct si_framebuffer {
bool dirty_zsbuf;
};
+struct si_clip_state {
+ struct r600_atom atom;
+ struct pipe_clip_state state;
+};
+
struct si_scissors {
struct r600_atom atom;
unsigned dirty_mask;
@@ -184,6 +189,7 @@ struct si_context {
struct si_scissors scissors;
struct si_viewports viewports;
+ struct si_clip_state clip_state;
struct r600_atom clip_regs;
struct r600_atom msaa_sample_locs;
struct r600_atom msaa_config;
diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c
index 3c25048..d3e05b5 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -473,22 +473,13 @@ static void si_set_clip_state(struct pipe_context *ctx,
const struct pipe_clip_state *state)
{
struct si_context *sctx = (struct si_context *)ctx;
- struct si_pm4_state *pm4 = CALLOC_STRUCT(si_pm4_state);
struct pipe_constant_buffer cb;
- if (pm4 == NULL)
+ if (memcmp(&sctx->clip_state.state, state, sizeof(*state)) == 0)
return;
- for (int i = 0; i < 6; i++) {
- si_pm4_set_reg(pm4, R_0285BC_PA_CL_UCP_0_X + i * 16,
- fui(state->ucp[i][0]));
- si_pm4_set_reg(pm4, R_0285C0_PA_CL_UCP_0_Y + i * 16,
- fui(state->ucp[i][1]));
- si_pm4_set_reg(pm4, R_0285C4_PA_CL_UCP_0_Z + i * 16,
- fui(state->ucp[i][2]));
- si_pm4_set_reg(pm4, R_0285C8_PA_CL_UCP_0_W + i * 16,
- fui(state->ucp[i][3]));
- }
+ sctx->clip_state.state = *state;
+ si_mark_atom_dirty(sctx, &sctx->clip_state.atom);
cb.buffer = NULL;
cb.user_buffer = state->ucp;
@@ -496,8 +487,14 @@ static void si_set_clip_state(struct pipe_context *ctx,
cb.buffer_size = 4*4*8;
ctx->set_constant_buffer(ctx, PIPE_SHADER_VERTEX, SI_DRIVER_STATE_CONST_BUF, &cb);
pipe_resource_reference(&cb.buffer, NULL);
+}
+
+static void si_emit_clip_state(struct si_context *sctx, struct r600_atom *atom)
+{
+ struct radeon_winsys_cs *cs = sctx->b.rings.gfx.cs;
- si_pm4_set_state(sctx, clip, pm4);
+ r600_write_context_reg_seq(cs, R_0285BC_PA_CL_UCP_0_X, 6*4);
+ radeon_emit_array(cs, (uint32_t*)sctx->clip_state.state.ucp, 6*4);
}
#define SIX_BITS 0x3F
@@ -3060,6 +3057,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->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);
si_init_atom(sctx, &sctx->viewports.atom, &sctx->atoms.s.viewports, si_emit_viewports, 16*8);
diff --git a/src/gallium/drivers/radeonsi/si_state.h b/src/gallium/drivers/radeonsi/si_state.h
index 8cf308d..a8a22eb 100644
--- a/src/gallium/drivers/radeonsi/si_state.h
+++ b/src/gallium/drivers/radeonsi/si_state.h
@@ -84,7 +84,6 @@ union si_state {
struct {
struct si_state_blend *blend;
struct si_pm4_state *blend_color;
- struct si_pm4_state *clip;
struct si_state_sample_mask *sample_mask;
struct si_state_rasterizer *rasterizer;
struct si_state_dsa *dsa;
@@ -115,6 +114,7 @@ union si_state_atoms {
struct r600_atom *db_render_state;
struct r600_atom *msaa_config;
struct r600_atom *clip_regs;
+ struct r600_atom *clip_state;
struct r600_atom *shader_userdata;
struct r600_atom *scissors;
struct r600_atom *viewports;
--
2.1.4
More information about the mesa-dev
mailing list