GPU: make placed-texture heap slots that shaders actually read #1962

Open
github-bot wants to merge 1 commit from github-bot/gh-1962 into main AGit
Owner

@⁠antocorvo3000 on GitHub · 2026-11-25 01:46 UTC · original
antocorvo3000:pr-heap-usage → main · +281 −2 · 17 files · 1 commits · open

Shaders that take descriptors from the resource heap itself (bindless
materials) read placed-texture slots that the heap mirror leaves null
until a draw reads them through a table (the shortcut that keeps ~20,000
host textures from being made at once). In Grand Theft Auto VI most
world materials sample that way, so their G-buffer albedo came out
black and the lit scene stayed dark.

Translated shaders now mark each heap slot they take a shader resource
view from in a bitmap (u1 in the memory space, an atomic OR per lane),
bound per list like the written-pages bitmap. After the list ran, each
marked slot still holding a placed texture left for later is made, so it
reads from the next list on. Only the textures in use are made.

VICTORY_HEAP_USAGE=0 turns the marks off (shaders as before). The frame
line reports slots marked, views made, and why marked slots were not
made. Unit tests leave the marks off (the hardware harness binds only
the parameters each test names).

Measured in the world: albedo coverage from ~20% to 99% of the screen;
about 10-20 views made per 5 s once streamed in; no view failed to make.

Testing

  • cargo test --release -p victory-shader -p victory-gpu --lib: 246 + 141 passed.
  • In game (Grand Theft Auto VI, Series X mode): world albedo went from ~20% to 99% of the screen; no placed-texture view failed to make.
