Store delegate attached state within the delegate itself

Avoids a costly map lookup for every AttachBuffer call, this was a serious bottleneck in SMO
This commit is contained in:
Billy Laws 2022-07-31 13:24:31 +01:00
parent 0268e1d5a0
commit 70eec5a414
3 changed files with 12 additions and 5 deletions

View File

@ -100,6 +100,7 @@ namespace skyline::gpu {
struct BufferDelegate {
LockableSharedPtr<Buffer> buffer;
const Buffer::BufferViewStorage *view;
bool attached{};
std::function<void(const BufferViewStorage &, const std::shared_ptr<Buffer> &)> usageCallback;
std::list<BufferDelegate *>::iterator iterator;

View File

@ -137,9 +137,11 @@ namespace skyline::gpu::interconnect {
if (didLock)
attachedBuffers.emplace_back(view->buffer);
if (!attachedBufferDelegates.contains(view.bufferDelegate))
attachedBufferDelegates.emplace(view.bufferDelegate);
if (view.bufferDelegate->attached)
return didLock;
attachedBufferDelegates.emplace_back(view.bufferDelegate);
view.bufferDelegate->attached = true;
return didLock;
}
@ -154,8 +156,11 @@ namespace skyline::gpu::interconnect {
lock.Release(); // The executor will handle unlocking the lock so it doesn't need to be handled here
}
if (!attachedBufferDelegates.contains(view.bufferDelegate))
attachedBufferDelegates.emplace(view.bufferDelegate);
if (view.bufferDelegate->attached)
return;
attachedBufferDelegates.emplace_back(view.bufferDelegate);
view.bufferDelegate->attached = true;
}
void CommandExecutor::AttachLockedBuffer(std::shared_ptr<Buffer> buffer, ContextLock<Buffer> &&lock) {
@ -320,6 +325,7 @@ namespace skyline::gpu::interconnect {
for (const auto &delegate : attachedBufferDelegates) {
delegate->usageCallback = nullptr;
delegate->attached = false;
delegate->view->megaBufferAllocation = {};
}

View File

@ -64,7 +64,7 @@ namespace skyline::gpu::interconnect {
std::vector<LockedBuffer> attachedBuffers; //!< All textures that are attached to the current execution
using SharedBufferDelegate = std::shared_ptr<Buffer::BufferDelegate>;
std::unordered_set<SharedBufferDelegate> attachedBufferDelegates; //!< All buffers that are attached to the current execution
std::vector<SharedBufferDelegate> attachedBufferDelegates; //!< All buffers that are attached to the current execution
std::vector<TextureView *> lastSubpassAttachments; //!< The storage backing for attachments used in the last subpass
span<TextureView *> lastSubpassInputAttachments; //!< The set of input attachments used in the last subpass