-
Notifications
You must be signed in to change notification settings - Fork 403
v0.15 release notes: state scoped events #1749
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
72 changes: 36 additions & 36 deletions
72
release-content/0.15/release-notes/14663_shader_storage_buffer.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,36 +1,36 @@ | ||
| A new asset `ShaderStorageBuffer` has been added to simplify working with storage buffers in custom materials and compute shaders. Storage buffers are large, GPU-accessible memory buffers designed for storing data that can be read from or written to by shaders. Unlike smaller, more restricted uniform buffers, storage buffers allow you to store large amounts of data, making them perfect for general purpose tasks where large datasets need to be processed. Examples include managing complex data in physics simulations (like particle systems), holding the transformation data for thousands of objects in a scene, or storing procedural geometry information for dynamic terrain generation. Storage buffers are particularly useful when different stages of the rendering pipeline (such as compute shaders and rendering passes) need to share and update large amounts of data efficiently. | ||
| ```rust | ||
| #[derive(Asset, TypePath, AsBindGroup, Debug, Clone)] | ||
| struct CustomMaterial { | ||
| #[storage(0, read_only)] | ||
| colors: Handle<ShaderStorageBuffer>, | ||
| } | ||
| fn setup( | ||
| mut buffers: ResMut<Assets<ShaderStorageBuffer>>, | ||
| mut materials: ResMut<Assets<CustomMaterial>>, | ||
| ) { | ||
| // Example data for the storage buffer | ||
| let color_data: Vec<[f32; 4]> = vec![ | ||
| [1.0, 0.0, 0.0, 1.0], | ||
| [0.0, 1.0, 0.0, 1.0], | ||
| [0.0, 0.0, 1.0, 1.0], | ||
| [1.0, 1.0, 0.0, 1.0], | ||
| [0.0, 1.0, 1.0, 1.0], | ||
| ]; | ||
| let colors = buffers.add(ShaderStorageBuffer::from(color_data)); | ||
| // Create the custom material with the storage buffer | ||
| let custom_material = CustomMaterial { colors }; | ||
| materials.add(custom_material); | ||
| } | ||
| ``` | ||
| By declaring `Handle<ShaderStorageBuffer>` on the material using `AsBindGroup`, this buffer can now be accessed in the shader: | ||
| ```wgsl | ||
| @group(2) @binding(0) var<storage, read> colors: array<vec4<f32>, 5>; | ||
| ``` | ||
| A new asset `ShaderStorageBuffer` has been added to simplify working with storage buffers in custom materials and compute shaders. Storage buffers are large, GPU-accessible memory buffers designed for storing data that can be read from or written to by shaders. Unlike smaller, more restricted uniform buffers, storage buffers allow you to store large amounts of data, making them perfect for general purpose tasks where large datasets need to be processed. Examples include managing complex data in physics simulations (like particle systems), holding the transformation data for thousands of objects in a scene, or storing procedural geometry information for dynamic terrain generation. Storage buffers are particularly useful when different stages of the rendering pipeline (such as compute shaders and rendering passes) need to share and update large amounts of data efficiently. | ||
|
|
||
| ```rust | ||
| #[derive(Asset, TypePath, AsBindGroup, Debug, Clone)] | ||
| struct CustomMaterial { | ||
| #[storage(0, read_only)] | ||
| colors: Handle<ShaderStorageBuffer>, | ||
| } | ||
|
|
||
| fn setup( | ||
| mut buffers: ResMut<Assets<ShaderStorageBuffer>>, | ||
| mut materials: ResMut<Assets<CustomMaterial>>, | ||
| ) { | ||
| // Example data for the storage buffer | ||
| let color_data: Vec<[f32; 4]> = vec![ | ||
| [1.0, 0.0, 0.0, 1.0], | ||
| [0.0, 1.0, 0.0, 1.0], | ||
| [0.0, 0.0, 1.0, 1.0], | ||
| [1.0, 1.0, 0.0, 1.0], | ||
| [0.0, 1.0, 1.0, 1.0], | ||
| ]; | ||
|
|
||
| let colors = buffers.add(ShaderStorageBuffer::from(color_data)); | ||
|
|
||
| // Create the custom material with the storage buffer | ||
| let custom_material = CustomMaterial { colors }; | ||
|
|
||
| materials.add(custom_material); | ||
| } | ||
| ``` | ||
|
|
||
| By declaring `Handle<ShaderStorageBuffer>` on the material using `AsBindGroup`, this buffer can now be accessed in the shader: | ||
|
|
||
| ```wgsl | ||
| @group(2) @binding(0) var<storage, read> colors: array<vec4<f32>, 5>; | ||
| ``` |
16 changes: 15 additions & 1 deletion
16
release-content/0.15/release-notes/15085_Add_state_scoped_events.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,18 @@ | ||
| <!-- Add state scoped events --> | ||
| <!-- https://github.com/bevyengine/bevy/pull/15085 --> | ||
|
|
||
| <!-- TODO --> | ||
| State scoped events will be automatically cleared when exiting a state (similar to [StateScoped entities](https://bevyengine.org/news/bevy-0-14/#state-scoped-entities)). Useful when you want to guarantee clean state transitions. | ||
|
|
||
| Normally, you would configure your event via: | ||
| ```rust | ||
| fn setup(app: &mut App) { | ||
| app.add_event::<MyGameEvent>(); | ||
| } | ||
| ``` | ||
|
|
||
| If you want the events to be cleared when you exit a specific state, change this to: | ||
| ```rust | ||
| fn setup(app: &mut App) { | ||
| app.add_state_scoped_event::<MyGameEvent>(GameState::Play); | ||
| } | ||
| ``` | ||
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.
Uh oh!
There was an error while loading. Please reload this page.