v3dv: fix dynamic state after meta operation
authorIago Toral Quiroga <itoral@igalia.com>
Thu, 23 Jul 2020 10:45:41 +0000 (12:45 +0200)
committerMarge Bot <eric+marge@anholt.net>
Tue, 13 Oct 2020 21:21:32 +0000 (21:21 +0000)
We should always save state on a push before starting a meta operation,
even if we don't have a pipeline, since dynamic state can be set at any
time directly on the command buffer. Similarly, we should always restore
it if the pop after the meta operation signals that it has written any
state, not only if we have a graphics pipeline to restore.

Fixes a rendering artifact in VkQuake.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

src/broadcom/vulkan/v3dv_cmd_buffer.c

index 283591e..89563d4 100644 (file)
@@ -3666,9 +3666,7 @@ v3dv_cmd_buffer_meta_state_push(struct v3dv_cmd_buffer *cmd_buffer,
    }
 
    state->meta.pipeline = v3dv_pipeline_to_handle(state->pipeline);
-   if (state->meta.pipeline) {
-      memcpy(&state->meta.dynamic, &state->dynamic, sizeof(state->dynamic));
-   }
+   memcpy(&state->meta.dynamic, &state->dynamic, sizeof(state->dynamic));
 
    /* We expect that meta operations are graphics-only and won't alter
     * compute state.
@@ -3736,14 +3734,15 @@ v3dv_cmd_buffer_meta_state_pop(struct v3dv_cmd_buffer *cmd_buffer,
       v3dv_CmdBindPipeline(v3dv_cmd_buffer_to_handle(cmd_buffer),
                            pipeline_binding,
                            state->meta.pipeline);
-      if (pipeline_binding == VK_PIPELINE_BIND_POINT_GRAPHICS) {
-         memcpy(&state->dynamic, &state->meta.dynamic, sizeof(state->dynamic));
-         state->dirty |= dirty_dynamic_state;
-      }
    } else {
       state->pipeline = VK_NULL_HANDLE;
    }
 
+   if (dirty_dynamic_state) {
+      memcpy(&state->dynamic, &state->meta.dynamic, sizeof(state->dynamic));
+      state->dirty |= dirty_dynamic_state;
+   }
+
    if (state->meta.has_descriptor_state) {
       if (state->meta.descriptor_state.valid != 0) {
          memcpy(&state->descriptor_state[VK_PIPELINE_BIND_POINT_GRAPHICS],