radeonsi: don't emit redundant PKT3_NUM_INSTANCES packets
authorMarek Olšák <marek.olsak@amd.com>
Tue, 13 Nov 2018 01:38:46 +0000 (20:38 -0500)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 2 Jan 2019 20:01:50 +0000 (15:01 -0500)
Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de>
src/gallium/drivers/radeonsi/si_pipe.h
src/gallium/drivers/radeonsi/si_state_draw.c

index bfcfc9151245ad15941c9a36a17759a4eca9de81..4512d2529afc08fdc0e3804ac6e024ec8ea12199 100644 (file)
@@ -47,6 +47,7 @@
  * the number shouldn't be a commonly-used one. */
 #define SI_BASE_VERTEX_UNKNOWN         INT_MIN
 #define SI_RESTART_INDEX_UNKNOWN       INT_MIN
+#define SI_INSTANCE_COUNT_UNKNOWN      INT_MIN
 #define SI_NUM_SMOOTH_AA_SAMPLES       8
 #define SI_MAX_POINT_SIZE              2048
 #define SI_GS_PER_ES                   128
@@ -925,6 +926,7 @@ struct si_context {
        int                     last_index_size;
        int                     last_base_vertex;
        int                     last_start_instance;
+       int                     last_instance_count;
        int                     last_drawid;
        int                     last_sh_base_reg;
        int                     last_primitive_restart_en;
@@ -1374,6 +1376,7 @@ static inline void
 si_invalidate_draw_sh_constants(struct si_context *sctx)
 {
        sctx->last_base_vertex = SI_BASE_VERTEX_UNKNOWN;
+       sctx->last_instance_count = SI_INSTANCE_COUNT_UNKNOWN;
 }
 
 static inline unsigned
index d011adb2cad37e25d67a5f3dc50efdd9eea8c851..cfd904e621cd00202c353da64191e3adc8bf3bd3 100644 (file)
@@ -813,10 +813,15 @@ static void si_emit_draw_packets(struct si_context *sctx,
                        radeon_emit(cs, di_src_sel);
                }
        } else {
+               unsigned instance_count = info->instance_count;
                int base_vertex;
 
-               radeon_emit(cs, PKT3(PKT3_NUM_INSTANCES, 0, 0));
-               radeon_emit(cs, info->instance_count);
+               if (sctx->last_instance_count == SI_INSTANCE_COUNT_UNKNOWN ||
+                   sctx->last_instance_count != instance_count) {
+                       radeon_emit(cs, PKT3(PKT3_NUM_INSTANCES, 0, 0));
+                       radeon_emit(cs, instance_count);
+                       sctx->last_instance_count = instance_count;
+               }
 
                /* Base vertex and start instance. */
                base_vertex = index_size ? info->index_bias : info->start;