[Mesa-dev] [PATCH 2/4] radv: add radv_dispatch() helper

Samuel Pitoiset samuel.pitoiset at gmail.com
Thu Sep 14 16:50:05 UTC 2017


To share common dispatch compute code.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
 src/amd/vulkan/radv_cmd_buffer.c | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c
index 6ffbba2f1d..143acf1719 100644
--- a/src/amd/vulkan/radv_cmd_buffer.c
+++ b/src/amd/vulkan/radv_cmd_buffer.c
@@ -3268,6 +3268,17 @@ radv_emit_dispatch_packets(struct radv_cmd_buffer *cmd_buffer,
 	assert(cmd_buffer->cs->cdw <= cdw_max);
 }
 
+static void
+radv_dispatch(struct radv_cmd_buffer *cmd_buffer,
+	      const struct radv_dispatch_info *info)
+{
+	radv_flush_compute_state(cmd_buffer);
+
+	radv_emit_dispatch_packets(cmd_buffer, info);
+
+	radv_cmd_buffer_after_draw(cmd_buffer);
+}
+
 void radv_CmdDispatch(
 	VkCommandBuffer                             commandBuffer,
 	uint32_t                                    x,
@@ -3277,15 +3288,11 @@ void radv_CmdDispatch(
 	RADV_FROM_HANDLE(radv_cmd_buffer, cmd_buffer, commandBuffer);
 	struct radv_dispatch_info info = {};
 
-	radv_flush_compute_state(cmd_buffer);
-
 	info.blocks[0] = x;
 	info.blocks[1] = y;
 	info.blocks[2] = z;
 
-	radv_emit_dispatch_packets(cmd_buffer, &info);
-
-	radv_cmd_buffer_after_draw(cmd_buffer);
+	radv_dispatch(cmd_buffer, &info);
 }
 
 void radv_CmdDispatchIndirect(
@@ -3297,14 +3304,10 @@ void radv_CmdDispatchIndirect(
 	RADV_FROM_HANDLE(radv_buffer, buffer, _buffer);
 	struct radv_dispatch_info info = {};
 
-	radv_flush_compute_state(cmd_buffer);
-
 	info.indirect = buffer;
 	info.indirect_offset = offset;
 
-	radv_emit_dispatch_packets(cmd_buffer, &info);
-
-	radv_cmd_buffer_after_draw(cmd_buffer);
+	radv_dispatch(cmd_buffer, &info);
 }
 
 void radv_unaligned_dispatch(
@@ -3320,11 +3323,7 @@ void radv_unaligned_dispatch(
 	info.blocks[2] = z;
 	info.unaligned = 1;
 
-	radv_flush_compute_state(cmd_buffer);
-
-	radv_emit_dispatch_packets(cmd_buffer, &info);
-
-	radv_cmd_buffer_after_draw(cmd_buffer);
+	radv_dispatch(cmd_buffer, &info);
 }
 
 void radv_CmdEndRenderPass(
-- 
2.14.1



More information about the mesa-dev mailing list