-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
add storage_texture
option to as_bind_group macro
#9943
Conversation
3cc6b7f
to
badfa20
Compare
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, took me a bit to get to this PR.
LGTM, good job!
@@ -106,7 +109,7 @@ fn prepare_bind_group( | |||
game_of_life_image: Res<GameOfLifeImage>, | |||
render_device: Res<RenderDevice>, | |||
) { | |||
let view = gpu_images.get(&game_of_life_image.0).unwrap(); | |||
let view = gpu_images.get(&game_of_life_image.texture).unwrap(); | |||
let bind_group = render_device.create_bind_group(&BindGroupDescriptor { |
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.
You could probably also use the AsBindGroup::as_bind_group()
here
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.
That would require me getting the FallbackImage
from somewhere, is that readily available? It's probably also not something we want here tbh.
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.
you can add fallback_image: Res<FallbackImage>,
as a system parameter and then use it
struct GameOfLifeImage(Handle<Image>); | ||
#[derive(Resource, Clone, Deref, ExtractResource, AsBindGroup)] | ||
struct GameOfLifeImage { | ||
#[storage_texture(0, image_format = Rgba8Unorm, access = ReadWrite)] |
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.
Good idea to use it here!
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.
Actually, could you also add some docs here
pub trait AsBindGroup { |
You can just copy the block for textures and change the attributes to match your PR.
81e510b
to
3817c64
Compare
ffbc453
to
899e070
Compare
Is the internal imports thing the only thing that's preventing this from being merged? Asking because I'm eager to use this 😅 |
I got a hunch that it's actually a flake, I'll try to rebase soon and see if that fixes it :) |
Changes: - Add storage_texture option to as_bind_group macro - Use it to generate the bind group layout for the compute shader example
@IceSentry are you in a position to get this merged? :) |
We need a second approval then I can merge this :) See CONTRIBUTING.md for the mechanisms on how reviews work around here. I would take a look myself, but this is beyond my rendering expertise. |
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.
game of life perf went from 1350-1400 fps to 1400-1450 fps, shaved 0.02ms or so
Objective
AsBindGroup
.Solution
#[storage_texture(0)]
annotation.Changelog
#[storage_texture(..)]
annotation is now accepted for fields ofHandle<Image>
in structs that deriveAsBindGroup
.AsBindGroup
together with[storage_texture(..)]
to obtain theBindGroupLayout
.Migration Guide