mirror of
https://github.com/Takiiiiiiii/strato.git
synced 2025-07-17 08:46:39 +00:00
Keep track of how often textures/buffers are locked on the CPU
For the upcoming preserve attachment optimisation, which will keep buffers/textures locked on the GPU between executions, we don't want to preserve any which are frequently locked on the CPU as that would result in lots of needless waiting for a resource to be unlocked by the GPU when it occasionally frees all preserve attachments when it could have been done much sooner. By checking if a resource has ever been locked on the CPU and using that to choose whether we preserve it we can avoid such waiting.
This commit is contained in:
@ -89,6 +89,9 @@ namespace skyline::gpu {
|
||||
int megaBufferTableShift; //!< Shift to apply to buffer offsets to get their megabuffer table index
|
||||
std::vector<MegaBufferTableEntry> megaBufferTable; //!< Table of megabuffer allocations for regions of the buffer
|
||||
|
||||
static constexpr size_t FrequentlyLockedThreshold{2}; //!< Threshold for the number of times a buffer can be locked (not from context locks, only normal) before it should be considered frequently locked
|
||||
size_t accumulatedCpuLockCounter{}; //!< Number of times buffer has been locked through non-ContextLocks
|
||||
|
||||
private:
|
||||
BufferDelegate *delegate;
|
||||
|
||||
@ -214,6 +217,13 @@ namespace skyline::gpu {
|
||||
return SequencedCpuBackingWritesBlocked();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return If the buffer is frequently locked by threads using non-ContextLocks
|
||||
*/
|
||||
bool FrequentlyLocked() {
|
||||
return accumulatedCpuLockCounter >= FrequentlyLockedThreshold;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
|
Reference in New Issue
Block a user