Keep track of buffer dirtiness within an execution

This commit is contained in:
Billy Laws 2023-02-12 20:21:16 +00:00
parent 6ea1483c9a
commit 2d97b9fc2c
2 changed files with 12 additions and 0 deletions

View File

@ -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();
}

View File

@ -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