-
Notifications
You must be signed in to change notification settings - Fork 1k
vulkan: Start on dynamic_state_commands system #7302
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
base: trunk
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for taking so long to get back to you on this one.
I generally don't hate the code, my only real apprehension is that it adds a good amount of complexity and opportunities to subtly mess the code up. Maybe if the dynamic state handling could be encapsulated in some way, I would feel better about this.
Are there performance ramifications to aggressively going to dynamic state? We might have more redundant state changes.
Yeah, that's how I felt writing a lot of this too, and why I filed a draft PR for this before working on it too much. Do you have any suggestions here? I could also limit the choices for dynamic state to only respect Vulkan 1.3 and stop caring about the older extensions. This would thin out the dynamic state code; and perhaps devices without Vulkan 1.3 are where this code would be the most helpful. The other issue right now is that create_render_pipeline and create_mesh_pipeline are 90% the same, and a lot of the same code exists in both; this PR just duplicates the same changes in both, which makes it more tedious to update and review. I tried to refactor these out, but the nature of on-the-stack variables means it's difficult to do without a bigger refactor, though probably one that's worth doing. Not sure I know enough Rust to attempt it in earnest though.
We could cache the state at a command buffer level and omit calls if they're the same (assuming it's cheap to compare), but in my experience, drivers already do a fair job at this, and all the dynamic state is often pretty cheap to set on the hardware side anyway. The big piece that's missing here to actually make it efficient is:
|
I don't have amazingly actionable ideas here besides "throw it in a struct with methods". Maybe something that amounts to a builder (so that you keep mutating the builder as you find what state to include) which you can then get an array to add to the vulkan descriptor and a state objet which contains the list of dynamic state changes the pipeline needs. I hope that makes any kind of sense. |
Description
The eventual goal here is to cache PSOs in a format that they can be reused; e.g. if the user creates two PSOs that only differ with depth-test, we could reuse the same PSO, and use dynamic state to flip things around. Even on D3D12, we could keep the same HLSL/DXC binary cached and only create a new PSO.
This is a very early version of this that still creates a new PSO, but switches to using dynamic state in Vulkan when available.
Checklist
cargo fmt
.taplo format
.cargo clippy
. If applicable, add:--target wasm32-unknown-unknown
cargo xtask test
to run tests.CHANGELOG.md
entry.