[Mesa-dev] [PATCH 09/10] radv: add RADV_META_SAVE_COMPUTE flag

Samuel Pitoiset samuel.pitoiset at gmail.com
Tue Oct 3 18:52:44 UTC 2017


This will allow use to merge the compute save/restore helpers.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
 src/amd/vulkan/radv_meta.c | 23 +++++++++++++++++++++--
 src/amd/vulkan/radv_meta.h |  1 +
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/src/amd/vulkan/radv_meta.c b/src/amd/vulkan/radv_meta.c
index 6972a0b592..0b6dee25d9 100644
--- a/src/amd/vulkan/radv_meta.c
+++ b/src/amd/vulkan/radv_meta.c
@@ -34,9 +34,13 @@ void
 radv_meta_save(struct radv_meta_saved_state *state,
 	       struct radv_cmd_buffer *cmd_buffer, uint32_t flags)
 {
+	assert(flags & (RADV_META_SAVE_GRAPHICS | RADV_META_SAVE_COMPUTE));
+
 	state->flags = flags;
 
 	if (state->flags & RADV_META_SAVE_GRAPHICS) {
+		assert(!(state->flags & RADV_META_SAVE_COMPUTE));
+
 		state->old_pipeline = cmd_buffer->state.pipeline;
 
 		/* Save all viewports. */
@@ -61,6 +65,12 @@ radv_meta_save(struct radv_meta_saved_state *state,
 					   1 << VK_DYNAMIC_STATE_SCISSOR;
 	}
 
+	if (state->flags & RADV_META_SAVE_COMPUTE) {
+		assert(!(state->flags & RADV_META_SAVE_GRAPHICS));
+
+		state->old_pipeline = cmd_buffer->state.compute_pipeline;
+	}
+
 	if (state->flags & RADV_META_SAVE_DESCRIPTORS) {
 		state->old_descriptor_set0 = cmd_buffer->state.descriptors[0];
 	}
@@ -106,6 +116,12 @@ radv_meta_restore(const struct radv_meta_saved_state *state,
 					   1 << VK_DYNAMIC_STATE_SCISSOR;
 	}
 
+	if (state->flags & RADV_META_SAVE_COMPUTE) {
+		radv_CmdBindPipeline(radv_cmd_buffer_to_handle(cmd_buffer),
+				     VK_PIPELINE_BIND_POINT_COMPUTE,
+				     radv_pipeline_to_handle(state->old_pipeline));
+	}
+
 	if (state->flags & RADV_META_SAVE_DESCRIPTORS) {
 		cmd_buffer->state.descriptors[0] = state->old_descriptor_set0;
 		cmd_buffer->state.descriptors_dirty |= (1 << 0);
@@ -114,8 +130,11 @@ radv_meta_restore(const struct radv_meta_saved_state *state,
 	if (state->flags & RADV_META_SAVE_CONSTANTS) {
 		memcpy(cmd_buffer->push_constants, state->push_constants,
 		       MAX_PUSH_CONSTANTS_SIZE);
-		cmd_buffer->push_constant_stages |= VK_SHADER_STAGE_ALL_GRAPHICS |
-						    VK_SHADER_STAGE_COMPUTE_BIT;
+		cmd_buffer->push_constant_stages |= VK_SHADER_STAGE_COMPUTE_BIT;
+
+		if (state->flags & RADV_META_SAVE_GRAPHICS) {
+			cmd_buffer->push_constant_stages |= VK_SHADER_STAGE_ALL_GRAPHICS;
+		}
 	}
 
 	if (state->flags & RADV_META_SAVE_PASS) {
diff --git a/src/amd/vulkan/radv_meta.h b/src/amd/vulkan/radv_meta.h
index 5c94ff5a84..87ff1babcb 100644
--- a/src/amd/vulkan/radv_meta.h
+++ b/src/amd/vulkan/radv_meta.h
@@ -38,6 +38,7 @@ enum radv_meta_save_flags {
 	RADV_META_SAVE_CONSTANTS   = (1 << 1),
 	RADV_META_SAVE_DESCRIPTORS = (1 << 2),
 	RADV_META_SAVE_GRAPHICS    = (1 << 3),
+	RADV_META_SAVE_COMPUTE     = (1 << 4),
 };
 
 struct radv_meta_saved_state {
-- 
2.14.2



More information about the mesa-dev mailing list