Skip to content

Commit 9da6d5d

Browse files
committed
bevy_pbr: Rename MAX_POINT_LIGHTS to MAX_UNIFORM_BUFFER_POINT_LIGHTS
1 parent 3b13f86 commit 9da6d5d

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

crates/bevy_pbr/src/light.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ use bevy_window::Windows;
1919

2020
use crate::{
2121
calculate_cluster_factors, CubeMapFace, CubemapVisibleEntities, ViewClusterBindings,
22-
CLUSTERED_FORWARD_STORAGE_BUFFER_COUNT, CUBE_MAP_FACES, MAX_POINT_LIGHTS, POINT_LIGHT_NEAR_Z,
22+
CLUSTERED_FORWARD_STORAGE_BUFFER_COUNT, CUBE_MAP_FACES, MAX_UNIFORM_BUFFER_POINT_LIGHTS,
23+
POINT_LIGHT_NEAR_Z,
2324
};
2425

2526
/// A light that emits light in all directions from a central point.
@@ -736,7 +737,7 @@ pub(crate) fn assign_lights_to_clusters(
736737
clustered_forward_buffer_binding_type,
737738
BufferBindingType::Storage { .. }
738739
);
739-
if lights.len() > MAX_POINT_LIGHTS && !supports_storage_buffers {
740+
if lights.len() > MAX_UNIFORM_BUFFER_POINT_LIGHTS && !supports_storage_buffers {
740741
lights.sort_by(|light_1, light_2| {
741742
point_light_order(
742743
(&light_1.entity, &light_1.shadows_enabled),
@@ -752,7 +753,7 @@ pub(crate) fn assign_lights_to_clusters(
752753
let mut lights_in_view_count = 0;
753754
lights.retain(|light| {
754755
// take one extra light to check if we should emit the warning
755-
if lights_in_view_count == MAX_POINT_LIGHTS + 1 {
756+
if lights_in_view_count == MAX_UNIFORM_BUFFER_POINT_LIGHTS + 1 {
756757
false
757758
} else {
758759
let light_sphere = Sphere {
@@ -772,12 +773,15 @@ pub(crate) fn assign_lights_to_clusters(
772773
}
773774
});
774775

775-
if lights.len() > MAX_POINT_LIGHTS && !*max_point_lights_warning_emitted {
776-
warn!("MAX_POINT_LIGHTS ({}) exceeded", MAX_POINT_LIGHTS);
776+
if lights.len() > MAX_UNIFORM_BUFFER_POINT_LIGHTS && !*max_point_lights_warning_emitted {
777+
warn!(
778+
"MAX_UNIFORM_BUFFER_POINT_LIGHTS ({}) exceeded",
779+
MAX_UNIFORM_BUFFER_POINT_LIGHTS
780+
);
777781
*max_point_lights_warning_emitted = true;
778782
}
779783

780-
lights.truncate(MAX_POINT_LIGHTS);
784+
lights.truncate(MAX_UNIFORM_BUFFER_POINT_LIGHTS);
781785
}
782786

783787
for (view_entity, camera_transform, camera, frustum, config, clusters, mut visible_lights) in

crates/bevy_pbr/src/render/light.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ pub struct GpuPointLight {
9494

9595
pub enum GpuPointLights {
9696
Uniform {
97-
buffer: UniformVec<[GpuPointLight; MAX_POINT_LIGHTS]>,
97+
buffer: UniformVec<[GpuPointLight; MAX_UNIFORM_BUFFER_POINT_LIGHTS]>,
9898
},
9999
Storage {
100100
buffer: StorageBuffer<GpuPointLight>,
@@ -136,7 +136,7 @@ impl GpuPointLights {
136136
let gpu_point_lights = lights
137137
.drain(..)
138138
.chain(std::iter::repeat_with(GpuPointLight::default))
139-
.take(MAX_POINT_LIGHTS)
139+
.take(MAX_UNIFORM_BUFFER_POINT_LIGHTS)
140140
.collect::<Vec<_>>();
141141
buffer.push(gpu_point_lights.try_into().unwrap());
142142
}
@@ -219,7 +219,7 @@ pub struct GpuLights {
219219
}
220220

221221
// NOTE: this must be kept in sync with the same constants in pbr.frag
222-
pub const MAX_POINT_LIGHTS: usize = 256;
222+
pub const MAX_UNIFORM_BUFFER_POINT_LIGHTS: usize = 256;
223223
// FIXME: How should we handle shadows for clustered forward? Limiting to maximum 10
224224
// point light shadow maps for now
225225
#[cfg(feature = "webgl")]
@@ -1008,7 +1008,7 @@ pub fn prepare_lights(
10081008
}
10091009

10101010
// this must match CLUSTER_COUNT_SIZE in pbr.wgsl
1011-
// and must be large enough to contain MAX_POINT_LIGHTS
1011+
// and must be large enough to contain MAX_UNIFORM_BUFFER_POINT_LIGHTS
10121012
const CLUSTER_COUNT_SIZE: u32 = 13;
10131013

10141014
const CLUSTER_OFFSET_MASK: u32 = (1 << (32 - CLUSTER_COUNT_SIZE)) - 1;

0 commit comments

Comments
 (0)