gpu/shader: fix ambient air cap and bitcode void panic, tune launcher for 10-15 FPS #56

Closed
github-bot wants to merge 1 commit from github-bot/gh-56 into main AGit
Owner

@⁠NoLogicAlan on GitHub · 2026-11-27 01:29 UTC · original
NoLogicAlan:main → main · +50 −28 · 4 files · 1 commits · closed without merging

  1. Shader Bitcode (crates/victory-shader/src/emit/bitcode.rs):
  • Fix panic in abs(v) when metadata references a void instruction (such as a store).
    Substitutes the last constant index instead of panicking with "use of a void value",
    allowing the translation worker to complete without crashing.
    Recovers full shader pre-translation (25,748 shaders cached).
  1. Ambient Lighting & Scattering (crates/victory-gpu/src/ambient.rs):
  • In clear_air(), cap scattered air light at air * constant when in constant ambient
    mode, and enable Role::Air whenever VICTORY_AMBIENT_AIR is non-zero. Eliminates the
    milky white doorway and transition washout in cutscenes.
  • Add NaN/Inf float guard to raise() before packing light values.
  1. Launcher & Performance Tuning (Play-VIctory.cmd):
  • Memory management: enable VICTORY_LEVELS_ON_DEMAND=1 with idle trimming
    (VICTORY_STAGING_IDLE_MS=2000, VICTORY_WINDOW_IDLE_MS=5000, VICTORY_LIST_IDLE_TRIM_S=10)
    to prevent RAM exhaustion at 31.8 GB and eliminate SSD pagefile thrashing.
  • CPU scheduling: enable VICTORY_THIN=1 with VICTORY_THIN_THREADS=6 (pinned to 6 P-cores),
    VICTORY_FAST_CORES=2, and VICTORY_D3D12_BACKGROUND=0.
  • GPU buffer acceleration: move small buffer copies to GPU VRAM
    (VICTORY_CARD_BUFFERS_MIN_KB=64, VICTORY_CARD_BUFFERS_MB=1024, VICTORY_CARD_STEPS=2)
    and enable pipelined relay (VICTORY_RELAY=2, VICTORY_LATE_WAIT=3).
  • Real-world impact: increases performance from 4 FPS up to 10–15 FPS in cutscenes
    and in-game at native resolution.
