Shaders, GPU: read through addresses passed in two root constants (stacked on #489) #710

Closed
github-bot wants to merge 5 commits from gh-pr/710/head into gh-pr/710/base
Owner

@⁠itsRevela on GitHub · 2026-11-24 07:12 UTC · original
itsRevela:shaders/root-constant-addresses → main · +1180 −40 · 10 files · 5 commits · closed without merging

Depends on: #302 and #489 (this branch is on top of #489, which carries #302). The measured programs also need #294 and #709 to translate all the way.

What

Reads through a 64-bit address that the title passes as two root constants (low half, high half). This is the an address from a root parameter that is no address case from #614.

  • victory-shader, resource.rs
    • The tracker recognises the constant pair from its high half. It handles a pair at any dword, a pair across two parameters, and a pair with an added offset carried into the high half.
    • Nothing that's accepted today is diverted, and a constant used as an index is never taken for a pair.
  • victory-shader, emit
    • A global_load_*, an s_load_dword*, or an s_buffer_load_* on a descriptor built around the pair reads a raw root SRV, t<n> in a new ROOT_ADDRESS_SPACE. The list is HostShader::address_srvs.
    • Writes and typed views through such an address stop with specific reasons.
  • victory-gpu
    • One SRV root parameter per view. At every draw and dispatch, bind composes the address from the two constants' current values and binds it with root_view.
    • If the address is unset or below 0x10000, the draw is dropped: counted, noted and warned once. That's today's outcome for these programs.
    • The shader cache encodes the new list.

Why

In the opening cutscene, 8 compute programs stop at an address from a root parameter that is no address once #302 rewrites their spill-table loads. On main they stop earlier. None writes through the address: 7 first use it in a global_load, the others in s_load_dword.

I measured with the title, cutscene, in local builds:

build those 8 programs
#302 #489 all 8 stop at no address
+ this 0 stop at no address; 3 at root UAVs, 2 at typed root views, 2 at an address from a phi, 1 at another non-root address
+ this + #294 + #709 3 of the 8 translate (the scalar-load ones), with their pipelines accepted by the host; the rest stop at an address from a phi (2), another non-root address (1) and an LDS operation (1)

The GPU bound the views without errors in those runs.

Tested

Windows 11 Pro 10.0.26200, NVIDIA GeForce RTX 3070 Ti (driver 32.0.16.1088), Rust 1.98.1.

  • New tests (13, synthetic code words only):
    • pair layouts and negative cases in resource.rs;
    • the read routes and the stop reasons in lower.rs;
    • two GPU tests, a global_load and an s_load_dword through a pair, in valu_tests.rs, each checking the dword read on the hardware GPU and on WARP;
    • pair_address tests in draw.rs.
  • The fix matters. With pair detection disabled, the pair tests fail.
  • Crate checks:
    • cargo test -p victory-shader: 81 passed.
    • -p victory-gpu: 46 passed, 1 ignored; with diagnostics, 48 passed, 1 ignored.
    • cargo test --workspace: 278 passed (on the first commit).
    • cargo clippy -p victory-shader -p victory-gpu --tests: nothing in the changed files.
    • cargo fmt --check: victory-shader clean; victory-gpu 79, the same as main.
    • cargo xtask policy: ok.

Overlap with #294: this touches the same files (draw.rs, pipeline/host.rs, shader_cache.rs, the emit structs). I merged the two locally for the measurements above. The conflicts are parallel additions, except shader_cache decode, which must read the lists in the order encode writes them. Whichever lands second rebases.

Known limits:

  • A root view has no size, so only the 1 MiB from the address is refreshed.
  • An offset below the start of the address can't be reached.
  • There's no fallback address yet; an unset address drops the draw.

AI-assisted (Claude Code). The design was reviewed before implementation, and the title runs used my own copy; no game data is in this PR.

🤖 Generated with Claude Code

**@⁠itsRevela** on GitHub · 2026-11-24 07:12 UTC · [original](https://github.com/Marvisak/VIctory/pull/710) `itsRevela:shaders/root-constant-addresses` → `main` · +1180 −40 · 10 files · 5 commits · closed without merging Depends on: #302 and #489 (this branch is on top of #489, which carries #302). The measured programs also need #294 and #709 to translate all the way. ## What Reads through a 64-bit address that the title passes as **two root constants** (low half, high half). This is the `an address from a root parameter that is no address` case from #614. - **`victory-shader`, `resource.rs`** - The tracker recognises the constant pair from its high half. It handles a pair at any dword, a pair across two parameters, and a pair with an added offset carried into the high half. - Nothing that's accepted today is diverted, and a constant used as an index is never taken for a pair. - **`victory-shader`, `emit`** - A `global_load_*`, an `s_load_dword*`, or an `s_buffer_load_*` on a descriptor built around the pair reads a raw root SRV, `t<n>` in a new `ROOT_ADDRESS_SPACE`. The list is `HostShader::address_srvs`. - Writes and typed views through such an address stop with specific reasons. - **`victory-gpu`** - One SRV root parameter per view. At every draw and dispatch, `bind` composes the address from the two constants' current values and binds it with `root_view`. - If the address is unset or below 0x10000, the draw is dropped: counted, noted and warned once. That's today's outcome for these programs. - The shader cache encodes the new list. ## Why In the opening cutscene, 8 compute programs stop at `an address from a root parameter that is no address` once #302 rewrites their spill-table loads. On `main` they stop earlier. None writes through the address: 7 first use it in a `global_load`, the others in `s_load_dword`. I measured with the title, cutscene, in local builds: | build | those 8 programs | |---|---| | #302 #489 | all 8 stop at `no address` | | + this | 0 stop at `no address`; 3 at root UAVs, 2 at typed root views, 2 at `an address from a phi`, 1 at another non-root address | | + this + #294 + #709 | **3 of the 8 translate** (the scalar-load ones), with their pipelines accepted by the host; the rest stop at `an address from a phi` (2), another non-root address (1) and an LDS operation (1) | The GPU bound the views without errors in those runs. ## Tested Windows 11 Pro 10.0.26200, NVIDIA GeForce RTX 3070 Ti (driver 32.0.16.1088), Rust 1.98.1. - **New tests** (13, synthetic code words only): - pair layouts and negative cases in `resource.rs`; - the read routes and the stop reasons in `lower.rs`; - two GPU tests, a `global_load` and an `s_load_dword` through a pair, in `valu_tests.rs`, each checking the dword read on the hardware GPU and on WARP; - `pair_address` tests in `draw.rs`. - **The fix matters.** With pair detection disabled, the pair tests fail. - **Crate checks:** - `cargo test -p victory-shader`: 81 passed. - `-p victory-gpu`: 46 passed, 1 ignored; with `diagnostics`, 48 passed, 1 ignored. - `cargo test --workspace`: 278 passed (on the first commit). - `cargo clippy -p victory-shader -p victory-gpu --tests`: nothing in the changed files. - `cargo fmt --check`: victory-shader clean; victory-gpu 79, the same as `main`. - `cargo xtask policy`: ok. **Overlap with #294:** this touches the same files (`draw.rs`, `pipeline/host.rs`, `shader_cache.rs`, the `emit` structs). I merged the two locally for the measurements above. The conflicts are parallel additions, except `shader_cache` decode, which must read the lists in the order `encode` writes them. Whichever lands second rebases. **Known limits:** - A root view has no size, so only the 1 MiB from the address is refreshed. - An offset below the start of the address can't be reached. - There's no fallback address yet; an unset address drops the draw. AI-assisted (Claude Code). The design was reviewed before implementation, and the title runs used my own copy; no game data is in this PR. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A compute program whose root signature does not fit the 16 user SGPRs
finds its arguments through a spill table: s[0:1] holds a pointer (high
dword masked to 40 bits, usually copied to s2/s3 first) to a table of
the user data, and the program s_loads descriptors and constants from
it. Table dword k is user SGPR 16 + k. The translator only knew
addresses that come from the declared root layout, so every such
program failed with "an address in an SGPR that is no root parameter".

For compute programs whose root layout lies entirely at user SGPR 16 and
above, loads from that pointer with a constant offset become s_mov_b32
copies of the user SGPRs the dwords stand for, before the SSA is built,
so resource tracking and lowering see what they see for ordinary root
arguments. Only straight-line code from the pointer's set-up is
rewritten (tags are dropped at branch targets and on any overwrite of
the pointer registers); other loads stay loads.

On the title's world shaders this took the "SGPR that is no root
parameter" failures from 34 programs to 4 in one run. Other failures
that were hidden behind it now show (address not from a root parameter,
root UAV or typed root view, an address from a phi...). Whether the
translated programs render correctly has not been checked beyond that.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The spill-table rewrite turned each load into `s_mov_b32 sK, s(16+k)`,
which reads what the register holds at that point. A program that has
already written SGPRs 16 and up (the destination of an earlier table
load, say) then reads the wrong root argument, with no refusal.

The program now first copies the user SGPRs its table loads stand for
into a block of SGPRs it never reads or writes, and the loads read that
block. Without such a block below VCC, or when a branch can return to
the program's entry, nothing is rewritten.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A title can pass a 64-bit buffer address as two root-constant dwords, low
half first in consecutive user SGPRs (within one parameter or across two).
Resource tracking only knew addresses from tables, heaps, root descriptors
and the code, so programs reading through such an address failed with "an
address from a root parameter that is no address" (or, for a pair past
dword 0, "an address in an SGPR that is no root parameter"). Once the
spill-table rewrite exposes their arguments, several compute programs stop
there.

The tracker now recognises a pair from its high half: a root constant
(possibly plus a carry) whose user SGPR below holds a root constant that
the low half's sum starts from. Nothing else has a root constant as its
high half, so no existing address is reclassified. Addresses get the
dword of their base and Resources lists the pairs.

Reads through a pair (global_load_*, s_buffer_load_* on a descriptor built
around it) become a raw root SRV t<n> in a new ROOT_ADDRESS_SPACE, listed
in HostShader::address_srvs with the two constants. Writes, typed views and
plain scalar loads through a pair stop with a specific reason.

The GPU layer declares one SRV root parameter per view, composes the
address from the constants' current values at every draw and dispatch
(pair_address) and binds it through root_view. An unset half or an
address below 0x10000 drops the draw or dispatch with a warning. The
shader cache encodes the new list; the test host binds it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
s_load_dword* through an address the title passes as two root constants reads the root SRV bound at that address, as s_buffer_load_dword* on a descriptor built around one does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:13:51 +00:00
github-bot closed this pull request 2026-11-26 04:13:51 +00:00
Author
Owner

@⁠MartinIndra02 on GitHub · 2026-11-24 09:19 UTC · original

Windows native D3D12 verification for a5a40bc (since @⁠catminou4 noted the Windows GPU run was still needed):

  • Setup: Windows 11 Pro 26200, NVIDIA GeForce RTX 3080 (10 GB, driver 621.24), Ryzen 7 5800X3D, Rust 1.98.1 (x86_64-pc-windows-msvc).
  • cargo test -p victory-shader --lib -- --test-threads=1: 81 passed, 0 failed (including both root-constant-pair GPU tests).
  • cargo test -p victory-gpu --lib -- --test-threads=1: 46 passed, 0 failed, 1 ignored (including addresses_in_root_constants_are_composed_from_both_halves, an_address_with_a_missing_half_is_unset, and null_and_low_addresses_are_unset).

No game data used. AI-assisted; tests run on my machine.

**@⁠MartinIndra02** on GitHub · 2026-11-24 09:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/710#issuecomment-7127262324) Windows native D3D12 verification for `a5a40bc` (since @⁠catminou4 noted the Windows GPU run was still needed): - **Setup:** Windows 11 Pro 26200, NVIDIA GeForce RTX 3080 (10 GB, driver `621.24`), Ryzen 7 5800X3D, Rust 1.98.1 (`x86_64-pc-windows-msvc`). - `cargo test -p victory-shader --lib -- --test-threads=1`: **81 passed, 0 failed** (including both root-constant-pair GPU tests). - `cargo test -p victory-gpu --lib -- --test-threads=1`: **46 passed, 0 failed, 1 ignored** (including `addresses_in_root_constants_are_composed_from_both_halves`, `an_address_with_a_missing_half_is_unset`, and `null_and_low_addresses_are_unset`). *No game data used. AI-assisted; tests run on my machine.*
Author
Owner

@⁠LAKSHYA-cmd-tech on GitHub · 2026-11-24 10:34 UTC · original

Verified and resolved cleanly against the latest dynamic slot reclaim and root signature fallbacks in github.com/LAKSHYA-cmd-tech/VIctory@44aec54b83 (branch eature/root-constant-addresses).

**@⁠LAKSHYA-cmd-tech** on GitHub · 2026-11-24 10:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/710#issuecomment-7128952346) Verified and resolved cleanly against the latest dynamic slot reclaim and root signature fallbacks in https://github.com/LAKSHYA-cmd-tech/VIctory/commit/44aec54b83ea9a35e959ce5012a8069503dc08eb (branch eature/root-constant-addresses).
Author
Owner

@⁠Zilumz1 on GitHub · 2026-11-24 10:34 UTC · original

Rebase check against current main (AI-assisted, no game files)

This branch no longer merges cleanly into main at 8e79c80: 8 conflicts in draw.rs, lower.rs and valu_tests.rs. I resolved them and have a version that applies cleanly. The resolutions were:

draw.rs: kept main's bind -> bool, added this PR's bound flag and note_drop.
lower.rs and valu_tests.rs: both sides added tests in the same spot, so I kept both.

Results:

cargo test -p victory-shader (Linux, Rust 1.100.0): 80 passed, 0 failed, 1 ignored. Plain main gives 70 passed.
victory-gpu and the Windows-only GPU tests don't build on Linux, so those are unchecked there.
On my machine (Windows 10, RX 580)

**@⁠Zilumz1** on GitHub · 2026-11-24 10:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/710#issuecomment-7128964137) Rebase check against current main (AI-assisted, no game files) This branch no longer merges cleanly into main at 8e79c80: 8 conflicts in draw.rs, lower.rs and valu_tests.rs. I resolved them and have a version that applies cleanly. The resolutions were: draw.rs: kept main's bind -> bool, added this PR's bound flag and note_drop. lower.rs and valu_tests.rs: both sides added tests in the same spot, so I kept both. Results: cargo test -p victory-shader (Linux, Rust 1.100.0): 80 passed, 0 failed, 1 ignored. Plain main gives 70 passed. victory-gpu and the Windows-only GPU tests don't build on Linux, so those are unchecked there. On my machine (Windows 10, RX 580)
Author
Owner

@⁠Zilumz1 on GitHub · 2026-11-24 10:47 UTC · original

Test Results – victory-shader

I ran the following command locally:

cargo test -p victory-shader 2>&1 | Tee-Object with-patch.log

Results:

  • Passed: 105
  • Failed: 15
  • Ignored: 1
  • Total: 121

Failure analysis:

Most of the failures appear to be related to the test environment rather than immediately indicating regressions in the shader implementation.

The 13 failures under emit::valu_tests consistently report:

no SM 6.6 hardware device; skipped
no SM 6.6 warp device; skipped

neither hardware nor WARP SM 6.6 device available

This suggests that the environment does not currently expose a compatible Direct3D 12 Shader Model 6.6 hardware device or WARP fallback.

There are also two failures in emit::waterfall_tests:

  • lanes_sample_the_entry_their_offset_names_in_the_console_waterfall
  • lanes_sample_their_own_texture_in_a_waterfall_narrowed_by_v_cmpx

Both fail because their expected execution results are empty:

assertion failed: !results.is_empty()

These may be consequences of the same missing graphics execution environment, but that needs to be verified.

Conclusion:

The remaining 105 tests pass successfully. I would not classify these 15 failures as confirmed implementation regressions without first reproducing them in an environment with working SM 6.6 support.

It would be useful to determine whether these tests should gracefully skip when neither hardware nor WARP is available, rather than report environment-dependent failures.

I haven't established whether the two waterfall failures are exclusively environment-related, so those still warrant investigation.

Full test output is available in with-patch.log.

**@⁠Zilumz1** on GitHub · 2026-11-24 10:47 UTC · [original](https://github.com/Marvisak/VIctory/pull/710#issuecomment-7129243319) ### Test Results – `victory-shader` I ran the following command locally: ```powershell cargo test -p victory-shader 2>&1 | Tee-Object with-patch.log ``` **Results:** - Passed: 105 - Failed: 15 - Ignored: 1 - Total: 121 **Failure analysis:** Most of the failures appear to be related to the test environment rather than immediately indicating regressions in the shader implementation. The 13 failures under `emit::valu_tests` consistently report: ```text no SM 6.6 hardware device; skipped no SM 6.6 warp device; skipped neither hardware nor WARP SM 6.6 device available ``` This suggests that the environment does not currently expose a compatible Direct3D 12 Shader Model 6.6 hardware device or WARP fallback. There are also two failures in `emit::waterfall_tests`: - `lanes_sample_the_entry_their_offset_names_in_the_console_waterfall` - `lanes_sample_their_own_texture_in_a_waterfall_narrowed_by_v_cmpx` Both fail because their expected execution results are empty: ```text assertion failed: !results.is_empty() ``` These may be consequences of the same missing graphics execution environment, but that needs to be verified. **Conclusion:** The remaining 105 tests pass successfully. I would not classify these 15 failures as confirmed implementation regressions without first reproducing them in an environment with working SM 6.6 support. It would be useful to determine whether these tests should gracefully skip when neither hardware nor WARP is available, rather than report environment-dependent failures. I haven't established whether the two waterfall failures are exclusively environment-related, so those still warrant investigation. Full test output is available in `with-patch.log`.
Author
Owner

@⁠DaviTostes on GitHub · 2026-11-24 11:08 UTC · original · edited 2026-11-24 11:18 UTC

A/B tested a5a40bc on the full 1.0.2.1 dump (RX 9060 XT, RDNA4/RADV 26.3.1, Arch, Wine 11.22 + vkd3d-proton 3.2 + DXVK 3.1.1 dxgi, WINEDLLOVERRIDES="d3d12,d3d12core,dxgi=n"). Base main ffe310e.

Both sides are actual title runs with the game (menus → intro → loading → world), not synthetic shader tests.

Before (main): 81 unique untranslated shaders in the first ~2 minutes of the world. Top reason exactly the one this targets:

35x  an address in an SGPR that is no root parameter
 8x  a structured buffer of unknown stride
 6x  an address from a phi
 5x  a 64-bit image atomic

After (this branch): 82 unique untranslated shaders, but:

 0x  an address in an SGPR that is no root parameter
16x  a root UAV or typed root view
15x  an address not from a root parameter
 9x  an address from a phi
 8x  a structured buffer of unknown stride
 8x  a 64-bit image atomic

So the #1 reason from #293 is gone, and what remains matches your table's “+ this” row (root UAVs, typed root views, phi). The mesh pipeline still builds (host mesh pipeline shaders=[mesh d4111a6e…, pixel c0a7fe77…]) and the title reaches the world, but it is still the dark frozen background at 0.2–0.3 fps, so no visible change yet.

Later in the same run: RtlReleaseSRWLockExclusive … not owned exclusive! on several threads, then host GPU device removed … 0x887A0005 after a 7-list submission (the #774/#714 signature), ~3 minutes in.
Build details (per the report template): branch head a5a40bc on base main ffe310e, release build (cargo xwin build --release -p victory, MSVC); victory run prints build unknown (b99f876b…b5c35a79d5decd9f716504239e93), package 1.0.2.1. Same command as above.

Not tested: Windows, other GPUs, the #193/#539 stacks, and a full world session — the device was removed after ~3 minutes.

Next things worth stacking here: #193 (stride), #539/#305 (64-bit atomics), and whatever covers root UAVs/typed root views; I can A/B those on this dump if useful.

**@⁠DaviTostes** on GitHub · 2026-11-24 11:08 UTC · [original](https://github.com/Marvisak/VIctory/pull/710#issuecomment-7129705817) · edited 2026-11-24 11:18 UTC A/B tested `a5a40bc` on the full 1.0.2.1 dump (RX 9060 XT, RDNA4/RADV 26.3.1, Arch, Wine 11.22 + vkd3d-proton 3.2 + DXVK 3.1.1 `dxgi`, `WINEDLLOVERRIDES="d3d12,d3d12core,dxgi=n"`). Base `main` `ffe310e`. Both sides are **actual title runs with the game** (menus → intro → loading → world), not synthetic shader tests. **Before (main):** 81 unique untranslated shaders in the first ~2 minutes of the world. Top reason exactly the one this targets: ``` 35x an address in an SGPR that is no root parameter 8x a structured buffer of unknown stride 6x an address from a phi 5x a 64-bit image atomic ``` **After (this branch):** 82 unique untranslated shaders, but: ``` 0x an address in an SGPR that is no root parameter 16x a root UAV or typed root view 15x an address not from a root parameter 9x an address from a phi 8x a structured buffer of unknown stride 8x a 64-bit image atomic ``` So the #1 reason from #293 is gone, and what remains matches your table's “+ this” row (root UAVs, typed root views, phi). The mesh pipeline still builds (`host mesh pipeline shaders=[mesh d4111a6e…, pixel c0a7fe77…]`) and the title reaches the world, but it is still the dark frozen background at 0.2–0.3 fps, so no visible change yet. Later in the same run: `RtlReleaseSRWLockExclusive … not owned exclusive!` on several threads, then `host GPU device removed … 0x887A0005` after a 7-list submission (the #774/#714 signature), ~3 minutes in. **Build details (per the report template):** branch head `a5a40bc` on base `main` `ffe310e`, release build (`cargo xwin build --release -p victory`, MSVC); `victory run` prints `build unknown (b99f876b…b5c35a79d5decd9f716504239e93)`, package 1.0.2.1. Same command as above. **Not tested:** Windows, other GPUs, the #193/#539 stacks, and a full world session — the device was removed after ~3 minutes. Next things worth stacking here: #193 (stride), #539/#305 (64-bit atomics), and whatever covers root UAVs/typed root views; I can A/B those on this dump if useful.
Author
Owner

@⁠erLCoder on GitHub · 2026-11-24 13:09 UTC · original

Independent root-constant address tests on GTX 1660 Ti, NVIDIA 581.42, Windows 10 22H2 build 19045.6466, Ryzen 5 3600, Rust 1.98.1 MSVC and Agility SDK 1.620.2. PR a5a40bc on #489 279eac1, which includes #302; #294 and #709 were not combined. Local SDK exports were added to the test executable and the fixture was restricted to the NVIDIA device, LUID 00000000:00017c52.

cargo test --offline --locked -p victory-shader --features host --lib through_a_root_constant_pair_read_its_root_srv -- --nocapture --test-threads=1 — 2 passed, 0 failed, 0 ignored, 79 filtered out. Both global and scalar load fixtures read the expected dword at byte offset 12. The fixture binds the buffer directly, so host address reconstruction during title dispatch remains untested, as do title shader recovery and composition.

Codex prepared the worktree, ran the tests and drafted this report.

**@⁠erLCoder** on GitHub · 2026-11-24 13:09 UTC · [original](https://github.com/Marvisak/VIctory/pull/710#issuecomment-7132418244) Independent root-constant address tests on GTX 1660 Ti, NVIDIA 581.42, Windows 10 22H2 build 19045.6466, Ryzen 5 3600, Rust 1.98.1 MSVC and Agility SDK 1.620.2. PR a5a40bc on #489 279eac1, which includes #302; #294 and #709 were not combined. Local SDK exports were added to the test executable and the fixture was restricted to the NVIDIA device, LUID 00000000:00017c52. `cargo test --offline --locked -p victory-shader --features host --lib through_a_root_constant_pair_read_its_root_srv -- --nocapture --test-threads=1` — 2 passed, 0 failed, 0 ignored, 79 filtered out. Both global and scalar load fixtures read the expected dword at byte offset 12. The fixture binds the buffer directly, so host address reconstruction during title dispatch remains untested, as do title shader recovery and composition. Codex prepared the worktree, ran the tests and drafted this report.
Author
Owner

@⁠qntic on GitHub · 2026-11-24 13:24 UTC · original

found a register space conflict while integrating this with main ffe310e. ROOT_ADDRESS_SPACE and STRIDE_SPACE both use register space 2.

moved ROOT_ADDRESS_SPACE to space 3 in my integration branch. clippy and workspace tests pass with the combined changes.

integration:
https://github.com/qntic/VIctory/tree/exp4/main-stack

**@⁠qntic** on GitHub · 2026-11-24 13:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/710#issuecomment-7132794400) found a register space conflict while integrating this with main ffe310e. ROOT_ADDRESS_SPACE and STRIDE_SPACE both use register space 2. moved ROOT_ADDRESS_SPACE to space 3 in my integration branch. clippy and workspace tests pass with the combined changes. integration: https://github.com/qntic/VIctory/tree/exp4/main-stack
Author
Owner

@⁠fiestorra on GitHub · 2026-11-24 14:32 UTC · original

Heads-up for anyone measuring this PR offline. On my own copy of the package (build b99f876b74d4a77f03af5f878223b27bd647b5c35a79d5decd9f716504239e93), whole-pack victory translate <shaders.rpf> --validate --list, clean worktrees and release builds:

  • at your head a5a40bc every count matches its merge base d2a4bae exactly: 21,971 programs validate, 185 are refused by the validator, 2,932 stop at emission, 594 stop during resource tracking;
  • no program moves to a different refusal and none newly validates;
  • the 195 programs stopped with an address in an SGPR that is no root parameter are 195 before and after, and all of them are GS_VoxelizeGeneric_* geometry programs — 0 of the 196 Gs programs validate in either build.

So this pack does not appear to contain whatever your commits change, and it contains 195 cases of the reason this row is usually described by, in a stage the row is not usually associated with. Table, method and the comparison against today's main in my comment here: #293

Written with an AI assistant.

**@⁠fiestorra** on GitHub · 2026-11-24 14:32 UTC · [original](https://github.com/Marvisak/VIctory/pull/710#issuecomment-7134557918) Heads-up for anyone measuring this PR offline. On my own copy of the package (build `b99f876b74d4a77f03af5f878223b27bd647b5c35a79d5decd9f716504239e93`), whole-pack `victory translate <shaders.rpf> --validate --list`, clean worktrees and release builds: - at your head `a5a40bc` every count matches its merge base `d2a4bae` exactly: 21,971 programs validate, 185 are refused by the validator, 2,932 stop at emission, 594 stop during resource tracking; - no program moves to a different refusal and none newly validates; - the 195 programs stopped with `an address in an SGPR that is no root parameter` are 195 before and after, and all of them are `GS_VoxelizeGeneric_*` geometry programs — 0 of the 196 `Gs` programs validate in either build. So this pack does not appear to contain whatever your commits change, and it contains 195 cases of the reason this row is usually described by, in a stage the row is not usually associated with. Table, method and the comparison against today's main in my comment here: https://git.gtahub.st/github/Marvisak--VIctory/issues/293 Written with an AI assistant.
Author
Owner

@⁠luisaugustz on GitHub · 2026-11-24 18:10 UTC · original

In-game test on AMD (RX 9070 XT), #302 + #489 + #710: the runtime refusals of this class go from 34 programs to 1

Machine: RX 9070 XT (native 64-lane waves), Adrenalin 32.0.32029.2010, Ryzen 7 5800X, Windows 11 build 26300. Title 1.0.2.1, diag build, prologue world, VICTORY_SHADER_LOOP_LIMIT=256.

Tree: r4tedx integration/testers (92bc27b) + #638 for the drop accounting. Then this PR's diff, which carries #302 and #489, applied on top. It conflicted in 11 places with that tree (#493's bounded root SRV tables in draw.rs, and the waterfall proof in resource.rs). I resolved those by hand: bind() returns bound next to the root SRV tables, and resource tracking keeps both the waterfall proof and the root-constant pairs.

Runtime result (same scene, before and after; per-frame drops summed over the programs that do not translate, peak per program):

without with #302/#489/#710
programs that do not translate (world) 107 101
an address in an SGPR that is no root parameter 34 programs, ~7,390 dropped/frame 1 program, ~150/frame
total dropped/frame from untranslated programs ~9,140 ~4,890

As @⁠Brazlucas measured on #489, most of the 34 now stop one step later:

  • a root UAV or typed root view: 18 programs, ~1,730/frame (needs #294/#709);
  • an address not from a root parameter: 29 programs, ~1,370/frame.

Stability: several world runs with this stack, up to 25 minutes, with no device removal from it. The world is still black on this card, for other reasons (see #71).

Note: offline victory translate --validate shows no change for this class, as expected. The rewrite depends on the root layout the title binds at run time.

AI-assisted (Claude Code): measured in-game on this machine with a diag build. Counts and hashes only.

**@⁠luisaugustz** on GitHub · 2026-11-24 18:10 UTC · [original](https://github.com/Marvisak/VIctory/pull/710#issuecomment-7140259933) **In-game test on AMD (RX 9070 XT), #302 + #489 + #710: the runtime refusals of this class go from 34 programs to 1** **Machine:** RX 9070 XT (native 64-lane waves), Adrenalin 32.0.32029.2010, Ryzen 7 5800X, Windows 11 build 26300. Title 1.0.2.1, diag build, prologue world, `VICTORY_SHADER_LOOP_LIMIT=256`. **Tree:** r4tedx `integration/testers` (`92bc27b`) + #638 for the drop accounting. Then this PR's diff, which carries #302 and #489, applied on top. It conflicted in 11 places with that tree (#493's bounded root SRV tables in `draw.rs`, and the waterfall proof in `resource.rs`). I resolved those by hand: `bind()` returns `bound` next to the root SRV tables, and resource tracking keeps both the waterfall proof and the root-constant pairs. **Runtime result** (same scene, before and after; per-frame drops summed over the programs that do not translate, peak per program): | | without | with #302/#489/#710 | |---|---|---| | programs that do not translate (world) | 107 | 101 | | `an address in an SGPR that is no root parameter` | **34 programs, ~7,390 dropped/frame** | **1 program, ~150/frame** | | total dropped/frame from untranslated programs | ~9,140 | ~4,890 | As @⁠Brazlucas measured on #489, most of the 34 now stop one step later: - `a root UAV or typed root view`: 18 programs, ~1,730/frame (needs #294/#709); - `an address not from a root parameter`: 29 programs, ~1,370/frame. **Stability:** several world runs with this stack, up to 25 minutes, with no device removal from it. The world is still black on this card, for other reasons (see #71). Note: offline `victory translate --validate` shows no change for this class, as expected. The rewrite depends on the root layout the title binds at run time. _AI-assisted (Claude Code): measured in-game on this machine with a diag build. Counts and hashes only._
@ -3249,1 +3348,4 @@
.ok_or("a descriptor built around a table in the code")?;
if rp.root == RootType::Constants {
return match props.0 {
11 => self.address_srv(address),
Author
Owner

@⁠raffclar on GitHub · 2026-11-24 08:09 UTC · original · edited 2026-11-24 08:17 UTC

If a shader adds an offset to the address pair before a buffer load (such as pair + 0x100), the translation drops the offset

I would add the offset there too or refuse as non-zero offset

**@⁠raffclar** on GitHub · 2026-11-24 08:09 UTC · [original](https://github.com/Marvisak/VIctory/pull/710#discussion_r4677150300) · edited 2026-11-24 08:17 UTC If a shader adds an offset to the address pair before a buffer load (such as pair + 0x100), the translation drops the offset I would add the offset there too or refuse as non-zero offset
@ -3249,1 +3348,4 @@
.ok_or("a descriptor built around a table in the code")?;
if rp.root == RootType::Constants {
return match props.0 {
11 => self.address_srv(address),
Author
Owner

@⁠raffclar on GitHub · 2026-11-24 08:10 UTC · original · edited 2026-11-24 08:17 UTC

Also the PR's tests only use an offset of zero so they miss this

**@⁠raffclar** on GitHub · 2026-11-24 08:10 UTC · [original](https://github.com/Marvisak/VIctory/pull/710#discussion_r4677155700) · edited 2026-11-24 08:17 UTC Also the PR's tests only use an offset of zero so they miss this
@ -384,1 +392,4 @@
}
for (n, &view) in t.address_srvs.iter().enumerate() {
stage.address_srvs.push((view, params.len() as u32));
params.push(D3D12_ROOT_PARAMETER1 {
Author
Owner

@⁠raffclar on GitHub · 2026-11-24 08:17 UTC · original

Check D3D12's limit of 64.

Count the u32s you're pushing. Consider using descriptor tables as fallback but tables have extra cost in the form of heap space on every draw so more work for the CPU.

Make sure to log the fallback i.e "root signature over 64 DWORDs" in the code for debugging

**@⁠raffclar** on GitHub · 2026-11-24 08:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/710#discussion_r4677219792) Check D3D12's limit of 64. Count the u32s you're pushing. Consider using descriptor tables as fallback but tables have extra cost in the form of heap space on every draw so more work for the CPU. Make sure to log the fallback i.e "root signature over 64 DWORDs" in the code for debugging
@ -384,1 +392,4 @@
}
for (n, &view) in t.address_srvs.iter().enumerate() {
stage.address_srvs.push((view, params.len() as u32));
params.push(D3D12_ROOT_PARAMETER1 {
Author
Owner

@⁠raffclar on GitHub · 2026-11-24 08:23 UTC · original

If the limit is never reached maybe a hard cap and error instead

**@⁠raffclar** on GitHub · 2026-11-24 08:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/710#discussion_r4677278255) If the limit is never reached maybe a hard cap and error instead
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:28 UTC · original

Automated triage for the maintainers. Closing because this change is already in main, or main has since replaced the code it patches.

Stacked on #489/#302. Addresses passed in two root constants are served in main by the raw-address page table (27c3dc9d, Lower::memory), builder programs included.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

**@⁠Marvisak** on GitHub · 2026-11-25 00:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/710#issuecomment-7148539874) Automated triage for the maintainers. Closing because this change is already in `main`, or `main` has since replaced the code it patches. Stacked on #489/#302. Addresses passed in two root constants are served in main by the raw-address page table (27c3dc9d, Lower::memory), builder programs included. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

Pull request closed

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!710
No description provided.