Preliminary live ray tracing, Series S overlay/upscaler, and 8 GB VRAM stability #814

Open
github-bot wants to merge 4 commits from github-bot/gh-814 into main AGit
Owner

@⁠staronthehorizon on GitHub · 2026-11-25 08:34 UTC · original
staronthehorizon:rt-preliminary → main · +5901 −871 · 36 files · 4 commits · open

Summary

Preliminary branch bringing sustained live ray-traced lighting (VICTORY_BVH_BUILDER=1, VICTORY_BVH_QUARANTINE=0) on --console series-s to 8 GB VRAM / 16 GB RAM hosts without crashes, OOMs, or device removals.

Structured as 4 independently compiling commits on top of main (happy to split any of these into standalone PRs if preferred):

  1. RT & wave32 shader translation, waterfall fixes, and translate --filter (9f19a7d)
    • Extends BVH/intersection and wave32/wave64 shader lowering (crates/victory-shader), adds SLOT_VIEW_ADDRESSES, USER_DISPATCH_THREADS, and wider MEMORY_FAULTS / dirty-page bitmask constants.
    • Adds --filter to victory translate and updates docs/fork-ray-tracing.md.
  2. Lazy physical-page chunks and non-destructive write-watch query (7c8e778)
    • Lazily backs physical-page sections in xmem.rs with section teardown notification (title_memory_section_gone) in inplace.rs.
    • Adds a zero-side-effect watch::is_write_watched (GetWriteWatch(0, ...)) query with unit tests.
  3. 8 GB VRAM texture headroom, drop-mips support, and unified writable shadow windows (ff09824)
    • Unifies writable shadow windows onto 4 MiB loose windows (find_writable / find_existing_writable) so root UAVs and SLOT_MEMORY bind the same D3D12 buffer, avoiding WDDM shared-memory aliasing/OOM.
    • Restores the 1024 MiB card-buffer budget default and unblocks local VRAM texture uploads on 8 GB GPUs when shared memory is occupied by SLOT_MEMORY buffers.
    • Adds VICTORY_TEXTURE_DROP_MIPS helpers (drop_levels, host_subresource, shift_levels).
  4. Live RT SLOT_MEMORY scaling, Series S overlay/upscaler, and host GPU sync (ece4a19)
    • Adds Series S two-plane overlay compositing (crates/victory-gpu/src/over*) and FidelityFX upscale stretch HLE (crates/victory-hle/src/modules/ffx.rs).
    • Adds GPU dirty-page bitmask tracking + per-64 KiB coalesced dirty-run writeback in memory.rs, immediate take_dirty() on relay_land, read/write address separation, and SLOT_VIEW_ADDRESSES descriptor sync.

Testing

  • Build & unit tests:
    • Every commit passes cargo check --workspace; tip passes cargo check -p victory --features diagnostics.
    • victory-shader --lib: 231 passed
    • victory-gpu --lib: 165 passed
    • victory-hle --lib: 101 passed
  • Live RT runs (Ryzen 5 5600, RTX 2070 Super 8 GB, 16 GB RAM, --console series-s):
    • 3 consecutive 150s runs (~70s post-BVH) with VICTORY_BVH_BUILDER=1 and VICTORY_BVH_QUARANTINE=0: 0 crashes, 0 OOMs, 0 device removals, 0 dropped shaders, 0 null buffer views.
    • Per-64 KiB coalesced dirty-run tracking cut loose-window CPU writeback compare from ~1,089 MB/frame to ~228–284 MB/frame (copy-back ~528 ms → ~108–214 ms; ~0.7–1.4 fps).
    • Recommended flags tested on 8 GB VRAM:
      • VICTORY_BVH_BUILDER=1
      • VICTORY_BVH_QUARANTINE=0
      • VICTORY_CARD_FETCH_INFLIGHT=1
      • VICTORY_TEXTURE_DROP_MIPS=1
      • VICTORY_TEXTURE_ROOM_PERCENT=82

