From e72fe02c15da09ec0d42e8b7099abf0f7a276bb0 Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Wed, 31 Aug 2022 15:04:31 +0100 Subject: [PATCH] Add inline fast-path for `Buffer::FindOrCreate()` This can be inlined by the compiler much easier which helps perf a fair bit due to the number of times buffers are looked up, also avoids the need for small vector construction that was done in the previous fast-path. --- app/src/main/cpp/skyline/gpu/buffer_manager.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/src/main/cpp/skyline/gpu/buffer_manager.h b/app/src/main/cpp/skyline/gpu/buffer_manager.h index c377b48f..f32b89fc 100644 --- a/app/src/main/cpp/skyline/gpu/buffer_manager.h +++ b/app/src/main/cpp/skyline/gpu/buffer_manager.h @@ -94,6 +94,15 @@ namespace skyline::gpu { * @return A pre-existing or newly created Buffer object which covers the supplied mappings * @note The buffer manager **must** be locked prior to calling this */ - BufferView FindOrCreate(GuestBuffer guestMapping, ContextTag tag = {}, const std::function, ContextLock &&)> &attachBuffer = {}); + BufferView FindOrCreateImpl(GuestBuffer guestMapping, ContextTag tag, const std::function, ContextLock &&)> &attachBuffer); + + BufferView FindOrCreate(GuestBuffer guestMapping, ContextTag tag = {}, const std::function, ContextLock &&)> &attachBuffer = {}) { + auto lookupBuffer{bufferTable[guestMapping.begin().base()]}; + if (lookupBuffer != nullptr) + if (auto view{lookupBuffer->TryGetView(guestMapping)}; view) + return view; + + return FindOrCreateImpl(guestMapping, tag, attachBuffer); + } }; }