[GH #979] Shaders: a scalar memory read as data (771 programs) - scalar use points infer the descriptor view, +231 DXIL offline #979
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Imported from Marvisak/VIctory. Originally posted by bittertea0323 on 2026-11-24T14:37:08Z.
Upstream labels: bug, triage: needs info, area: shader
What
a scalar memory read as datais the largest single translation failure class in the corpus — 771 of 26,084 programs offline. I diagnosed which of its three return points produces them and found a fix that clears the class and raises DXIL emission by 231 programs.Diagnosis
Splitting the three returns (
descriptor_data: non-register operand / unusual load width / use-instruction kind) into distinct messages and re-running the batch puts all 771 on the third one. A second split of that branch by instruction prefix shows the use instruction is always ans_operation — never an image or buffer access, and never anothers_loadors_buffer_load.So these programs read a descriptor's words as data (dimension or address arithmetic) and never sample or store through it. The lowering insisted on an image/buffer use point to learn the view's kind, and refused the program when the only use was scalar.
Fix
That branch now infers the view from the used-resource entry the load falls in — the same way the "no use point at all" path already does:
0x409, kind 4)Sizes are rebuilt through
getDimensionsand written back as the descriptor's dwords.Measured offline
victory translateover the title's shader container dump (26,503 containers / 26,084 programs), release build, same host, both runs:emit: a scalar memory read as dataemit: a descriptor's address or format read as data+231 programs (mesh +166, vertex/pixel +57, compute +8).
The last row is the next failure being exposed, not a regression: those programs now translate further and reach the address/format class, which is a different problem — those dwords genuinely have no host value. It becomes the second largest class at 589.
Not measured
Patch is on our fork (
try/pr89, commit0691fdb); happy to open a PR on request.Imported from Marvisak/VIctory. Originally posted by Machad3x on 2026-11-24T14:48:53Z.
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.Imported from Marvisak/VIctory. Originally posted by bittertea0323 on 2026-11-24T14:56:36Z.
Thanks for the independent measurement — and especially for the 0 → 4 → 19 of 21 on mesh programs, which is
further than we got.
Two notes on how our 771 → 0 relates to your path, so the two are not confused:
s_buffer_load. It infers the view from the used-resource entry the loadfalls in (8-dword descriptor → 2D image, 4-dword → structured buffer when the stride is known, raw
otherwise) and rebuilds the sizes through
getDimensions, applied at both the "no use point" and "scalar usepoint" branches. The class went 771 → 0 over 26,084 programs and DXIL emission rose by 231 (mesh +166,
vertex/pixel +57, compute +8). So it likely overlaps your #953 result rather than stacking with it — worth
knowing before someone adds both.
descriptor's SGPRs for loaded data, so a "join" of that descriptor is reached with data the translator no
longer tracks. That is very likely the remaining gap between 4/21 and 19/21, and it is not something our
branch attempts.
If you can say which function that second change touches, I can try it on our corpus (26,503 containers,
NVIDIA 4070 SUPER, offline) to see whether it clears an existing class or adds a new one, and post the numbers
on your branch. That would give the two of us a clean A/B across two different corpora.
Also worth flagging for whoever reads this later: our runs show #189 (wave64 emulation) adds 26 new failures
(14 "LDS accesses without a uniform LDS fence in split wave64", 12 "a cross-lane wave operation in divergent
control flow") — so a mesh-emission count measured on a tree with #189 is not directly comparable to one
without it unless both are stated.
Imported from Marvisak/VIctory. Originally posted by Machad3x on 2026-11-24T15:25:03Z.
Offline measurement over 78 console shader containers dumped from an RTX 3080 Ti world run (fork github.com/Machad3x/VIctory branch claude/gta6-shader-translation-crashes-705550): validated programs went from 30 to 48 of 78 with: #621 (packed input padding), #563 (cube gradients, 3 hunks resolved), #683 (zero the unavailable FMA half), plus three changes of ours: (1) a resource-heap descriptor read only for its size gets a type (2D SRV for 8 dwords, raw buffer for 4; a shortcut that reads garbage if the real view is another kind), 14 'descriptor read only as data' failures mostly gone; (2) signature rows keep the module's metadata order instead of sorting by register (the validator rebuilds ISG1/OSG1 from metadata order; fixed 3 validator errors 'Container part Program Output Signature does not match', unit test added); (3) sub-dword buffer loads and stores (byte/ubyte/sbyte/short/ushort/sshort): loads read the aligned dword and shift, stores clear and set the field with two atomics (two lanes writing halves of one dword at once can lose a half). Mesh 19 of 21 emitted and validated, compute 4 of 4. Still failing: compute address groups (12 + 8; need #667/#710-style root views, which conflict with #294), 6 sampler-heap descriptor dwords read as numbers, 4 mesh descriptors computed by v_sub_f32/v_fmac_f32, 2 unknown stride, 2 other.
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-24T17:18:53Z.
Cross-checked all three
Lower::descriptor_datafailure slices raised here (s_buffer_load*Fields::Smem+dword 2size read, twins_load_dword*to the same 32-byte heap slot, and pures_load_dwordx4/x8/x1size queries backed only byUsedResource) against#953,#1067, and#1130, and verified a combined branch on NVIDIA GeForce RTX 5090, D3D12 WARP, anddxil.dll:fuzeofficlal/VIctory@66a9fde(fix/descriptor-data-infer-view-979).Key subtleties uncovered during GPU +
dxil.dllverification:Fields::Smem(s_buffer_load*):Lower::smemonly emits a raw SRV(11, 0)whenused.is_some_and(|u| u.kind == ResourceType::Srv), and declares CBV(13, 0x1_0000)whenusedisSome(Cbv)orNone— sodescriptor_datamust requireSome(Srv)(and keepuav = false) to avoid emitting conflicting CBV + SRV handles on the same slot.UsedResourcefallback: Matchingb.offset + 4 * other_first == (a.offset & !31)preserves exact 1D/2D/3D/Array/Typed dimensions when another load accesses the same 32-byte entry, while keepingsite's ownfirst = 0andin_slot = (a.offset & 31) / 4.UsedResourcefallback: Checkingin_slot + count <= u32::from(used.dwords)and restricting 4-dword raw buffers toused.stride == 0supports narrowed+0x08single-dwordNUM_RECORDSloads while preventing non-multiple-of-4 structured strides from silently returning byte counts instead of element counts.Imported from Marvisak/VIctory. Originally posted by EduAzevedo on 2026-11-24T17:32:47Z.
finding: "a descriptor's address or format read as data" can't be fixed from host view dimensions. Programs read real V# fields that a host view doesn't have.
Where:
crates/victory-shader/src/emit/lower.rs,descriptor_data, theNone =>arm that storesVal::Missing(OTHER). That function rebuilds only the size fields (image dwords 1–4, buffer dword 2) fromgetDimensions.How it was measured: I ran
victory translate --jobs 8offline on all 26,148 programs of a retail dump, twice:main(ffe310e);mainwith only Machad3x'sbc2b1b5(#979) cherry-picked.0691fdbfrom the issue body is no longer ontry/pr89.A local, uncommitted census renamed each
OTHERrefusal by dword index and by the first instruction consuming that dword. Only counts are given here.On main: 92 programs
s_cmp_lt_u32 dword1, 0x1000000, i.e. "is the stride below 256?".v_writelane_b32.With #979: about 600 programs, matching the issue's 92 → 589. Almost all are raw buffers (kind 11, which #979 gives
s_buffer_loadsites).s_bfe_u32 …, 0x80010,s_and_b32 …, 0xff0000,s_cmp_eq_u32 …, 0x80,s_cmp_lt_u32 …, 0x1000000; a few test bit 8 or bit 20s_and_b32 …, 0x100000: bit 20 of the base address; a few test bit 8s_and_b32 …, 0x100: bit 8, inside dst_sel_z; or the whole dword viav_writelane_b32v_writelane_b32Why it matters: these bits pick the program's path, and a ByteAddressBuffer view has no stride, address or dst_sel. Synthesising them, for example
stride << 16with a made-up stride, would be a guess. Rebuilding more fields from the host view can't fix this class.The fix that looks correct is to give the program the descriptor's real dwords: the runtime already reads them from title memory to build the views, so they could be passed to the program. That changes the root signature and how the translator and runtime hand off descriptors, so it needs a maintainer's call before anyone writes code.
Needs: game files for the census; any GPU, since the census is offline. AI-assisted measurement, run on my own dump.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T07:00:18Z.
Automated triage for the maintainers.
The 2026-11-25 13:04 correction is right about
main(da82e44). Incrates/victory-shader/src/emit/lower.rs,descriptor_datareaches its use-pointmatchonly throughuse_of, which keeps descriptors withRole::Resource. Incrates/victory-shader/src/resource.rs, that role is given only to image instructions, buffer instructions (except_inv) ands_buffer_*loads. TheFields::Image,Fields::BufferandFields::Smemarms cover all three, so the final_ => Err("a scalar memory read as data")cannot be reached. A descriptor that is used only by scalar ALU instructions goes toview_addressesinstead, which reports "a descriptor read only as data".So the branch this issue diagnosed (from
ffe310e) no longer exists in that form. On currentmain, "a scalar memory read as data" can only come from the first two returns ofdescriptor_data: no SGPRdataoperand, or a scalar memory instruction other thans_load_dword/x2/x4/x8/x16. The commit in the body is also gone from the fork.To settle what is left, run
victory translateover the corpus on currentmainand post the counts for "a scalar memory read as data", "a descriptor read only as data" and "a descriptor's address or format read as data". Counts only, nothing from the title. The open PR #1083 names each scalar read and would show which return is hit. If a gap remains, a PR rebased onmainis welcome; pull requests are open to everyone.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by Dathinel on 2026-11-25T13:02:57Z.
@bittertea0323 are you planning to open the PR Marvisak asked for above?
0691fdbis no longer on your fork, so nobody else can pick it up from there.If you would rather not, I can rebuild the remaining case on current
main(940d32f): indescriptor_data, when the descriptor's use is a scalar ALU instruction, take the view's kind from the used-resource entry the way theFields::Smemarm andview_addressesalready do (constant buffers still refused). Your diagnosis would be credited in the PR, and it would come with a synthetic regression test for a size read through scalar arithmetic. I cannot rerun your corpus numbers; the PR would say so and leave both rows (this class and "a descriptor's address or format read as data") to someone who can.I'll wait for your answer before opening anything. AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by Dathinel on 2026-11-25T13:04:08Z.
Correction to my offer above, after reading
main(940d32f) more closely: the case I offered to rebuild cannot occur there.descriptor_data(crates/victory-shader/src/emit/lower.rs), the arm that takes the kind from the use point is reached only throughuse_of, which keeps descriptors withRole::Resource.resource.rsgives that role only to image instructions, to buffer instructions (except the_invones) and tos_buffer_*. Thematch &ui.fieldscovers exactlyFields::Image,Fields::BufferandFields::Smem, so its final_ => Err("a scalar memory read as data")(line 4113) is unreachable today. A use that is only scalar ALU never becomes ause_at: it goes toview_addresses, which reports "a descriptor read only as data".smemsends every scalar memory instruction that is nots_buffer_load_dword*, and does not come from the code, user data or memory, intodescriptor_data. So any "a scalar memory read as data" left on currentmaincomes from one of its first two returns: line 4005, where the instruction has no SGPRdataoperand, or line 4013, where the name is nots_load_dword,x2,x4,x8orx16(for example ans_scratch_load_*,s_atomic_*ors_store_*reaching this path).Which of the two the remaining programs hit needs a corpus run on current
main; #1083's per-read names would show it directly. I don't have the corpus, so I'm not opening a PR for this. bittertea0323's inference from the used-resource entry may still be the right fix for whatever is left, but only once the run shows which return it is. Code reading only, nothing executed. AI-assisted (Claude Code).