radeonsi: don't rebind GSVS ring buffers every draw call using GS
authorMarek Olšák <marek.olsak@amd.com>
Sat, 29 Aug 2015 00:02:29 +0000 (02:02 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 1 Sep 2015 19:51:14 +0000 (21:51 +0200)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Acked-by: Christian König <christian.koenig@amd.com>
src/gallium/drivers/radeonsi/si_pipe.h
src/gallium/drivers/radeonsi/si_shader.h
src/gallium/drivers/radeonsi/si_state_shaders.c

index 9fe17985290574cd27a78d604240ae603b1e1f96..47ad619ccdcc85bf732082d5b9b96495063e65ad 100644 (file)
@@ -234,6 +234,7 @@ struct si_context {
        int                     last_rast_prim;
        unsigned                last_sc_line_stipple;
        int                     current_rast_prim; /* primitive type after TES, GS */
+       unsigned                last_gsvs_itemsize;
 
        /* Scratch buffer */
        boolean                 emit_scratch_reloc;
index c748f71430b4f8d4a115499f503c87a35486d58f..2305b9988b8e2f04797e3e32282822eee72e088a 100644 (file)
@@ -185,6 +185,7 @@ struct si_shader_selector {
        unsigned        gs_output_prim;
        unsigned        gs_max_out_vertices;
        unsigned        gs_num_invocations;
+       unsigned        gsvs_itemsize;
 
        /* masks of "get_unique_index" bits */
        uint64_t        inputs_read;
index a4c33fa620203e5dcfb865432f0549b0ac824026..af91af97ce8f1df8d49b1749453fc1451244edb7 100644 (file)
@@ -679,6 +679,8 @@ static void *si_create_shader_state(struct pipe_context *ctx,
                        sel->info.properties[TGSI_PROPERTY_GS_MAX_OUTPUT_VERTICES];
                sel->gs_num_invocations =
                        sel->info.properties[TGSI_PROPERTY_GS_INVOCATIONS];
+               sel->gsvs_itemsize = sel->info.num_outputs * 16 *
+                                    sel->gs_max_out_vertices;
 
                for (i = 0; i < sel->info.num_inputs; i++) {
                        unsigned name = sel->info.input_semantic_name[i];
@@ -1096,11 +1098,14 @@ static void si_init_gs_rings(struct si_context *sctx)
 
 static void si_update_gs_rings(struct si_context *sctx)
 {
-       unsigned gs_vert_itemsize = sctx->gs_shader->info.num_outputs * 16;
-       unsigned gs_max_vert_out = sctx->gs_shader->gs_max_out_vertices;
-       unsigned gsvs_itemsize = gs_vert_itemsize * gs_max_vert_out;
+       unsigned gsvs_itemsize = sctx->gs_shader->gsvs_itemsize;
        uint64_t offset;
 
+       if (gsvs_itemsize == sctx->last_gsvs_itemsize)
+               return;
+
+       sctx->last_gsvs_itemsize = gsvs_itemsize;
+
        si_set_ring_buffer(&sctx->b.b, PIPE_SHADER_GEOMETRY, SI_RING_GSVS,
                           sctx->gsvs_ring, gsvs_itemsize,
                           64, true, true, 4, 16, 0);