[Mesa-dev] [PATCH 2/2] radv: only update ia_multi_vgt_param if something changes.

Dave Airlie airlied at gmail.com
Wed Jun 7 01:16:03 UTC 2017


From: Dave Airlie <airlied at redhat.com>

This in theory should reduce the number of calculations for this register
per draw.
---
 src/amd/vulkan/radv_private.h  |  2 ++
 src/amd/vulkan/si_cmd_buffer.c | 11 +++++++++++
 2 files changed, 13 insertions(+)

diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h
index c88f1ff..8f60d9b 100644
--- a/src/amd/vulkan/radv_private.h
+++ b/src/amd/vulkan/radv_private.h
@@ -775,6 +775,8 @@ struct radv_cmd_state {
 	uint32_t                                      descriptors_dirty;
 	uint32_t                                      trace_id;
 	uint32_t                                      last_ia_multi_vgt_param;
+	bool last_draw_instanced, last_draw_indirect, last_multi_instances_smaller_than_primgroup, ia_set_once;
+	
 };
 
 struct radv_cmd_pool {
diff --git a/src/amd/vulkan/si_cmd_buffer.c b/src/amd/vulkan/si_cmd_buffer.c
index 3464def..9b65b45 100644
--- a/src/amd/vulkan/si_cmd_buffer.c
+++ b/src/amd/vulkan/si_cmd_buffer.c
@@ -700,6 +700,17 @@ si_get_ia_multi_vgt_param(struct radv_cmd_buffer *cmd_buffer,
 
 	multi_instances_smaller_than_primgroup = indirect_draw || instance_less_than_primgroup_size;
 
+	if (cmd_buffer->state.ia_set_once &&
+	    cmd_buffer->state.last_draw_instanced == instanced_draw &&
+	    cmd_buffer->state.last_draw_indirect == indirect_draw &&
+	    cmd_buffer->state.last_multi_instances_smaller_than_primgroup == multi_instances_smaller_than_primgroup)
+		return cmd_buffer->state.last_ia_multi_vgt_param;
+
+	cmd_buffer->state.ia_set_once = true;
+	cmd_buffer->state.last_draw_instanced = instanced_draw;
+	cmd_buffer->state.last_draw_indirect = indirect_draw;
+	cmd_buffer->state.last_multi_instances_smaller_than_primgroup = multi_instances_smaller_than_primgroup;
+
 	ia_switch_on_eoi = cmd_buffer->state.pipeline->graphics.tess_ia_switch_on_eoi;
 	partial_vs_wave = cmd_buffer->state.pipeline->graphics.tess_partial_vs_wave;
 	partial_es_wave = cmd_buffer->state.pipeline->graphics.partial_es_wave;
-- 
2.9.4



More information about the mesa-dev mailing list