Skip a draw's vertex and index binds when they are already on the command buffer. #423
No reviewers
Labels
No labels
accessibility
autorelease: pending
autorelease: tagged
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
question
testing wanted
wontfix
No milestone
No assignees
1 participant
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Hookshot!423
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/draw-binds"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Replay is CPU-bound. Every draw still walks all 16 vertex streams, fills the bind arrays, and compares them, and every indexed draw calls
vkCmdBindIndexBuffer, even when that state is already on the command buffer. Consecutive draws in a scene usually keep the same streams and the same index buffer.Change
Remember the guest vertex set (address, size, stride, and the pool stamp) and the index buffer (buffer, offset, and type) bound on this command buffer.
vkCmdBindVertexBuffers2.vkCmdBindIndexBuffer. Quads, indirect draws, and direct indexed draws share that one bind, so a quad's new stream range is what the next draw compares against.draw_begin_recordingbefore they draw.A masked clear draws without rebinding vertex or index buffers, so those memos stay. They are command-buffer state and survive the clear.
Why this is safe
The remembered state is what the command buffer already has bound. It is cleared when the command buffer is begun, which is the point those bindings die. A miss takes the existing lookup and bind path, in the same order.
Testing
Both pass. With
vk_draw.cpprestored and the new test kept,tests/test_draw_binds.pyfails because the predicates are gone.Not playtested. Frame rate was not remeasured.
Scope
Pipeline creation and submit batching are left as they are. Happy to adjust naming or split this if it reads better that way.