diff options
author | Samuel Pitoiset <samuel.pitoiset@gmail.com> | 2017-10-03 14:47:32 +0200 |
---|---|---|
committer | Samuel Pitoiset <samuel.pitoiset@gmail.com> | 2017-10-06 09:49:06 +0200 |
commit | 213f86e514249dba245c97877b3eae3c2018a599 (patch) | |
tree | 2bea6606d654588a606d712c7d7ea331adfcbf00 | |
parent | ba3dc3519d6b6fa45772bb70351b29dc0e8d5f12 (diff) |
radv: add RADV_META_SAVE_COMPUTE_PIPELINE flag
This will allow use to merge the compute save/restore helpers.
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
-rw-r--r-- | src/amd/vulkan/radv_meta.c | 24 | ||||
-rw-r--r-- | src/amd/vulkan/radv_meta.h | 1 |
2 files changed, 23 insertions, 2 deletions
diff --git a/src/amd/vulkan/radv_meta.c b/src/amd/vulkan/radv_meta.c index 647742273c1..a35e23167a9 100644 --- a/src/amd/vulkan/radv_meta.c +++ b/src/amd/vulkan/radv_meta.c @@ -34,9 +34,14 @@ 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_PIPELINE | + RADV_META_SAVE_COMPUTE_PIPELINE)); + state->flags = flags; if (state->flags & RADV_META_SAVE_GRAPHICS_PIPELINE) { + assert(!(state->flags & RADV_META_SAVE_COMPUTE_PIPELINE)); + state->old_pipeline = cmd_buffer->state.pipeline; /* Save all viewports. */ @@ -61,6 +66,12 @@ radv_meta_save(struct radv_meta_saved_state *state, 1 << VK_DYNAMIC_STATE_SCISSOR; } + if (state->flags & RADV_META_SAVE_COMPUTE_PIPELINE) { + assert(!(state->flags & RADV_META_SAVE_GRAPHICS_PIPELINE)); + + 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 +117,12 @@ radv_meta_restore(const struct radv_meta_saved_state *state, 1 << VK_DYNAMIC_STATE_SCISSOR; } + if (state->flags & RADV_META_SAVE_COMPUTE_PIPELINE) { + 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 +131,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_PIPELINE) { + 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 c4806daa3d4..358df705991 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_PIPELINE = (1 << 3), + RADV_META_SAVE_COMPUTE_PIPELINE = (1 << 4), }; struct radv_meta_saved_state { |