Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[d3d9] Optimize late buffer uploads with dirty bitmasks #4275

Merged
merged 3 commits into from
Sep 22, 2024

Conversation

K0bin
Copy link
Collaborator

@K0bin K0bin commented Sep 18, 2024

Based on #4274

Optimizes late buffer uploads (managed or per-draw) similar to how we're doing it for textures.
This avoids having to iterate over all 16 vertex buffers multiple times for every draw.

@K0bin K0bin added the d3d9 label Sep 18, 2024
@K0bin K0bin force-pushed the vbo-bitmask-opt branch 4 times, most recently from 0ed6075 to df1f634 Compare September 21, 2024 18:54
@K0bin K0bin marked this pull request as ready for review September 21, 2024 20:03
@K0bin K0bin force-pushed the vbo-bitmask-opt branch 2 times, most recently from b08305b to 0ddfbf4 Compare September 22, 2024 19:07
Copy link
Owner

@doitsujin doitsujin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question, not sure how any of this is really supposed to work though.

dynamicSysmemVBOs &= vbo == nullptr || (vbo->DoPerDrawUpload() || CanOnlySWVP());
}
const uint32_t usedBuffersMask = (m_state.vertexDecl != nullptr ? m_state.vertexDecl->GetStreamMask() : ~0u) & m_activeVertexBuffers;
bool dynamicSysmemVBOs = usedBuffersMask == m_activeVertexBuffersToUploadPerDraw;
Copy link
Owner

@doitsujin doitsujin Sep 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the intention here with the ==, what if usedBuffersMask is a superset of m_activeVertexBuffersToUploadPerDraw?

Copy link
Collaborator Author

@K0bin K0bin Sep 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that we change the BaseVertexIndex so it can only work if we copy the data for all bound vertex buffers.

=> all bound buffers that get actually used by the draw need to be part of the bitmask.

If usedBuffersMask is a superset, we don't copy the data this specific draw needs into a separate buffer and instead bind the buffer directly.

... similar to what we're doing for textures.
The same texture could be bound to
multiple slots and if the shader doesn't
use the lower index texture, we'd never
end up uploading it.
@doitsujin doitsujin merged commit ca3aa20 into doitsujin:master Sep 22, 2024
4 checks passed
@K0bin K0bin deleted the vbo-bitmask-opt branch September 22, 2024 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants