-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Push Constants #4825
Description
What problem does this solve or what need does it fill?
It would be nice to support using push constants. Even though the initial wgsl spec will not have push constants (gpuweb/gpuweb#612) they are supported in naga (https://github.com/gfx-rs/naga/blob/master/tests/in/push-constants.wgsl) as well as wgpu.
But it seems that there was a decision not to include them. Specifically you cannot create pipelines with layouts that contain push constants. This is because the concept of a RenderPipelineLayout in wgpu was not translated to the bevy API and instead became just &[BindGroupLayout]. To create a RenderPipelineLayout in wgpu you specify bind group layouts and push constant ranges, so this seems like a weird design to me.
I'm talking about this code, which always sets the push constant ranges to be empty:
bevy/crates/bevy_render/src/render_resource/pipeline_cache.rs
Lines 236 to 239 in fed93a0
| render_device.create_pipeline_layout(&PipelineLayoutDescriptor { | |
| bind_group_layouts: &bind_group_layouts, | |
| ..default() | |
| }) |
What solution would you like?
Change RenderPipelineDescriptor or it's layout field so it's possible to specify push constant ranges.
What alternative(s) have you considered?
Create a pipeline without using pipeline cache or don't use push constants.
Additional Context
In order to use push constants in shaders we would also need #4824
I'd be happy to implement this, but it would require minor breaking changes to RenderPipelineDescriptor and it seems to me that maybe there already was a decision to not support them, so I wanted to ask first.