vulkan: Handle VK_SUBPASS_EXTERNAL at the end of a subpass

Fixes: 1d726940d2 ("vulkan: Add a common CmdBegin/EndRederPass implementation")
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19599>
(cherry picked from commit 4ff5051944e7a7a8bf003c331af1a73ac6c7df61)
This commit is contained in:
Jason Ekstrand 2022-11-08 10:23:02 -06:00 committed by Dylan Baker
parent fca0249e9c
commit 71be5b2549
2 changed files with 37 additions and 4 deletions

View File

@ -256,7 +256,7 @@
"description": "vulkan: Handle VK_SUBPASS_EXTERNAL at the end of a subpass",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "1d726940d2881395994751078dad3bda0cabbdfb"
},
@ -868,7 +868,7 @@
"description": "meson: Fixes name_prefix for clover on mingw",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null
},
@ -877,7 +877,7 @@
"description": "clover: Fixes building with mingw-x86",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null
},
@ -886,7 +886,7 @@
"description": "clover: Rename *OpenCL.def to *OpenCL.def.in",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null
},

View File

@ -2054,9 +2054,42 @@ static void
end_subpass(struct vk_command_buffer *cmd_buffer,
const VkSubpassEndInfo *end_info)
{
const struct vk_render_pass *pass = cmd_buffer->render_pass;
const uint32_t subpass_idx = cmd_buffer->subpass_idx;
struct vk_device_dispatch_table *disp =
&cmd_buffer->base.device->dispatch_table;
disp->CmdEndRendering(vk_command_buffer_to_handle(cmd_buffer));
bool needs_mem_barrier = false;
VkMemoryBarrier2 mem_barrier = {
.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER_2,
};
for (uint32_t d = 0; d < pass->dependency_count; d++) {
const struct vk_subpass_dependency *dep = &pass->dependencies[d];
if (dep->src_subpass != subpass_idx)
continue;
if (dep->dst_subpass != VK_SUBPASS_EXTERNAL)
continue;
needs_mem_barrier = true;
mem_barrier.srcStageMask |= dep->src_stage_mask;
mem_barrier.srcAccessMask |= dep->src_access_mask;
mem_barrier.dstStageMask |= dep->dst_stage_mask;
mem_barrier.dstAccessMask |= dep->dst_access_mask;
}
if (needs_mem_barrier) {
const VkDependencyInfo dependency_info = {
.sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
.dependencyFlags = 0,
.memoryBarrierCount = 1,
.pMemoryBarriers = &mem_barrier,
};
disp->CmdPipelineBarrier2(vk_command_buffer_to_handle(cmd_buffer),
&dependency_info);
}
}
VKAPI_ATTR void VKAPI_CALL