radeonsi: convert clip state into an atom
authorMarek Olšák <marek.olsak@amd.com>
Sat, 29 Aug 2015 12:54:58 +0000 (14:54 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 1 Sep 2015 19:51:14 +0000 (21:51 +0200)
Reducing calloc overhead.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Acked-by: Christian König <christian.koenig@amd.com>
src/gallium/drivers/radeonsi/si_hw_context.c
src/gallium/drivers/radeonsi/si_pipe.h
src/gallium/drivers/radeonsi/si_state.c
src/gallium/drivers/radeonsi/si_state.h

index 5613781..689f816 100644 (file)
@@ -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);
index 9be4aa7..829acf7 100644 (file)
@@ -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;
index 3c25048..d3e05b5 100644 (file)
@@ -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);
 
index 8cf308d..a8a22eb 100644 (file)
@@ -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;