Skip to content
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

use VISIBILITY_RANGE_UNIFORM_BUFFER_SIZE const #4

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions crates/bevy_pbr/src/render/mesh_functions.wgsl
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -94,8 +98,8 @@ fn get_visibility_range_dither_level(instance_index: u32, world_position: vec4<f
// If we're using a storage buffer, then the length is variable.
let visibility_buffer_array_len = arrayLength(&visibility_ranges);
#else // AVAILABLE_STORAGE_BUFFER_BINDINGS >= 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;
Expand Down
5 changes: 2 additions & 3 deletions crates/bevy_pbr/src/render/mesh_view_bindings.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,11 @@
@group(0) @binding(10) var<uniform> fog: types::Fog;
@group(0) @binding(11) var<uniform> 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<storage> visibility_ranges: array<vec4<f32>>;
#else
@group(0) @binding(12) var<uniform> visibility_ranges: array<vec4<f32>, 64u>;
@group(0) @binding(12) var<uniform> visibility_ranges: array<vec4<f32>, VISIBILITY_RANGE_UNIFORM_BUFFER_SIZE>;
#endif

@group(0) @binding(13) var screen_space_ambient_occlusion_texture: texture_2d<f32>;
Expand Down