- 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);
+ VkPipelineBindPoint bind_point =
+ flags & RADV_META_SAVE_GRAPHICS_PIPELINE ?
+ VK_PIPELINE_BIND_POINT_GRAPHICS :
+ VK_PIPELINE_BIND_POINT_COMPUTE;
+ struct radv_descriptor_state *descriptors_state =
+ radv_get_descriptors_state(cmd_buffer, bind_point);
+
+ 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. */
+ 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);
+
+ /* The most common meta operations all want to have the
+ * viewport reset and any scissors disabled. The rest of the
+ * dynamic state should have no effect.
+ */
+ cmd_buffer->state.dynamic.viewport.count = 0;
+ cmd_buffer->state.dynamic.scissor.count = 0;
+ cmd_buffer->state.dirty |= 1 << VK_DYNAMIC_STATE_VIEWPORT |
+ 1 << VK_DYNAMIC_STATE_SCISSOR;
+ }