From 7670c834058ab155223f6457da81f618a2164980 Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Tue, 25 Oct 2022 21:38:10 +0100 Subject: [PATCH] Ensure textures are clean before paging them out --- app/src/main/cpp/skyline/gpu/texture/texture.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/src/main/cpp/skyline/gpu/texture/texture.cpp b/app/src/main/cpp/skyline/gpu/texture/texture.cpp index ba4b48e1..9ca7934b 100644 --- a/app/src/main/cpp/skyline/gpu/texture/texture.cpp +++ b/app/src/main/cpp/skyline/gpu/texture/texture.cpp @@ -752,8 +752,12 @@ namespace skyline::gpu { cycle = lCycle; } - if (gpuDirty) - gpu.state.nce->PageOutRegions(*trapHandle); // All data can be paged out from the guest as the guest mirror won't be used + { + std::scoped_lock lock{stateMutex}; + + if (dirtyState == DirtyState::Clean && gpuDirty) + gpu.state.nce->PageOutRegions(*trapHandle); // All data can be paged out from the guest as the guest mirror won't be used + } } void Texture::SynchronizeHostInline(const vk::raii::CommandBuffer &commandBuffer, const std::shared_ptr &pCycle, bool gpuDirty) { @@ -785,8 +789,12 @@ namespace skyline::gpu { cycle = pCycle; } - if (gpuDirty) - gpu.state.nce->PageOutRegions(*trapHandle); + { + std::scoped_lock lock{stateMutex}; + + if (dirtyState == DirtyState::Clean && gpuDirty) + gpu.state.nce->PageOutRegions(*trapHandle); // All data can be paged out from the guest as the guest mirror won't be used + } } void Texture::SynchronizeGuest(bool cpuDirty, bool skipTrap) {