diff options
| author | Victor Garcia <victorgf2011@gmail.com> | 2026-11-23 01:44:40 +0100 |
|---|---|---|
| committer | Victor Garcia <victorgf2011@gmail.com> | 2026-11-23 01:44:40 +0100 |
| commit | 7c2252609d8f21dfe9f49d2b0cdf80cefc13b2f5 (patch) | |
| tree | 567269e052e5a0ec705d7214624d77724699cca5 /docs/d3d12_vulkan.md | |
| parent | aa2988cc555bad7ecd508b48a702adbb32fe7c95 (diff) | |
D3D-448: console root-argument layout, measured for compute and used 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>
Diffstat (limited to 'docs/d3d12_vulkan.md')
| -rw-r--r-- | docs/d3d12_vulkan.md | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/docs/d3d12_vulkan.md b/docs/d3d12_vulkan.md index 07db247b0..7dc16a001 100644 --- a/docs/d3d12_vulkan.md +++ b/docs/d3d12_vulkan.md | |||
| @@ -645,7 +645,8 @@ The compute path, end to end: | |||
| 645 | and an integer field outside 0..2^32−1 reads as 0. | 645 | and an integer field outside 0..2^32−1 reads as 0. |
| 646 | - Root signatures use the model already on `main` (`runtime/src/root_signature.h`, `rt::rootsig`): `parse_rts0` | 646 | - Root signatures use the model already on `main` (`runtime/src/root_signature.h`, `rt::rootsig`): `parse_rts0` |
| 647 | reads the serialized blob and `pack()` lays out the 32 user-data dwords by the section 3.5 default mapping, | 647 | reads the serialized blob and `pack()` lays out the 32 user-data dwords by the section 3.5 default mapping, |
| 648 | refusing anything that would spill. | 648 | refusing anything that would spill. `pack_stage()` lays them out in the console layout of one stage (section 3.5, |
| 649 | D3D-448); the compute bind point uses it. | ||
| 649 | - **GPU address arena** (section 3.3, when the device has `bufferDeviceAddress`): one host-visible, | 650 | - **GPU address arena** (section 3.3, when the device has `bufferDeviceAddress`): one host-visible, |
| 650 | device-addressable buffer, 256 MiB by default (`LEONIDA_ARENA_MB`, at most 4095 MiB, so every VA fits 32-bit | 651 | device-addressable buffer, 256 MiB by default (`LEONIDA_ARENA_MB`, at most 4095 MiB, so every VA fits 32-bit |
| 651 | table pointers). | 652 | table pointers). |
| @@ -654,8 +655,11 @@ The compute path, end to end: | |||
| 654 | so descriptor bytes the application writes itself are what shaders load. | 655 | so descriptor bytes the application writes itself are what shaders load. |
| 655 | - Upload and readback buffers keep their own memory, and their VA is their device address minus the heap base. | 656 | - Upload and readback buffers keep their own memory, and their VA is their device address minus the heap base. |
| 656 | - Shader programs (FSSM blobs) are copied in as the code base. | 657 | - Shader programs (FSSM blobs) are copied in as the code base. |
| 657 | - **`CreateRootSignature`** parses the blob with `parse_rts0` and keeps each parameter's place from `pack()`; a | 658 | - **`CreateRootSignature`** parses the blob with `parse_rts0` and keeps each parameter's place in two layouts: |
| 658 | signature `pack()` refuses (more than 32 user dwords: the spill layout is open) is refused with its reason. Before | 659 | `pack()` for the graphics bind point and `pack_stage(Stage::Compute)` for the compute one (from s4, one dword per |
| 660 | table; section 3.5, D3D-448). A signature neither can place (the spill layout is open) is refused with both | ||
| 661 | reasons; one only a single layout places is created with a log line, and binding it at the other bind point | ||
| 662 | invalidates the list. Before | ||
| 659 | that it answers as the host runtime does (`compare_invalid_arguments`, "root signature:", RTX 5070 / 621.14): | 663 | that it answers as the host runtime does (`compare_invalid_arguments`, "root signature:", RTX 5070 / 621.14): |
| 660 | `S_FALSE` for a null output whatever the blob, then `E_INVALIDARG` for a node other than node 0 or a DXBC | 664 | `S_FALSE` for a null output whatever the blob, then `E_INVALIDARG` for a node other than node 0 or a DXBC |
| 661 | container whose size (the dword at +24) is not the size passed. | 665 | container whose size (the dword at +24) is not the size passed. |
| @@ -1438,6 +1442,34 @@ Measured on the corpus (`python -I tools/user_sgpr_census.py <spirv/index.json> | |||
| 1438 | 1442 | ||
| 1439 | Taken together this disagrees with the packing above (from s0, two dwords per table) and is consistent with a per-stage base (s8 VS/PS, s4 CS, s16 MS) and one dword per table pointer. It is a census of shader reads, not a confirmed mapping: it does not show which root parameter feeds which SGPR, and the GS behave differently. `--expect ps=8 vs=8 cs=4 ms=16` turns it into a check; `tests/test_user_sgpr_census.py` shows that the two packing models give different results. | 1443 | Taken together this disagrees with the packing above (from s0, two dwords per table) and is consistent with a per-stage base (s8 VS/PS, s4 CS, s16 MS) and one dword per table pointer. It is a census of shader reads, not a confirmed mapping: it does not show which root parameter feeds which SGPR, and the GS behave differently. `--expect ps=8 vs=8 cs=4 ms=16` turns it into a check; `tests/test_user_sgpr_census.py` shows that the two packing models give different results. |
| 1440 | 1444 | ||
| 1445 | **Console layout, measured for compute (D3D-448).** `rt::rootsig::pack_stage` lays the parameters out for one stage: | ||
| 1446 | in root order from the stage base, each while it fits whole, a constant taking one dword per value, a root | ||
| 1447 | CBV/SRV/UAV two (its 64-bit VA), a descriptor table **one** (the 32-bit VA of its first descriptor; the heaps live | ||
| 1448 | below 4 GiB). A parameter that does not fit goes, with every later one, to the spill array behind `s[0:1]` | ||
| 1449 | (section 7), which is not modelled, so such a signature is refused. How each part is known: | ||
| 1450 | - **Compute, base s4: measured three ways.** | ||
| 1451 | - The console compiler's output (section 7). | ||
| 1452 | - The package's FidelityFX DLL, whose 29 compute containers carry their `RTS0` next to the console-compiled | ||
| 1453 | program (`tools/rootsig_census.py <fspx> --disasm <fspx>/disasm`, Xbox Series 1.0.2.1). Base s4 plus the | ||
| 1454 | signature's span in this layout equals the program's RSRC2 `USER_SGPR` count in 29 of 29: 27 signatures | ||
| 1455 | (table, table, four root CBVs) span 10 dwords and launch with 14 user SGPRs, 2 (table, table, one root CBV) | ||
| 1456 | span 4 and launch with 8. The `pack()` layout spans 12 and 6, two short of both. | ||
| 1457 | - The reads: `tools/root_sig_contract.py <fspx index.json> --rootsig <that shape> --model console` finds all 20 | ||
| 1458 | translated programs compatible (tables read at s4/s5 as 32-bit pointers, each root CBV's VA copied whole as | ||
| 1459 | two dwords from s6). The `pack()` layout contradicts 7 of them, which read the second table at s5, the first | ||
| 1460 | table's high half in that layout. | ||
| 1461 | - **Vertex/pixel/geometry s8 and mesh s16: a hypothesis.** It rests on the census above only; no signature | ||
| 1462 | confirms these bases, and visibility is not modelled (every parameter takes its place in every stage). | ||
| 1463 | |||
| 1464 | The runtime uses the console layout for the **compute** bind point only. Graphics keeps `pack()`: every stage of a | ||
| 1465 | pipeline reads `s0..s31` from one push-constant block at offset 0 (`tools/rdna2spirv.py`, `ShaderUserData` in | ||
| 1466 | `runtime/src/vulkan_replay.h`), so a mesh shader (base s16) and a pixel shader (base s8) in one pipeline would need | ||
| 1467 | the same root argument at two offsets. That needs per-stage user-data windows in the translator's push-constant | ||
| 1468 | contract (D3D-448 follow-up). A root signature carries both layouts; one that only one of them can place is | ||
| 1469 | created, and binding it at the other bind point invalidates the command list (`Close` returns `E_INVALIDARG`). | ||
| 1470 | `s0..s3` of a compute dispatch are the driver's block; the layer leaves them zero (109 CS read `s1` as a constant, | ||
| 1471 | 42 `s3`; their meaning is open). | ||
| 1472 | |||
| 1441 | **Measured: a real signature beside the count it produced.** `tools/fspx_unpack.py` decodes `COMPUTE_PGM_RSRC2` of | 1473 | **Measured: a real signature beside the count it produced.** `tools/fspx_unpack.py` decodes `COMPUTE_PGM_RSRC2` of |
| 1442 | each of the 29 compute programs in `amd_fidelityfx_upscaler_xbox.dll`, and its `USER_SGPR` field is the count the | 1474 | each of the 29 compute programs in `amd_fidelityfx_upscaler_xbox.dll`, and its `USER_SGPR` field is the count the |
| 1443 | console launched the dispatch with. Every one of those 29 containers also carries an `RTS0`, which makes this the | 1475 | console launched the dispatch with. Every one of those 29 containers also carries an `RTS0`, which makes this the |