diff --git a/crates/bevy_render/src/render_resource/bind_group_layout_entries.rs b/crates/bevy_render/src/render_resource/bind_group_layout_entries.rs index 7bb9ff1caf..4d4553399a 100644 --- a/crates/bevy_render/src/render_resource/bind_group_layout_entries.rs +++ b/crates/bevy_render/src/render_resource/bind_group_layout_entries.rs @@ -13,7 +13,7 @@ use wgpu::{BindGroupLayoutEntry, BindingType, ShaderStages}; /// ShaderStages::FRAGMENT, /// ( /// // Screen texture -/// (2, tepxture_2d(TextureSampleType::Float { filterable: true })), +/// (2, texture_2d(TextureSampleType::Float { filterable: true })), /// // Sampler /// (3, sampler(SamplerBindingType::Filtering)), /// ), diff --git a/examples/shader/texture_binding_array.rs b/examples/shader/texture_binding_array.rs index 710bec904b..d01df7b953 100644 --- a/examples/shader/texture_binding_array.rs +++ b/examples/shader/texture_binding_array.rs @@ -6,7 +6,10 @@ use bevy::{ reflect::TypePath, render::{ render_asset::RenderAssets, - render_resource::*, + render_resource::{ + binding_types::{sampler, texture_2d}, + *, + }, renderer::RenderDevice, texture::{FallbackImage, GpuImage}, RenderApp, @@ -148,29 +151,36 @@ impl AsBindGroup for BindlessMaterial { where Self: Sized, { - vec![ - // @group(2) @binding(0) var textures: binding_array>; - BindGroupLayoutEntry { - binding: 0, - visibility: ShaderStages::FRAGMENT, - ty: BindingType::Texture { - sample_type: TextureSampleType::Float { filterable: true }, - view_dimension: TextureViewDimension::D2, - multisampled: false, - }, - count: NonZeroU32::new(MAX_TEXTURE_COUNT as u32), - }, - // @group(2) @binding(1) var nearest_sampler: sampler; - BindGroupLayoutEntry { - binding: 1, - visibility: ShaderStages::FRAGMENT, - ty: BindingType::Sampler(SamplerBindingType::Filtering), - count: None, - // Note: as textures, multiple samplers can also be bound onto one binding slot. - // One may need to pay attention to the limit of sampler binding amount on some platforms. - // count: NonZeroU32::new(MAX_TEXTURE_COUNT as u32), - }, - ] + BindGroupLayoutEntries::with_indices( + // The layout entries will only be visible in the fragment stage + ShaderStages::FRAGMENT, + ( + // Screen texture + // + // @group(2) @binding(0) var textures: binding_array>; + ( + 0, + texture_2d(TextureSampleType::Float { filterable: true }) + .count(NonZeroU32::new(MAX_TEXTURE_COUNT as u32).unwrap()), + ), + // Sampler + // + // @group(2) @binding(1) var nearest_sampler: sampler; + // + // Note: as with textures, multiple samplers can also be bound + // onto one binding slot: + // + // ``` + // sampler(SamplerBindingType::Filtering) + // .count(NonZeroU32::new(MAX_TEXTURE_COUNT as u32).unwrap()), + // ``` + // + // One may need to pay attention to the limit of sampler binding + // amount on some platforms. + (1, sampler(SamplerBindingType::Filtering)), + ), + ) + .to_vec() } }