[Vulkan] Barrier consecutive uploads to the same image
Avoids a TRANSFER_WRITE -> TRANSFER_WRITE hazard identified by the Vulkan validation layer when a texture is reuploaded (after guest memory invalidation) without having been used for drawing in between, leaving it in the transfer destination usage with no layout transition to order the copies. Co-authored-by: Herman S. <429230+has207@users.noreply.github.com>
This commit is contained in:
committed by
Radosław Gliński
parent
cde5d85ec9
commit
1fdbe569e4
@@ -1642,6 +1642,16 @@ bool VulkanTextureCache::LoadTextureDataFromResidentMemoryImpl(Texture& texture,
|
||||
vulkan_texture.image(), ui::vulkan::util::InitializeSubresourceRange(),
|
||||
texture_src_stage_mask, texture_dst_stage_mask, texture_src_access_mask,
|
||||
texture_dst_access_mask, texture_old_layout, texture_new_layout);
|
||||
} else {
|
||||
// Same layout/usage but another upload may have written the image earlier
|
||||
// in this submission - emit a TRANSFER_WRITE -> TRANSFER_WRITE barrier so
|
||||
// the next CmdCopyBufferToImage is ordered after any prior copy.
|
||||
command_processor_.PushImageMemoryBarrier(
|
||||
vulkan_texture.image(), ui::vulkan::util::InitializeSubresourceRange(),
|
||||
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_TRANSFER_WRITE_BIT,
|
||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
||||
}
|
||||
command_processor_.SubmitBarriers(true);
|
||||
VkBufferImageCopy* copy_regions = command_buffer.CmdCopyBufferToImageEmplace(
|
||||
|
||||
Reference in New Issue
Block a user