**@⁠antocorvo3000** on GitHub · 2026-11-25 01:46 UTC · [original](https://github.com/Marvisak/VIctory/pull/1962) `antocorvo3000:pr-heap-usage` → `main` · +281 −2 · 17 files · 1 commits · open Shaders that take descriptors from the resource heap itself (bindless materials) read placed-texture slots that the heap mirror leaves null until a draw reads them through a table (the shortcut that keeps ~20,000 host textures from being made at once). In Grand Theft Auto VI most world materials sample that way, so their G-buffer albedo came out black and the lit scene stayed dark. Translated shaders now mark each heap slot they take a shader resource view from in a bitmap (u1 in the memory space, an atomic OR per lane), bound per list like the written-pages bitmap. After the list ran, each marked slot still holding a placed texture left for later is made, so it reads from the next list on. Only the textures in use are made. VICTORY_HEAP_USAGE=0 turns the marks off (shaders as before). The frame line reports slots marked, views made, and why marked slots were not made. Unit tests leave the marks off (the hardware harness binds only the parameters each test names). Measured in the world: albedo coverage from ~20% to 99% of the screen; about 10-20 views made per 5 s once streamed in; no view failed to make. ## Testing - `cargo test --release -p victory-shader -p victory-gpu --lib`: 246 + 141 passed. - In game (Grand Theft Auto VI, Series X mode): world albedo went from ~20% to 99% of the screen; no placed-texture view failed to make.
Shaders that take descriptors from the resource heap itself (bindless
materials) read placed-texture slots that the heap mirror leaves null
until a draw reads them through a table (the shortcut that keeps ~20,000
host textures from being made at once). In Grand Theft Auto VI most
world materials sample that way, so their G-buffer albedo came out
black and the lit scene stayed dark.

Translated shaders now mark each heap slot they take a shader resource
view from in a bitmap (u1 in the memory space, an atomic OR per lane),
bound per list like the written-pages bitmap. After the list ran, each
marked slot still holding a placed texture left for later is made, so it
reads from the next list on. Only the textures in use are made.

VICTORY_HEAP_USAGE=0 turns the marks off (shaders as before). The frame
line reports slots marked, views made, and why marked slots were not
made. Unit tests leave the marks off (the hardware harness binds only
the parameters each test names).

Measured in the world: albedo coverage from ~20% to 99% of the screen;
about 10-20 views made per 5 s once streamed in; no view failed to make.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:50:14 +00:00
Author
Owner

@⁠DesertGamer on GitHub · 2026-11-25 02:15 UTC · original

VIctory V2: community PRs, merged and tested

Open PRs sitting in the queue? V2 pulls them into one build, screens each one (binaries, build scripts, hooks, new deps) and runs tests after every batch.

Where it stands today: launches, runs the menu at 30 fps, plays the intro video, reaches the start screen and loads the world (~50 s). Entering the world is the current blocker: rendering fails with a GPU "device removed" error (tracked in issue #1).

⚠️ Entering the world on a real GPU can hang it and make Windows reset the driver. Try it at your own risk.

Not playable yet, but every batch of merged fixes moves it closer. If you have a PR that's stuck, or a GPU to test on, I'd love your help:
https://DesertGamer/VIctory-V2

Unofficial community fork of Marvisak/VIctory, GPL-3.0.

**@⁠DesertGamer** on GitHub · 2026-11-25 02:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/1962#issuecomment-7150506842) ### VIctory V2: community PRs, merged and tested Open PRs sitting in the queue? V2 pulls them into one build, screens each one (binaries, build scripts, hooks, new deps) and runs tests after every batch. **Where it stands today:** launches, runs the menu at 30 fps, plays the intro video, reaches the start screen and loads the world (~50 s). Entering the world is the current blocker: rendering fails with a GPU "device removed" error (tracked in issue #1). :warning: Entering the world on a real GPU can hang it and make Windows reset the driver. Try it at your own risk. Not playable yet, but every batch of merged fixes moves it closer. If you have a PR that's stuck, or a GPU to test on, I'd love your help: https://DesertGamer/VIctory-V2 *Unofficial community fork of Marvisak/VIctory, GPL-3.0.*
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 02:19 UTC · original

Automated triage for the maintainers.

This pull request does not merge cleanly into main. Conflicting files: crates/victory-gpu/src/shader_cache.rs, crates/victory-shader/src/emit/host.rs, crates/victory-shader/src/emit/shader.rs.

It will be reviewed once it is rebased onto the current main.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 02:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/1962#issuecomment-7150587178) <!-- victory-triage v1 head=3c18447f6202c27d7ecc44919ab739c293f6a6b7 verdict=needs-rebase at=2026-11-25T02:15:48Z --> Automated triage for the maintainers. This pull request does not merge cleanly into `main`. Conflicting files: `crates/victory-gpu/src/shader_cache.rs`, `crates/victory-shader/src/emit/host.rs`, `crates/victory-shader/src/emit/shader.rs`. It will be reviewed once it is rebased onto the current `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠ryotdev on GitHub · 2026-11-25 02:58 UTC · original

On Windows I reproduced a warm-cache issue at 3c18447. Start with VICTORY_HEAP_USAGE=0, translate a shader that reads a bindless texture, then start a fresh process with the same cache and VICTORY_HEAP_USAGE=1. The second process reports a cache hit and the returned shader still has heap_usage=false. Starting with the modes reversed also reuses the first translation. This can hide the effect of the setting in an A/B test.

Fix and regression assertion. The cache now keys on the same effective boolean that controls emission and feedback consumption. With that commit, the first run in each mode missed, repeat runs in both modes hit with matching flags, and the default shared the enabled cache. I tested both toggle orders in separate Windows processes and ran the GPU crate suite with diagnostics on WARP (144 passed, 2 ignored). AI-assisted.

**@⁠ryotdev** on GitHub · 2026-11-25 02:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/1962#issuecomment-7151445667) On Windows I reproduced a warm-cache issue at `3c18447`. Start with `VICTORY_HEAP_USAGE=0`, translate a shader that reads a bindless texture, then start a fresh process with the same cache and `VICTORY_HEAP_USAGE=1`. The second process reports a cache hit and the returned shader still has `heap_usage=false`. Starting with the modes reversed also reuses the first translation. This can hide the effect of the setting in an A/B test. [Fix and regression assertion](https://github.com/ryotdev/VIctory/commit/6006a230c7055c35cd5e39bd704ef3cd1941d58e). The cache now keys on the same effective boolean that controls emission and feedback consumption. With that commit, the first run in each mode missed, repeat runs in both modes hit with matching flags, and the default shared the enabled cache. I tested both toggle orders in separate Windows processes and ran the GPU crate suite with diagnostics on WARP (144 passed, 2 ignored). AI-assisted.
Author
Owner

@⁠r4tedx on GitHub · 2026-11-25 10:51 UTC · original

@⁠antocorvo3000, this PR conflicts with main 940d32f, so I rebased it there, keeping your authorship. You're welcome to take the branch for this PR: r4tedx/VIctory@rebase/1962-on-main (015274f4).

  • 0c791faa: your change, where it applied cleanly.
  • 3a4d6a8e: the conflict resolution. main now uses u1 and shader-cache flag bit 5 for its buffer-write marks (cd94d35), so the heap-read marks move to u2 and bit 6. That way both run side by side.
  • 015274f4: a fix for @⁠ryotdev's warm-cache report. VICTORY_HEAP_USAGE=0 changes the DXIL but was in neither the shader-cache key nor the pipeline pre-build tag. Now both include it. With marks on (the default), nothing is added to either, and a synthetic test (heap_usage_changes_the_key_only_when_disabled) checks both.

Tested on WARP only (the software adapter), each revision with its own build:

main 940d32f rebased 015274f4
victory-gpu --lib --features diagnostics 146 passed, 0 failed, 2 ignored 147 passed, 0 failed, 2 ignored
victory-shader --lib (every-adapter tests skipped) 244 passed, 2 failed 244 passed, 2 failed (the same two, same values: gathers_at_a_level_match_the_hardware, permutes_read_the_lane_named_and_zero_from_lanes_left_out)
clippy -D warnings, both crates, with and without diagnostics clean clean

Not verified: the shader test harness runs with heap marks off, so placed-texture feedback end to end, hardware rendering and a warm cache across processes are untested. The title was not used in these tests.

AI-assisted

**@⁠r4tedx** on GitHub · 2026-11-25 10:51 UTC · [original](https://github.com/Marvisak/VIctory/pull/1962#issuecomment-7160265649) @⁠antocorvo3000, this PR conflicts with `main` 940d32f, so I rebased it there, keeping your authorship. You're welcome to take the branch for this PR: [`r4tedx/VIctory@rebase/1962-on-main`](https://github.com/r4tedx/VIctory/tree/rebase/1962-on-main) (`015274f4`). - `0c791faa`: your change, where it applied cleanly. - `3a4d6a8e`: the conflict resolution. `main` now uses `u1` and shader-cache flag bit 5 for its buffer-write marks (cd94d35), so the heap-read marks move to `u2` and bit 6. That way both run side by side. - `015274f4`: a fix for @⁠ryotdev's warm-cache report. `VICTORY_HEAP_USAGE=0` changes the DXIL but was in neither the shader-cache key nor the pipeline pre-build tag. Now both include it. With marks on (the default), nothing is added to either, and a synthetic test (`heap_usage_changes_the_key_only_when_disabled`) checks both. **Tested on WARP only** (the software adapter), each revision with its own build: | | `main` 940d32f | rebased `015274f4` | |---|---|---| | `victory-gpu --lib --features diagnostics` | 146 passed, 0 failed, 2 ignored | 147 passed, 0 failed, 2 ignored | | `victory-shader --lib` (every-adapter tests skipped) | 244 passed, 2 failed | 244 passed, 2 failed (the same two, same values: `gathers_at_a_level_match_the_hardware`, `permutes_read_the_lane_named_and_zero_from_lanes_left_out`) | | clippy `-D warnings`, both crates, with and without `diagnostics` | clean | clean | **Not verified:** the shader test harness runs with heap marks off, so placed-texture feedback end to end, hardware rendering and a warm cache across processes are untested. The title was not used in these tests. AI-assisted
Author
Owner

@⁠Slay326 on GitHub · 2026-11-25 12:53 UTC · original

Hardware test on an RTX 3070 (8 GB VRAM, 32-lane waves), Windows 11, Series X mode. I merged the PR onto our local test branch: main plus #1890, #1906, #1779, #1763, #1762, #1883, and a page-mark guard like #2167.

The image: the merge works. Before, world albedo covered ~1.3 % of the screen in a target dump (the G-buffer albedo target, 2560x1440). After the merge, materials show in the world and in cutscenes: prison clothes, shirt prints, hair, buttons.

Merge conflict: on current main (940d32f), u1 in the memory space is already taken by the buffer views' written-pages bitmap (VIEW_WRITES). The heap-usage bitmap needs its own register. I used u3; r4tedx's rebase (015274f) uses u2. Either works, since VIEW_MARKS is t2, an SRV. The shader-cache flag goes to bit 6.

Performance (the main problem on this card): the bitmap comes from shared_buffer, which is system memory. Every texture read does an unconditional atomicBinOp OR into it, and with a uniform index all lanes of a wave hit the same dword.

Run (480 s, BVH builder skipped) GPU ms/frame in the world Result
without the PR ~190 ~2.2 fps
with the PR, bitmap in system memory 3,000-6,900 (0.1-0.2 fps) device removed (hung, 0x887A0006) after ~450 s
with the PR, bitmap in GPU memory 130-1,400 still 0.3-0.8 fps, device removed after ~167 s
  • The atomics: the same pattern (system-memory bitmap, all lanes on one dword) cost us 560 us per 64-thread group in a synthetic test on the written-pages bitmap. A load first, and the atomic only where the bit is clear, brought that to 0.1 us (#2167 does the same).
  • Bitmap in GPU memory: in my patch the bitmap lives in GPU memory, one per list, kept across resets. It is zeroed by a copy at the first bind of each recording and copied to a read-back buffer as the list closes. Patch/branch available if useful. This removes the multi-second GPU stalls.
  • What remains on 8 GB: the PR then makes 300-580 placed-texture views per 5 s. Process commit grows past 34 GB, then come page-fault storms (313k against 8k per interval without the PR) and many 0x8007000E "no host texture / no upload buffer" errors. The device is then removed after ~167 s.
  • Suggestions: a budget for the textures made per frame, or releasing views that are no longer marked, would probably be needed for 8 GB cards. A shader-side test-before-or guard would also help, but #1962 notes that a branch there broke dominance. Callers keep emitting into the block they started in, so the guard would have to hand the new block back to them.

AI-assisted.

**@⁠Slay326** on GitHub · 2026-11-25 12:53 UTC · [original](https://github.com/Marvisak/VIctory/pull/1962#issuecomment-7162996785) Hardware test on an RTX 3070 (8 GB VRAM, 32-lane waves), Windows 11, Series X mode. I merged the PR onto our local test branch: main plus #1890, #1906, #1779, #1763, #1762, #1883, and a page-mark guard like #2167. **The image:** the merge works. Before, world albedo covered ~1.3 % of the screen in a target dump (the G-buffer albedo target, 2560x1440). After the merge, materials show in the world and in cutscenes: prison clothes, shirt prints, hair, buttons. **Merge conflict:** on current main (940d32f), `u1` in the memory space is already taken by the buffer views' written-pages bitmap (`VIEW_WRITES`). The heap-usage bitmap needs its own register. I used `u3`; r4tedx's rebase (015274f) uses `u2`. Either works, since `VIEW_MARKS` is `t2`, an SRV. The shader-cache flag goes to bit 6. **Performance (the main problem on this card):** the bitmap comes from `shared_buffer`, which is system memory. Every texture read does an unconditional `atomicBinOp` OR into it, and with a uniform index all lanes of a wave hit the same dword. | Run (480 s, BVH builder skipped) | GPU ms/frame in the world | Result | |---|---|---| | without the PR | ~190 | ~2.2 fps | | with the PR, bitmap in system memory | 3,000-6,900 (0.1-0.2 fps) | device removed (hung, 0x887A0006) after ~450 s | | with the PR, bitmap in GPU memory | 130-1,400 | still 0.3-0.8 fps, device removed after ~167 s | - **The atomics:** the same pattern (system-memory bitmap, all lanes on one dword) cost us 560 us per 64-thread group in a synthetic test on the written-pages bitmap. A load first, and the atomic only where the bit is clear, brought that to 0.1 us (#2167 does the same). - **Bitmap in GPU memory:** in my patch the bitmap lives in GPU memory, one per list, kept across resets. It is zeroed by a copy at the first bind of each recording and copied to a read-back buffer as the list closes. Patch/branch available if useful. This removes the multi-second GPU stalls. - **What remains on 8 GB:** the PR then makes 300-580 placed-texture views per 5 s. Process commit grows past 34 GB, then come page-fault storms (313k against 8k per interval without the PR) and many `0x8007000E` "no host texture / no upload buffer" errors. The device is then removed after ~167 s. - **Suggestions:** a budget for the textures made per frame, or releasing views that are no longer marked, would probably be needed for 8 GB cards. A shader-side test-before-or guard would also help, but #1962 notes that a branch there broke dominance. Callers keep emitting into the block they started in, so the guard would have to hand the new block back to them. AI-assisted.
Author
Owner

@⁠Slay326 on GitHub · 2026-11-25 14:13 UTC · original

Follow-up on the 8 GB card: the device removal was memory, and it is gone with five open PRs merged on top. Same test branch as above, 480 s runs.

Run Result Process commit Host textures Placed textures World fps
#1962 alone device removed after ~170 s 45.3 GB (system 74.1 of 75.2 GB) 10.9 GB 5,819 / 3.6 GB, growing 0.3-0.9
+ #2129, #2180, #1873, #1969, #2161 and idle staging buffers let go 480 s, no removal, no allocation failures 29.8 GB 7.4 GB 4,150 / 2.9 GB, steady median 1.8 (1.1-1.9)
  • What grew: each placed texture the PR makes held three copies: the host texture, a staging upload buffer of the same size, and a read buffer of the same size. After 80 s in the world that was 3.6 + 3.3 + 3.3 GB.
  • Besides that: the pipeline library was 3.8 GB of private memory and was serialised and written again every 20-30 s with made=0.
  • The image: the G-buffer albedo target is 90.0 % non-zero in a target dump (1.3 % before the PR). Walls, hair and clothes show.
  • Still open on this card: GPU time per frame is ~260 ms with the PR against ~190 ms without. I have not measured how much of that is the unconditional atomicBinOp per texture read.

AI-assisted.

**@⁠Slay326** on GitHub · 2026-11-25 14:13 UTC · [original](https://github.com/Marvisak/VIctory/pull/1962#issuecomment-7164937029) Follow-up on the 8 GB card: the device removal was memory, and it is gone with five open PRs merged on top. Same test branch as above, 480 s runs. | Run | Result | Process commit | Host textures | Placed textures | World fps | |---|---|---|---|---|---| | #1962 alone | device removed after ~170 s | 45.3 GB (system 74.1 of 75.2 GB) | 10.9 GB | 5,819 / 3.6 GB, growing | 0.3-0.9 | | + #2129, #2180, #1873, #1969, #2161 and idle staging buffers let go | 480 s, no removal, no allocation failures | 29.8 GB | 7.4 GB | 4,150 / 2.9 GB, steady | median 1.8 (1.1-1.9) | - **What grew:** each placed texture the PR makes held three copies: the host texture, a staging upload buffer of the same size, and a read buffer of the same size. After 80 s in the world that was 3.6 + 3.3 + 3.3 GB. - **Besides that:** the pipeline library was 3.8 GB of private memory and was serialised and written again every 20-30 s with `made=0`. - **The image:** the G-buffer albedo target is 90.0 % non-zero in a target dump (1.3 % before the PR). Walls, hair and clothes show. - **Still open on this card:** GPU time per frame is ~260 ms with the PR against ~190 ms without. I have not measured how much of that is the unconditional `atomicBinOp` per texture read. AI-assisted.
Author
Owner

@⁠r4tedx on GitHub · 2026-11-25 14:39 UTC · original

Following up on Slay326's measurements above, with a fix for the per-read atomic cost and for two translation problems we hit with this PR rebased onto main 940d32f. It's on r4tedx/VIctory fix/1962-marks-once-per-wave (97bb0e1c), five commits on top of our rebase of this PR (015274f4, u2 for the bitmap, cache-flag bit 6).

1. Marks: one atomic per wave, and only if the bit is clear (fed19ba4, 288cbd38). As Slay326 found, every lane's atomicBinOp OR went to a few dwords of a bitmap in system memory.

  • Where every lane reads the same slot, only the first lane of the wave marks. This is checked at run time with WaveActiveAllEqual, because a console wave's uniform index need not be uniform in one host wave. Otherwise every lane marks.
  • The marking lane loads the dword first and does the atomic only if the bit is still clear. That's Slay326's suggestion, the same pattern as the buffer write marks.
  • Helper lanes are not in wave operations (no WaveOpsIncludeHelperLanes), so the marking lane is a live one.

2. The branch no longer breaks dominance (cc221485). Callers of handle() keep emitting into the block they started in, so a branch that makes a new current block gives "forward reference outside a phi". That's the failure the PR's comment mentions; on a wave64 tree it panicked within the first containers. A new Module::branch_at_end puts the branch at the end of the current block, which stays current: the block's terminator moves to the branch's tail, and phis are repointed. A unit test covers the terminator being set both before and after the branch.

3. Vertex and mesh shaders that mark declare UAVsAtEveryStage (595f77c9, the shader flag and its feature-info bit). The bitmap is the only UAV these stages get. Without the flag, the validator refuses them with "Flags must match usage".

4. heap_usage_marks moves above lower.rs's test module (97bb0e1c), because clippy's items_after_test_module refused it.

Offline check. victory translate --validate --list over a local copy of the title's shader pack, program by program. Only counts and reasons are reported here.

Tree Validated before → after Lost
main + this PR (our rebase), default host lanes 16,588 → 24,785 of 25,889 0
main 940d32f alone → main + this PR + fix 23,918 → 24,785 0
our wave64 play tree with this PR, --host-lanes 32-32 18,371 → 25,701 0

The 7,330 programs regained are 7,256 mesh and 74 vertex shaders, all "Flags must match usage" before. In game nothing runs the validator, and the NVIDIA driver accepted those shaders without the flag. So this matters for validation and for stricter drivers, not for what ran in our earlier game runs.

In game. RTX 5070 12 GB, 32 GB RAM, our play build: layer 2 of our tree, which includes #2242 and #2280, plus this PR and the fix above. Local title data used for the in-game measurement; only timings and log counts are reported.

  • GPU time: 115-440 ms a frame in the world. The same tree without this PR ran at about 360 ms. Without the fix (one atomic per lane, on our layer-3 tree) GPU time had climbed to 4-18.6 s a frame as the scene filled. So the marks no longer cost GPU time we can see.

  • Memory: this confirms Slay326's finding. We stopped the run by hand at about 4.5 min:

    • process private memory grew from 30.7 to 37.3 GB in about 1.5 min;
    • system commit free fell to 274 MB of 78 GB;
    • VRAM was at 11.87 of 12.23 GB;
    • 75-716 placed-texture views were made per 5 s, with 13-20k slots marked read;
    • the "textures" prep step spiked to 400-2,300 ms;
    • the pipeline library was rewritten every few seconds (760 → 860 MB, 3-40 new pipelines each time).

    So on 12 GB the memory work Slay326 lists is needed too. We're putting that set together next (#1873, #1969, #2161 and releasing idle staging/read buffers on top of #2129 and #2180), plus a check of the open pipeline-library-save PRs.

  • Not yet confirmed: whether albedo now shows on 3D surfaces. Our captures only reached a 2D loading screen.

Unit tests. victory-shader clippy -D warnings is clean with and without diagnostics, and victory-gpu clippy (diagnostics) is clean. The bitcode unit tests pass, 7 of them including the new one. The full WARP suites for the branch are running now; I'll add their counts here.

AI-assisted

**@⁠r4tedx** on GitHub · 2026-11-25 14:39 UTC · [original](https://github.com/Marvisak/VIctory/pull/1962#issuecomment-7165622390) Following up on Slay326's measurements above, with a fix for the per-read atomic cost and for two translation problems we hit with this PR rebased onto `main` 940d32f. It's on [r4tedx/VIctory `fix/1962-marks-once-per-wave`](https://github.com/r4tedx/VIctory/tree/fix/1962-marks-once-per-wave) (`97bb0e1c`), five commits on top of our rebase of this PR (`015274f4`, `u2` for the bitmap, cache-flag bit 6). **1. Marks: one atomic per wave, and only if the bit is clear** (`fed19ba4`, `288cbd38`). As Slay326 found, every lane's `atomicBinOp` OR went to a few dwords of a bitmap in system memory. - Where every lane reads the same slot, only the first lane of the wave marks. This is checked at run time with `WaveActiveAllEqual`, because a console wave's uniform index need not be uniform in one host wave. Otherwise every lane marks. - The marking lane loads the dword first and does the atomic only if the bit is still clear. That's Slay326's suggestion, the same pattern as the buffer write marks. - Helper lanes are not in wave operations (no `WaveOpsIncludeHelperLanes`), so the marking lane is a live one. **2. The branch no longer breaks dominance** (`cc221485`). Callers of `handle()` keep emitting into the block they started in, so a branch that makes a new current block gives "forward reference outside a phi". That's the failure the PR's comment mentions; on a wave64 tree it panicked within the first containers. A new `Module::branch_at_end` puts the branch at the end of the current block, which stays current: the block's terminator moves to the branch's tail, and phis are repointed. A unit test covers the terminator being set both before and after the branch. **3. Vertex and mesh shaders that mark declare `UAVsAtEveryStage`** (`595f77c9`, the shader flag and its feature-info bit). The bitmap is the only UAV these stages get. Without the flag, the validator refuses them with "Flags must match usage". **4.** `heap_usage_marks` moves above `lower.rs`'s test module (`97bb0e1c`), because clippy's `items_after_test_module` refused it. **Offline check.** `victory translate --validate --list` over a local copy of the title's shader pack, program by program. Only counts and reasons are reported here. | Tree | Validated before → after | Lost | |---|---|---:| | `main` + this PR (our rebase), default host lanes | 16,588 → 24,785 of 25,889 | 0 | | `main` 940d32f alone → `main` + this PR + fix | 23,918 → 24,785 | 0 | | our wave64 play tree with this PR, `--host-lanes 32-32` | 18,371 → 25,701 | 0 | The 7,330 programs regained are 7,256 mesh and 74 vertex shaders, all "Flags must match usage" before. In game nothing runs the validator, and the NVIDIA driver accepted those shaders without the flag. So this matters for validation and for stricter drivers, not for what ran in our earlier game runs. **In game.** RTX 5070 12 GB, 32 GB RAM, our play build: layer 2 of our tree, which includes #2242 and #2280, plus this PR and the fix above. Local title data used for the in-game measurement; only timings and log counts are reported. - **GPU time:** 115-440 ms a frame in the world. The same tree without this PR ran at about 360 ms. Without the fix (one atomic per lane, on our layer-3 tree) GPU time had climbed to 4-18.6 s a frame as the scene filled. So the marks no longer cost GPU time we can see. - **Memory:** this confirms Slay326's finding. We stopped the run by hand at about 4.5 min: - process private memory grew from 30.7 to 37.3 GB in about 1.5 min; - system commit free fell to 274 MB of 78 GB; - VRAM was at 11.87 of 12.23 GB; - 75-716 placed-texture views were made per 5 s, with 13-20k slots marked read; - the "textures" prep step spiked to 400-2,300 ms; - the pipeline library was rewritten every few seconds (760 → 860 MB, 3-40 new pipelines each time). So on 12 GB the memory work Slay326 lists is needed too. We're putting that set together next (#1873, #1969, #2161 and releasing idle staging/read buffers on top of #2129 and #2180), plus a check of the open pipeline-library-save PRs. - **Not yet confirmed:** whether albedo now shows on 3D surfaces. Our captures only reached a 2D loading screen. **Unit tests.** victory-shader clippy `-D warnings` is clean with and without diagnostics, and victory-gpu clippy (diagnostics) is clean. The bitcode unit tests pass, 7 of them including the new one. The full WARP suites for the branch are running now; I'll add their counts here. AI-assisted
Author
Owner

@⁠r4tedx on GitHub · 2026-11-25 14:42 UTC · original

WARP suite counts for fix/1962-marks-once-per-wave (97bb0e1c), as promised above:

  • VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --features diagnostics --lib -- --test-threads=1: 147 passed, 0 failed, 2 ignored.
  • VICTORY_WARP=1 cargo test -p victory-shader --lib -- --skip split_tests --skip lane_read_loop_tests --skip edge_flagged_triangles_draw_as_unflagged_ones: 245 passed, 2 failed, 3 ignored.

The two failures are gathers_at_a_level_match_the_hardware and permutes_read_the_lane_named_and_zero_from_lanes_left_out, and they fail the same way on main 940d32f on this machine's WARP. The marks code itself is off under cfg(test), so these suites check that nothing else changed. The offline validate in the comment above is what covers the mark emission.

The title was not used in these tests.

AI-assisted

**@⁠r4tedx** on GitHub · 2026-11-25 14:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/1962#issuecomment-7165682244) WARP suite counts for `fix/1962-marks-once-per-wave` (`97bb0e1c`), as promised above: - `VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --features diagnostics --lib -- --test-threads=1`: 147 passed, 0 failed, 2 ignored. - `VICTORY_WARP=1 cargo test -p victory-shader --lib -- --skip split_tests --skip lane_read_loop_tests --skip edge_flagged_triangles_draw_as_unflagged_ones`: 245 passed, 2 failed, 3 ignored. The two failures are `gathers_at_a_level_match_the_hardware` and `permutes_read_the_lane_named_and_zero_from_lanes_left_out`, and they fail the same way on `main` 940d32f on this machine's WARP. The marks code itself is off under `cfg(test)`, so these suites check that nothing else changed. The offline validate in the comment above is what covers the mark emission. The title was not used in these tests. AI-assisted
Author
Owner

@⁠r4tedx on GitHub · 2026-11-25 16:28 UTC · original

In-game result with this PR in our play tree, thanks to @⁠antocorvo3000 for the PR and @⁠Slay326 for the measurements that shaped the fixes. RTX 5070 12 GB, 32 GB RAM, local title data used for the in-game measurement; only timings and a description of the picture are reported, no images.

The tree has this PR as rebased, our marks fix (r4tedx/VIctory fix/1962-marks-once-per-wave, 97bb0e1c), and the memory set Slay326 listed. In our tree that set is #1873, #2221 (instead of #1969: with #1969, a placed view read before the GPU-written texture got its own host texture and missed the GPU's writes), #2161, #2129 and #2180, plus a release of idle staging buffers.

  • Picture: for the first time in our runs, world materials have their colour and texture: plants, fences, benches and window frames. In a run that also had opt-in stand-ins for the never-built ray-traced lighting, the prison cell scene was fully lit and textured.
  • GPU time: 265 ms a frame against 358 for the same tree without this PR. The marks no longer cost GPU time we can see.
  • Memory: it stabilises. Process private plateaus at ~25 GB after world load and creeps to ~28 GB over 10 min, against a runaway past 37 GB in 4.5 min with this PR alone.
  • Preparation time: about 4x higher, 585 vs 150 ms a frame. It's the CPU upload/detile of the placed textures made for marked slots ("textures" in the preparing line, 80-600 ms a frame). We're looking at uploading only changed levels and moving detiling off the submitting thread.

Not separated: how much of the lighting comes from this PR and how much from the stand-ins.

AI-assisted

**@⁠r4tedx** on GitHub · 2026-11-25 16:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/1962#issuecomment-7168047129) In-game result with this PR in our play tree, thanks to @⁠antocorvo3000 for the PR and @⁠Slay326 for the measurements that shaped the fixes. RTX 5070 12 GB, 32 GB RAM, local title data used for the in-game measurement; only timings and a description of the picture are reported, no images. The tree has this PR as rebased, our marks fix (`r4tedx/VIctory fix/1962-marks-once-per-wave`, 97bb0e1c), and the memory set Slay326 listed. In our tree that set is #1873, #2221 (instead of #1969: with #1969, a placed view read before the GPU-written texture got its own host texture and missed the GPU's writes), #2161, #2129 and #2180, plus a release of idle staging buffers. - **Picture:** for the first time in our runs, world materials have their colour and texture: plants, fences, benches and window frames. In a run that also had opt-in stand-ins for the never-built ray-traced lighting, the prison cell scene was fully lit and textured. - **GPU time:** 265 ms a frame against 358 for the same tree without this PR. The marks no longer cost GPU time we can see. - **Memory:** it stabilises. Process private plateaus at ~25 GB after world load and creeps to ~28 GB over 10 min, against a runaway past 37 GB in 4.5 min with this PR alone. - **Preparation time:** about 4x higher, 585 vs 150 ms a frame. It's the CPU upload/detile of the placed textures made for marked slots ("textures" in the preparing line, 80-600 ms a frame). We're looking at uploading only changed levels and moving detiling off the submitting thread. Not separated: how much of the lighting comes from this PR and how much from the stand-ins. AI-assisted
Author
Owner

@⁠Venom2054 on GitHub · 2026-11-25 18:06 UTC · original

I tested antocorvo3000’s change with r4tedx’s 97bb0e1c on a native Windows 11 RTX 5070 Ti (driver 621.01), using a local 940d32f integration. Both runs used the same executable, save, starting caches, scripted input and SDR gamma. Five character pixel shaders reported which texture views they read. The control recorded those reads. The second run also created the requested placed-texture views on the host.

  • Hair: In the control, the foreground character had a smooth scalp silhouette and all eight indirect hair resolve dispatches had zero X groups in the captured window frame. In the second run, strands were visible around her head and at the nape, and several courtyard NPCs had distinct hairstyles. One of the eight dispatches (1c8165626a581de4) now had 14,902 X groups. This follows up on the earlier zero-work capture on #71.
  • Textures: Immediately after the geometry pass, median 8-bit RGB in the same central head and shirt regions went from (0, 0, 0) in both to (89, 74, 61) and (204, 88, 48) respectively. The orange fabric, seams and printed lettering became visible in the material buffer. The character was still dark in the final lit frame.
  • Descriptor check: For two texture-index fields across ten head-material records, CPU and GPU indices agreed in 20/20 checks in each run. At draw recording, the host texture was null in all 20 control checks and present in all 20 checks in the second run.

This comparison isolates the effect of creating the requested views as a group. Which individual texture made the hair visible is still open. Capture and analysis were assisted by OpenAI Codex.

**@⁠Venom2054** on GitHub · 2026-11-25 18:06 UTC · [original](https://github.com/Marvisak/VIctory/pull/1962#issuecomment-7170446037) I tested antocorvo3000’s change with r4tedx’s `97bb0e1c` on a native Windows 11 RTX 5070 Ti (driver 621.01), using a local `940d32f` integration. Both runs used the same executable, save, starting caches, scripted input and SDR gamma. Five character pixel shaders reported which texture views they read. The control recorded those reads. The second run also created the requested placed-texture views on the host. - **Hair:** In the control, the foreground character had a smooth scalp silhouette and all eight indirect hair resolve dispatches had zero X groups in the captured window frame. In the second run, strands were visible around her head and at the nape, and several courtyard NPCs had distinct hairstyles. One of the eight dispatches (`1c8165626a581de4`) now had 14,902 X groups. This follows up on the [earlier zero-work capture on #71](https://git.gtahub.st/github/Marvisak--VIctory/issues/71). - **Textures:** Immediately after the geometry pass, median 8-bit RGB in the same central head and shirt regions went from `(0, 0, 0)` in both to `(89, 74, 61)` and `(204, 88, 48)` respectively. The orange fabric, seams and printed lettering became visible in the material buffer. The character was still dark in the final lit frame. - **Descriptor check:** For two texture-index fields across ten head-material records, CPU and GPU indices agreed in 20/20 checks in each run. At draw recording, the host texture was null in all 20 control checks and present in all 20 checks in the second run. This comparison isolates the effect of creating the requested views as a group. Which individual texture made the hair visible is still open. Capture and analysis were assisted by OpenAI Codex.
Author
Owner

@⁠r4tedx on GitHub · 2026-11-25 18:08 UTC · original

@⁠Venom2054, thank you. That's a clean A/B: same exe, save, caches and input, with the descriptor indices checked 20/20. It's the first independent in-game confirmation that creating the requested placed-texture views brings back the hair and the material-buffer textures.

On the character still being dark in the final lit frame: in our runs (RTX 5070, 32-lane waves) that comes from a separate gap, not from this PR. On main 940d32f, all of the title's cascade shadow-map compute programs (cascadeshadows_rendering CS_ShadowRenderTiledCascades*, plus two cascadeshadows_classify programs) are refused on 32-lane hosts with "console wave64 lanes in a group of more than 64 threads on a host without 64-lane waves is not supported". With no sun shadow map, lit surfaces read as fully shadowed. The probe GI passes are refused too (the irradiance-cache shading programs, and the screen-probe activate/fallback trace). In our test tree, where most of those cascade programs translate (multi-wave groups run as one host group per console wave, fork branch shader/wave-per-group), the same opening scenes come out lit. So on a 32-lane card I'd expect the final frame to stay dark with #1962 alone.

Local title data was used for those in-game observations; only program names and hashes, refusal reasons and a description of the picture are given here.

AI-assisted

**@⁠r4tedx** on GitHub · 2026-11-25 18:08 UTC · [original](https://github.com/Marvisak/VIctory/pull/1962#issuecomment-7170497781) @⁠Venom2054, thank you. That's a clean A/B: same exe, save, caches and input, with the descriptor indices checked 20/20. It's the first independent in-game confirmation that creating the requested placed-texture views brings back the hair and the material-buffer textures. On the character still being dark in the final lit frame: in our runs (RTX 5070, 32-lane waves) that comes from a separate gap, not from this PR. On `main` 940d32f, all of the title's cascade shadow-map compute programs (`cascadeshadows_rendering` CS_ShadowRenderTiledCascades*, plus two `cascadeshadows_classify` programs) are refused on 32-lane hosts with "console wave64 lanes in a group of more than 64 threads on a host without 64-lane waves is not supported". With no sun shadow map, lit surfaces read as fully shadowed. The probe GI passes are refused too (the irradiance-cache shading programs, and the screen-probe activate/fallback trace). In our test tree, where most of those cascade programs translate (multi-wave groups run as one host group per console wave, fork branch `shader/wave-per-group`), the same opening scenes come out lit. So on a 32-lane card I'd expect the final frame to stay dark with #1962 alone. Local title data was used for those in-game observations; only program names and hashes, refusal reasons and a description of the picture are given here. AI-assisted
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/descriptor.rs
  • crates/victory-gpu/src/shader_cache.rs
  • crates/victory-shader/src/emit/host.rs
  • crates/victory-shader/src/emit/lower.rs
  • crates/victory-shader/src/emit/mod.rs
  • crates/victory-shader/src/emit/shader.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/1962/head:github-bot/gh-1962'
git switch 'github-bot/gh-1962'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1962'
git switch 'github-bot/gh-1962'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1962'
git switch 'github-bot/gh-1962'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1962'
git switch 'main'
git merge --squash 'github-bot/gh-1962'
git switch 'main'
git merge --ff-only 'github-bot/gh-1962'
git switch 'main'
git merge 'github-bot/gh-1962'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1962
No description provided.