From e65ca52d911b268768f0593ae27a834b7228fab6 Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Thu, 3 Nov 2022 22:32:18 +0000 Subject: [PATCH] Avoid potential buffer copy race --- app/src/main/cpp/skyline/gpu/buffer.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/main/cpp/skyline/gpu/buffer.cpp b/app/src/main/cpp/skyline/gpu/buffer.cpp index 4f7f162c..feff2aaf 100644 --- a/app/src/main/cpp/skyline/gpu/buffer.cpp +++ b/app/src/main/cpp/skyline/gpu/buffer.cpp @@ -291,8 +291,7 @@ namespace skyline::gpu { AdvanceSequence(); // We are modifying GPU backing contents so advance to the next sequence everHadInlineUpdate = true; - std::scoped_lock dstLock{stateMutex}; - std::scoped_lock srcLock{src->stateMutex}; // Fine even if src and dst are same since recursive mutex + std::scoped_lock lock{stateMutex, src->stateMutex}; // Fine even if src and dst are same since recursive mutex if (dirtyState == DirtyState::CpuDirty && SequencedCpuBackingWritesBlocked()) // If the buffer is used in sequence directly on the GPU, SynchronizeHost before modifying the mirror contents to ensure proper sequencing. This write will then be sequenced on the GPU instead (the buffer will be kept clean for the rest of the execution due to gpuCopyCallback blocking all writes)