You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactor AsBindGroup to use a associated SystemParam. (#14909)
# Objective
Adding more features to `AsBindGroup` proc macro means making the trait
arguments uglier. Downstream implementors of the trait without the proc
macro might want to do different things than our default arguments.
## Solution
Make `AsBindGroup` take an associated `Param` type.
## Migration Guide
`AsBindGroup` now allows the user to specify a `SystemParam` to be used
for creating bind groups.
use bevy_ecs::system::{SystemParam,SystemParamItem};
8
9
pubuse bevy_render_macros::AsBindGroup;
9
10
use encase::ShaderType;
10
11
use std::ops::Deref;
@@ -57,7 +58,7 @@ impl Deref for BindGroup {
57
58
///
58
59
/// This is an opinionated trait that is intended to make it easy to generically
59
60
/// convert a type into a [`BindGroup`]. It provides access to specific render resources,
60
-
/// such as [`RenderAssets<GpuImage>`] and [`FallbackImage`]. If a type has a [`Handle<Image>`](bevy_asset::Handle),
61
+
/// such as [`RenderAssets<GpuImage>`] and [`crate::texture::FallbackImage`]. If a type has a [`Handle<Image>`](bevy_asset::Handle),
61
62
/// these can be used to retrieve the corresponding [`Texture`](crate::render_resource::Texture) resource.
62
63
///
63
64
/// [`AsBindGroup::as_bind_group`] is intended to be called once, then the result cached somewhere. It is generally
@@ -115,7 +116,7 @@ impl Deref for BindGroup {
115
116
/// * This field's [`Handle<Image>`](bevy_asset::Handle) will be used to look up the matching [`Texture`](crate::render_resource::Texture)
116
117
/// GPU resource, which will be bound as a texture in shaders. The field will be assumed to implement [`Into<Option<Handle<Image>>>`]. In practice,
117
118
/// most fields should be a [`Handle<Image>`](bevy_asset::Handle) or [`Option<Handle<Image>>`]. If the value of an [`Option<Handle<Image>>`] is
118
-
/// [`None`], the [`FallbackImage`] resource will be used instead. This attribute can be used in conjunction with a `sampler` binding attribute
119
+
/// [`None`], the [`crate::texture::FallbackImage`] resource will be used instead. This attribute can be used in conjunction with a `sampler` binding attribute
119
120
/// (with a different binding index) if a binding of the sampler for the [`Image`](crate::texture::Image) is also required.
120
121
///
121
122
/// | Arguments | Values | Default |
@@ -130,7 +131,7 @@ impl Deref for BindGroup {
130
131
/// * This field's [`Handle<Image>`](bevy_asset::Handle) will be used to look up the matching [`Texture`](crate::render_resource::Texture)
131
132
/// GPU resource, which will be bound as a storage texture in shaders. The field will be assumed to implement [`Into<Option<Handle<Image>>>`]. In practice,
132
133
/// most fields should be a [`Handle<Image>`](bevy_asset::Handle) or [`Option<Handle<Image>>`]. If the value of an [`Option<Handle<Image>>`] is
133
-
/// [`None`], the [`FallbackImage`] resource will be used instead.
134
+
/// [`None`], the [`crate::texture::FallbackImage`] resource will be used instead.
/// * This field's [`Handle<Image>`](bevy_asset::Handle) will be used to look up the matching [`Sampler`] GPU
144
145
/// resource, which will be bound as a sampler in shaders. The field will be assumed to implement [`Into<Option<Handle<Image>>>`]. In practice,
145
146
/// most fields should be a [`Handle<Image>`](bevy_asset::Handle) or [`Option<Handle<Image>>`]. If the value of an [`Option<Handle<Image>>`] is
146
-
/// [`None`], the [`FallbackImage`] resource will be used instead. This attribute can be used in conjunction with a `texture` binding attribute
147
+
/// [`None`], the [`crate::texture::FallbackImage`] resource will be used instead. This attribute can be used in conjunction with a `texture` binding attribute
147
148
/// (with a different binding index) if a binding of the texture for the [`Image`](crate::texture::Image) is also required.
148
149
///
149
150
/// | Arguments | Values | Default |
@@ -187,7 +188,7 @@ impl Deref for BindGroup {
187
188
/// color_texture: Option<Handle<Image>>,
188
189
/// }
189
190
/// ```
190
-
/// This is useful if you want a texture to be optional. When the value is [`None`], the [`FallbackImage`] will be used for the binding instead, which defaults
191
+
/// This is useful if you want a texture to be optional. When the value is [`None`], the [`crate::texture::FallbackImage`] will be used for the binding instead, which defaults
191
192
/// to "pure white".
192
193
///
193
194
/// Field uniforms with the same index will be combined into a single binding:
@@ -284,6 +285,8 @@ pub trait AsBindGroup {
284
285
/// Data that will be stored alongside the "prepared" bind group.
0 commit comments