Skip to content

Commit a567f4d

Browse files
committed
Guard renderer module graph against cycles
1 parent da30355 commit a567f4d

8 files changed

Lines changed: 401 additions & 18 deletions

File tree

crates/renderide/src/config/persist/load/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ fn max_local_reflection_probe_env_override_clamps_effective_value() {
118118
settings
119119
.experimental
120120
.effective_max_local_reflection_probes(),
121-
crate::reflection_probes::specular::MAX_LOCAL_PROBES
121+
crate::render_contract::MAX_LOCAL_REFLECTION_PROBES
122122
);
123123
}
124124

crates/renderide/src/config/types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ mod tests {
107107
assert_eq!(settings.display.focused_fps_cap, 75);
108108
assert_eq!(
109109
settings.experimental.max_local_reflection_probes,
110-
crate::reflection_probes::specular::MAX_LOCAL_PROBES
110+
crate::render_contract::MAX_LOCAL_REFLECTION_PROBES
111111
);
112112
assert!(!settings.experimental.reflection_probe_sh2_enabled);
113113
}
@@ -123,7 +123,7 @@ mod tests {
123123
assert!(text.contains("[experimental]"), "got:\n{text}");
124124
assert_eq!(
125125
decoded.experimental.max_local_reflection_probes,
126-
crate::reflection_probes::specular::MAX_LOCAL_PROBES
126+
crate::render_contract::MAX_LOCAL_REFLECTION_PROBES
127127
);
128128
assert!(!decoded.experimental.reflection_probe_sh2_enabled);
129129
}

crates/renderide/src/config/types/experimental.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use serde::{Deserialize, Serialize};
44

5-
use crate::reflection_probes::specular::MAX_LOCAL_PROBES;
5+
use crate::render_contract::MAX_LOCAL_REFLECTION_PROBES;
66

77
/// Feature flags for renderer behavior that is still experimental.
88
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
@@ -19,7 +19,7 @@ pub struct ExperimentalSettings {
1919
impl Default for ExperimentalSettings {
2020
fn default() -> Self {
2121
Self {
22-
max_local_reflection_probes: MAX_LOCAL_PROBES,
22+
max_local_reflection_probes: MAX_LOCAL_REFLECTION_PROBES,
2323
reflection_probe_sh2_enabled: false,
2424
material_shader_hot_reload_enabled: false,
2525
}
@@ -30,7 +30,8 @@ impl ExperimentalSettings {
3030
/// Returns the local reflection-probe count clamped to the fixed per-draw packing capacity.
3131
#[must_use]
3232
pub fn effective_max_local_reflection_probes(self) -> usize {
33-
self.max_local_reflection_probes.min(MAX_LOCAL_PROBES)
33+
self.max_local_reflection_probes
34+
.min(MAX_LOCAL_REFLECTION_PROBES)
3435
}
3536
}
3637

@@ -42,23 +43,26 @@ mod tests {
4243
fn default_local_reflection_probe_limit_matches_packed_capacity() {
4344
let settings = ExperimentalSettings::default();
4445

45-
assert_eq!(settings.max_local_reflection_probes, MAX_LOCAL_PROBES);
46+
assert_eq!(
47+
settings.max_local_reflection_probes,
48+
MAX_LOCAL_REFLECTION_PROBES
49+
);
4650
assert_eq!(
4751
settings.effective_max_local_reflection_probes(),
48-
MAX_LOCAL_PROBES
52+
MAX_LOCAL_REFLECTION_PROBES
4953
);
5054
}
5155

5256
#[test]
5357
fn effective_local_reflection_probe_limit_clamps_to_packed_capacity() {
5458
let settings = ExperimentalSettings {
55-
max_local_reflection_probes: MAX_LOCAL_PROBES + 10,
59+
max_local_reflection_probes: MAX_LOCAL_REFLECTION_PROBES + 10,
5660
..Default::default()
5761
};
5862

5963
assert_eq!(
6064
settings.effective_max_local_reflection_probes(),
61-
MAX_LOCAL_PROBES
65+
MAX_LOCAL_REFLECTION_PROBES
6266
);
6367
}
6468
}

crates/renderide/src/diagnostics/hud/windows/renderer_config/experimental.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Experimental renderer-config HUD controls.
22
33
use crate::config::RendererSettings;
4-
use crate::reflection_probes::specular::MAX_LOCAL_PROBES;
4+
use crate::render_contract::MAX_LOCAL_REFLECTION_PROBES;
55

66
use super::controls::drag_u32_slider_setting;
77

@@ -15,7 +15,7 @@ pub(super) fn experimental_section(ui: &imgui::Ui, g: &mut RendererSettings, dir
1515
"Maximum number of local reflection probes per mesh",
1616
&mut mrp,
1717
0,
18-
MAX_LOCAL_PROBES as u32,
18+
MAX_LOCAL_REFLECTION_PROBES as u32,
1919
) {
2020
g.experimental.max_local_reflection_probes = mrp as usize;
2121
*dirty = true;

crates/renderide/src/reflection_probes/specular.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ pub(crate) use captures::{
1212
RuntimeReflectionProbeCaptureStore,
1313
};
1414
pub(crate) use resources::ReflectionProbeSpecularResources;
15-
pub(crate) use selection::MAX_LOCAL_PROBES;
1615
pub use selection::{ReflectionProbeDrawSelection, ReflectionProbeFrameSelection};
1716
pub(crate) use system::ReflectionProbeSpecularMaintainParams;
1817
pub use system::ReflectionProbeSpecularSystem;

crates/renderide/src/reflection_probes/specular/selection.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ use rayon::prelude::*;
55
use crate::cpu_parallelism::{
66
admit_coarse_space_items, current_reference_worker_count, record_parallel_admission,
77
};
8+
use crate::render_contract::MAX_LOCAL_REFLECTION_PROBES;
89
use crate::scene::RenderSpaceId;
910

1011
/// Maximum number of probes in one BVH leaf.
1112
const BVH_LEAF_SIZE: usize = 8;
1213
const MIN_BLEND_DISTANCE: f32 = 1e-6;
1314
/// Maximum number of local reflection probes packed into one draw.
14-
pub const MAX_LOCAL_PROBES: usize = 4;
15+
pub const MAX_LOCAL_PROBES: usize = MAX_LOCAL_REFLECTION_PROBES;
1516
const CONTAINMENT_EPSILON: f32 = 1e-5;
1617

1718
/// Clamps user configuration to the fixed per-draw packing capacity.

crates/renderide/src/render_contract.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ pub const BLENDSHAPE_PACKED_VECTOR_SPARSE_ENTRY_WORDS: u32 = 3;
2222
/// Minimum storage buffer size used when a mesh has blendshapes but zero sparse bytes.
2323
pub const BLENDSHAPE_SPARSE_MIN_BUFFER_BYTES: u64 = 16;
2424

25+
/// Maximum number of local reflection probes packed into one draw.
26+
pub const MAX_LOCAL_REFLECTION_PROBES: usize = 4;
27+
2528
/// GPU-ready channel-sparse blendshape deltas and CPU scatter ranges.
2629
pub struct BlendshapeGpuPack {
2730
/// Tightly packed `u32` words containing position, normal, and tangent sparse sections.

0 commit comments

Comments
 (0)