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.
This commit is contained in:
Billy Laws 2022-08-31 15:04:31 +01:00
parent 49478e178a
commit e72fe02c15

View File

@ -94,6 +94,15 @@ namespace skyline::gpu {
* @return A pre-existing or newly created Buffer object which covers the supplied mappings * @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 * @note The buffer manager **must** be locked prior to calling this
*/ */
BufferView FindOrCreate(GuestBuffer guestMapping, ContextTag tag = {}, const std::function<void(std::shared_ptr<Buffer>, ContextLock<Buffer> &&)> &attachBuffer = {}); BufferView FindOrCreateImpl(GuestBuffer guestMapping, ContextTag tag, const std::function<void(std::shared_ptr<Buffer>, ContextLock<Buffer> &&)> &attachBuffer);
BufferView FindOrCreate(GuestBuffer guestMapping, ContextTag tag = {}, const std::function<void(std::shared_ptr<Buffer>, ContextLock<Buffer> &&)> &attachBuffer = {}) {
auto lookupBuffer{bufferTable[guestMapping.begin().base()]};
if (lookupBuffer != nullptr)
if (auto view{lookupBuffer->TryGetView(guestMapping)}; view)
return view;
return FindOrCreateImpl(guestMapping, tag, attachBuffer);
}
}; };
} }