Known Limitations / Follow-ups

  • Live RT is still CPU-bound (~0.7–1.4 fps) primarily due to the remaining ~250 MB/frame loose-window CPU writeback scan.
  • SLOT_MEMORY shaders still fault on low addresses (0x10000 range) and hit the 1536 MiB cap ~60s post-BVH (capped cleanly without crashing).
  • Character facial skin can intermittently stay dark when the decoration bake runs before face textures finish draining.
  • VICTORY_TEXTURE_DROP_MIPS=1 should not be combined with VICTORY_LEVELS_ON_DEMAND=1 yet (held_levels in texture.rs does not yet offset by self.drop).

Co-Authored-By: Gemini 4 Neon [email protected]

**@⁠staronthehorizon** on GitHub · 2026-11-25 08:34 UTC · [original](https://github.com/fxceless/victory-fork/pull/814) `staronthehorizon:rt-preliminary` → `main` · +5901 −871 · 36 files · 4 commits · open ## Summary Preliminary branch bringing sustained live ray-traced lighting (`VICTORY_BVH_BUILDER=1`, `VICTORY_BVH_QUARANTINE=0`) on `--console series-s` to 8 GB VRAM / 16 GB RAM hosts without crashes, OOMs, or device removals. Structured as 4 independently compiling commits on top of `main` (happy to split any of these into standalone PRs if preferred): 1. **RT & wave32 shader translation, waterfall fixes, and `translate --filter`** (`9f19a7d`) - Extends BVH/intersection and wave32/wave64 shader lowering (`crates/victory-shader`), adds `SLOT_VIEW_ADDRESSES`, `USER_DISPATCH_THREADS`, and wider `MEMORY_FAULTS` / dirty-page bitmask constants. - Adds `--filter` to `victory translate` and updates `docs/fork-ray-tracing.md`. 2. **Lazy physical-page chunks and non-destructive write-watch query** (`7c8e778`) - Lazily backs physical-page sections in `xmem.rs` with section teardown notification (`title_memory_section_gone`) in `inplace.rs`. - Adds a zero-side-effect `watch::is_write_watched` (`GetWriteWatch(0, ...)`) query with unit tests. 3. **8 GB VRAM texture headroom, drop-mips support, and unified writable shadow windows** (`ff09824`) - Unifies writable shadow windows onto 4 MiB loose windows (`find_writable` / `find_existing_writable`) so root UAVs and `SLOT_MEMORY` bind the same D3D12 buffer, avoiding WDDM shared-memory aliasing/OOM. - Restores the `1024 MiB` card-buffer budget default and unblocks local VRAM texture uploads on 8 GB GPUs when shared memory is occupied by `SLOT_MEMORY` buffers. - Adds `VICTORY_TEXTURE_DROP_MIPS` helpers (`drop_levels`, `host_subresource`, `shift_levels`). 4. **Live RT `SLOT_MEMORY` scaling, Series S overlay/upscaler, and host GPU sync** (`ece4a19`) - Adds Series S two-plane overlay compositing (`crates/victory-gpu/src/over*`) and FidelityFX upscale stretch HLE (`crates/victory-hle/src/modules/ffx.rs`). - Adds GPU dirty-page bitmask tracking + per-64 KiB coalesced dirty-run writeback in `memory.rs`, immediate `take_dirty()` on `relay_land`, read/write address separation, and `SLOT_VIEW_ADDRESSES` descriptor sync. ## Testing - **Build & unit tests:** - Every commit passes `cargo check --workspace`; tip passes `cargo check -p victory --features diagnostics`. - `victory-shader --lib`: 231 passed - `victory-gpu --lib`: 165 passed - `victory-hle --lib`: 101 passed - **Live RT runs (Ryzen 5 5600, RTX 2070 Super 8 GB, 16 GB RAM, `--console series-s`):** - 3 consecutive 150s runs (~70s post-BVH) with `VICTORY_BVH_BUILDER=1` and `VICTORY_BVH_QUARANTINE=0`: **0 crashes, 0 OOMs, 0 device removals, 0 dropped shaders, 0 null buffer views**. - Per-64 KiB coalesced dirty-run tracking cut loose-window CPU writeback compare from ~1,089 MB/frame to ~228–284 MB/frame (copy-back ~528 ms → ~108–214 ms; ~0.7–1.4 fps). - Recommended flags tested on 8 GB VRAM: - `VICTORY_BVH_BUILDER=1` - `VICTORY_BVH_QUARANTINE=0` - `VICTORY_CARD_FETCH_INFLIGHT=1` - `VICTORY_TEXTURE_DROP_MIPS=1` - `VICTORY_TEXTURE_ROOM_PERCENT=82` ## Known Limitations / Follow-ups - Live RT is still CPU-bound (~0.7–1.4 fps) primarily due to the remaining ~250 MB/frame loose-window CPU writeback scan. - `SLOT_MEMORY` shaders still fault on low addresses (`0x10000` range) and hit the `1536 MiB` cap ~60s post-BVH (capped cleanly without crashing). - Character facial skin can intermittently stay dark when the decoration bake runs before face textures finish draining. - `VICTORY_TEXTURE_DROP_MIPS=1` should not be combined with `VICTORY_LEVELS_ON_DEMAND=1` yet (`held_levels` in `texture.rs` does not yet offset by `self.drop`). Co-Authored-By: Gemini 4 Neon <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:51:42 +00:00
Author
Owner

@⁠Filip722 on GitHub · 2026-11-25 09:01 UTC · original · edited 2026-11-25 09:20 UTC

I reproduced the dropped-mip / levels-on-demand interaction from the limitations section on an RTX 5060 Laptop GPU (8 GB, NVIDIA 615.78.08) on Bazzite 44 with Proton Experimental 11.0-20261112 and vkd3d-proton 3.1.0. The Windows release tests used Rust 1.98.1 and the same synthetic fixture on both arms.

On ece4a19, a partially backed 1024×1024 BC7 texture with one mip dropped fell back to a committed heap. The tiling query received three title mips for a two-mip host texture. The patch derives the count from the host resource and shifts the staging mask into host mip indices. With both switches enabled, the fixture kept a reserved texture, gave both retained mips tiles, and verified that host mip zero was the first visible level.

Cherry-pickable fix and regression. The staged asset-policy check passed for all three changed files. The full check hits the parent branch's unchanged 552,640-byte emit/lower.rs (512 KiB limit). The fixture used our own texture bytes.

OpenAI Codex (GPT-6.2-Sol) wrote the fix and fixture, ran the comparison, and drafted this update.

A separate test-only commit covers Wine's single committed section and preserves the native assertions for two lazily materialized chunks. The original test expected two runs across the boundary and observed one on GE-Proton 11-14. The corrected test checks section layout, maps the boundary page, writes to its backing, and reads the same bytes through the view. It passed on GE-Proton 11-14. The native Windows arm still needs a run. Codex prepared and ran this follow-up.

**@⁠Filip722** on GitHub · 2026-11-25 09:01 UTC · [original](https://github.com/fxceless/victory-fork/pull/814#issuecomment-7157779482) · edited 2026-11-25 09:20 UTC I reproduced the dropped-mip / levels-on-demand interaction from the limitations section on an RTX 5060 Laptop GPU (8 GB, NVIDIA 615.78.08) on Bazzite 44 with Proton Experimental 11.0-20261112 and vkd3d-proton 3.1.0. The Windows release tests used Rust 1.98.1 and the same synthetic fixture on both arms. On `ece4a19`, a partially backed 1024×1024 BC7 texture with one mip dropped fell back to a committed heap. The tiling query received three title mips for a two-mip host texture. The patch derives the count from the host resource and shifts the staging mask into host mip indices. With both switches enabled, the fixture kept a reserved texture, gave both retained mips tiles, and verified that host mip zero was the first visible level. [Cherry-pickable fix and regression](https://github.com/Filip722/victory-fork/commit/fcadc661113de108a9d316aa54090381157cb362). The staged asset-policy check passed for all three changed files. The full check hits the parent branch's unchanged 552,640-byte `emit/lower.rs` (512 KiB limit). The fixture used our own texture bytes. OpenAI Codex (GPT-6.2-Sol) wrote the fix and fixture, ran the comparison, and drafted this update. A separate [test-only commit](https://github.com/Filip722/victory-fork/commit/a6ca349d59d249536e559564ee9d253cec401582) covers Wine's single committed section and preserves the native assertions for two lazily materialized chunks. The original test expected two runs across the boundary and observed one on GE-Proton 11-14. The corrected test checks section layout, maps the boundary page, writes to its backing, and reads the same bytes through the view. It passed on GE-Proton 11-14. The native Windows arm still needs a run. Codex prepared and ran this follow-up.
Author
Owner

@⁠Danigamer05 on GitHub · 2026-11-25 11:05 UTC · original

Tested on Turing with 8 GB: RTX 2080 SUPER 8 GB (32-lane waves, driver 621.01), Ryzen 7 3700X, 32 GB, Windows 11. Build: ece4a19 plus #683's commit (loop limit for compute programs, needed for hair strands at VICTORY_SHADER_LOOP_LIMIT=32), diagnostics build. Flags as recommended: VICTORY_BVH_BUILDER=1 VICTORY_BVH_QUARANTINE=0 VICTORY_CARD_FETCH_INFLIGHT=1 VICTORY_TEXTURE_DROP_MIPS=1 VICTORY_TEXTURE_ROOM_PERCENT=82, plus VICTORY_SHADER_LOOP_LIMIT=32 VICTORY_SHADER_LOOP_LIMIT_CS=128. Prison window shot and cell, captured every 8th frame.

Run Length Device removed Card in use / budget refused_budget pages* fps Picture
--console series-s 25 min 0 5,426 / 6,933 MB 0 1.5 shadowed cell lit (walls, bunks, floor, people); hair grainy
Series X, VICTORY_MEMORY_MB default (1536) 13 min 0 7,094 / 6,959 MB 339 0.8 blue-tinted light on the window frame and hair, blocky garbage under the window
Series X, VICTORY_MEMORY_MB=3072 25 min 0 about the same 359 0.9 blue light and garbage gone in the window shot; a small blue patch stays on the character's head; budget reached again after ~2 min

* Summed over the "shaders touched pages that had no copy" warnings, which stop after 50 lines, so these are lower bounds.

Notes:

  • The builder log says all of its programs have host pipelines pipelines=53 on this card in both modes.
  • The wrong colours in Series X mode follow the loose-window budget rather than card memory: going over the card budget made frames slower but did not change colours; raising VICTORY_MEMORY_MB fixed most of them. The windows are shared_buffers in system memory, so 1536 MiB looks low for Series X mode on a 32 GB host. A larger default, or one scaled to system memory, might be worth it.
  • Early in the first cutscene a close-up face has near-black skin while eyes, brows, hair and clothes are lit. That matches the dark facial skin limitation you list.
  • Series S mode was the only one that fit in 8 GB without paging.

Numbers and text only; no game data or screenshots attached. AI-assisted (Claude Code).

**@⁠Danigamer05** on GitHub · 2026-11-25 11:05 UTC · [original](https://github.com/fxceless/victory-fork/pull/814#issuecomment-7160584092) Tested on Turing with 8 GB: **RTX 2080 SUPER 8 GB** (32-lane waves, driver 621.01), Ryzen 7 3700X, 32 GB, Windows 11. Build: `ece4a19` plus #683's commit (loop limit for compute programs, needed for hair strands at `VICTORY_SHADER_LOOP_LIMIT=32`), diagnostics build. Flags as recommended: `VICTORY_BVH_BUILDER=1 VICTORY_BVH_QUARANTINE=0 VICTORY_CARD_FETCH_INFLIGHT=1 VICTORY_TEXTURE_DROP_MIPS=1 VICTORY_TEXTURE_ROOM_PERCENT=82`, plus `VICTORY_SHADER_LOOP_LIMIT=32 VICTORY_SHADER_LOOP_LIMIT_CS=128`. Prison window shot and cell, captured every 8th frame. | Run | Length | Device removed | Card in use / budget | `refused_budget` pages* | fps | Picture | |---|---|---|---|---|---|---| | `--console series-s` | 25 min | 0 | 5,426 / 6,933 MB | 0 | 1.5 | shadowed cell lit (walls, bunks, floor, people); hair grainy | | Series X, `VICTORY_MEMORY_MB` default (1536) | 13 min | 0 | 7,094 / 6,959 MB | 339 | 0.8 | blue-tinted light on the window frame and hair, blocky garbage under the window | | Series X, `VICTORY_MEMORY_MB=3072` | 25 min | 0 | about the same | 359 | 0.9 | blue light and garbage gone in the window shot; a small blue patch stays on the character's head; budget reached again after ~2 min | \* Summed over the "shaders touched pages that had no copy" warnings, which stop after 50 lines, so these are lower bounds. Notes: - The builder log says `all of its programs have host pipelines pipelines=53` on this card in both modes. - The wrong colours in Series X mode follow the loose-window budget rather than card memory: going over the card budget made frames slower but did not change colours; raising `VICTORY_MEMORY_MB` fixed most of them. The windows are `shared_buffer`s in system memory, so 1536 MiB looks low for Series X mode on a 32 GB host. A larger default, or one scaled to system memory, might be worth it. - Early in the first cutscene a close-up face has near-black skin while eyes, brows, hair and clothes are lit. That matches the dark facial skin limitation you list. - Series S mode was the only one that fit in 8 GB without paging. Numbers and text only; no game data or screenshots attached. AI-assisted (Claude Code).
Author
Owner

@⁠sagouindupm on GitHub · 2026-11-25 11:33 UTC · original

Hi @⁠staronthehorizon — just a quick coordination note on the Series S portion (crates/victory-gpu/src/over.rs and over/readback.rs): that overlaps directly with our open PR #188 (https://github.com/fxceless/victory-fork/pull/188), which still merges cleanly onto main (f85101b) with readback unit tests and independent confirmations on RTX 4060 8 GB (Proton) and RTX 4070 SUPER (Windows).

Happy to coordinate so Series S overlay/stretch changes aren't duplicated or conflicted while keeping PRs focused on single concerns per maintainer review feedback.

AI-assisted: diff comparison and coordination note prepared with AI assistance.

**@⁠sagouindupm** on GitHub · 2026-11-25 11:33 UTC · [original](https://github.com/fxceless/victory-fork/pull/814#issuecomment-7161208339) Hi @⁠staronthehorizon — just a quick coordination note on the Series S portion (`crates/victory-gpu/src/over.rs` and `over/readback.rs`): that overlaps directly with our open PR #188 (`https://github.com/fxceless/victory-fork/pull/188`), which still merges cleanly onto `main` (`f85101b`) with readback unit tests and independent confirmations on RTX 4060 8 GB (Proton) and RTX 4070 SUPER (Windows). Happy to coordinate so Series S overlay/stretch changes aren't duplicated or conflicted while keeping PRs focused on single concerns per maintainer review feedback. AI-assisted: diff comparison and coordination note prepared with AI assistance.
Author
Owner

@⁠Danigamer05 on GitHub · 2026-11-25 12:33 UTC · original

Follow-up from the same RTX 2080 SUPER 8 GB (same build, ece4a19 + #683's commit; Series X unless noted, VICTORY_MEMORY_MB=3072):

  • Blue tint on the character's hair follows the relay. With the default relay a blue-white patch stays on Lucia's hair at the prison window in every run (also with VICTORY_MEMORY_MB=6144, where no page was refused). With VICTORY_RELAY=0 it is gone in all window frames of the run. Cost here: 0.8 → 0.6 fps. This looks like the missing-skin/relay report in #89.
  • Dark facial skin is not from this PR. It shows the same way without ray tracing (fork 9376fd6 + #683, no BVH builder), and neither VICTORY_RELAY=0 nor VICTORY_BAKE_TEXTURES_MS=10000 changes it.
  • VICTORY_DISPLAY_MODE=2560x1440 does not change the Series X render targets (3,289 MB against 3,313 MB with the default 4K mode).
  • With #798 merged on top (title keeps its own upscaler on Series S; merges cleanly), --console series-s, VICTORY_RELAY=0, no DROP_MIPS: 25 minutes, no device removed, card 5,514 / 6,778 MB with 2,280 MB of textures, 0.78 fps. The picture is much sharper than with the stretch upscale (yard, tower and people crisp, hair strands whole instead of grainy). The cell interior looks darker than in my first Series S run (relay on, stretch upscale); I have not yet separated whether that comes from the relay or from the upscaler change.

Numbers and text only. AI-assisted (Claude Code).

**@⁠Danigamer05** on GitHub · 2026-11-25 12:33 UTC · [original](https://github.com/fxceless/victory-fork/pull/814#issuecomment-7162546873) Follow-up from the same RTX 2080 SUPER 8 GB (same build, `ece4a19` + #683's commit; Series X unless noted, `VICTORY_MEMORY_MB=3072`): - **Blue tint on the character's hair follows the relay.** With the default relay a blue-white patch stays on Lucia's hair at the prison window in every run (also with `VICTORY_MEMORY_MB=6144`, where no page was refused). With `VICTORY_RELAY=0` it is gone in all window frames of the run. Cost here: 0.8 → 0.6 fps. This looks like the missing-skin/relay report in #89. - **Dark facial skin is not from this PR.** It shows the same way without ray tracing (fork `9376fd6` + #683, no BVH builder), and neither `VICTORY_RELAY=0` nor `VICTORY_BAKE_TEXTURES_MS=10000` changes it. - **`VICTORY_DISPLAY_MODE=2560x1440`** does not change the Series X render targets (3,289 MB against 3,313 MB with the default 4K mode). - **With #798 merged on top** (title keeps its own upscaler on Series S; merges cleanly), `--console series-s`, `VICTORY_RELAY=0`, no `DROP_MIPS`: 25 minutes, no device removed, card 5,514 / 6,778 MB with 2,280 MB of textures, 0.78 fps. The picture is much sharper than with the stretch upscale (yard, tower and people crisp, hair strands whole instead of grainy). The cell interior looks darker than in my first Series S run (relay on, stretch upscale); I have not yet separated whether that comes from the relay or from the upscaler change. Numbers and text only. AI-assisted (Claude Code).
This pull request has changes conflicting with the target branch.
  • README.md
  • crates/victory-gpu/src/copystat.rs
  • crates/victory-gpu/src/descriptor/host.rs
  • crates/victory-gpu/src/draw.rs
  • crates/victory-gpu/src/host.rs
  • crates/victory-gpu/src/indirect.rs
  • crates/victory-gpu/src/inplace.rs
  • crates/victory-gpu/src/list.rs
  • crates/victory-gpu/src/memory.rs
  • crates/victory-gpu/src/pipeline.rs
  • crates/victory-gpu/src/pipeline/host.rs
  • crates/victory-gpu/src/shadow.rs
  • crates/victory-gpu/src/texture.rs
  • crates/victory-gpu/src/watch.rs
  • crates/victory-hle/src/modules/xmem.rs
  • crates/victory-shader/src/emit/lower.rs
  • crates/victory-shader/src/emit/mod.rs
  • crates/victory-shader/src/emit/shader.rs
  • crates/victory-shader/src/emit/wave64_tests.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/814/head:github-bot/gh-814'
git switch 'github-bot/gh-814'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-814'
git switch 'github-bot/gh-814'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-814'
git switch 'github-bot/gh-814'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-814'
git switch 'main'
git merge --squash 'github-bot/gh-814'
git switch 'main'
git merge --ff-only 'github-bot/gh-814'
git switch 'main'
git merge 'github-bot/gh-814'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.