diff --git a/app/src/main/cpp/skyline/gpu/buffer.h b/app/src/main/cpp/skyline/gpu/buffer.h index 3ccb96d3..e4374657 100644 --- a/app/src/main/cpp/skyline/gpu/buffer.h +++ b/app/src/main/cpp/skyline/gpu/buffer.h @@ -382,45 +382,24 @@ namespace skyline::gpu { vk::DeviceSize GetOffset() const; /** - * @brief Templated lock function that ensures correct locking of the delegate's underlying buffer + * @note The buffer manager **MUST** be locked prior to calling this */ - template - std::conditional_t LockWithFunction(LockFunction lock, UnlockFunction unlock) { - while (true) { - auto preLockBuffer{delegate->GetBuffer()}; - if constexpr (TryLock) { - if (!lock(preLockBuffer)) - return false; - } else { - lock(preLockBuffer); - } - auto postLockBuffer{delegate->GetBuffer()}; - if (preLockBuffer == postLockBuffer) - break; - - preLockBuffer->unlock(); - }; - - ResolveDelegate(); - - if constexpr (TryLock) - return true; - else - return; - } - void lock() { - LockWithFunction([](Buffer *buffer) { buffer->lock(); }, [](Buffer *buffer) { buffer->unlock(); }); + delegate->GetBuffer()->lock(); } + /** + * @note The buffer manager **MUST** be locked prior to calling this + */ bool try_lock() { - return LockWithFunction([](Buffer *buffer) { return buffer->try_lock(); }, [](Buffer *buffer) { buffer->unlock(); }); + return delegate->GetBuffer()->try_lock(); } + /** + * @note The buffer manager **MUST** be locked prior to calling this + */ bool LockWithTag(ContextTag tag) { - bool result{}; - LockWithFunction([&result, tag](Buffer *buffer) { result = buffer->LockWithTag(tag); }, [](Buffer *buffer) { buffer->unlock(); }); - return result; + return delegate->GetBuffer()->LockWithTag(tag); } void unlock() { diff --git a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/constant_buffers.cpp b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/constant_buffers.cpp index 6aa7d523..4c1ae404 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/constant_buffers.cpp +++ b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/constant_buffers.cpp @@ -30,6 +30,7 @@ namespace skyline::gpu::interconnect::maxwell3d { } void ConstantBuffer::Read(CommandExecutor &executor, span dstBuffer, size_t srcOffset) { + executor.AcquireBufferManager(); ContextLock lock{executor.tag, view}; view.Read(lock.IsFirstUsage(), FlushHostCallback, dstBuffer, srcOffset); } @@ -44,6 +45,7 @@ namespace skyline::gpu::interconnect::maxwell3d { auto &view{*selectorState.UpdateGet(ctx).view}; auto srcCpuBuf{data.cast()}; + ctx.executor.AcquireBufferManager(); ContextLock lock{ctx.executor.tag, view}; // First attempt the write without setting up the gpu copy callback as a fast path