From 0678bb03d7e281707223c7e1c6e733b922e78efc Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sat, 26 Aug 2023 15:47:20 +1000 Subject: [PATCH] GS/Vulkan: Prevent transition back to Undefined layout --- pcsx2/GS/Renderers/Vulkan/GSTextureVK.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pcsx2/GS/Renderers/Vulkan/GSTextureVK.cpp b/pcsx2/GS/Renderers/Vulkan/GSTextureVK.cpp index 5232a54c25814..0ce46811d7de6 100644 --- a/pcsx2/GS/Renderers/Vulkan/GSTextureVK.cpp +++ b/pcsx2/GS/Renderers/Vulkan/GSTextureVK.cpp @@ -342,7 +342,9 @@ void GSTextureVK::UpdateFromBuffer(VkCommandBuffer cmdbuf, int level, u32 x, u32 u32 buffer_height, u32 row_length, VkBuffer buffer, u32 buffer_offset) { const Layout old_layout = m_layout; - if (old_layout != Layout::TransferDst) + if (old_layout == Layout::Undefined) + TransitionToLayout(cmdbuf, Layout::TransferDst); + else if (old_layout != Layout::TransferDst) TransitionSubresourcesToLayout(cmdbuf, level, 1, old_layout, Layout::TransferDst); const VkBufferImageCopy bic = {static_cast(buffer_offset), row_length, buffer_height, @@ -351,7 +353,7 @@ void GSTextureVK::UpdateFromBuffer(VkCommandBuffer cmdbuf, int level, u32 x, u32 vkCmdCopyBufferToImage(cmdbuf, buffer, m_image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &bic); - if (old_layout != Layout::TransferDst) + if (old_layout != Layout::TransferDst && old_layout != Layout::Undefined) TransitionSubresourcesToLayout(cmdbuf, level, 1, Layout::TransferDst, old_layout); } @@ -499,6 +501,9 @@ void GSTextureVK::GenerateMipmap() { const VkCommandBuffer cmdbuf = GetCommandBufferForUpdate(); + if (m_layout == Layout::Undefined) + TransitionToLayout(cmdbuf, Layout::TransferSrc); + for (int dst_level = 1; dst_level < m_mipmap_levels; dst_level++) { const int src_level = dst_level - 1; @@ -885,7 +890,9 @@ void GSDownloadTextureVK::CopyFromTexture( GL_INS("GSDownloadTextureVK::CopyFromTexture: {%d,%d} %ux%u", src.left, src.top, src.width(), src.height()); GSTextureVK::Layout old_layout = vkTex->GetLayout(); - if (old_layout != GSTextureVK::Layout::TransferSrc) + if (old_layout == GSTextureVK::Layout::Undefined) + vkTex->TransitionToLayout(cmdbuf, GSTextureVK::Layout::TransferSrc); + else if (old_layout != GSTextureVK::Layout::TransferSrc) vkTex->TransitionSubresourcesToLayout(cmdbuf, src_level, 1, old_layout, GSTextureVK::Layout::TransferSrc); VkBufferImageCopy image_copy = {}; @@ -915,7 +922,7 @@ void GSDownloadTextureVK::CopyFromTexture( vkCmdPipelineBarrier( cmdbuf, VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_HOST_BIT, 0, 0, nullptr, 1, &buffer_info, 0, nullptr); - if (old_layout != GSTextureVK::Layout::TransferSrc) + if (old_layout != GSTextureVK::Layout::TransferSrc && old_layout != GSTextureVK::Layout::Undefined) vkTex->TransitionSubresourcesToLayout(cmdbuf, src_level, 1, GSTextureVK::Layout::TransferSrc, old_layout); m_copy_fence_counter = GSDeviceVK::GetInstance()->GetCurrentFenceCounter();