Submission CPU time, ambient light following the exposure, unattended benchmark #139

Open
Zetsukae wants to merge 12 commits from upstream-pr/139 into main
Zetsukae commented 2026-11-25 16:12:53 +00:00 (Migrated from github.com)

Imported from Belobug/VIctory-Belobug-AMD. Originally posted by Zetsukae on 2026-11-25T16:12:53Z.


What this does

Speeds up the work the submitting thread does around each submission, found with VICTORY_PROFILE and measured with an unattended benchmark (included).

  • in_parallel keeps its helper threads for the run instead of starting and joining five threads on each call. That was about an eighth of the submitting thread's time.
  • Bindless plans keep their lists (reads, writes, bounces, held resources) while no busy slot changes what it adds to them. When a slot does change, the lists are made from counted contributions, kept up to date as slots change, instead of walking every busy slot. bindless plans went from 45–70 ms to about 19 ms a frame in the world. In test builds, every remake also makes the lists the old way and asserts they are equal.
  • The guards' block sets are bit sets instead of trees. The wait at the guard check disappears from the profile, but it moves to the copy-back's use of the same lock: no measurable frame-rate change. It is kept because it is equivalent (a test compares it against a tree) and makes the next step on that lock easier.
  • Diagnostics: the time spent taking snapshots now appears in the sparse-writes line. Scripted keys (VICTORY_KEYS, VICTORY_KEYS_FILE) also press the stand-in pad's buttons on a real pad in slot 0: while a pad is connected, the title reads the pad and ignores the keyboard.
  • scripts/bench.ps1: an unattended benchmark. It presses Enter at the title screen, waits through the opening cinematic, measures 90 s in the world, can take screenshots, and writes a summary. -GpuTiming also sets VICTORY_D3D12_DRED: per-pipeline GPU times are only recorded when it is set (this is not in the README). scripts/profile-run.ps1 is the same run played by hand.

Results

Standing still in the world (frame lines averaged over 90 s): 3.5–4 fps (250–300 ms) before, 4.75 fps (216 ms) after. Walking: 3–4 fps before, about 5 after.

What is left per frame: GPU about 72 ms (spread over about 1,300 pipelines, the slowest 4.5 ms), refresh copies about 42 ms, snapshots about 36–40 ms, copy-back about 31 ms, bindless plans about 19 ms. These still run one after the other.

Lighting: the ambient stand-in follows the title's exposure

The stand-in for the missing ray-traced indirect light was one constant (0.6). The lighting images it goes into are already multiplied by the title's exposure, so in a dark scene where the title raises the exposure (interiors, night: -5.5 EV) the constant came out as strong as at noon (-9.75 EV): flat and too bright at night, pure black in daytime shadows.

PS_CalculateExposure draws a 1×1 RGBA32F holding (multiplier, EV, EV); in the prison interior it read (0.0221, -5.5, -5.5). The program is found by name, the same way as the resolve, its target is noted, and the ambient pass reads it as a shader resource. The level becomes at · 2^(-k·(EV - ev)): by default k = 0.5 and 1.4 at -9.75 EV, which gives about 0.32 at -5.5 EV. Those are the README's hand-tuned noon and dusk levels. VICTORY_AMBIENT_EXPOSURE=k,ev,at tunes it; setting VICTORY_AMBIENT or using the ambient file still forces a fixed level.

Only checked at dusk in the prison so far. Night has not been looked at yet.

Also new in diagnostics: VICTORY_RESOLVE_CONSTANTS=1 logs the resolve's constants (that's how the exposure was ruled out there), and bench.ps1 gains cinematic screenshots, render-target dumps and -ExtraEnv.

Textures written by the GPU through another view

Skin and tattoos on people showed noise (the guard's forearms, inmates' faces), with a new pattern each launch. With VICTORY_TEXTURES=always (every texture looked at on every use) they rendered correctly, so the data in title memory was right and only the upload was stale. The GPU writes those textures' memory through a buffer view. Copying that back into title memory told the guards, but not the textures placed there. watch::writing, which every write of ours into title memory goes through, now marks the textures in that range (and at the other views of its pages) as rewritten, the same way a streamed file does. The tattoos have rendered correctly since. Textures the title's own CPU threads write are still only caught at their next periodic look.

