mirror of
https://github.com/Takiiiiiiii/strato.git
synced 2025-07-21 13:37:23 +00:00
Improve ContextLock
semantics
`ContextLock` had unoptimal semantics in the form of direct access to the `isFirst` member which wasn't clearly defined, it's now been broken up into function calls `IsFirstUsage` and `OwnsLock` with explicit move semantics and a function for releasing the lock. Co-authored-by: PixelyIon <pixelyion@protonmail.com>
This commit is contained in:
@ -24,7 +24,7 @@ namespace skyline::gpu {
|
||||
return mutex.try_lock();
|
||||
}
|
||||
|
||||
BufferView BufferManager::FindOrCreate(GuestBuffer guestMapping, ContextTag tag, const std::function<void(std::shared_ptr<Buffer>, ContextLock<Buffer> &)> &attachBuffer) {
|
||||
BufferView BufferManager::FindOrCreate(GuestBuffer guestMapping, ContextTag tag, const std::function<void(std::shared_ptr<Buffer>, ContextLock<Buffer> &&)> &attachBuffer) {
|
||||
/*
|
||||
* We align the buffer to the page boundary to ensure that:
|
||||
* 1) Any buffer view has the same alignment guarantees as on the guest, this is required for UBOs, SSBOs and Texel buffers
|
||||
@ -65,7 +65,7 @@ namespace skyline::gpu {
|
||||
for (auto &overlap : overlaps) {
|
||||
ContextLock overlapLock{tag, *overlap};
|
||||
|
||||
if (!overlapLock.isFirst)
|
||||
if (!overlapLock.IsFirstUsage())
|
||||
hasAlreadyAttached = true;
|
||||
|
||||
buffers.erase(std::find(buffers.begin(), buffers.end(), overlap));
|
||||
@ -101,7 +101,7 @@ namespace skyline::gpu {
|
||||
|
||||
if (hasAlreadyAttached)
|
||||
// We need to reattach the buffer if any overlapping views were already attached to the current context
|
||||
attachBuffer(newBuffer, newLock);
|
||||
attachBuffer(newBuffer, std::move(newLock));
|
||||
|
||||
buffers.insert(std::lower_bound(buffers.begin(), buffers.end(), newBuffer->guest->end().base(), BufferLessThan), newBuffer);
|
||||
|
||||
|
Reference in New Issue
Block a user