Skip to content

Conversation

MDeiml
Copy link
Contributor

@MDeiml MDeiml commented Jun 3, 2022

Objective

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

Solution

Add a field push_constant_ranges to RenderPipelineDescriptor and ComputePipelineDescriptor


Changelog

  • Add a field push_constant_ranges to RenderPipelineDescriptor and ComputePipelineDescriptor
  • Update bevy_sprite, bevy_ui and bevy_pbr to declare the new field

Migration Guide

  • Add push_constant_ranges: None to every RenderPipelineDescriptor and ComputePipelineDescriptor

@james7132 james7132 requested a review from superdump June 3, 2022 10:10
@james7132 james7132 added C-Feature A new feature, making something new possible A-Rendering Drawing game state to the screen labels Jun 3, 2022
#[derive(Default)]
struct LayoutCache {
layouts: HashMap<Vec<BindGroupLayoutId>, wgpu::PipelineLayout>,
layouts: HashMap<(Vec<BindGroupLayoutId>, Vec<PushConstantRange>), wgpu::PipelineLayout>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This key is getting pretty darn big. We should probably consider making this a dedicated type and use bevy_utils::PreHashMap

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@james7132 I don't understand how PreHashMap helps in this case. Hashed<K> also stores K. If anything, using PreHashMap makes the key bigger because it memoizes the u64 hash.

I'm necromancing this thread b/c @Neo-Zhixing is trying to do something similar in #7681 .

@MDeiml MDeiml force-pushed the push_constants branch 5 times, most recently from a83116e to cd8482c Compare June 4, 2022 10:00
@PixelDust22
Copy link
Contributor

This feature would be super useful. Any updates on this? It's been a while. @cart @superdump

@alice-i-cecile
Copy link
Member

Adopted in #7681.

bors bot pushed a commit that referenced this pull request Feb 17, 2023
# 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 <[email protected]>
myreprise1 pushed a commit to myreprise1/bevy that referenced this pull request Feb 18, 2023
# Objective

Allow for creating pipelines that use push constants. To be able to use push constants. Fixes bevyengine#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 bevyengine#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 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Rendering Drawing game state to the screen C-Feature A new feature, making something new possible

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Push Constants

5 participants