diff options
author | Samuel Pitoiset <samuel.pitoiset@gmail.com> | 2017-10-03 14:12:05 +0200 |
---|---|---|
committer | Samuel Pitoiset <samuel.pitoiset@gmail.com> | 2017-10-06 09:49:05 +0200 |
commit | 807f2d4f338f456fdf662546ac4a2ae30172a5c0 (patch) | |
tree | 52711a5e88744b53e3ad004a0e2f89942935dd38 /src/amd/vulkan/radv_meta.c | |
parent | a3a497c92152bece5698f05969d497694e033c19 (diff) |
radv: introduce the concept of meta save flags
This will allow us to save/restore the different states on-demand
based on the meta operation. For now, this saves/restores all
states. Compute will follow once the graphics part is done.
The main idea is to merge all save/restore helpers.
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Diffstat (limited to 'src/amd/vulkan/radv_meta.c')
-rw-r--r-- | src/amd/vulkan/radv_meta.c | 99 |
1 files changed, 61 insertions, 38 deletions
diff --git a/src/amd/vulkan/radv_meta.c b/src/amd/vulkan/radv_meta.c index 3ddbc2e9af..4a45f083f6 100644 --- a/src/amd/vulkan/radv_meta.c +++ b/src/amd/vulkan/radv_meta.c @@ -32,53 +32,75 @@ static void radv_meta_save_novertex(struct radv_meta_saved_state *state, - const struct radv_cmd_buffer *cmd_buffer) + const struct radv_cmd_buffer *cmd_buffer, + uint32_t flags) { - state->old_pipeline = cmd_buffer->state.pipeline; - state->old_descriptor_set0 = cmd_buffer->state.descriptors[0]; - - /* Save all viewports. */ - state->viewport.count = cmd_buffer->state.dynamic.viewport.count; - typed_memcpy(state->viewport.viewports, - cmd_buffer->state.dynamic.viewport.viewports, - MAX_VIEWPORTS); + state->flags = flags; + + if (state->flags & RADV_META_SAVE_GRAPHICS_PIPELINE) { + state->old_pipeline = cmd_buffer->state.pipeline; + + /* Save all viewports. */ + state->viewport.count = cmd_buffer->state.dynamic.viewport.count; + typed_memcpy(state->viewport.viewports, + cmd_buffer->state.dynamic.viewport.viewports, + MAX_VIEWPORTS); + + /* Save all scissors. */ + state->scissor.count = cmd_buffer->state.dynamic.scissor.count; + typed_memcpy(state->scissor.scissors, + cmd_buffer->state.dynamic.scissor.scissors, + MAX_SCISSORS); + } - /* Save all scissors. */ - state->scissor.count = cmd_buffer->state.dynamic.scissor.count; - typed_memcpy(state->scissor.scissors, - cmd_buffer->state.dynamic.scissor.scissors, - MAX_SCISSORS); + if (state->flags & RADV_META_SAVE_DESCRIPTORS) { + state->old_descriptor_set0 = cmd_buffer->state.descriptors[0]; + } - memcpy(state->push_constants, cmd_buffer->push_constants, MAX_PUSH_CONSTANTS_SIZE); + if (state->flags & RADV_META_SAVE_CONSTANTS) { + memcpy(state->push_constants, cmd_buffer->push_constants, + MAX_PUSH_CONSTANTS_SIZE); + } } void radv_meta_restore(const struct radv_meta_saved_state *state, struct radv_cmd_buffer *cmd_buffer) { - radv_CmdBindPipeline(radv_cmd_buffer_to_handle(cmd_buffer), VK_PIPELINE_BIND_POINT_GRAPHICS, - radv_pipeline_to_handle(state->old_pipeline)); - cmd_buffer->state.descriptors[0] = state->old_descriptor_set0; - - cmd_buffer->state.dirty |= RADV_CMD_DIRTY_PIPELINE; - - /* Restore all viewports. */ - cmd_buffer->state.dynamic.viewport.count = state->viewport.count; - typed_memcpy(cmd_buffer->state.dynamic.viewport.viewports, - state->viewport.viewports, - MAX_VIEWPORTS); - - /* Restore all scissors. */ - cmd_buffer->state.dynamic.scissor.count = state->scissor.count; - typed_memcpy(cmd_buffer->state.dynamic.scissor.scissors, - state->scissor.scissors, - MAX_SCISSORS); + if (state->flags & RADV_META_SAVE_GRAPHICS_PIPELINE) { + radv_CmdBindPipeline(radv_cmd_buffer_to_handle(cmd_buffer), + VK_PIPELINE_BIND_POINT_GRAPHICS, + radv_pipeline_to_handle(state->old_pipeline)); + + cmd_buffer->state.dirty |= RADV_CMD_DIRTY_PIPELINE; + + /* Restore all viewports. */ + cmd_buffer->state.dynamic.viewport.count = state->viewport.count; + typed_memcpy(cmd_buffer->state.dynamic.viewport.viewports, + state->viewport.viewports, + MAX_VIEWPORTS); + + /* Restore all scissors. */ + cmd_buffer->state.dynamic.scissor.count = state->scissor.count; + typed_memcpy(cmd_buffer->state.dynamic.scissor.scissors, + state->scissor.scissors, + MAX_SCISSORS); + + cmd_buffer->state.dirty |= 1 << VK_DYNAMIC_STATE_VIEWPORT | + 1 << VK_DYNAMIC_STATE_SCISSOR; + } - cmd_buffer->state.dirty |= 1 << VK_DYNAMIC_STATE_VIEWPORT | - 1 << VK_DYNAMIC_STATE_SCISSOR; + if (state->flags & RADV_META_SAVE_DESCRIPTORS) { + cmd_buffer->state.descriptors[0] = state->old_descriptor_set0; + cmd_buffer->state.descriptors_dirty |= (1 << 0); + } - 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; + 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; + } } void @@ -410,9 +432,10 @@ radv_device_finish_meta(struct radv_device *device) */ void radv_meta_save_graphics_reset_vport_scissor_novertex(struct radv_meta_saved_state *saved_state, - struct radv_cmd_buffer *cmd_buffer) + struct radv_cmd_buffer *cmd_buffer, + uint32_t flags) { - radv_meta_save_novertex(saved_state, cmd_buffer); + radv_meta_save_novertex(saved_state, cmd_buffer, flags); cmd_buffer->state.dynamic.viewport.count = 0; cmd_buffer->state.dynamic.scissor.count = 0; cmd_buffer->state.dirty |= 1 << VK_DYNAMIC_STATE_VIEWPORT | |