From 98b366c1f562309cc3314816f400f80f79c44a93 Mon Sep 17 00:00:00 2001 From: PixelyIon Date: Mon, 10 Jan 2022 04:16:56 +0530 Subject: [PATCH] Fix Texture Synchronization Bug Fixes texture corruption due to incorrect synchronization, the barrier would not enforce waiting till the texture was entirely rendered causing an incomplete texture to be downloaded which lead to rendering bugs for certain GPUs including ARM's Mali GPUs. --- app/src/main/cpp/skyline/gpu/texture/texture.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/src/main/cpp/skyline/gpu/texture/texture.cpp b/app/src/main/cpp/skyline/gpu/texture/texture.cpp index dd04ab83..2271f9bf 100644 --- a/app/src/main/cpp/skyline/gpu/texture/texture.cpp +++ b/app/src/main/cpp/skyline/gpu/texture/texture.cpp @@ -118,7 +118,7 @@ namespace skyline::gpu { void Texture::CopyFromStagingBuffer(const vk::raii::CommandBuffer &commandBuffer, const std::shared_ptr &stagingBuffer) { auto image{GetBacking()}; if (layout == vk::ImageLayout::eUndefined) - commandBuffer.pipelineBarrier(vk::PipelineStageFlagBits::eTopOfPipe, vk::PipelineStageFlagBits::eTransfer, {}, {}, {}, vk::ImageMemoryBarrier{ + commandBuffer.pipelineBarrier(vk::PipelineStageFlagBits::eHost, vk::PipelineStageFlagBits::eTransfer, {}, {}, {}, vk::ImageMemoryBarrier{ .image = image, .srcAccessMask = vk::AccessFlagBits::eMemoryRead, .dstAccessMask = vk::AccessFlagBits::eTransferWrite, @@ -157,7 +157,7 @@ namespace skyline::gpu { void Texture::CopyIntoStagingBuffer(const vk::raii::CommandBuffer &commandBuffer, const std::shared_ptr &stagingBuffer) { auto image{GetBacking()}; - commandBuffer.pipelineBarrier(vk::PipelineStageFlagBits::eTopOfPipe, vk::PipelineStageFlagBits::eTransfer, {}, {}, {}, vk::ImageMemoryBarrier{ + commandBuffer.pipelineBarrier(vk::PipelineStageFlagBits::eBottomOfPipe, vk::PipelineStageFlagBits::eTransfer, {}, {}, {}, vk::ImageMemoryBarrier{ .image = image, .srcAccessMask = vk::AccessFlagBits::eMemoryWrite, .dstAccessMask = vk::AccessFlagBits::eTransferRead, @@ -206,7 +206,6 @@ namespace skyline::gpu { void Texture::CopyToGuest(u8 *hostBuffer) { auto guestOutput{guest->mappings[0].data()}; - auto size{format->GetSize(dimensions)}; if (guest->tileConfig.mode == texture::TileMode::Block) CopyLinearToBlockLinear(*guest, hostBuffer, guestOutput);