Mesa (master): radeonsi: don't emit redundant PKT3_NUM_INSTANCES packets

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jan 2 20:06:09 UTC 2019


Module: Mesa
Branch: master
Commit: d28e20821349f6ba0172904d8c54e16d734de8d6
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=d28e20821349f6ba0172904d8c54e16d734de8d6

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Mon Nov 12 20:38:46 2018 -0500

radeonsi: don't emit redundant PKT3_NUM_INSTANCES packets

Tested-by: Dieter Nützel <Dieter at nuetzel-hh.de>

---

 src/gallium/drivers/radeonsi/si_pipe.h       | 3 +++
 src/gallium/drivers/radeonsi/si_state_draw.c | 9 +++++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h
index bfcfc91512..4512d2529a 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.h
+++ b/src/gallium/drivers/radeonsi/si_pipe.h
@@ -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
diff --git a/src/gallium/drivers/radeonsi/si_state_draw.c b/src/gallium/drivers/radeonsi/si_state_draw.c
index d011adb2ca..cfd904e621 100644
--- a/src/gallium/drivers/radeonsi/si_state_draw.c
+++ b/src/gallium/drivers/radeonsi/si_state_draw.c
@@ -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;




More information about the mesa-commit mailing list