From 2d97b9fc2cfe01aaf47491770b35226ede3f7204 Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Sun, 12 Feb 2023 20:21:16 +0000 Subject: [PATCH] Keep track of buffer dirtiness within an execution --- app/src/main/cpp/skyline/gpu/buffer.cpp | 3 +++ app/src/main/cpp/skyline/gpu/buffer.h | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/app/src/main/cpp/skyline/gpu/buffer.cpp b/app/src/main/cpp/skyline/gpu/buffer.cpp index 277a84d2..bcaa5c88 100644 --- a/app/src/main/cpp/skyline/gpu/buffer.cpp +++ b/app/src/main/cpp/skyline/gpu/buffer.cpp @@ -430,6 +430,8 @@ namespace skyline::gpu { if (!guest) return; + currentExecutionGpuDirty = true; + if (isDirect) MarkGpuDirtyImplDirect(); else @@ -648,6 +650,7 @@ namespace skyline::gpu { void Buffer::unlock() { tag = ContextTag{}; AllowAllBackingWrites(); + currentExecutionGpuDirty = false; mutex.unlock(); } diff --git a/app/src/main/cpp/skyline/gpu/buffer.h b/app/src/main/cpp/skyline/gpu/buffer.h index 102508e5..5092a47e 100644 --- a/app/src/main/cpp/skyline/gpu/buffer.h +++ b/app/src/main/cpp/skyline/gpu/buffer.h @@ -80,6 +80,8 @@ namespace skyline::gpu { } backingImmutability{}; //!< Describes how the buffer backing should be accessed by the current context RecursiveSpinLock stateMutex; //!< Synchronizes access to the dirty state and backing immutability + bool currentExecutionGpuDirty{}; //!< If the buffer is GPU dirty within the current execution + static constexpr u32 InitialSequenceNumber{1}; //!< Sequence number that all buffers start off with static constexpr u32 FrequentlySyncedThreshold{6}; //!< Threshold for the sequence number after which the buffer is considered elegible for megabuffering u32 sequenceNumber{InitialSequenceNumber}; //!< Sequence number that is incremented after all modifications to the host side `backing` buffer, used to prevent redundant copies of the buffer being stored in the megabuffer by views @@ -322,6 +324,13 @@ namespace skyline::gpu { return accumulatedCpuLockCounter >= FrequentlyLockedThreshold; } + /* + * @note The buffer **must** be locked prior to calling this + */ + bool IsCurrentExecutionGpuDirty() { + return currentExecutionGpuDirty; + } + /** * @brief Waits on a fence cycle if it exists till it's signalled and resets it after * @note The buffer **must** be locked prior to calling this