Repository navigation
D3D-448: console root-argument layout, measured for compute and used there - #4312
Conversation
…there rt::rootsig::pack_stage() lays a root signature out for one stage the way the console compiler does: root order from the stage base, a table one dword (its 32-bit VA), a root view two, constants one per value, and the first parameter that does not fit refused (the spill array behind s[0:1] is not modelled). Compute (base s4) is measured: on the package's FidelityFX DLL, whose 29 compute containers carry their RTS0 next to the console-compiled program, base plus span equals RSRC2 USER_SGPR in 29 of 29, and root_sig_contract.py --model console finds all 20 translated programs compatible (the s0 model contradicts 7). VS/PS/GS s8 and MS s16 stay a census hypothesis. The compute bind point now uses this layout; graphics keeps pack(), since every stage reads one push-constant block and a mesh shader (s16) and a pixel shader (s8) would collide. A signature carries both layouts; binding it where its layout refused it invalidates the list. Test fixtures follow: the compute GLSL shaders read the new places, and the asm fixtures a D3D12 compute PSO runs are built with LEONIDA_USER_DATA_SHIFT=4 (compute_fixture.py shifts every SGPR and the RSRC2 user count), so the standalone harness keeps using them at s0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Kam471
left a comment
There was a problem hiding this comment.
Checked 7c225260 on Windows 11, RTX 5070 Ti:
tests/test_compute_fixture_shift.py-> 8 tests, OK;tests/test_root_sig_contract.py-> exit 0 (run withtools/onsys.path, as its import expects).root_signature_test.exe-> exit 0: per-stage packing checks pass, including compute budget 28 dwords (20 one-dword tables fit compute, whichpack()refuses at 40 dwords), 16 mesh tables exactly and the 17th spilling, zero-value/over-cost/too-many-parameter refusals.d3d12_compute_test.exe-> exit 0: CBVs, raw/structured/typed buffer SRVs with OOB zeroing and negative controls, and compute root constants + a root UAV + a descriptor table reached the shader through the arena; 64 elements matched in each of three dispatches.ctest -R 'root_signature|d3d12_compute'-> the two built tests passed;root_signature_oracleis not built by these targets (Not Run).git diff --checkclean.
No blocking issue.
|
Tested
AI-assisted review. |
|
Independent check of
This is the focused GLSL-backed runtime run plus the Python checks. AI-assisted (Codex). |
Flyander
left a comment
There was a problem hiding this comment.
Reviewed the current head 7c225260. The new compute root-argument offsets are used by the compute bind point, while graphics keeps its separately documented layout; spill cases fail closed. The measured signatures and focused tests support the one-dword table model. No blocking issue found.
|
Heads-up for when this lands: open PRs that add a D3D12 compute fixture without
AI-assisted (Claude Code). |
|
Tested Direct binding, on the GPU. A hand-written wave32 compute kernel, run through
So the per-stage bases and one-dword tables are modelled for every stage, while the runtime uses them only for compute, as the description says. Gap: ExecuteIndirect with a DISPATCH signature.
No game files. AI-assisted (Claude Code). |
|
Tested The PR's tests here: Independent check. We have a small synthetic Xbox-style title (our own code, no game files) that runs under
The second form was written before this PR, from the census alone. Each dispatch writes 1,024 texels that are compared with a CPU reference.
0 validation messages in every run. So a program written to the console layout by someone else, without knowledge of Graphics, for whoever takes the next step: the same title has a VS/PS pair that reads from s8 with one-dword tables. It stays wrong with this PR (graphics keeps One note for reviewers: on AI-assisted (Claude Code); run on this machine. |
|
Tested 7c22526 on NVIDIA GeForce RTX 4080, driver 617.42, Windows 11 (clang-cl cross-build): root_signature_test exits 0 with 40 PASS lines and no FAIL, including "pack_stage: compute budget is 28, not 32" and "pack_stage: a parameter that does not fit whole is refused and named" (the PR body says 56 checks; I count 40 printed lines). d3d12_compute_test, d3d12_fspx_compute_test, d3d12_set0_compute_test, d3d12_m4_compute_test and d3d12_subgroup_test exit 0 and print no pass summary, so only their exit codes are confirmed. d3d12_buffer_uav_test, d3d12_pipeline_library_test and d3d12_com_test were not run. AI-assisted. |
|
Tested
AI-assisted (Claude Code). |
|
@TortitasT, a follow-up to this PR rather than an overlap, as @KoertLichtendonk asked me to compare them here. #4312 is on #5792 changes only that fixture, to AI-assisted (Claude Code). |
…layout main's ItsNotRexed#4312 (D3D-448) gives a D3D12 compute PSO its root arguments from s4, a descriptor table as one 32-bit dword. cs_lanterns_rise.asm now count those user SGPRs in RSRC2 and start with moves that rebuild the layout the code was written for (the table as s[0:1] or s[4:5] with a zero high half).
…layout main's ItsNotRexed#4312 (D3D-448) gives a D3D12 compute PSO its root arguments from s4, a descriptor table as one 32-bit dword. cs_lanterns_bloom_h.asm, cs_lanterns_bloom_h_nobarrier.asm, cs_lanterns_bloom_v.asm now count those user SGPRs in RSRC2 and start with moves that rebuild the layout the code was written for (the table as s[0:1] or s[4:5] with a zero high half).
…layout main's ItsNotRexed#4312 (D3D-448) gives a D3D12 compute PSO its root arguments from s4, a descriptor table as one 32-bit dword. cs_lanterns_tiled.asm now count those user SGPRs in RSRC2 and start with moves that rebuild the layout the code was written for (the table as s[0:1] or s[4:5] with a zero high half).
… layout main's ItsNotRexed#4312 (D3D-448) gives a D3D12 compute PSO its root arguments from s4, a descriptor table as one 32-bit dword. cs_lanterns_rt_shadow.asm now count those user SGPRs in RSRC2 and start with moves that rebuild the layout the code was written for (the table as s[0:1] or s[4:5] with a zero high half).
… layout main's ItsNotRexed#4312 (D3D-448) gives a D3D12 compute PSO its root arguments from s4, a descriptor table as one 32-bit dword. cs_lanterns_samplers.asm now count those user SGPRs in RSRC2 and start with moves that rebuild the layout the code was written for (the table as s[0:1] or s[4:5] with a zero high half).
… layout main's ItsNotRexed#4312 (D3D-448) gives a D3D12 compute PSO its root arguments from s4, a descriptor table as one 32-bit dword. cs_lanterns_xy.asm now count those user SGPRs in RSRC2 and start with moves that rebuild the layout the code was written for (the table as s[0:1] or s[4:5] with a zero high half).
… layout main's ItsNotRexed#4312 (D3D-448) gives a D3D12 compute PSO its root arguments from s4, a descriptor table as one 32-bit dword. cs_lanterns_gbuf_decode.asm now count those user SGPRs in RSRC2 and start with moves that rebuild the layout the code was written for (the table as s[0:1] or s[4:5] with a zero high half).
… layout main's ItsNotRexed#4312 (D3D-448) gives a D3D12 compute PSO its root arguments from s4, a descriptor table as one 32-bit dword. cs_lanterns_rt_alpha.asm now count those user SGPRs in RSRC2 and start with moves that rebuild the layout the code was written for (the table as s[0:1] or s[4:5] with a zero high half).
ItsNotRexed#4312 moved the compute root arguments to start at s4 and updated cs_user_data.comp, cs_set0_sample.comp and cs_sg_probe.comp, but not this fixture, which still read the root UAV from pc.s[0], pc.s[1] (the driver's block, zero). d3d12_indirect_dispatch_count then failed on main with "count 0 update 1: host 6/10, layer 0/0, expected 6/10". Read it from pc.s[4], pc.s[5] and fix the header comment. Fixes ItsNotRexed#6162. Claim: ItsNotRexed#6089 (comment) AI-assisted (Claude Code).
Item: D3D-448 (claimed in #4084; my finding from the D3D-315 work, #4163).
What and why
rt::rootsig::pack()lays root arguments out from s0 with two dwords per descriptor table. The shader census indocs/d3d12_vulkan.md§3.5 points to a per-stage base and one-dword table pointers instead. If the game's signatures follow the console layout, every root argument lands at the wrong push-constant offset. This PR measures the console layout where it can be measured (compute), models it, and switches the compute bind point to it.Model:
rt::rootsig::pack_stage(sig, Stage)puts parameters in root order from the stage base, each while it fits whole:s[0:1]isn't modelled.Compute (base s4) is measured three ways, on my own Xbox Series 1.0.2.1 copy (counts only):
RTS0next to the console-compiled program. With the existingtools/rootsig_census.py --disasm, base s4 plus the signature's span in this layout equals the program's RSRC2USER_SGPRin 29 of 29:pack()spans 12 and 6, two short of both.tools/root_sig_contract.py --model console(new) finds all 20 translated FidelityFX programs compatible. Thepack()layout contradicts 7: they read the second table at s5, which that layout calls the first table's high half.Vertex/pixel/geometry (s8) and mesh (s16) stay a hypothesis from the census only. Visibility isn't modelled.
Runtime change: compute only
CreateRootSignaturebuilds both layouts.RootArgumentLayout::Parametergainscompute_offset, and the layout recordsgraphics_ok/compute_ok.pack(). Every stage readss0..s31from one push-constant block at offset 0 (ShaderUserData,rdna2spirv.py), so a mesh shader (s16) and a pixel shader (s8) in one pipeline would need the same argument at two offsets. That needs per-stage user-data windows in the push-constant contract, which I'll propose separately in D3D12 → Vulkan layer: critical path, who builds what, open methods #313 as a follow-up.ClosereturnsE_INVALIDARG).s0..s3of a compute dispatch are the driver's block and stay zero. 109 CS reads1and 42 reads3as constants; their meaning is open.Test fixtures
cs_user_data,cs_set0_sample,cs_sg_probe) read the new places: constants from s4, root views as pairs, tables as one 32-bit dword.cs_m4_fill,cs_m4_indirect,cs_buf_typed,cs_buf_counter, andcs_w64x_readlane/cs_wqm_w32ind3d12_subgroup_test) are built withLEONIDA_USER_DATA_SHIFT=4.compute_fixture.pyshifts every SGPR by 4 and raises the RSRC2 user count, so the thread-group IDs follow..asmsources are unchanged, so the standalone harness (check.py,run_gpu_tests.py) andtests/semantickeep running them with user data at s0.s[8:9]: s8 is the 32-bit VA, and s9 is a user dword the runtime leaves zero. A note in each header says so.Tested
NVIDIA GeForce RTX 4080, driver 621.24, Windows 11, MSVC 14.44, Vulkan SDK 1.4.363, LLVM 21.1.8
llvm-mc:ctestpasses 153 of 153 (gameinputis disabled here because SDL3 isn't installed);root_signature_test: 56 checks, including thepack_stagecases (the FidelityFX shape, stage bases, the 28/16-SGPR budgets, spill refusal);d3d12_compute,d3d12_fspx_compute,d3d12_set0_compute,d3d12_m4_compute,d3d12_buffer_uav,d3d12_subgroup,d3d12_pipeline_library,d3d12_com: all pass;python -I tests/test_compute_fixture_shift.py: 8 tests pass;tests/test_root_sig_contract.py: all functions and parametrized cases pass. I ran them through a small local harness because pytest isn't installed here; please let CI's pytest job confirm.tests/test_docs_links.pypasses.Overlaps: #3929 also edits
runtime/src/root_signature.{h,cpp}, and #3987 editstools/root_sig_contract.py. My changes there are additive. Whichever lands second may need a small rebase.AI-assisted (Claude Code). No game data: counts and signature shapes only.
🤖 Generated with Claude Code