Shaders: read the per-stage root layout of console shader containers #2217
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2217
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2217/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?
@CharlyRien on GitHub · 2026-11-25 10:04 UTC · original
CharlyRien:pr/fssm-root-layout→main· +329 −0 · 2 files · 1 commits · merged 2026-11-25 18:37 UTCEvery stage of a console shader container (FSSM) carries a record that says where the program expects each root argument and the descriptor heaps' addresses in its user data, and which resources it uses. XCL does not read it today: it derives the placement from the root signature. This PR adds a bounds-checked parser for those two tables and prints them in
xcl disasm, so a placement question can be answered from the container instead of from a game run. It changes no binding or translation behaviour; nothing outsidexcl disasmcalls the parser yet.Part of #697. The type-5 / type-6 entries (view-heap and sampler-heap address) are what #1803 places after the root arguments: in the title I checked they always come right after the last argument, the view heap's first. I first posted the format on #724 (#724).
The format (record at the stage descriptor − 0x40; offsets relative to FSSM+0x10):
u32 type | u32 offset in the table (dwords) | u32 user SGPRs | u32 base register | u8 first user-data dword | u8 root slot | u16 0. Types: 0 constants, 1 root descriptor, 3 descriptor table (one entry per range), 4 static sampler, 5 view-heap address, 6 sampler-heap address.u8 kind (0 SRV, 1 sampler, 2 CBV, 3 UAV) | u8 root type | u16 0 | u32 table offset | u32 register | u32 ? | u8 descriptor dwords | u8 first user-data dword | u8 root slot | u8 0.s(i)in CS, VS and PS stages ands(i+8)in NGG (mesh) stages.xcl disasmprints the register only for those stage types; ES / GS / LS / HS were not checked.How it was worked out: a standalone decoder over every stage of a retail title's shader pack. Every count reads in bounds, no type outside the list above appears, and every used-resource entry agrees with the root-layout entry of its slot. The NGG
+8and the CS mapping were checked against the disassembled code of a few programs. Where these tables exist and what the fields mean, I first learned from reading the container parser of the VIctory project (GPL-3.0) as a reference. No code was taken from it: the byte layout above was worked out from the data by a decoder written without its source, and this parser was written from that layout.Example output (synthetic):
What is in it
crates/xcl/src/gpu/xbox.rs:root_layout(fssm, stage) -> Result<RootLayout, String>(root slots with type, first dword and SGPR count; the view-heap and sampler-heap dwords; static sampler count; used resources),user_sgpr(hw, dword); an unreadable table (count over 4096, offset or size outside the FSSM, unknown type or kind) is an error, never a panic. Unit tests on synthetic containers: a compute layout, a mesh layout with both heaps (s23 / s24), the empty case, and the error cases (truncated table, count overflow, offset out of bounds including an offset that overflows, unknown type / kind / root type, a descriptor too close to the start).crates/xcl/src/disasm.rs:xcl disasmprints the layout under each hardware stage, and the first 8 used resources (all with--hex, as for the header dump).Tested
rustc 1.100.0 (0ef1bc386 2026-11-09).cargo build -p xcl(debug): builds, no new warning.cargo test -p xcl --lib gpu::xbox:::test result: ok. 12 passed; 0 failed; 0 ignored; 0 measured; 1115 filtered out(the 3 new tests:reads_the_root_layout_of_a_compute_stage,mesh_stage_heaps_follow_the_arguments,bad_root_layouts_are_errors).xcl disasmon three containers of the retail title's pack (one CS, two MS, kept locally): the printed layouts match the standalone decoder's output.cargo test --workspace -- --test-threads=4on this head, aftercargo build --workspace: 1157 passed, 0 failed, 46 ignored (21 test binaries). SKIPPED lines:Regression run
scripts/smoke.ps1 -Game <title folder>(default 60 s), same retail title and settings, release builds. The title run does not reach the changed code (onlyxcl disasmcalls the parser), so this checks that the build does not regress, nothing more.main(568e7db):This PR's head:
Not tested
xcl shadersdoes not print the layout (left for a follow-up if wanted).xcl disasmcalls it.AI use
🤖 Generated with Claude Code
@raylitebull on GitHub · 2026-11-25 10:49 UTC · original
Full diff review on
f3b66bd(crates/xcl/src/gpu/xbox.rs,crates/xcl/src/disasm.rs) looks clean: bounds-checkedroot_layout()/user_sgpr()with no binding/translation changes and 3 solid synthetic tests, and CI is green.Awaiting an independent verification check (including AMD) on
f3b66bdbefore merge.@luckyteagirl on GitHub · 2026-11-25 11:18 UTC · original
Independent AMD verification requested in the review discussion, on exact clean head
f3b66bd1cafd924ea354b9780734fddc7aeca159and main568e7db7729c8fa6c8f0f4b32d798faaf11462bb.Environment: Windows 11 build 26200; Ryzen 9 5980HX; Radeon RX 6800M (RDNA2), driver
30.0.13002.13003; Rust 1.99.0 MSVC; DXC/DXIL 1.9.2609.5;XCL_ADAPTER=6800M.cargo build --locked --workspace -j 2andcargo build --release --locked -p xcl -j 2: passed.cargo test --locked -p xcl --lib -j 2 gpu::xbox:: -- --test-threads=1 --show-output: 12 passed, 0 failed, 0 ignored; includes the three new root-layout tests.xcl disasm(debug binary) on three locally extracted, owned console shader containers (CS, MS, PS): exit0for each; each printed oneroot layout:line, none printedroot layout: not readable; CS and MS each printed eight resource lines (the default display cap), PS printed one. This checks real container parsing and output, not independent validation of every field's meaning. The private blobs and full disassembly stay local; none are attached.cargo test --locked --workspace --no-fail-fast -- --test-threads=4: across 21 targets, 996 passed, 161 failed, 46 ignored, six explicit SKIPPED lines. The failing library target contains the RX 6800M's D3D12 device-suspension cluster (0x887A0005); the full suite is not green on this driver.Paired guarded retail smoke: Same locally owned title (
title: 2ef5fd64), release binaries, 12 seconds, separate fresh XCL data/DXIL caches, networking off. Neither run hit the external memory guard. Onlyxcl disasmcalls the new parser, so the title run is a build regression check, not parser coverage.Main:
PR head:
AI assistance: OpenAI Codex (GPT-6; exact variant not exposed) prepared and ran the checks, inspected logs and exact revisions, and drafted this report.
@DavidM1911 on GitHub · 2026-11-25 16:07 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!