From c9f68361a8ac762b54505eda541a167b014ce0a2 Mon Sep 17 00:00:00 2001 From: Iago Toral Quiroga Date: Tue, 26 Apr 2022 09:28:59 +0200 Subject: [PATCH] v3dv: ignore barriers for image layout transitions from undefined layouts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Layout transitions are not relevant to us, we only care about barriers that involve a sync point between read/write actions on the image across GPU jobs. Image transitions from undefined layout can only happen before the image is ever used by the GPU, which means they are never relevant to our implementation. This improves performance in vkQuake. Reviewed-by: Alejandro PiƱeiro Part-of: --- src/broadcom/vulkan/v3dv_cmd_buffer.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/broadcom/vulkan/v3dv_cmd_buffer.c b/src/broadcom/vulkan/v3dv_cmd_buffer.c index ea4e9a5e820..7ed795f12c0 100644 --- a/src/broadcom/vulkan/v3dv_cmd_buffer.c +++ b/src/broadcom/vulkan/v3dv_cmd_buffer.c @@ -2650,6 +2650,19 @@ v3dv_CmdPipelineBarrier(VkCommandBuffer commandBuffer, { V3DV_FROM_HANDLE(v3dv_cmd_buffer, cmd_buffer, commandBuffer); + /* We can safely skip barriers for image layout transitions from UNDEFINED + * layout. + */ + if (imageBarrierCount > 0) { + bool all_undefined = true; + for (int i = 0; all_undefined && i < imageBarrierCount; i++) { + if (pImageBarriers[i].oldLayout != VK_IMAGE_LAYOUT_UNDEFINED) + all_undefined = false; + } + if (all_undefined) + imageBarrierCount = 0; + } + if (memoryBarrierCount + bufferBarrierCount + imageBarrierCount == 0) return;