shader: read a buffer descriptor with its stride cleared as the raw view (found on a game run) #157
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/157"
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 LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-26T22:03:27Z.
Found and verified on a real game run (Apple M5 Pro, 48 GB,
--console series-s): the dominant form of "a descriptor changed after loading" (#131), and its lowering. Two commits, the diagnostic first.1.
shader: name the operation and constants of a descriptor dword masked after loading. For a dword masked by a SOP instruction, the refusal now names the operation and its constant operands:... dword 1 masked or merged (s_and_b32 with 0xc000ffff), or(s_xor_b32 with computed values). The prefix is unchanged, so tallies still group them. The refusal type is&'static streverywhere, so the formatted texts are interned once each (resource::interned, a marked shortcut: a handful per title).On the game run, it showed:
dword 1 masked or merged (s_and_b32 with 0xc000ffff)dword 0 masked or merged (s_xor_b32 with computed values)dword 0 masked or merged (s_xor_b64 with computed values)dword 2 masked or merged (s_xor_b64 with computed values)0xc000ffffon buffer V# dword 1 keeps base_address[47:32] (bits 15:0) and the swizzle bits (31:30), and clears the stride (29:16): the title turns a structured view into a raw one.2.
shader: read a loaded buffer descriptor with its stride cleared as the raw view.base + sgpr_offset + inst_offset + vgpr_offset + index × stride, so with stride 0 the index adds nothing. Table 33: with stride 0, num_records counts bytes.Tracer::stride_clearedmatches a non-typed buffer access whose descriptor is 4 dwords of one load, except dword 1 =s_and_b32(loaded dword 1, c), whereconly clears stride bits.unstrided.lower.rsdrops its index, so it takes the existing raw path: the loaded view read at byte offsets.Tests.
gfx_refusal_tests::a_descriptor_with_its_stride_cleared_reads_the_loaded_view_raw:0xc000fffftranslates with idxen and with offen, and so does0xc03fffff.0xc000fffe(a base bit) and a format load stay refused. It fails on main.addr_tests::a_descriptor_with_its_stride_cleared_reads_the_view_raw_on_the_gpu, on Metal: a structured SRV with 16-byte elements and a raw UAV, read with idxen+offen through the cleared descriptor; each lane gets dwordlane. It fails without the fix, and with the index kept it fails on values ([3, 38, 73, …]).resource.rstests are updated to the new texts. No other test or doc used them.In game, same Mac, same setup, before and after: the
s_and_b32 … 0xc000ffffrefusals went from 7 to 1. The one left is in a guessed vertex+pixel pipeline (vertex a2217fcc62753463 pixel 7e3f953d03860288, code at 0x4e0c), most likely a typed load, which stays refused by design. The run still ends at the knownimage+0x55e56f8crash.victory-shader (261) and victory-gpu (224, arm64, Metal) tests, Windows clippy and
cargo xtask policypass.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-26T22:08:32Z.
Pushed
597ad90eafter a review pass: only a mask that clears the whole stride field (bits 29:16) lowers. A partial clear such as 0xc03fffff could leave a non-zero stride (16 survives it), and dropping the index would then read the wrong element. It is refused now, and the test pins it (it fails on the previous commit). The docs also note that the dropped index skips the console's OOB_SELECT 1 index check, under the same marked bounds guess. The in-game form 0xc000ffff is unaffected.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T22:39:23Z.
Review: APPROVED
Reviewed and tested together with the other open PRs on main (macOS x86_64 workspace tests, the setup shell tests, and Windows clippy). Thanks!