bevy/crates/bevy_render/src/render_resource
Zhixing Zhang 16feb9acb7 Add push contant config to layout (#7681)
# Objective

Allow for creating pipelines that use push constants. To be able to use push constants. Fixes #4825

As of right now, trying to call `RenderPass::set_push_constants` will trigger the following error:

```
thread 'main' panicked at 'wgpu error: Validation Error

Caused by:
    In a RenderPass
      note: encoder = `<CommandBuffer-(0, 59, Vulkan)>`
    In a set_push_constant command
    provided push constant is for stage(s) VERTEX | FRAGMENT | VERTEX_FRAGMENT, however the pipeline layout has no push constant range for the stage(s) VERTEX | FRAGMENT | VERTEX_FRAGMENT
```
## Solution

Add a field push_constant_ranges to` RenderPipelineDescriptor` and `ComputePipelineDescriptor`.

This PR supersedes #4908 which now contains merge conflicts due to significant changes to `bevy_render`.

Meanwhile, this PR also made the `layout` field of `RenderPipelineDescriptor` and `ComputePipelineDescriptor` non-optional. If the user do not need to specify the bind group layouts, they can simply supply an empty vector here. No need for it to be optional.

---

## Changelog
- Add a field push_constant_ranges to RenderPipelineDescriptor and ComputePipelineDescriptor
- Made the `layout` field of RenderPipelineDescriptor and ComputePipelineDescriptor non-optional.


## Migration Guide

- Add push_constant_ranges: Vec::new() to every `RenderPipelineDescriptor` and `ComputePipelineDescriptor`
- Unwrap the optional values on the `layout` field of `RenderPipelineDescriptor` and `ComputePipelineDescriptor`. If the descriptor has no layout, supply an empty vector.


Co-authored-by: Zhixing Zhang <me@neoto.xin>
2023-02-17 06:20:16 +00:00
..
bind_group_layout.rs Replace UUID based IDs with a atomic-counted ones (#6988) 2022-12-25 00:23:15 +00:00
bind_group.rs Support storage buffers in derive AsBindGroup (#6129) 2023-01-09 18:50:55 +00:00
buffer_vec.rs Directly extract joints into SkinnedMeshJoints (#6833) 2022-12-20 16:17:05 +00:00
buffer.rs Replace UUID based IDs with a atomic-counted ones (#6988) 2022-12-25 00:23:15 +00:00
mod.rs Add push contant config to layout (#7681) 2023-02-17 06:20:16 +00:00
pipeline_cache.rs Add push contant config to layout (#7681) 2023-02-17 06:20:16 +00:00
pipeline_specializer.rs Changed &mut PipelineCache to &PipelineCache (#7598) 2023-02-10 11:17:18 +00:00
pipeline.rs Add push contant config to layout (#7681) 2023-02-17 06:20:16 +00:00
resource_macros.rs remove potential ub in render_resource_wrapper (#7279) 2023-02-06 17:14:00 +00:00
shader.rs Shaders can now have #else ifdef chains (#7431) 2023-02-04 15:29:35 +00:00
storage_buffer.rs Added buffer usage field to buffers (#7423) 2023-02-06 21:41:14 +00:00
texture.rs Replace UUID based IDs with a atomic-counted ones (#6988) 2022-12-25 00:23:15 +00:00
uniform_buffer.rs Added buffer usage field to buffers (#7423) 2023-02-06 21:41:14 +00:00