Shaders: use declared structured SRVs for scalar loads and record counts #995
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!995
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/995/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?
@jeremygold02 on GitHub · 2026-11-24 14:46 UTC · original
jeremygold02:codex/declared-structured-srv-scalar-loads→main· +478 −8 · 5 files · 2 commits · closed without mergingScalar
s_buffer_load_dword*instructions use byte addresses. Onffe310e, a descriptor-table SRV takes the raw-buffer path even when the original shader declares a structured SRV. Reading descriptor word 2 (NUM_RECORDS) as ordinary data can also stop translation. Native stride alone cannot identify the view because a raw SRV can carry the same stride metadata.This change checks the original
PSV0declaration and the exact, statically addressed native table slot. A unique, single-register structured SRV with a matching native binding uses structured addressing. Each dword of a wide load gets its own record index and byte offset, including when the load crosses a record boundary. A use of the record count as ordinary data or through a phi obtains it fromGetDimensions. Loads that only need the descriptor handle omit that query. Raw, ambiguous, dynamically selected and mixed-consumer bindings keep their existing behavior.Relationship to other PRs
#984, opened while this branch was being verified, also splits each scalar dword address and covers flat vector loads, stores and atomics. It selects the structured path from table binding and aligned stride. The scalar address arithmetic overlaps. This patch adds the declaration and slot check and recovers the consumed record count for that same structured SRV.
#136 demonstrated the structured scalar case using native stride. #329 recovers counts for descriptors with no tracked resource consumer. #437 preserves raw scalar loads, and #953 uses a raw view to query size for a scalar consumer. The case here reads an element count from a declared structured view and addresses each scalar dword within that view.
Verification
ffe310e, all five new regression tests and the upstream stencil-export test passed with Windows SDK 10.0.26100.0dxil.dll. The broadervictory-shaderlibrary run passed 103 tests, with one benchmark ignored and 22 GPU or differential cases filtered.cargo clippy --locked -p victory-shader --all-targets --all-features -- -D warningspassed.c2e7254, two vertex shaders failed on the scalar descriptor-data read. Both translated and passed SDK validation on89b6c67. Each emitted one live count query and 21 dword loads split into record index and byte offset.89b6c67reproduced the three hardware-tested DXIL containers byte for byte.d2a4baecovered 25,694 inputs. Fifteen additional shaders passed SDK validation and all 21,971 previously valid shaders still passed. The emitted code changed for 18,136 of those previously valid shaders.Gameplay impact remains unverified.
@Zipettte on GitHub · 2026-11-24 14:54 UTC · original
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at
78c8078:cargo test -p victory-shaderpasses, 125 passed / 0 failed. Workspace baseline on main (ffe310e) was green on the same machine (342 passed).Tested with AI assistance (Claude).
@jeremygold02 on GitHub · 2026-11-24 15:47 UTC · original
I compared the same two mission vertex shaders on Windows 11 with Windows SDK 10.0.26100.0. The draw-entry observations for the affected slot are in the earlier verification on #136.
ffe310e(main)c42cbb0(#953)5011645(#984)78c8078(this PR)I also ran #984’s separate one-thread buffer-read regression on a physical RTX 5070. I restricted the test adapter loop to hardware and checked the device LUID’s adapter description before dispatch. Both scalar and flat vector reads returned the expected word at all nine offsets across three 56-byte records. That fixture covers a distinct case worth retaining alongside the count-consuming shaders here. The mission shaders were translated offline.
@jtrudeau1530 on GitHub · 2026-11-24 16:39 UTC · original
Validated this exact change (
78c8078a) locally on RX 7900 XT / RADV under Wine 11.18 and vkd3d-proton 3.2.0. The test base also contains the mapped-copy fix and #1056; no title-derived fixtures were used.A synthetic scalar-buffer fixture passed 12 hardware dispatches with exact eight-word readbacks: stride 80, x2/x4 loads across record boundaries at byte offsets 76 and 156, a count-derived last-record address, both count-guard outcomes, and raw-buffer controls with the same native stride. Canary words remain intact. The raw count remains refused rather than being inferred from stride. Microsoft DXIL validator release 1.7.2308 was required and passed.
The identical declaration/count fixture on the test-only parent reproduces the original scalar-memory-read refusal; the patched candidate passes. This establishes those scalar cases, not full game correctness or performance.
@Ctrl-Alt-Haze on GitHub · 2026-11-24 16:51 UTC · original
Independent verification at
78c8078on Windows 11, RTX 5070 Ti (driver32.0.16.2135) + WARP (VICTORY_D3D12_DEBUG=1), dxil.dll1.8.2502.11, Rust1.98.1againstupstream/main(ffe310eb):ffe310eb;cargo xtask policy:154 files ok; bothclippychecks pass.cargo test --workspace --locked: 347 passed, 0 failed, 6 ignored.victory-shader --features host(VICTORY_D3D12_DEBUG=1, RTX 5070 Ti &VICTORY_WARP=1): 125 passed, 0 failed, 1 ignored (0 D3D12 debug errors/warnings).victory-gpu --features diagnostics(VICTORY_D3D12_DEBUG=1, RTX 5070 Ti &VICTORY_D3D12_WARP=1): 53 passed, 0 failed, 1 ignored (0 D3D12 debug errors/warnings).unsafeadded;PSV0+ unique static slot check + wide-load dword splitting avoids the rawbytes/4NUM_RECORDSmismatch in#953(note textual conflict with#953inlower.rs— prefer#995).AI-assisted verification on local RTX 5070 Ti + WARP; no game data.
@sinan-cmyk on GitHub · 2026-11-24 19:50 UTC · original
Offline measurement on a retail dump, and the shader tests on Ada
Result: +15 programs over
main, 0 lost.Offline. I merged head
78c8078ontomainffe310e(clean merge) and ranvictory translate --validate --listonshaders.rpf(1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result withmainprogram by program (25,889 programs). Validated: 21,724 onmain, 21,739 with this PR.mainAll 15 are among the programs that #1319 gains. Another 114 programs move from "a scalar memory read as data" on to "a descriptor's address or format read as data". That is the reason #1597 targets, and I'm measuring this PR stacked on #1597.
Tests: with the same merge,
cargo test --locked -p victory-shader --libpassed 125, failed 0. The bitcode benchmark is ignored, as onmain, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, withVICTORY_WARPunset.No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
@anlnimus on GitHub · 2026-11-24 20:33 UTC · original
Hardware note from testing on AMD Radeon RX 6900 XT (RDNA2), Adrenalin driver
32.0.21045.16010, Windows 11 Pro (10.0.26200):While verifying structured SRVs on hardware in a local integration build (
#986+ #995-style lowering), reading a structured heap SRV (StructureByteStride > 0) through a raw DXILByteAddressBufferhandle returned all zeros on RX 6900 XT (even where WARP / NVIDIA tolerate the view/resource kind mismatch). Lowering scalar buffer loads on structured table SRVs with a matchingStructuredBufferhandle ((12, stride)+UDiv/URemelement indexing) returned the exact expected bytes on RX 6900 XT.This directly supports #995's motivation on AMD RDNA2 hardware. (No game assets or dumps attached; tested with AI assistance.)
@Marvisak on GitHub · 2026-11-25 00:29 UTC · original
Automated triage for the maintainers. Closing because this change is already in
main, ormainhas since replaced the code it patches.Structured addressing for scalar loads chosen from PSV0, and record counts: main settled this the other way (scalar loads read raw views by byte address, emit/mod.rs notes) and reads record counts through getDimensions (
75677cb8).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.
@sinan-cmyk on GitHub · 2026-11-25 01:45 UTC · original
Stacked results
mainthis PR gained 15 programs, and all of them are among #1319's gains (inside #1402).The merge with #1402 conflicts in 4 hunks (
emit/lower.rs,emit/mod.rs). In two places the intents contradict each other:s_buffer_loadarm, the view becomes structured if this PR's record-count and declaration conditions hold. Otherwise it stays #953's raw view.This PR's test
scalar_table_record_count_requires_an_exact_unambiguous_declarationexpects a refusal, but with #953 the merge falls back to a raw view. I had to relax that test to merge. On the merge,cargo test --locked -p victory-shader --lib: 142 passed, 0 failed.Method:
victory translate --validate --listonshaders.rpf(1.0.2.1), dxil.dll 1.8.2502.11, compared program by program (25,889 programs). AI-assisted (Claude Code). No shader names or data are included, per the asset policy.Pull request closed