Use a single line for of large binding lists (#9849)

# Objective

- When adding/removing bindings in large binding lists, git would
generate very difficult-to-read diffs

## Solution

- Move the `@group(X) @binding(Y)` into the same line as the binding
type declaration
This commit is contained in:
Nicola Papale 2023-09-20 00:17:44 +02:00 committed by GitHub
parent 692ef9508c
commit 7163aabf29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
36 changed files with 136 additions and 277 deletions

View File

@ -4,10 +4,8 @@
#import bevy_core_pipeline::tonemapping tone_mapping #import bevy_core_pipeline::tonemapping tone_mapping
#import bevy_pbr::pbr_functions as fns #import bevy_pbr::pbr_functions as fns
@group(1) @binding(0) @group(1) @binding(0) var my_array_texture: texture_2d_array<f32>;
var my_array_texture: texture_2d_array<f32>; @group(1) @binding(1) var my_array_texture_sampler: sampler;
@group(1) @binding(1)
var my_array_texture_sampler: sampler;
@fragment @fragment
fn fragment( fn fragment(

View File

@ -1,15 +1,12 @@
#import bevy_pbr::mesh_vertex_output MeshVertexOutput #import bevy_pbr::mesh_vertex_output MeshVertexOutput
#ifdef CUBEMAP_ARRAY #ifdef CUBEMAP_ARRAY
@group(1) @binding(0) @group(1) @binding(0) var base_color_texture: texture_cube_array<f32>;
var base_color_texture: texture_cube_array<f32>;
#else #else
@group(1) @binding(0) @group(1) @binding(0) var base_color_texture: texture_cube<f32>;
var base_color_texture: texture_cube<f32>;
#endif #endif
@group(1) @binding(1) @group(1) @binding(1) var base_color_sampler: sampler;
var base_color_sampler: sampler;
@fragment @fragment
fn fragment( fn fragment(

View File

@ -4,12 +4,9 @@ struct CustomMaterial {
color: vec4<f32>, color: vec4<f32>,
}; };
@group(1) @binding(0) @group(1) @binding(0) var<uniform> material: CustomMaterial;
var<uniform> material: CustomMaterial; @group(1) @binding(1) var base_color_texture: texture_2d<f32>;
@group(1) @binding(1) @group(1) @binding(2) var base_color_sampler: sampler;
var base_color_texture: texture_2d<f32>;
@group(1) @binding(2)
var base_color_sampler: sampler;
@fragment @fragment
fn fragment( fn fragment(

View File

@ -2,10 +2,8 @@
#import bevy_pbr::mesh_vertex_output MeshVertexOutput #import bevy_pbr::mesh_vertex_output MeshVertexOutput
#import bevy_pbr::utils coords_to_viewport_uv #import bevy_pbr::utils coords_to_viewport_uv
@group(1) @binding(0) @group(1) @binding(0) var texture: texture_2d<f32>;
var texture: texture_2d<f32>; @group(1) @binding(1) var texture_sampler: sampler;
@group(1) @binding(1)
var texture_sampler: sampler;
@fragment @fragment
fn fragment( fn fragment(

View File

@ -4,8 +4,7 @@
struct CustomMaterial { struct CustomMaterial {
color: vec4<f32>, color: vec4<f32>,
}; };
@group(1) @binding(0) @group(1) @binding(0) var<uniform> material: CustomMaterial;
var<uniform> material: CustomMaterial;
struct Vertex { struct Vertex {
@builtin(instance_index) instance_index: u32, @builtin(instance_index) instance_index: u32,

View File

@ -2,35 +2,23 @@
#import bevy_pbr::mesh_bindings #import bevy_pbr::mesh_bindings
#import bevy_pbr::mesh_vertex_output MeshVertexOutput #import bevy_pbr::mesh_vertex_output MeshVertexOutput
@group(1) @binding(0) @group(1) @binding(0) var test_texture_1d: texture_1d<f32>;
var test_texture_1d: texture_1d<f32>; @group(1) @binding(1) var test_texture_1d_sampler: sampler;
@group(1) @binding(1)
var test_texture_1d_sampler: sampler;
@group(1) @binding(2) @group(1) @binding(2) var test_texture_2d: texture_2d<f32>;
var test_texture_2d: texture_2d<f32>; @group(1) @binding(3) var test_texture_2d_sampler: sampler;
@group(1) @binding(3)
var test_texture_2d_sampler: sampler;
@group(1) @binding(4) @group(1) @binding(4) var test_texture_2d_array: texture_2d_array<f32>;
var test_texture_2d_array: texture_2d_array<f32>; @group(1) @binding(5) var test_texture_2d_array_sampler: sampler;
@group(1) @binding(5)
var test_texture_2d_array_sampler: sampler;
@group(1) @binding(6) @group(1) @binding(6) var test_texture_cube: texture_cube<f32>;
var test_texture_cube: texture_cube<f32>; @group(1) @binding(7) var test_texture_cube_sampler: sampler;
@group(1) @binding(7)
var test_texture_cube_sampler: sampler;
@group(1) @binding(8) @group(1) @binding(8) var test_texture_cube_array: texture_cube_array<f32>;
var test_texture_cube_array: texture_cube_array<f32>; @group(1) @binding(9) var test_texture_cube_array_sampler: sampler;
@group(1) @binding(9)
var test_texture_cube_array_sampler: sampler;
@group(1) @binding(10) @group(1) @binding(10) var test_texture_3d: texture_3d<f32>;
var test_texture_3d: texture_3d<f32>; @group(1) @binding(11) var test_texture_3d_sampler: sampler;
@group(1) @binding(11)
var test_texture_3d_sampler: sampler;
@fragment @fragment
fn fragment(in: MeshVertexOutput) {} fn fragment(in: MeshVertexOutput) {}

View File

@ -1,5 +1,4 @@
@group(0) @binding(0) @group(0) @binding(0) var texture: texture_storage_2d<rgba8unorm, read_write>;
var texture: texture_storage_2d<rgba8unorm, read_write>;
fn hash(value: u32) -> u32 { fn hash(value: u32) -> u32 {
var state = value; var state = value;

View File

@ -4,8 +4,7 @@ struct LineMaterial {
color: vec4<f32>, color: vec4<f32>,
}; };
@group(1) @binding(0) @group(1) @binding(0) var<uniform> material: LineMaterial;
var<uniform> material: LineMaterial;
@fragment @fragment
fn fragment( fn fragment(

View File

@ -22,10 +22,8 @@
// You don't need to worry about this too much since bevy will compute the correct UVs for you. // You don't need to worry about this too much since bevy will compute the correct UVs for you.
#import bevy_core_pipeline::fullscreen_vertex_shader FullscreenVertexOutput #import bevy_core_pipeline::fullscreen_vertex_shader FullscreenVertexOutput
@group(0) @binding(0) @group(0) @binding(0) var screen_texture: texture_2d<f32>;
var screen_texture: texture_2d<f32>; @group(0) @binding(1) var texture_sampler: sampler;
@group(0) @binding(1)
var texture_sampler: sampler;
struct PostProcessSettings { struct PostProcessSettings {
intensity: f32, intensity: f32,
#ifdef SIXTEEN_BYTE_ALIGNMENT #ifdef SIXTEEN_BYTE_ALIGNMENT
@ -33,8 +31,7 @@ struct PostProcessSettings {
_webgl2_padding: vec3<f32> _webgl2_padding: vec3<f32>
#endif #endif
} }
@group(0) @binding(2) @group(0) @binding(2) var<uniform> settings: PostProcessSettings;
var<uniform> settings: PostProcessSettings;
@fragment @fragment
fn fragment(in: FullscreenVertexOutput) -> @location(0) vec4<f32> { fn fragment(in: FullscreenVertexOutput) -> @location(0) vec4<f32> {

View File

@ -4,8 +4,7 @@ struct CustomMaterial {
color: vec4<f32>, color: vec4<f32>,
}; };
@group(1) @binding(0) @group(1) @binding(0) var<uniform> material: CustomMaterial;
var<uniform> material: CustomMaterial;
@fragment @fragment
fn fragment( fn fragment(

View File

@ -10,8 +10,7 @@ struct ShowPrepassSettings {
padding_1: u32, padding_1: u32,
padding_2: u32, padding_2: u32,
} }
@group(1) @binding(0) @group(1) @binding(0) var<uniform> settings: ShowPrepassSettings;
var<uniform> settings: ShowPrepassSettings;
@fragment @fragment
fn fragment( fn fragment(

View File

@ -1,9 +1,7 @@
#import bevy_pbr::mesh_vertex_output MeshVertexOutput #import bevy_pbr::mesh_vertex_output MeshVertexOutput
@group(1) @binding(0) @group(1) @binding(0) var textures: binding_array<texture_2d<f32>>;
var textures: binding_array<texture_2d<f32>>; @group(1) @binding(1) var nearest_sampler: sampler;
@group(1) @binding(1)
var nearest_sampler: sampler;
// We can also have array of samplers // We can also have array of samplers
// var samplers: binding_array<sampler>; // var samplers: binding_array<sampler>;

View File

@ -1,9 +1,7 @@
#import bevy_core_pipeline::fullscreen_vertex_shader FullscreenVertexOutput #import bevy_core_pipeline::fullscreen_vertex_shader FullscreenVertexOutput
@group(0) @binding(0) @group(0) @binding(0) var in_texture: texture_2d<f32>;
var in_texture: texture_2d<f32>; @group(0) @binding(1) var in_sampler: sampler;
@group(0) @binding(1)
var in_sampler: sampler;
@fragment @fragment
fn fs_main(in: FullscreenVertexOutput) -> @location(0) vec4<f32> { fn fs_main(in: FullscreenVertexOutput) -> @location(0) vec4<f32> {

View File

@ -14,13 +14,10 @@ struct BloomUniforms {
aspect: f32, aspect: f32,
}; };
@group(0) @binding(0) @group(0) @binding(0) var input_texture: texture_2d<f32>;
var input_texture: texture_2d<f32>; @group(0) @binding(1) var s: sampler;
@group(0) @binding(1)
var s: sampler;
@group(0) @binding(2) @group(0) @binding(2) var<uniform> uniforms: BloomUniforms;
var<uniform> uniforms: BloomUniforms;
#ifdef FIRST_DOWNSAMPLE #ifdef FIRST_DOWNSAMPLE
// https://catlikecoding.com/unity/tutorials/advanced-rendering/bloom/#3.4 // https://catlikecoding.com/unity/tutorials/advanced-rendering/bloom/#3.4

View File

@ -23,12 +23,9 @@ struct CASUniforms {
sharpness: f32, sharpness: f32,
}; };
@group(0) @binding(0) @group(0) @binding(0) var screenTexture: texture_2d<f32>;
var screenTexture: texture_2d<f32>; @group(0) @binding(1) var samp: sampler;
@group(0) @binding(1) @group(0) @binding(2) var<uniform> uniforms: CASUniforms;
var samp: sampler;
@group(0) @binding(2)
var<uniform> uniforms: CASUniforms;
// This is set at the limit of providing unnatural results for sharpening. // This is set at the limit of providing unnatural results for sharpening.
const FSR_RCAS_LIMIT = 0.1875; const FSR_RCAS_LIMIT = 0.1875;

View File

@ -8,10 +8,8 @@
#import bevy_core_pipeline::fullscreen_vertex_shader FullscreenVertexOutput #import bevy_core_pipeline::fullscreen_vertex_shader FullscreenVertexOutput
@group(0) @binding(0) @group(0) @binding(0) var screenTexture: texture_2d<f32>;
var screenTexture: texture_2d<f32>; @group(0) @binding(1) var samp: sampler;
@group(0) @binding(1)
var samp: sampler;
// Trims the algorithm from processing darks. // Trims the algorithm from processing darks.
#ifdef EDGE_THRESH_MIN_LOW #ifdef EDGE_THRESH_MIN_LOW

View File

@ -1,11 +1,8 @@
#import bevy_render::view View #import bevy_render::view View
@group(0) @binding(0) @group(0) @binding(0) var skybox: texture_cube<f32>;
var skybox: texture_cube<f32>; @group(0) @binding(1) var skybox_sampler: sampler;
@group(0) @binding(1) @group(0) @binding(2) var<uniform> view: View;
var skybox_sampler: sampler;
@group(0) @binding(2)
var<uniform> view: View;
struct VertexOutput { struct VertexOutput {
@builtin(position) clip_position: vec4<f32>, @builtin(position) clip_position: vec4<f32>,

View File

@ -4,17 +4,12 @@
#import bevy_render::view View #import bevy_render::view View
#import bevy_core_pipeline::tonemapping tone_mapping, powsafe, screen_space_dither #import bevy_core_pipeline::tonemapping tone_mapping, powsafe, screen_space_dither
@group(0) @binding(0) @group(0) @binding(0) var<uniform> view: View;
var<uniform> view: View;
@group(0) @binding(1) @group(0) @binding(1) var hdr_texture: texture_2d<f32>;
var hdr_texture: texture_2d<f32>; @group(0) @binding(2) var hdr_sampler: sampler;
@group(0) @binding(2) @group(0) @binding(3) var dt_lut_texture: texture_3d<f32>;
var hdr_sampler: sampler; @group(0) @binding(4) var dt_lut_sampler: sampler;
@group(0) @binding(3)
var dt_lut_texture: texture_3d<f32>;
@group(0) @binding(4)
var dt_lut_sampler: sampler;
#import bevy_core_pipeline::tonemapping #import bevy_core_pipeline::tonemapping

View File

@ -4,15 +4,11 @@
// hack !! not sure what to do with this // hack !! not sure what to do with this
#ifdef TONEMAPPING_PASS #ifdef TONEMAPPING_PASS
@group(0) @binding(3) @group(0) @binding(3) var dt_lut_texture: texture_3d<f32>;
var dt_lut_texture: texture_3d<f32>; @group(0) @binding(4) var dt_lut_sampler: sampler;
@group(0) @binding(4)
var dt_lut_sampler: sampler;
#else #else
@group(0) @binding(15) @group(0) @binding(15) var dt_lut_texture: texture_3d<f32>;
var dt_lut_texture: texture_3d<f32>; @group(0) @binding(16) var dt_lut_sampler: sampler;
@group(0) @binding(16)
var dt_lut_sampler: sampler;
#endif #endif
fn sample_current_lut(p: vec3<f32>) -> vec3<f32> { fn sample_current_lut(p: vec3<f32>) -> vec3<f32> {

View File

@ -1,8 +1,7 @@
// TODO use common view binding // TODO use common view binding
#import bevy_render::view View #import bevy_render::view View
@group(0) @binding(0) @group(0) @binding(0) var<uniform> view: View;
var<uniform> view: View;
struct LineGizmoUniform { struct LineGizmoUniform {
@ -14,8 +13,7 @@ struct LineGizmoUniform {
#endif #endif
} }
@group(1) @binding(0) @group(1) @binding(0) var<uniform> line_gizmo: LineGizmoUniform;
var<uniform> line_gizmo: LineGizmoUniform;
struct VertexInput { struct VertexInput {
@location(0) position_a: vec3<f32>, @location(0) position_a: vec3<f32>,

View File

@ -95,12 +95,9 @@ use std::marker::PhantomData;
/// In WGSL shaders, the material's binding would look like this: /// In WGSL shaders, the material's binding would look like this:
/// ///
/// ```wgsl /// ```wgsl
/// @group(1) @binding(0) /// @group(1) @binding(0) var<uniform> color: vec4<f32>;
/// var<uniform> color: vec4<f32>; /// @group(1) @binding(1) var color_texture: texture_2d<f32>;
/// @group(1) @binding(1) /// @group(1) @binding(2) var color_sampler: sampler;
/// var color_texture: texture_2d<f32>;
/// @group(1) @binding(2)
/// var color_sampler: sampler;
/// ``` /// ```
pub trait Material: Asset + AsBindGroup + Clone + Sized { pub trait Material: Asset + AsBindGroup + Clone + Sized {
/// Returns this material's vertex shader. If [`ShaderRef::Default`] is returned, the default mesh vertex shader /// Returns this material's vertex shader. If [`ShaderRef::Default`] is returned, the default mesh vertex shader

View File

@ -3,16 +3,12 @@
#import bevy_render::globals Globals #import bevy_render::globals Globals
#import bevy_pbr::mesh_types #import bevy_pbr::mesh_types
@group(0) @binding(0) @group(0) @binding(0) var<uniform> view: View;
var<uniform> view: View; @group(0) @binding(1) var<uniform> globals: Globals;
@group(0) @binding(1)
var<uniform> globals: Globals;
#ifdef MOTION_VECTOR_PREPASS #ifdef MOTION_VECTOR_PREPASS
@group(0) @binding(2) @group(0) @binding(2) var<uniform> previous_view_proj: mat4x4<f32>;
var<uniform> previous_view_proj: mat4x4<f32>;
#endif // MOTION_VECTOR_PREPASS #endif // MOTION_VECTOR_PREPASS
// Material bindings will be in @group(1) // Material bindings will be in @group(1)
#import bevy_pbr::mesh_bindings mesh #import bevy_pbr::mesh_bindings mesh

View File

@ -445,11 +445,9 @@ pub struct MeshPipeline {
/// Use code like this in custom shaders: /// Use code like this in custom shaders:
/// ```wgsl /// ```wgsl
/// ##ifdef PER_OBJECT_BUFFER_BATCH_SIZE /// ##ifdef PER_OBJECT_BUFFER_BATCH_SIZE
/// @group(2) @binding(0) /// @group(2) @binding(0) var<uniform> mesh: array<Mesh, #{PER_OBJECT_BUFFER_BATCH_SIZE}u>;
/// var<uniform> mesh: array<Mesh, #{PER_OBJECT_BUFFER_BATCH_SIZE}u>;
/// ##else /// ##else
/// @group(2) @binding(0) /// @group(2) @binding(0) var<storage> mesh: array<Mesh>;
/// var<storage> mesh: array<Mesh>;
/// ##endif // PER_OBJECT_BUFFER_BATCH_SIZE /// ##endif // PER_OBJECT_BUFFER_BATCH_SIZE
/// ``` /// ```
pub per_object_buffer_batch_size: Option<u32>, pub per_object_buffer_batch_size: Option<u32>,

View File

@ -5,21 +5,17 @@
#ifdef MESH_BINDGROUP_1 #ifdef MESH_BINDGROUP_1
#ifdef PER_OBJECT_BUFFER_BATCH_SIZE #ifdef PER_OBJECT_BUFFER_BATCH_SIZE
@group(1) @binding(0) @group(1) @binding(0) var<uniform> mesh: array<Mesh, #{PER_OBJECT_BUFFER_BATCH_SIZE}u>;
var<uniform> mesh: array<Mesh, #{PER_OBJECT_BUFFER_BATCH_SIZE}u>;
#else #else
@group(1) @binding(0) @group(1) @binding(0) var<storage> mesh: array<Mesh>;
var<storage> mesh: array<Mesh>;
#endif // PER_OBJECT_BUFFER_BATCH_SIZE #endif // PER_OBJECT_BUFFER_BATCH_SIZE
#else // MESH_BINDGROUP_1 #else // MESH_BINDGROUP_1
#ifdef PER_OBJECT_BUFFER_BATCH_SIZE #ifdef PER_OBJECT_BUFFER_BATCH_SIZE
@group(2) @binding(0) @group(2) @binding(0) var<uniform> mesh: array<Mesh, #{PER_OBJECT_BUFFER_BATCH_SIZE}u>;
var<uniform> mesh: array<Mesh, #{PER_OBJECT_BUFFER_BATCH_SIZE}u>;
#else #else
@group(2) @binding(0) @group(2) @binding(0) var<storage> mesh: array<Mesh>;
var<storage> mesh: array<Mesh>;
#endif // PER_OBJECT_BUFFER_BATCH_SIZE #endif // PER_OBJECT_BUFFER_BATCH_SIZE
#endif // MESH_BINDGROUP_1 #endif // MESH_BINDGROUP_1

View File

@ -4,77 +4,49 @@
#import bevy_render::view View #import bevy_render::view View
#import bevy_render::globals Globals #import bevy_render::globals Globals
@group(0) @binding(0) @group(0) @binding(0) var<uniform> view: View;
var<uniform> view: View; @group(0) @binding(1) var<uniform> lights: types::Lights;
@group(0) @binding(1)
var<uniform> lights: types::Lights;
#ifdef NO_ARRAY_TEXTURES_SUPPORT #ifdef NO_ARRAY_TEXTURES_SUPPORT
@group(0) @binding(2) @group(0) @binding(2) var point_shadow_textures: texture_depth_cube;
var point_shadow_textures: texture_depth_cube;
#else #else
@group(0) @binding(2) @group(0) @binding(2) var point_shadow_textures: texture_depth_cube_array;
var point_shadow_textures: texture_depth_cube_array;
#endif #endif
@group(0) @binding(3) @group(0) @binding(3) var point_shadow_textures_sampler: sampler_comparison;
var point_shadow_textures_sampler: sampler_comparison;
#ifdef NO_ARRAY_TEXTURES_SUPPORT #ifdef NO_ARRAY_TEXTURES_SUPPORT
@group(0) @binding(4) @group(0) @binding(4) var directional_shadow_textures: texture_depth_2d;
var directional_shadow_textures: texture_depth_2d;
#else #else
@group(0) @binding(4) @group(0) @binding(4) var directional_shadow_textures: texture_depth_2d_array;
var directional_shadow_textures: texture_depth_2d_array;
#endif #endif
@group(0) @binding(5) @group(0) @binding(5) var directional_shadow_textures_sampler: sampler_comparison;
var directional_shadow_textures_sampler: sampler_comparison;
#if AVAILABLE_STORAGE_BUFFER_BINDINGS >= 3 #if AVAILABLE_STORAGE_BUFFER_BINDINGS >= 3
@group(0) @binding(6) @group(0) @binding(6) var<storage> point_lights: types::PointLights;
var<storage> point_lights: types::PointLights; @group(0) @binding(7) var<storage> cluster_light_index_lists: types::ClusterLightIndexLists;
@group(0) @binding(7) @group(0) @binding(8) var<storage> cluster_offsets_and_counts: types::ClusterOffsetsAndCounts;
var<storage> cluster_light_index_lists: types::ClusterLightIndexLists;
@group(0) @binding(8)
var<storage> cluster_offsets_and_counts: types::ClusterOffsetsAndCounts;
#else #else
@group(0) @binding(6) @group(0) @binding(6) var<uniform> point_lights: types::PointLights;
var<uniform> point_lights: types::PointLights; @group(0) @binding(7) var<uniform> cluster_light_index_lists: types::ClusterLightIndexLists;
@group(0) @binding(7) @group(0) @binding(8) var<uniform> cluster_offsets_and_counts: types::ClusterOffsetsAndCounts;
var<uniform> cluster_light_index_lists: types::ClusterLightIndexLists;
@group(0) @binding(8)
var<uniform> cluster_offsets_and_counts: types::ClusterOffsetsAndCounts;
#endif #endif
@group(0) @binding(9) @group(0) @binding(9) var<uniform> globals: Globals;
var<uniform> globals: Globals; @group(0) @binding(10) var<uniform> fog: types::Fog;
@group(0) @binding(10)
var<uniform> fog: types::Fog;
@group(0) @binding(11) @group(0) @binding(11) var screen_space_ambient_occlusion_texture: texture_2d<f32>;
var screen_space_ambient_occlusion_texture: texture_2d<f32>;
@group(0) @binding(12) @group(0) @binding(12) var environment_map_diffuse: texture_cube<f32>;
var environment_map_diffuse: texture_cube<f32>; @group(0) @binding(13) var environment_map_specular: texture_cube<f32>;
@group(0) @binding(13) @group(0) @binding(14) var environment_map_sampler: sampler;
var environment_map_specular: texture_cube<f32>;
@group(0) @binding(14)
var environment_map_sampler: sampler;
@group(0) @binding(15) @group(0) @binding(15) var dt_lut_texture: texture_3d<f32>;
var dt_lut_texture: texture_3d<f32>; @group(0) @binding(16) var dt_lut_sampler: sampler;
@group(0) @binding(16)
var dt_lut_sampler: sampler;
#ifdef MULTISAMPLED #ifdef MULTISAMPLED
@group(0) @binding(17) @group(0) @binding(17) var depth_prepass_texture: texture_depth_multisampled_2d;
var depth_prepass_texture: texture_depth_multisampled_2d; @group(0) @binding(18) var normal_prepass_texture: texture_multisampled_2d<f32>;
@group(0) @binding(18) @group(0) @binding(19) var motion_vector_prepass_texture: texture_multisampled_2d<f32>;
var normal_prepass_texture: texture_multisampled_2d<f32>;
@group(0) @binding(19)
var motion_vector_prepass_texture: texture_multisampled_2d<f32>;
#else #else
@group(0) @binding(17) @group(0) @binding(17) var depth_prepass_texture: texture_depth_2d;
var depth_prepass_texture: texture_depth_2d; @group(0) @binding(18) var normal_prepass_texture: texture_2d<f32>;
@group(0) @binding(18) @group(0) @binding(19) var motion_vector_prepass_texture: texture_2d<f32>;
var normal_prepass_texture: texture_2d<f32>;
@group(0) @binding(19)
var motion_vector_prepass_texture: texture_2d<f32>;
#endif #endif

View File

@ -13,17 +13,13 @@
#ifdef MESH_BINDGROUP_1 #ifdef MESH_BINDGROUP_1
@group(1) @binding(2) @group(1) @binding(2) var<uniform> morph_weights: MorphWeights;
var<uniform> morph_weights: MorphWeights; @group(1) @binding(3) var morph_targets: texture_3d<f32>;
@group(1) @binding(3)
var morph_targets: texture_3d<f32>;
#else #else
@group(2) @binding(2) @group(2) @binding(2) var<uniform> morph_weights: MorphWeights;
var<uniform> morph_weights: MorphWeights; @group(2) @binding(3) var morph_targets: texture_3d<f32>;
@group(2) @binding(3)
var morph_targets: texture_3d<f32>;
#endif #endif

View File

@ -2,29 +2,16 @@
#import bevy_pbr::pbr_types StandardMaterial #import bevy_pbr::pbr_types StandardMaterial
@group(1) @binding(0) @group(1) @binding(0) var<uniform> material: StandardMaterial;
var<uniform> material: StandardMaterial; @group(1) @binding(1) var base_color_texture: texture_2d<f32>;
@group(1) @binding(1) @group(1) @binding(2) var base_color_sampler: sampler;
var base_color_texture: texture_2d<f32>; @group(1) @binding(3) var emissive_texture: texture_2d<f32>;
@group(1) @binding(2) @group(1) @binding(4) var emissive_sampler: sampler;
var base_color_sampler: sampler; @group(1) @binding(5) var metallic_roughness_texture: texture_2d<f32>;
@group(1) @binding(3) @group(1) @binding(6) var metallic_roughness_sampler: sampler;
var emissive_texture: texture_2d<f32>; @group(1) @binding(7) var occlusion_texture: texture_2d<f32>;
@group(1) @binding(4) @group(1) @binding(8) var occlusion_sampler: sampler;
var emissive_sampler: sampler; @group(1) @binding(9) var normal_map_texture: texture_2d<f32>;
@group(1) @binding(5) @group(1) @binding(10) var normal_map_sampler: sampler;
var metallic_roughness_texture: texture_2d<f32>; @group(1) @binding(11) var depth_map_texture: texture_2d<f32>;
@group(1) @binding(6) @group(1) @binding(12) var depth_map_sampler: sampler;
var metallic_roughness_sampler: sampler;
@group(1) @binding(7)
var occlusion_texture: texture_2d<f32>;
@group(1) @binding(8)
var occlusion_sampler: sampler;
@group(1) @binding(9)
var normal_map_texture: texture_2d<f32>;
@group(1) @binding(10)
var normal_map_sampler: sampler;
@group(1) @binding(11)
var depth_map_texture: texture_2d<f32>;
@group(1) @binding(12)
var depth_map_sampler: sampler;

View File

@ -5,15 +5,9 @@
#ifdef SKINNED #ifdef SKINNED
#ifdef MESH_BINDGROUP_1 #ifdef MESH_BINDGROUP_1
@group(1) @binding(1) var<uniform> joint_matrices: SkinnedMesh;
@group(1) @binding(1)
var<uniform> joint_matrices: SkinnedMesh;
#else #else
@group(2) @binding(1) var<uniform> joint_matrices: SkinnedMesh;
@group(2) @binding(1)
var<uniform> joint_matrices: SkinnedMesh;
#endif #endif

View File

@ -92,14 +92,10 @@ impl Deref for BindGroup {
/// In WGSL shaders, the binding would look like this: /// In WGSL shaders, the binding would look like this:
/// ///
/// ```wgsl /// ```wgsl
/// @group(1) @binding(0) /// @group(1) @binding(0) var<uniform> color: vec4<f32>;
/// var<uniform> color: vec4<f32>; /// @group(1) @binding(1) var color_texture: texture_2d<f32>;
/// @group(1) @binding(1) /// @group(1) @binding(2) var color_sampler: sampler;
/// var color_texture: texture_2d<f32>; /// @group(1) @binding(3) var<storage> values: array<f32>;
/// @group(1) @binding(2)
/// var color_sampler: sampler;
/// @group(1) @binding(3)
/// var<storage> values: array<f32>;
/// ``` /// ```
/// Note that the "group" index is determined by the usage context. It is not defined in [`AsBindGroup`]. For example, in Bevy material bind groups /// Note that the "group" index is determined by the usage context. It is not defined in [`AsBindGroup`]. For example, in Bevy material bind groups
/// are generally bound to group 1. /// are generally bound to group 1.
@ -194,8 +190,7 @@ impl Deref for BindGroup {
/// roughness: f32, /// roughness: f32,
/// }; /// };
/// ///
/// @group(1) @binding(0) /// @group(1) @binding(0) var<uniform> material: CoolMaterial;
/// var<uniform> material: CoolMaterial;
/// ``` /// ```
/// ///
/// Some less common scenarios will require "struct-level" attributes. These are the currently supported struct-level attributes: /// Some less common scenarios will require "struct-level" attributes. These are the currently supported struct-level attributes:

View File

@ -13,12 +13,9 @@ struct ColorMaterial {
}; };
const COLOR_MATERIAL_FLAGS_TEXTURE_BIT: u32 = 1u; const COLOR_MATERIAL_FLAGS_TEXTURE_BIT: u32 = 1u;
@group(1) @binding(0) @group(1) @binding(0) var<uniform> material: ColorMaterial;
var<uniform> material: ColorMaterial; @group(1) @binding(1) var texture: texture_2d<f32>;
@group(1) @binding(1) @group(1) @binding(2) var texture_sampler: sampler;
var texture: texture_2d<f32>;
@group(1) @binding(2)
var texture_sampler: sampler;
@fragment @fragment
fn fragment( fn fragment(

View File

@ -100,12 +100,9 @@ use crate::{
/// color: vec4<f32>, /// color: vec4<f32>,
/// } /// }
/// ///
/// @group(1) @binding(0) /// @group(1) @binding(0) var<uniform> material: CustomMaterial;
/// var<uniform> material: CustomMaterial; /// @group(1) @binding(1) var color_texture: texture_2d<f32>;
/// @group(1) @binding(1) /// @group(1) @binding(2) var color_sampler: sampler;
/// var color_texture: texture_2d<f32>;
/// @group(1) @binding(2)
/// var color_sampler: sampler;
/// ``` /// ```
pub trait Material2d: AsBindGroup + Asset + Clone + Sized { pub trait Material2d: AsBindGroup + Asset + Clone + Sized {
/// Returns this material's vertex shader. If [`ShaderRef::Default`] is returned, the default mesh vertex shader /// Returns this material's vertex shader. If [`ShaderRef::Default`] is returned, the default mesh vertex shader

View File

@ -2,5 +2,4 @@
#import bevy_sprite::mesh2d_types #import bevy_sprite::mesh2d_types
@group(2) @binding(0) @group(2) @binding(0) var<uniform> mesh: bevy_sprite::mesh2d_types::Mesh2d;
var<uniform> mesh: bevy_sprite::mesh2d_types::Mesh2d;

View File

@ -3,8 +3,6 @@
#import bevy_render::view View #import bevy_render::view View
#import bevy_render::globals Globals #import bevy_render::globals Globals
@group(0) @binding(0) @group(0) @binding(0) var<uniform> view: View;
var<uniform> view: View;
@group(0) @binding(1) @group(0) @binding(1) var<uniform> globals: Globals;
var<uniform> globals: Globals;

View File

@ -5,8 +5,7 @@
#import bevy_render::maths affine_to_square #import bevy_render::maths affine_to_square
#import bevy_render::view View #import bevy_render::view View
@group(0) @binding(0) @group(0) @binding(0) var<uniform> view: View;
var<uniform> view: View;
struct VertexInput { struct VertexInput {
@builtin(vertex_index) index: u32, @builtin(vertex_index) index: u32,
@ -47,10 +46,8 @@ fn vertex(in: VertexInput) -> VertexOutput {
return out; return out;
} }
@group(1) @binding(0) @group(1) @binding(0) var sprite_texture: texture_2d<f32>;
var sprite_texture: texture_2d<f32>; @group(1) @binding(1) var sprite_sampler: sampler;
@group(1) @binding(1)
var sprite_sampler: sampler;
@fragment @fragment
fn fragment(in: VertexOutput) -> @location(0) vec4<f32> { fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {

View File

@ -2,8 +2,7 @@
const TEXTURED_QUAD: u32 = 0u; const TEXTURED_QUAD: u32 = 0u;
@group(0) @binding(0) @group(0) @binding(0) var<uniform> view: View;
var<uniform> view: View;
struct VertexOutput { struct VertexOutput {
@location(0) uv: vec2<f32>, @location(0) uv: vec2<f32>,
@ -27,10 +26,8 @@ fn vertex(
return out; return out;
} }
@group(1) @binding(0) @group(1) @binding(0) var sprite_texture: texture_2d<f32>;
var sprite_texture: texture_2d<f32>; @group(1) @binding(1) var sprite_sampler: sampler;
@group(1) @binding(1)
var sprite_sampler: sampler;
@fragment @fragment
fn fragment(in: VertexOutput) -> @location(0) vec4<f32> { fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {

View File

@ -215,8 +215,7 @@ const COLORED_MESH2D_SHADER: &str = r"
#import bevy_sprite::mesh2d_types as MeshTypes #import bevy_sprite::mesh2d_types as MeshTypes
#import bevy_sprite::mesh2d_functions as MeshFunctions #import bevy_sprite::mesh2d_functions as MeshFunctions
@group(1) @binding(0) @group(1) @binding(0) var<uniform> mesh: MeshTypes::Mesh2d;
var<uniform> mesh: MeshTypes::Mesh2d;
// The structure of the vertex buffer is as specified in `specialize()` // The structure of the vertex buffer is as specified in `specialize()`
struct Vertex { struct Vertex {