radv: add RADV_META_SAVE_COMPUTE_PIPELINE flag
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Tue, 3 Oct 2017 12:47:32 +0000 (14:47 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 6 Oct 2017 07:49:06 +0000 (09:49 +0200)
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>
src/amd/vulkan/radv_meta.c
src/amd/vulkan/radv_meta.h

index 647742273c1e22f231bc6c9a147bcc108f1496b7..a35e23167a99953c76daaa9832da193182bc9874 100644 (file)
@@ -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) {
index c4806daa3d4e6db002b3c279ae30ec69e8037990..358df7059912c1eadd01fa9c38322fbec9a8809d 100644 (file)
@@ -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 {