Repository navigation
Skip a draw's vertex and index binds when they are already on the command buffer. - #423
Merged
Merged
Conversation
…mand buffer. Every draw walked its vertex streams and every indexed draw rebound its index buffer. Both stay on the command buffer until the next recording. A failed vertex bind, or a mirror while the streams are looked up, is not remembered.
Closed
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.