**@⁠NoLogicAlan** on GitHub · 2026-11-27 01:29 UTC · [original](https://github.com/DoubleGhosty/cool_fox/pull/56) `NoLogicAlan:main` → `main` · +50 −28 · 4 files · 1 commits · closed without merging 1. Shader Bitcode (crates/victory-shader/src/emit/bitcode.rs): - Fix panic in abs(v) when metadata references a void instruction (such as a store). Substitutes the last constant index instead of panicking with "use of a void value", allowing the translation worker to complete without crashing. Recovers full shader pre-translation (25,748 shaders cached). 2. Ambient Lighting & Scattering (crates/victory-gpu/src/ambient.rs): - In clear_air(), cap scattered air light at `air * constant` when in constant ambient mode, and enable Role::Air whenever VICTORY_AMBIENT_AIR is non-zero. Eliminates the milky white doorway and transition washout in cutscenes. - Add NaN/Inf float guard to raise() before packing light values. 3. Launcher & Performance Tuning (Play-VIctory.cmd): - Memory management: enable VICTORY_LEVELS_ON_DEMAND=1 with idle trimming (VICTORY_STAGING_IDLE_MS=2000, VICTORY_WINDOW_IDLE_MS=5000, VICTORY_LIST_IDLE_TRIM_S=10) to prevent RAM exhaustion at 31.8 GB and eliminate SSD pagefile thrashing. - CPU scheduling: enable VICTORY_THIN=1 with VICTORY_THIN_THREADS=6 (pinned to 6 P-cores), VICTORY_FAST_CORES=2, and VICTORY_D3D12_BACKGROUND=0. - GPU buffer acceleration: move small buffer copies to GPU VRAM (VICTORY_CARD_BUFFERS_MIN_KB=64, VICTORY_CARD_BUFFERS_MB=1024, VICTORY_CARD_STEPS=2) and enable pipelined relay (VICTORY_RELAY=2, VICTORY_LATE_WAIT=3). - Real-world impact: increases performance from 4 FPS up to 10–15 FPS in cutscenes and in-game at native resolution.
- shader/bitcode: replace assertion panic on void-instruction metadata references with a fallback value ID, allowing translation of 25,748 shaders without aborting.

- gpu/ambient: apply clear_air ceiling during constant ambient mode and add NaN/infinity clamp in raise() to eliminate doorway wash-out and bloom artifacts.

- launchers: configure Pareto residency memory trims (staging/window idle limits) to prevent 32 GB RAM commit exhaustion and NVMe pagefile thrashing; tune thin translation workers for 6 P-cores with D3D12 background compilation disabled; migrate small card buffers to GPU VRAM with pipelined relay.

Measured: cutscene and in-game frame rate improved to 10-15 FPS at native Series X resolution with clean interior lighting and stable asset streaming.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 06:08:05 +00:00
Author
Owner

@⁠steven-seagull27 on GitHub · 2026-11-27 01:57 UTC · original

I checked the bitcode fallback at a9ba9d00 with the two standalone deferred-ballot fixtures from #53. Each build starts from 69718c00. The inputs are synthetic and use 128 threads.

Fixture This PR #53 at 8e371e67
Ballot feeding a whole-group branch Emitted 3,508 bytes. Windows SDK 10.0.26100.0 DXIL validator reported Invalid record. Validated. Actual readbacks matched all 640 expected words across five cases on both RTX 5080 and WARP 1.0.22.
Ballot whose predecessor executes in only one host wave Emitted 3,920 bytes. The same validator reported Invalid type for value. Translation reports that the closed block needs a per-wave meet.

In bitcode.rs, funcs is the index where constants begin. The expression funcs.saturating_sub(1) can therefore return a function index. The resulting bitcode can get past the writer and still fail DXIL validation. The change in #53 resolves the deferred exchange at its definition. It should be possible to take that change independently of the ambient work here.

To reproduce, copy the test-only files crates/victory-shader/src/emit/wave64_tests.rs and crates/victory-shader/src/emit/host.rs from #53 onto this head, set VICTORY_DXIL to the SDK's dxil.dll, and run the two filters a_mask_ballot_in_a_uniform_predecessor_keeps_its_branch and a_deferred_ballot_in_a_wave_only_predecessor_is_refused with cargo test -p victory-shader --lib.

AI-assisted testing.

**@⁠steven-seagull27** on GitHub · 2026-11-27 01:57 UTC · [original](https://github.com/DoubleGhosty/cool_fox/pull/56#issuecomment-7207712027) I checked the bitcode fallback at `a9ba9d00` with the two standalone deferred-ballot fixtures from [#53](https://git.gtahub.st/github/DoubleGhosty--cool_fox/pulls/53). Each build starts from `69718c00`. The inputs are synthetic and use 128 threads. | Fixture | This PR | #53 at `8e371e67` | | --- | --- | --- | | Ballot feeding a whole-group branch | Emitted 3,508 bytes. Windows SDK 10.0.26100.0 DXIL validator reported `Invalid record`. | Validated. Actual readbacks matched all 640 expected words across five cases on both RTX 5080 and WARP 1.0.22. | | Ballot whose predecessor executes in only one host wave | Emitted 3,920 bytes. The same validator reported `Invalid type for value`. | Translation reports that the closed block needs a per-wave meet. | In `bitcode.rs`, `funcs` is the index where constants begin. The expression `funcs.saturating_sub(1)` can therefore return a function index. The resulting bitcode can get past the writer and still fail DXIL validation. The change in #53 resolves the deferred exchange at its definition. It should be possible to take that change independently of the ambient work here. To reproduce, copy the test-only files `crates/victory-shader/src/emit/wave64_tests.rs` and `crates/victory-shader/src/emit/host.rs` from #53 onto this head, set `VICTORY_DXIL` to the SDK's `dxil.dll`, and run the two filters `a_mask_ballot_in_a_uniform_predecessor_keeps_its_branch` and `a_deferred_ballot_in_a_wave_only_predecessor_is_refused` with `cargo test -p victory-shader --lib`. AI-assisted testing.
Author
Owner

@⁠steven-seagull27 on GitHub · 2026-11-27 02:50 UTC · original

I also tested the constant-mode air change independently. A generated 9 × 7 × 3 texture passes through the production Role::Air path. I read all 189 packed R11G11B10_FLOAT texels back on an RTX 5080 and Windows’ built-in WARP. Both adapters gave the same results in all four cases.

Revision Ambient setting Air multiplier Readback on each adapter
Parent 69718c00 constant:0.8 1.5 Pass skipped. All 189 texels retained their input bits.
PR a9ba9d00 constant:0.8 1.5 All 94 above-cap texels were reduced within the reference’s format-conversion bounds. All 95 below-cap texels retained their input bits.
Parent and PR separately constant:0.8 0 Pass skipped. All 189 texels retained their input bits.

For a gray texel initialized to (2, 2, 2), the nominal cap is 1.2. Both devices returned (1.1875, 1.1875, 1.1875), packed as 0x799e63cc, from input 0x80200400. This verifies the constant-mode lighting change independently of the shader-writer issue above. Standalone test commit

To rerun on this PR head in PowerShell:

git fetch https://github.com/steven-seagull27/cool_fox.git refs/heads/codex/test-56-air-volume
git cherry-pick 0cc0f9826cbeeb456c71c7b2517b10ab4ba8109f
$env:VICTORY_AMBIENT = 'constant:0.8'
$env:VICTORY_AMBIENT_AIR = '1.5'
$env:VICTORY_D3D12_WARP = '0'
cargo test -p victory-gpu --lib --features diagnostics ambient::air_readback::constant_air_volume_has_the_expected_packed_voxels -- --exact --ignored --nocapture

Set VICTORY_D3D12_WARP=1 for WARP and VICTORY_AMBIENT_AIR=0 for the disabled control. When applying the same test to parent 69718c00, also set VICTORY_TEST_PARENT_AIR=1 to check the original behavior. AI-assisted testing.

**@⁠steven-seagull27** on GitHub · 2026-11-27 02:50 UTC · [original](https://github.com/DoubleGhosty/cool_fox/pull/56#issuecomment-7208482207) I also tested the constant-mode air change independently. A generated 9 × 7 × 3 texture passes through the production `Role::Air` path. I read all 189 packed R11G11B10_FLOAT texels back on an RTX 5080 and Windows’ built-in WARP. Both adapters gave the same results in all four cases. | Revision | Ambient setting | Air multiplier | Readback on each adapter | | --- | --- | --- | --- | | Parent `69718c00` | `constant:0.8` | 1.5 | Pass skipped. All 189 texels retained their input bits. | | PR `a9ba9d00` | `constant:0.8` | 1.5 | All 94 above-cap texels were reduced within the reference’s format-conversion bounds. All 95 below-cap texels retained their input bits. | | Parent and PR separately | `constant:0.8` | 0 | Pass skipped. All 189 texels retained their input bits. | For a gray texel initialized to (2, 2, 2), the nominal cap is 1.2. Both devices returned (1.1875, 1.1875, 1.1875), packed as `0x799e63cc`, from input `0x80200400`. This verifies the constant-mode lighting change independently of the shader-writer issue above. [Standalone test commit](https://github.com/steven-seagull27/cool_fox/commit/0cc0f9826cbeeb456c71c7b2517b10ab4ba8109f) To rerun on this PR head in PowerShell: ```powershell git fetch https://github.com/steven-seagull27/cool_fox.git refs/heads/codex/test-56-air-volume git cherry-pick 0cc0f9826cbeeb456c71c7b2517b10ab4ba8109f $env:VICTORY_AMBIENT = 'constant:0.8' $env:VICTORY_AMBIENT_AIR = '1.5' $env:VICTORY_D3D12_WARP = '0' cargo test -p victory-gpu --lib --features diagnostics ambient::air_readback::constant_air_volume_has_the_expected_packed_voxels -- --exact --ignored --nocapture ``` Set `VICTORY_D3D12_WARP=1` for WARP and `VICTORY_AMBIENT_AIR=0` for the disabled control. When applying the same test to parent `69718c00`, also set `VICTORY_TEST_PARENT_AIR=1` to check the original behavior. AI-assisted testing.
Author
Owner

@⁠DoubleGhosty on GitHub · 2026-11-27 05:21 UTC · original

Cherry-picked the bitcode void-value fallback (substituting last constant index), the constant-mode clear_air ceiling, the raise() NaN/inf guard, and the Role::Air enablement into main. Thank you for these fixes.

The launcher changes (THIN=1, thread pinning, memory trim defaults) were not taken as they are tuned for a specific CPU (i5-13400F) and override the existing NVIDIA-safe defaults (THIN=0, JOIN_PARTS=0). Users can set those env vars for their hardware.

**@⁠DoubleGhosty** on GitHub · 2026-11-27 05:21 UTC · [original](https://github.com/DoubleGhosty/cool_fox/pull/56#issuecomment-7210563015) Cherry-picked the bitcode void-value fallback (substituting last constant index), the constant-mode clear_air ceiling, the raise() NaN/inf guard, and the Role::Air enablement into main. Thank you for these fixes. The launcher changes (THIN=1, thread pinning, memory trim defaults) were not taken as they are tuned for a specific CPU (i5-13400F) and override the existing NVIDIA-safe defaults (THIN=0, JOIN_PARTS=0). Users can set those env vars for their hardware.
github-bot closed this pull request 2026-11-27 08:56:30 +00:00
Author
Owner

@⁠DoubleGhosty on GitHub · 2026-11-27 08:54 UTC · original

Already cherry-picked into main (1bd5e1a3).

**@⁠DoubleGhosty** on GitHub · 2026-11-27 08:54 UTC · [original](https://github.com/DoubleGhosty/cool_fox/pull/56#issuecomment-7214049969) Already cherry-picked into main (1bd5e1a3).

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.