Findings that are not fixed here

  • VICTORY_ASYNC_SUBMIT=1 and lighting bugs. With async on, prewarm refreshes the next submission's copies while the previous submission's GPU work may still be reading them. Only the ranges it writes are skipped, so a constant buffer it reads can change under it. This fits the lighting errors seen with async on; it is not confirmed with a capture.
  • Snapshots retaken within a frame. Measured at about 13% of snapshot bytes (around 4 ms a frame), so keeping them across submissions is not worth the risk.

Tests

cargo test -p victory-gpu passes, except for the watch::tests failures that already happen on main. Those tests share the guards' global state: run in parallel they fail now and then, with or without this change (3 of 5 runs failed on main), and written_pages_are_reported_to_every_asker fails every time with --test-threads=1, with or without this change. cargo xtask policy reports only the known lower.rs size.

🤖 Generated with Claude Code

<!-- greyfinch-sync:Belobug/VIctory-Belobug-AMD:issue:5494881681 --> Imported from [Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD/pull/139). Originally posted by [Zetsukae](https://github.com/Zetsukae) on 2026-11-25T16:12:53Z. --- ## What this does Speeds up the work the submitting thread does around each submission, found with `VICTORY_PROFILE` and measured with an unattended benchmark (included). - **`in_parallel` keeps its helper threads** for the run instead of starting and joining five threads on each call. That was about an eighth of the submitting thread's time. - **Bindless plans keep their lists** (reads, writes, bounces, held resources) while no busy slot changes what it adds to them. When a slot does change, the lists are made from counted contributions, kept up to date as slots change, instead of walking every busy slot. `bindless plans` went from 45–70 ms to about 19 ms a frame in the world. In test builds, every remake also makes the lists the old way and asserts they are equal. - **The guards' block sets are bit sets instead of trees.** The wait at the guard check disappears from the profile, but it moves to the copy-back's use of the same lock: no measurable frame-rate change. It is kept because it is equivalent (a test compares it against a tree) and makes the next step on that lock easier. - **Diagnostics:** the time spent taking snapshots now appears in the sparse-writes line. Scripted keys (`VICTORY_KEYS`, `VICTORY_KEYS_FILE`) also press the stand-in pad's buttons on a real pad in slot 0: while a pad is connected, the title reads the pad and ignores the keyboard. - **`scripts/bench.ps1`:** an unattended benchmark. It presses Enter at the title screen, waits through the opening cinematic, measures 90 s in the world, can take screenshots, and writes a summary. `-GpuTiming` also sets `VICTORY_D3D12_DRED`: per-pipeline GPU times are only recorded when it is set (this is not in the README). `scripts/profile-run.ps1` is the same run played by hand. ## Results Standing still in the world (frame lines averaged over 90 s): 3.5–4 fps (250–300 ms) before, **4.75 fps (216 ms)** after. Walking: 3–4 fps before, about 5 after. What is left per frame: GPU about 72 ms (spread over about 1,300 pipelines, the slowest 4.5 ms), refresh copies about 42 ms, snapshots about 36–40 ms, copy-back about 31 ms, bindless plans about 19 ms. These still run one after the other. ## Lighting: the ambient stand-in follows the title's exposure The stand-in for the missing ray-traced indirect light was one constant (0.6). The lighting images it goes into are already multiplied by the title's exposure, so in a dark scene where the title raises the exposure (interiors, night: -5.5 EV) the constant came out as strong as at noon (-9.75 EV): flat and too bright at night, pure black in daytime shadows. `PS_CalculateExposure` draws a 1×1 RGBA32F holding (multiplier, EV, EV); in the prison interior it read (0.0221, -5.5, -5.5). The program is found by name, the same way as the resolve, its target is noted, and the ambient pass reads it as a shader resource. The level becomes `at · 2^(-k·(EV - ev))`: by default k = 0.5 and 1.4 at -9.75 EV, which gives about 0.32 at -5.5 EV. Those are the README's hand-tuned noon and dusk levels. `VICTORY_AMBIENT_EXPOSURE=k,ev,at` tunes it; setting `VICTORY_AMBIENT` or using the ambient file still forces a fixed level. **Only checked at dusk in the prison so far. Night has not been looked at yet.** Also new in diagnostics: `VICTORY_RESOLVE_CONSTANTS=1` logs the resolve's constants (that's how the exposure was ruled out there), and `bench.ps1` gains cinematic screenshots, render-target dumps and `-ExtraEnv`. ## Textures written by the GPU through another view Skin and tattoos on people showed noise (the guard's forearms, inmates' faces), with a new pattern each launch. With `VICTORY_TEXTURES=always` (every texture looked at on every use) they rendered correctly, so the data in title memory was right and only the upload was stale. The GPU writes those textures' memory through a buffer view. Copying that back into title memory told the guards, but not the textures placed there. `watch::writing`, which every write of ours into title memory goes through, now marks the textures in that range (and at the other views of its pages) as rewritten, the same way a streamed file does. The tattoos have rendered correctly since. Textures the title's own CPU threads write are still only caught at their next periodic look. ## Findings that are not fixed here - **`VICTORY_ASYNC_SUBMIT=1` and lighting bugs.** With async on, `prewarm` refreshes the next submission's copies while the previous submission's GPU work may still be reading them. Only the ranges it writes are skipped, so a constant buffer it reads can change under it. This fits the lighting errors seen with async on; it is not confirmed with a capture. - **Snapshots retaken within a frame.** Measured at about 13% of snapshot bytes (around 4 ms a frame), so keeping them across submissions is not worth the risk. ## Tests `cargo test -p victory-gpu` passes, except for the `watch::tests` failures that already happen on `main`. Those tests share the guards' global state: run in parallel they fail now and then, with or without this change (3 of 5 runs failed on `main`), and `written_pages_are_reported_to_every_asker` fails every time with `--test-threads=1`, with or without this change. `cargo xtask policy` reports only the known `lower.rs` size. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
battledogegames-design commented 2026-11-25 21:19:10 +00:00 (Migrated from github.com)

Imported from Belobug/VIctory-Belobug-AMD. Originally posted by battledogegames-design on 2026-11-25T21:19:10Z.


WARP reproducer for prewarm overwriting an in-flight upload read

Zetsukae, I tested the overlap you identified in #139 using two D3D12 copy commands and synthetic data. With the first read held on the queue, the next submission's prewarm can update the same upload bytes before the GPU consumes them. The first copy then returns the second submission's value.

Revision Original prewarm Early call omitted as a diagnostic
main, 4f62c2a 20/20 overlap failures 20/20 passes
#139, a208d61 20/20 overlap failures 20/20 passes

Each run used a fresh process. Synchronous overlap and asynchronous disjoint ranges both passed. In every overlap failure, the two reads returned [0xAABBCCDD, 0xAABBCCDD]; the expected values were [0x11223344, 0xAABBCCDD]. A separate fence on the same WARP queue verified completion before readback. No timeouts occurred.

The attached ZIP contains the test patch against main, commands, and results. With the patch applied, run:

cargo test --locked -p victory-gpu --lib host::prewarm_tests::async_prewarm_preserves_an_in_flight_read -- --exact --ignored --nocapture --test-threads=1

The test is opt-in while it demonstrates the open bug. Default CI skips it. The diagnostic comparison leaves the ordinary post-drain refresh in place; its performance cost is unmeasured. These runs establish the buffer overwrite on software WARP. Physical GPU behavior and the proposed connection to lighting still need separate evidence.

Would it help to carry this case in the eventual fix PR, or would you prefer a separate test-only PR?

warp-reproducer.zip

<!-- greyfinch-sync:Belobug/VIctory-Belobug-AMD:comment:7174915714 --> Imported from [Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD/pull/139#issuecomment-7174915714). Originally posted by [battledogegames-design](https://github.com/battledogegames-design) on 2026-11-25T21:19:10Z. --- # WARP reproducer for prewarm overwriting an in-flight upload read Zetsukae, I tested the overlap you identified in #139 using two D3D12 copy commands and synthetic data. With the first read held on the queue, the next submission's prewarm can update the same upload bytes before the GPU consumes them. The first copy then returns the second submission's value. | Revision | Original prewarm | Early call omitted as a diagnostic | |---|---|---| | main, 4f62c2a | 20/20 overlap failures | 20/20 passes | | #139, a208d61 | 20/20 overlap failures | 20/20 passes | Each run used a fresh process. Synchronous overlap and asynchronous disjoint ranges both passed. In every overlap failure, the two reads returned [0xAABBCCDD, 0xAABBCCDD]; the expected values were [0x11223344, 0xAABBCCDD]. A separate fence on the same WARP queue verified completion before readback. No timeouts occurred. The attached ZIP contains the test patch against main, commands, and results. With the patch applied, run: cargo test --locked -p victory-gpu --lib host::prewarm_tests::async_prewarm_preserves_an_in_flight_read -- --exact --ignored --nocapture --test-threads=1 The test is opt-in while it demonstrates the open bug. Default CI skips it. The diagnostic comparison leaves the ordinary post-drain refresh in place; its performance cost is unmeasured. These runs establish the buffer overwrite on software WARP. Physical GPU behavior and the proposed connection to lighting still need separate evidence. Would it help to carry this case in the eventual fix PR, or would you prefer a separate test-only PR? [warp-reproducer.zip](https://github.com/user-attachments/files/35434156/warp-reproducer.zip)
Zetsukae commented 2026-11-25 21:38:34 +00:00 (Migrated from github.com)

Imported from Belobug/VIctory-Belobug-AMD. Originally posted by Zetsukae on 2026-11-25T21:38:34Z.


Thanks, this is a great reproducer, and it matches what I saw: the early refresh rewrites memory the in-flight submission still reads. Since prewarm is on main and not something #139 adds, a separate test-only PR against main seems cleanest, so the maintainer can take it on its own and a fix can land against it. One data point from here: on an RX 9060 XT, async submission measured within noise of async off (7.85 vs 7.56 fps standing), so skipping the early refresh might cost little; it would be worth measuring alongside the fix.

<!-- greyfinch-sync:Belobug/VIctory-Belobug-AMD:comment:7175350127 --> Imported from [Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD/pull/139#issuecomment-7175350127). Originally posted by [Zetsukae](https://github.com/Zetsukae) on 2026-11-25T21:38:34Z. --- Thanks, this is a great reproducer, and it matches what I saw: the early refresh rewrites memory the in-flight submission still reads. Since `prewarm` is on `main` and not something #139 adds, a separate test-only PR against `main` seems cleanest, so the maintainer can take it on its own and a fix can land against it. One data point from here: on an RX 9060 XT, async submission measured within noise of async off (7.85 vs 7.56 fps standing), so skipping the early refresh might cost little; it would be worth measuring alongside the fix.
MamaLeVrai commented 2026-11-26 05:10:53 +00:00 (Migrated from github.com)

Imported from Belobug/VIctory-Belobug-AMD. Originally posted by MamaLeVrai on 2026-11-26T05:10:53Z.


One side effect of the change to watch::writing (watch.rs, the new stale loop that calls crate::resource::textures_rewritten). It comes from reading the code; I have not run it.

writing is also called where nothing is written. Twice in shadow.rs on this branch, just before title memory is opened in place: crate::watch::writing(start, len) "Read-only guards would refuse the GPU's writes", followed by OpenExistingHeapFromAddress1. With this PR those calls now mark every placed texture in the window as rewritten. texture::rewritten then removes it from HOST_WRITTEN: these are the textures whose contents a host copy or resolve made, while their title memory stayed as it was. At its next use such a texture would be uploaded again from the stale title memory, over what the copy wrote.

That only matters for host-written textures that lie in a window opened in place, so it may be rare. Keeping the textures_rewritten part out of the guard-opening calls (for example a flag, or a separate function for the write-back path) would avoid it.

AI-assisted (Claude Code); no game data.

<!-- greyfinch-sync:Belobug/VIctory-Belobug-AMD:comment:7183252664 --> Imported from [Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD/pull/139#issuecomment-7183252664). Originally posted by [MamaLeVrai](https://github.com/MamaLeVrai) on 2026-11-26T05:10:53Z. --- One side effect of the change to `watch::writing` (`watch.rs`, the new `stale` loop that calls `crate::resource::textures_rewritten`). It comes from reading the code; I have not run it. `writing` is also called where nothing is written. Twice in `shadow.rs` on this branch, just before title memory is opened in place: `crate::watch::writing(start, len)` "Read-only guards would refuse the GPU's writes", followed by `OpenExistingHeapFromAddress1`. With this PR those calls now mark every placed texture in the window as rewritten. `texture::rewritten` then removes it from `HOST_WRITTEN`: these are the textures whose contents a host copy or resolve made, while their title memory stayed as it was. At its next use such a texture would be uploaded again from the stale title memory, over what the copy wrote. That only matters for host-written textures that lie in a window opened in place, so it may be rare. Keeping the `textures_rewritten` part out of the guard-opening calls (for example a flag, or a separate function for the write-back path) would avoid it. AI-assisted (Claude Code); no game data.
Zetsukae commented 2026-11-26 12:21:22 +00:00 (Migrated from github.com)

Imported from Belobug/VIctory-Belobug-AMD. Originally posted by Zetsukae on 2026-11-26T12:21:22Z.


Good catch, thanks. Confirmed: the two writing calls before OpenExistingHeapFromAddress1 only open guards, and with a208d61 they also marked the window's textures rewritten. Fixed in faac6de: watch::writing is back to opening guards only, and a new watch::written_back does that and marks the textures. It's used only where we actually write title memory (the copy-backs in shadow.rs, the read-backs and title copies in host.rs). Tests pass; the tattoo fix goes through written_back unchanged.

<!-- greyfinch-sync:Belobug/VIctory-Belobug-AMD:comment:7191895828 --> Imported from [Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD/pull/139#issuecomment-7191895828). Originally posted by [Zetsukae](https://github.com/Zetsukae) on 2026-11-26T12:21:22Z. --- Good catch, thanks. Confirmed: the two `writing` calls before `OpenExistingHeapFromAddress1` only open guards, and with a208d61 they also marked the window's textures rewritten. Fixed in faac6de: `watch::writing` is back to opening guards only, and a new `watch::written_back` does that and marks the textures. It's used only where we actually write title memory (the copy-backs in `shadow.rs`, the read-backs and title copies in `host.rs`). Tests pass; the tattoo fix goes through `written_back` unchanged.
gut0to commented 2026-11-27 15:11:35 +00:00 (Migrated from github.com)

Imported from Belobug/VIctory-Belobug-AMD. Originally posted by gut0to on 2026-11-27T15:11:35Z.

Code review location: crates/victory-gpu/src/ambient.rs; line 68

@@ -28,6 +35,43 @@ use crate::object::This;
 
 /// The programs it follows, by the start of their name.
 pub(crate) const PROGRAM: &[u8] = b"CS_ScreenProbes_TemporalResolve";
+
+/// The program that draws the title's exposure, by the start of its name.
+pub(crate) const EXPOSURE: &[u8] = b"PS_CalculateExposure";
+
+/// The texture [`EXPOSURE`] last drew to (a title object; 0 for none).
+static EXPOSURE_TARGET: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);
+
+/// [`EXPOSURE`] draws to `target`.
+pub(crate) fn note_exposure(target: This) {
+    // The title draws it to two textures in turn (this frame's, the last).
+    let before = EXPOSURE_TARGET.swap(target as usize, Ordering::Relaxed);
+    static ONCE: std::sync::Once = std::sync::Once::new();
+    if before == 0 {
+        ONCE.call_once(|| tracing::info!("the ambient light follows the title's exposure"));
+    }
+}
+
+/// Whether the level follows the exposure: `VICTORY_AMBIENT` unset.
+fn follows_exposure() -> bool {
+    static ON: OnceLock<bool> = OnceLock::new();
+    *ON.get_or_init(|| std::env::var_os("VICTORY_AMBIENT").is_none())
+}
+
+/// `k`, the EV and the level there (`VICTORY_AMBIENT_EXPOSURE=k,ev,at`).
+fn exposure_curve() -> [f32; 3] {
+    static SET: OnceLock<[f32; 3]> = OnceLock::new();
+    *SET.get_or_init(|| {
+        let mut curve = [0.5, -9.75, 1.4];
+        let set = std::env::var("VICTORY_AMBIENT_EXPOSURE").unwrap_or_default();
+        for (to, v) in curve.iter_mut().zip(set.split(',')) {
+            if let Ok(v) = v.trim().parse() {

AI-assisted review: f32::parse accepts NaN and infinities, so if let Ok treats them as valid and passes them into the shader constants. For example, k=NaN satisfies the later k != 0.0 check and makes the exposure exponent NaN instead of falling back to the constant level. Could the parser require is_finite() and add a non-finite override case?

<!-- greyfinch-sync:Belobug/VIctory-Belobug-AMD:review-comment:4721005191 --> Imported from [Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD/pull/139#discussion_r4721005191). Originally posted by [gut0to](https://github.com/gut0to) on 2026-11-27T15:11:35Z. **Code review location:** `crates/victory-gpu/src/ambient.rs`; line 68 ~~~~diff @@ -28,6 +35,43 @@ use crate::object::This; /// The programs it follows, by the start of their name. pub(crate) const PROGRAM: &[u8] = b"CS_ScreenProbes_TemporalResolve"; + +/// The program that draws the title's exposure, by the start of its name. +pub(crate) const EXPOSURE: &[u8] = b"PS_CalculateExposure"; + +/// The texture [`EXPOSURE`] last drew to (a title object; 0 for none). +static EXPOSURE_TARGET: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0); + +/// [`EXPOSURE`] draws to `target`. +pub(crate) fn note_exposure(target: This) { + // The title draws it to two textures in turn (this frame's, the last). + let before = EXPOSURE_TARGET.swap(target as usize, Ordering::Relaxed); + static ONCE: std::sync::Once = std::sync::Once::new(); + if before == 0 { + ONCE.call_once(|| tracing::info!("the ambient light follows the title's exposure")); + } +} + +/// Whether the level follows the exposure: `VICTORY_AMBIENT` unset. +fn follows_exposure() -> bool { + static ON: OnceLock<bool> = OnceLock::new(); + *ON.get_or_init(|| std::env::var_os("VICTORY_AMBIENT").is_none()) +} + +/// `k`, the EV and the level there (`VICTORY_AMBIENT_EXPOSURE=k,ev,at`). +fn exposure_curve() -> [f32; 3] { + static SET: OnceLock<[f32; 3]> = OnceLock::new(); + *SET.get_or_init(|| { + let mut curve = [0.5, -9.75, 1.4]; + let set = std::env::var("VICTORY_AMBIENT_EXPOSURE").unwrap_or_default(); + for (to, v) in curve.iter_mut().zip(set.split(',')) { + if let Ok(v) = v.trim().parse() { ~~~~ --- AI-assisted review: `f32::parse` accepts `NaN` and infinities, so `if let Ok` treats them as valid and passes them into the shader constants. For example, `k=NaN` satisfies the later `k != 0.0` check and makes the exposure exponent NaN instead of falling back to the constant level. Could the parser require `is_finite()` and add a non-finite override case?
gut0to commented 2026-11-27 15:11:35 +00:00 (Migrated from github.com)

Imported from Belobug/VIctory-Belobug-AMD. Originally posted by gut0to on 2026-11-27T15:11:35Z.

Review: COMMENTED


AI-assisted static review; I traced the new exposure-curve override parser and its shader use. I did not run the test suite.

<!-- greyfinch-sync:Belobug/VIctory-Belobug-AMD:review:6090169627 --> Imported from [Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD/pull/139#pullrequestreview-6090169627). Originally posted by [gut0to](https://github.com/gut0to) on 2026-11-27T15:11:35Z. **Review:** COMMENTED --- AI-assisted static review; I traced the new exposure-curve override parser and its shader use. I did not run the test suite.
gut0to commented 2026-11-27 15:17:55 +00:00 (Migrated from github.com)

Imported from Belobug/VIctory-Belobug-AMD. Originally posted by gut0to on 2026-11-27T15:17:55Z.

Code review location: crates/victory-gpu/src/ambient.rs; line 331

@@ -268,17 +312,30 @@ fn live_level() -> Option<f32> {
 }
 
 const SOURCE: &str = r#"
-#define RS "RootConstants(num32BitConstants=13, b0), DescriptorTable(UAV(u0), SRV(t0), SRV(t1))"
+#define RS "RootConstants(num32BitConstants=17, b0), DescriptorTable(UAV(u0), SRV(t0), SRV(t1), SRV(t2))"
 cbuffer Floor : register(b0) {
     float level; float3 tint;
     float strength; float radius; float near; float tan_y;
     float gain; float least;
     float held; float floor_part; float power;
+    // Following the exposure (`k` 0: not): at_ev * 2^(-k (EV - ev)).
+    float k; float ev; float at_ev; float has_exposure;
 };
 Texture2DArray<float4> sky : register(t1);
-// The light, from the sky's mean when it follows the sky (gain above 0).
+Texture2D<float4> exposure : register(t2);
+// The level, from the title's exposure when it follows it.
+float exposed_level() {
+    if (has_exposure > 0.0 && k != 0.0) {
+        float e = exposure.Load(int3(0, 0, 0)).y;
+        // A plausible EV only; else the constant.
+        if (e > -20.0 && e < 10.0) return clamp(at_ev * exp2(-k * (e - ev)), 0.01, 4.0);

AI-assisted review: the default ambient level now depends on this EV curve, whose direction and constants were tuned by hand. Could a deterministic test cover the default point (EV = -9.75 gives 1.4), a darker point (EV = -5.5 gives about 0.3), and the fallback for an out-of-range EV? That would lock the intended behavior and catch a future sign or clamp regression.

<!-- greyfinch-sync:Belobug/VIctory-Belobug-AMD:review-comment:4721066705 --> Imported from [Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD/pull/139#discussion_r4721066705). Originally posted by [gut0to](https://github.com/gut0to) on 2026-11-27T15:17:55Z. **Code review location:** `crates/victory-gpu/src/ambient.rs`; line 331 ~~~~diff @@ -268,17 +312,30 @@ fn live_level() -> Option<f32> { } const SOURCE: &str = r#" -#define RS "RootConstants(num32BitConstants=13, b0), DescriptorTable(UAV(u0), SRV(t0), SRV(t1))" +#define RS "RootConstants(num32BitConstants=17, b0), DescriptorTable(UAV(u0), SRV(t0), SRV(t1), SRV(t2))" cbuffer Floor : register(b0) { float level; float3 tint; float strength; float radius; float near; float tan_y; float gain; float least; float held; float floor_part; float power; + // Following the exposure (`k` 0: not): at_ev * 2^(-k (EV - ev)). + float k; float ev; float at_ev; float has_exposure; }; Texture2DArray<float4> sky : register(t1); -// The light, from the sky's mean when it follows the sky (gain above 0). +Texture2D<float4> exposure : register(t2); +// The level, from the title's exposure when it follows it. +float exposed_level() { + if (has_exposure > 0.0 && k != 0.0) { + float e = exposure.Load(int3(0, 0, 0)).y; + // A plausible EV only; else the constant. + if (e > -20.0 && e < 10.0) return clamp(at_ev * exp2(-k * (e - ev)), 0.01, 4.0); ~~~~ --- AI-assisted review: the default ambient level now depends on this EV curve, whose direction and constants were tuned by hand. Could a deterministic test cover the default point (`EV = -9.75` gives `1.4`), a darker point (`EV = -5.5` gives about `0.3`), and the fallback for an out-of-range EV? That would lock the intended behavior and catch a future sign or clamp regression.
gut0to commented 2026-11-27 15:17:55 +00:00 (Migrated from github.com)

Imported from Belobug/VIctory-Belobug-AMD. Originally posted by gut0to on 2026-11-27T15:17:55Z.

Review: COMMENTED


AI-assisted static review; I checked the new exposure formula and its documented defaults. I did not run the GPU tests.

<!-- greyfinch-sync:Belobug/VIctory-Belobug-AMD:review:6090242861 --> Imported from [Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD/pull/139#pullrequestreview-6090242861). Originally posted by [gut0to](https://github.com/gut0to) on 2026-11-27T15:17:55Z. **Review:** COMMENTED --- AI-assisted static review; I checked the new exposure formula and its documented defaults. I did not run the GPU tests.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/139:upstream-pr/139'
git switch 'upstream-pr/139'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/139'
git switch 'upstream-pr/139'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/139'
git switch 'upstream-pr/139'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/139'
git switch 'main'
git merge --squash 'upstream-pr/139'
git switch 'main'
git merge --ff-only 'upstream-pr/139'
git switch 'main'
git merge 'upstream-pr/139'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Belobug/VIctory-Belobug-AMD!139
No description provided.