Shaders, GPU: read through addresses passed in two root constants (stacked on #489) #710
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!710
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/710/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@itsRevela on GitHub · 2026-11-24 07:12 UTC · original
itsRevela:shaders/root-constant-addresses→main· +1180 −40 · 10 files · 5 commits · closed without mergingDepends 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 addresscase from #614.victory-shader,resource.rsvictory-shader,emitglobal_load_*, ans_load_dword*, or ans_buffer_load_*on a descriptor built around the pair reads a raw root SRV,t<n>in a newROOT_ADDRESS_SPACE. The list isHostShader::address_srvs.victory-gpubindcomposes the address from the two constants' current values and binds it withroot_view.Why
In the opening cutscene, 8 compute programs stop at
an address from a root parameter that is no addressonce #302 rewrites their spill-table loads. Onmainthey stop earlier. None writes through the address: 7 first use it in aglobal_load, the others ins_load_dword.I measured with the title, cutscene, in local builds:
no addressno address; 3 at root UAVs, 2 at typed root views, 2 atan address from a phi, 1 at another non-root addressan 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.
resource.rs;lower.rs;global_loadand ans_load_dwordthrough a pair, invalu_tests.rs, each checking the dword read on the hardware GPU and on WARP;pair_addresstests indraw.rs.cargo test -p victory-shader: 81 passed.-p victory-gpu: 46 passed, 1 ignored; withdiagnostics, 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 asmain.cargo xtask policy: ok.Overlap with #294: this touches the same files (
draw.rs,pipeline/host.rs,shader_cache.rs, theemitstructs). I merged the two locally for the measurements above. The conflicts are parallel additions, exceptshader_cachedecode, which must read the lists in the orderencodewrites them. Whichever lands second rebases.Known limits:
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
@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):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 (includingaddresses_in_root_constants_are_composed_from_both_halves,an_address_with_a_missing_half_is_unset, andnull_and_low_addresses_are_unset).No game data used. AI-assisted; tests run on my machine.
@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).@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:47 UTC · original
Test Results –
victory-shaderI ran the following command locally:
Results:
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_testsconsistently report: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_waterfalllanes_sample_their_own_texture_in_a_waterfall_narrowed_by_v_cmpxBoth fail because their expected execution results are 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.@DaviTostes on GitHub · 2026-11-24 11:08 UTC · original · edited 2026-11-24 11:18 UTC
A/B tested
a5a40bcon 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.1dxgi,WINEDLLOVERRIDES="d3d12,d3d12core,dxgi=n"). Basemainffe310e.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:
After (this branch): 82 unique untranslated shaders, but:
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, thenhost GPU device removed … 0x887A0005after a 7-list submission (the #774/#714 signature), ~3 minutes in.Build details (per the report template): branch head
a5a40bcon basemainffe310e, release build (cargo xwin build --release -p victory, MSVC);victory runprintsbuild 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.
@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
a5a40bcon #489279eac1, 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.
@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
@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-packvictory translate <shaders.rpf> --validate --list, clean worktrees and release builds:a5a40bcevery count matches its merge based2a4baeexactly: 21,971 programs validate, 185 are refused by the validator, 2,932 stop at emission, 594 stop during resource tracking;an address in an SGPR that is no root parameterare 195 before and after, and all of them areGS_VoxelizeGeneric_*geometry programs — 0 of the 196Gsprograms 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.
@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 indraw.rs, and the waterfall proof inresource.rs). I resolved those by hand:bind()returnsboundnext 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):
an address in an SGPR that is no root parameterAs @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 --validateshows 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),@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
@ -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),@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
@ -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 {@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
@ -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 {@raffclar on GitHub · 2026-11-24 08:23 UTC · original
If the limit is never reached maybe a hard cap and error instead
@Marvisak on GitHub · 2026-11-25 00:28 UTC · original
Automated triage for the maintainers. Closing because this change is already in
main, ormainhas 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