From ebc41da844adcacd384b46d0af2f71e098d82551 Mon Sep 17 00:00:00 2001 From: IceSentry Date: Fri, 3 May 2024 23:02:00 -0400 Subject: [PATCH 1/2] use VISIBILITY_RANGE_UNIFORM_BUFFER_SIZE const --- crates/bevy_pbr/src/render/mesh_functions.wgsl | 10 +++++++--- crates/bevy_pbr/src/render/mesh_view_bindings.wgsl | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/crates/bevy_pbr/src/render/mesh_functions.wgsl b/crates/bevy_pbr/src/render/mesh_functions.wgsl index 19ddfc64f5959..ce8e9701271a5 100644 --- a/crates/bevy_pbr/src/render/mesh_functions.wgsl +++ b/crates/bevy_pbr/src/render/mesh_functions.wgsl @@ -1,7 +1,11 @@ #define_import_path bevy_pbr::mesh_functions #import bevy_pbr::{ - mesh_view_bindings::{view, visibility_ranges}, + mesh_view_bindings::{ + view, + visibility_ranges, + VISIBILITY_RANGE_UNIFORM_BUFFER_SIZE + }, mesh_bindings::mesh, mesh_types::MESH_FLAGS_SIGN_DETERMINANT_MODEL_3X3_BIT, view_transformations::position_world_to_clip, @@ -94,8 +98,8 @@ fn get_visibility_range_dither_level(instance_index: u32, world_position: vec4= 6 - // If we're using a uniform buffer, then the length is *exactly* 64. - let visibility_buffer_array_len = 64u; + // If we're using a uniform buffer, then the length is constant + let visibility_buffer_array_len = VISIBILITY_RANGE_UNIFORM_BUFFER_SIZE; #endif // AVAILABLE_STORAGE_BUFFER_BINDINGS >= 6 let visibility_buffer_index = mesh[instance_index].flags & 0xffffu; diff --git a/crates/bevy_pbr/src/render/mesh_view_bindings.wgsl b/crates/bevy_pbr/src/render/mesh_view_bindings.wgsl index 415ecf6b9a487..6241f32ba6d1f 100644 --- a/crates/bevy_pbr/src/render/mesh_view_bindings.wgsl +++ b/crates/bevy_pbr/src/render/mesh_view_bindings.wgsl @@ -40,7 +40,8 @@ #if AVAILABLE_STORAGE_BUFFER_BINDINGS >= 6 @group(0) @binding(12) var visibility_ranges: array>; #else -@group(0) @binding(12) var visibility_ranges: array, 64u>; +const VISIBILITY_RANGE_UNIFORM_BUFFER_SIZE: u32 = 64u; +@group(0) @binding(12) var visibility_ranges: array, VISIBILITY_RANGE_UNIFORM_BUFFER_SIZE>; #endif @group(0) @binding(13) var screen_space_ambient_occlusion_texture: texture_2d; From 16b34ee45c532a8cd7799ea5c5a7598852933907 Mon Sep 17 00:00:00 2001 From: IceSentry Date: Fri, 3 May 2024 23:05:11 -0400 Subject: [PATCH 2/2] remove comment and move out of ifdef --- crates/bevy_pbr/src/render/mesh_view_bindings.wgsl | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/crates/bevy_pbr/src/render/mesh_view_bindings.wgsl b/crates/bevy_pbr/src/render/mesh_view_bindings.wgsl index 6241f32ba6d1f..b8e74c60b8b43 100644 --- a/crates/bevy_pbr/src/render/mesh_view_bindings.wgsl +++ b/crates/bevy_pbr/src/render/mesh_view_bindings.wgsl @@ -35,12 +35,10 @@ @group(0) @binding(10) var fog: types::Fog; @group(0) @binding(11) var light_probes: types::LightProbes; -// NB: If you change this `#if`, make sure to update the corresponding `#if` in -// `mesh_functions.wgsl` too. +const VISIBILITY_RANGE_UNIFORM_BUFFER_SIZE: u32 = 64u; #if AVAILABLE_STORAGE_BUFFER_BINDINGS >= 6 @group(0) @binding(12) var visibility_ranges: array>; #else -const VISIBILITY_RANGE_UNIFORM_BUFFER_SIZE: u32 = 64u; @group(0) @binding(12) var visibility_ranges: array, VISIBILITY_RANGE_UNIFORM_BUFFER_SIZE>; #endif