Shaders: handle s_buffer_load SMEM uses in descriptor_data (#798) #953
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!953
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/953/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?
@MartinIndra02 on GitHub · 2026-11-24 14:27 UTC · original
MartinIndra02:fix/shader-smem-descriptor-data→main· +46 −0 · 1 files · 1 commits · closed without mergingAddresses #798
Summary
In
crates/victory-shader/src/emit/lower.rs,descriptor_datapreviously matched onlyFields::ImageandFields::Bufferon the using instructionui, causings_buffer_load*(Fields::Smem) buffer descriptor uses to fall through toa scalar memory read as data.Handling
Fields::Smem { .. } if un.starts_with("s_buffer_load")as a raw buffer ((11 | u, 0), still refusingResourceType::Cbv) eliminates 100% ofa scalar memory read as data(771 -> 0) and immediately translates +231 shaders on build 1.0.2.1 (+166mesh,+57vertex/pixel,+8compute), while routing the remaining subset that readsdword 0/1(address/format) accurately toa descriptor's address or format read as data.Full-corpus A/B (
victory translateon retail 1.0.2.1, 26,084 programs)main(ffe310e)c42cbb0)12,231 / 14,02712,288 / 14,027+571,441 / 2,5821,449 / 2,582+88,214 / 8,7138,380 / 8,713+16621,88622,117+231a scalar memory read as data7710-771Verification (Windows 11, RTX 3080
621.24, Rust1.98.1)emit::lower::tests::s_buffer_load_descriptor_size_reads_as_data(covers bothResourceType::Srvlowering andResourceType::Cbvrefusal).@fuzeofficlalin #798 (32-byte view returned[86, 32], 48-byte view returned[86, 48]).cargo test -p victory-shader --lib -- --test-threads=1: 121 passed, 0 failed, 1 ignoredcargo clippy -p victory-shader --all-targets -- -D warnings(default +--features diagnostics): 0 warningscargo xtask policy: 154 files okAggregate counts only; no game data used. AI-assisted; all builds and tests executed on my machine.
@MichaelSmithAI on GitHub · 2026-11-24 14:42 UTC · original
On
c42cbb0, a second live scalar-load case passed on an RTX 4090 under Wine/vkd3d-proton 3.2. The raw table started at slot 1 with a different valid view in slot 0. A two-dword scalar load returned the expected words 86 and 87 from the selected view. The shader also stored the reconstructed view size between those words, giving[86, 32, 87]and[86, 48, 87]for the two view sizes. The original single-dword control passed on the same build.On
ffe310e, the same two-dword fixture stopped in lowering at byte 52 witha scalar memory read as data, before dispatch. This verifies table selection, both loaded words, and the live size in this compute case. The reported 231 additional programs are an offline emission count. Their runtime output remains unmeasured here.@Machad3x on GitHub · 2026-11-24 14:48 UTC · original
Offline measurement (fork github.com/Machad3x/VIctory branch claude/gta6-shader-translation-crashes-705550, tip 9018be9) over 78 console shader containers dumped from an RTX 3080 Ti world run (victory translate --list --validate): MESH programs emitted 0 of 21 on the branch without these changes; 4 of 21 after cherry-picking MartinIndra02's
c42cbb0(PR #953: a descriptor whose only use is s_buffer_load is a raw buffer; 'a scalar memory read as data' 25 -> 0); 19 of 21 (18 validated) after one more change: when the console reuses a dead descriptor's SGPRs for loaded data, a join of that descriptor's address/format dword with a data edge no longer refuses the program (the join reads undefined on that edge, like the lane-mask join already does; commit 9018be9, assumption: the value is only read on paths from the data edge). One of the newly emitted mesh programs (mesh f841ad74ec6e7367) fails DXIL validation: "Container part 'Program Output Signature' does not match expected for module". Remaining mesh failures: structured buffer of unknown stride (2), descriptor read from the first lane of computed VGPRs (4 by group count), descriptor partly joined by control flow (1). In the game (4-minute runs, wave64 mesh allowed by a diagnostics switch) the world still shows only the background plus the loading artwork; one run ended with a title fault writing to a reserved never-committed address.@Zipettte on GitHub · 2026-11-24 15:40 UTC · original
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at
c42cbb0:cargo test -p victory-shaderpasses, 121 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).Tested with AI assistance (Claude).
@adamdotpy on GitHub · 2026-11-24 15:48 UTC · original
Reviewed
c42cbb0here (Windows 11, Rust 1.98.1):cargo test -p victory-shader— 121 passed, 1 ignored. That agrees with @Zipettte's RDNA3 run, so the change is green on a second machine and a second vendor.The design reads right, and one detail in it deserves a sentence in the code, because it is what keeps the change honest: with
image: Nonethe only dword given a value is 2, and the tail loop insertsVal::Missing(OTHER)for every other dword — so a program that reads the address or format still stops, rather than silently reading a zero. That is the correct shape for "translate what can be proven".One question about dword 2 when the descriptor is structured.
getDimensions().xis the view's element count: for the raw view this arm asks for (11 | u, 0) that is bytes/4, while a console buffer descriptor's dword 2 is records of its STRIDE, so bytes/stride. For ausedentry withstride >= 4the two differ by the stride — 4× at stride 16. TheFields::Bufferarm already draws that distinction ((12 | u, stride)when the stride is usable), and since the handle here is only used forgetDimensions, taking(12 | u, stride)whenused.stride >= 4would give bytes/stride and cost nothing else.Why it matters: that count is usually a loop bound, and translation success proves the program lowered, not that its loop ends where the console's does. A GPU test in the style of
root_view_tests— structured view with a known stride,s_buffer_load_dwordof dword 2, store it, read it back — would settle which value the title's programs need. If a run in-game shows some of the +231 programs looping long or reading past their buffer, I would look here first.Two smaller things:
ResourceType::Cbvrefusal duplicates the one in theFields::Bufferarm; hoisting it above the match would cover every arm once.Fields::Smem), but names the dword instead of lowering it. If this merges, that arm is superseded and I will drop it — and the two will conflict textually indescriptor_data, so whichever lands second wants a rebase.@jebaczydow on GitHub · 2026-11-24 16:01 UTC · original
Offline count with this PR on top of the #439 stack (RTX 5070 Ti host, 32-lane waves)
Tree:
mainffe310e+ #439 (bf0f951) + #334, #578, #452 and #650. This PR applies cleanly on top of that.Input: the 6,633 mesh programs the title created in one run, from my own copy. Command:
victory translate --validate --host-lanes 32-32. Counts only.With this PR applied,
cargo test --workspace --lockedgives 395 passed, 0 failed, 6 ignored on the 5070 Ti.Not tested in a title run.
AI-assisted (Claude Code, Claude Opus 5.5).
@Ctrl-Alt-Haze on GitHub · 2026-11-24 16:51 UTC · original
Independent verification at
c42cbb0on Windows 11, RTX 5070 Ti + WARP (VICTORY_D3D12_DEBUG=1), dxil.dll1.8.2502.11, Rust1.98.1againstupstream/main(ffe310eb):ffe310eb;policy(154 ok), bothclippychecks,workspace(343 passed, 0 failed, 6 ignored),victory-shader --features host(121/0/1 ign RTX & WARP), andvictory-gpu --features diagnostics(53/0/1 ign RTX & WARP) all pass with 0 D3D12 errors/warnings.stride >= 4), loweringFields::Smemwith raw(11 | u, 0)causesgetDimensions().xto returnbytes / 4instead ofNUM_RECORDS(bytes / stride), and#953conflicts textually inlower.rswith#995(78c8078), which resolves structuredNUM_RECORDSviaPSV0proof + per-dword splitting.AI-assisted verification on local RTX 5070 Ti + WARP; no game data.
@ghost on GitHub · 2026-11-24 17:32 UTC · original
In-game result on AMD, which this PR hasn't had yet: RX 9060 XT (RDNA4, 64-lane waves), Windows 11, diag build. Tree: r4tedx's
integration/testersupdate 9 (94e0ea5, onmainffe310e) with this PR's code change fromc42cbb0hand-applied (6 lines; its test left out), against the same tree without it.VICTORY_HEAP_GUARD_FORM=uminin both (the tree's default form crashes AMD's compiler, see #293).910b4be059bfb28f321d411b20a35ef94e35b816f2f91d68(Per-frame means over the log's summary lines that name each program.) Offline over the title's shader file on the same tree: +269 programs translate, 0 lost, all of them previously "a scalar memory read as data".
Not shown: whether what they draw is correct (the presented image is still black on this tree).
AI-assisted (Claude Code, Claude Opus 5.5); no game data.
@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.descriptor_data handles s_buffer_load uses in main (Fields::Smem arm: structured by the used entry's stride, else raw;
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.
Pull request closed