[PR #974] [MERGED] D3D-448-GRAPHICS: graphics root arguments in the console layout, mesh shaders through a window #1011

Closed
opened 2026-11-26 20:19:47 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/974
Author: @iFeyz
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @aslan2142

Base: main ← Head: feat/d3d448-graphics-root-layout


📝 Commits (7)

  • 5fdd6ab D3D-448-GRAPHICS: graphics root arguments in the console layout, mesh shaders through a window
  • 74e55ac D3D-448-GRAPHICS: a graphics signature past the console window keeps the PC layout instead of being refused
  • 161314c D3D-448-GRAPHICS: docs - what mesh shaders read below s16, counted on the corpus (#14 comment 7138532347): 3 of 9,282, one 32-bit constant each
  • c170c08 D3D-448-GRAPHICS: LEONIDA_GRAPHICS_ROOT_LAYOUT=pc puts every graphics signature back in the PC layout (diagnostic)
  • b2da1c0 D3D-448-GRAPHICS: a graphics signature past the console window logs its dwords per shader visibility
  • 00fc23b D3D-448-GRAPHICS: a graphics signature past the console window keeps its inline part; the rest goes to the argument block
  • b8563e9 Merge main into D3D-448-GRAPHICS (#974)

📊 Changes

15 files changed (+354 additions, -41 deletions)

View changed files

📝 docs/d3d12_vulkan.md (+29 -9)
📝 docs/design.md (+1 -1)
📝 runtime/CMakeLists.txt (+2 -12)
📝 runtime/shims/d3d12_com.cpp (+17 -0)
📝 runtime/shims/d3d12_com.h (+10 -4)
📝 runtime/shims/d3d12_vulkan_device.cpp (+23 -2)
📝 runtime/src/root_signature.h (+5 -2)
📝 runtime/src/shader_library.h (+9 -0)
📝 runtime/test/d3d12_mesh_test.cpp (+67 -6)
📝 runtime/test/glsl/ms_draw.mesh (+3 -2)
📝 runtime/test/glsl/ps_draw.frag (+1 -1)
📝 runtime/test/glsl/ps_image_atomic.frag (+1 -1)
📝 runtime/test/root_signature_test.cpp (+42 -0)
➕ tests/semantic/test_ms_root_window.py (+116 -0)
📝 tools/rdna2spirv.py (+28 -1)

📄 Description

Claimed in the coordination issue as: D3D-448-GRAPHICS (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7136707785)

What and why

The graphics bind point still laid root arguments out with pack() (from s0, two dwords per table), while the console
starts them at s8 for VS/PS/GS with one dword per table (census in docs/d3d12_vulkan.md 3.5, and @DadaCap's live
retail measurement in #14, comment 7131556366: the VS of a textured draw reads its tables at s8/s10, the PS at s9).
So on the retail frame loop no root argument reached a graphics shader. Compute already used the console layout
(D3D-448, 7c225260); graphics was held back because a mesh shader (s16) and a pixel shader (s8) share one
push-constant block. This adds the per-stage window that was missing and switches graphics over.

  • Translator (tools/rdna2spirv.py): user_data_dword() — a mesh shader loads s16..s31 from push dwords 8..23
    (root dword k sits at push dword 8 + k for every graphics stage), s8..s15 (below its base, not root data) as 0,
    s0..s7 unchanged. VS/PS/GS/CS are unchanged (SGPR i = push dword i). The index records
    "root_window": {"sgpr": 16, "dword": 8} on mesh shaders.
  • Runtime: CreateRootSignature builds the graphics layout with pack_stage(Stage::Vertex) and checks
    Stage::Mesh (RootArgumentLayout::mesh_ok); address() writes a table as one dword at both bind points;
    DispatchMesh with a signature past the 16-dword mesh window invalidates the list; a mesh PSO whose mesh shader
    has no root_window in the index (translated before this) is refused with a log line asking for the shaders stage.
  • Test fixtures: the GLSL stand-ins read the root arguments at push dword 8 + k; the M1.5/M2/M3 asm fixtures read
    their tables as one 32-bit dword from s8 (a short prologue rebuilds the 64-bit pair with a zero high half, as game
    shaders do; ps_m15/vs_m15 rewritten since s_getpc_b64 must stay first).
  • Docs: docs/d3d12_vulkan.md 3.5 and the CreateRootSignature bullet, the user-data row of docs/design.md,
    d3d12_com.h and root_signature.h comments.

Retail evidence: @DadaCap's boot-prototype branch (not for merge) switches the graphics layout to the same
pack_stage(Stage::Vertex) when its title window is active, and with it the title's first-run menu appears on screen
(@DesertGamer, RTX 5070, #14 comment 7134166197). This PR makes that layout unconditional, with tests, and adds what
the prototype does not have: the mesh window (there a mesh shader still reads its s16.. from push dword 16 while the
arguments sit at 8..) and the refusals for a signature or a mesh shader the window cannot serve.

Compatible with the spill block of ROOT-SIG-SPILL-MODEL (@djrolfes, #14 comments 7135596787 / 7135760764): every
graphics stage, mesh included, still reads s0..s7 from push dwords 0..7, so the block pointer in s[0:1] can be
written there for graphics as it will be for compute.

Open, not guessed: what a mesh shader reads in s8..s15 (it now reads 0). python -I tools/user_sgpr_census.py <spirv/index.json> --base ms=16 on a corpus lists any read below s16 — a run from someone with the package would
settle it. Visibility is still not modelled (D3D-318 measured one block in root order for VS/PS).

Coordination: touches CreateRootSignature and address() next to ROOT-SIG-SPILL-MODEL (@djrolfes, spill area
for compute); pack_stage and the spill refusal are unchanged here, so either rebases cleanly on the other. If
#424 (indirect mesh dispatch) lands, its path should check mesh_ok like DispatchMesh does.

Tested

  • Translator: python -I scripts/run_semantic_tests.py tests/semantic — 470 files, 6,147 tests, 1 file failed:
    test_image_cube_store_glc, the Windows LLVM_MC path split reported as TEST-CUBE-WINPATH (claimed by
    TimIdle; that file and the code it tests are untouched here). New
    tests/semantic/test_ms_root_window.py (4 tests: the dword mapping, a mesh shader as MeshEXT and with
    --mesh-compute run by the CPU interpreter, no window on other stages); it fails on main.
  • Runtime (Windows 11, MSVC 2022 Build Tools, RelWithDebInfo): ctest on main 1504c1af + this: 301 of 305 pass. The 4 failures are the same
    as on main here (d3d12_clear, d3d12_execute_indirect_validation, d3d12_texture_tiles,
    d3d12_pipeline_library_host, all already reported in #14); vk_queue_query_sync is flaky here on main too.
    d3d12_draw_test, d3d12_translated_draw_test (M1.5), d3d12_m2_textured_test, d3d12_m2_formats_test,
    d3d12_m3_frame_test, d3d12_mesh_test, d3d12_geometry_test, d3d12_depth24_draw_test and
    d3d12_bundle_test run on the GPU and match pixel-exact. d3d12_mesh_test adds the two refusals;
    root_signature_test adds the graphics-window cases.
  • scripts/check_no_game_data.py on every changed file, tests/test_docs_links.py,
    tests/test_text_write_line_endings.py, python -m compileall -q make_game.py tools tests.
  • Not tested: a retail boot (no game files here). A check on the frame-loop stack (#321 / #432) by someone who has
    it would show whether the black frame moves.

GPUs tested: AMD Radeon RX 9070 XT (RDNA4), AMD Windows driver 32.0.32029.2010 (Vulkan 1.4.359), Windows 11 26200

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/974 **Author:** [@iFeyz](https://github.com/iFeyz) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/25/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `feat/d3d448-graphics-root-layout` --- ### 📝 Commits (7) - [`5fdd6ab`](https://github.com/ubiquitarianism/leonida/commit/5fdd6abbc07a0b2e4120944b4e624e3a70ddb76e) D3D-448-GRAPHICS: graphics root arguments in the console layout, mesh shaders through a window - [`74e55ac`](https://github.com/ubiquitarianism/leonida/commit/74e55acfbcabb49e387625b14328af1b1309375d) D3D-448-GRAPHICS: a graphics signature past the console window keeps the PC layout instead of being refused - [`161314c`](https://github.com/ubiquitarianism/leonida/commit/161314c2660db1d6b240d3d03eebc4aa8736e391) D3D-448-GRAPHICS: docs - what mesh shaders read below s16, counted on the corpus (#14 comment 7138532347): 3 of 9,282, one 32-bit constant each - [`c170c08`](https://github.com/ubiquitarianism/leonida/commit/c170c08dfa64e4495b7e5037dc546a4383ba7d6e) D3D-448-GRAPHICS: LEONIDA_GRAPHICS_ROOT_LAYOUT=pc puts every graphics signature back in the PC layout (diagnostic) - [`b2da1c0`](https://github.com/ubiquitarianism/leonida/commit/b2da1c0add9009678130b9bf898f2e6b8a4ae30f) D3D-448-GRAPHICS: a graphics signature past the console window logs its dwords per shader visibility - [`00fc23b`](https://github.com/ubiquitarianism/leonida/commit/00fc23b9a9eeb1a75f1fec2b58024bea15c26663) D3D-448-GRAPHICS: a graphics signature past the console window keeps its inline part; the rest goes to the argument block - [`b8563e9`](https://github.com/ubiquitarianism/leonida/commit/b8563e949ed389fff20be91c73687a70b5213469) Merge main into D3D-448-GRAPHICS (#974) ### 📊 Changes **15 files changed** (+354 additions, -41 deletions) <details> <summary>View changed files</summary> 📝 `docs/d3d12_vulkan.md` (+29 -9) 📝 `docs/design.md` (+1 -1) 📝 `runtime/CMakeLists.txt` (+2 -12) 📝 `runtime/shims/d3d12_com.cpp` (+17 -0) 📝 `runtime/shims/d3d12_com.h` (+10 -4) 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+23 -2) 📝 `runtime/src/root_signature.h` (+5 -2) 📝 `runtime/src/shader_library.h` (+9 -0) 📝 `runtime/test/d3d12_mesh_test.cpp` (+67 -6) 📝 `runtime/test/glsl/ms_draw.mesh` (+3 -2) 📝 `runtime/test/glsl/ps_draw.frag` (+1 -1) 📝 `runtime/test/glsl/ps_image_atomic.frag` (+1 -1) 📝 `runtime/test/root_signature_test.cpp` (+42 -0) ➕ `tests/semantic/test_ms_root_window.py` (+116 -0) 📝 `tools/rdna2spirv.py` (+28 -1) </details> ### 📄 Description Claimed in the coordination issue as: D3D-448-GRAPHICS (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7136707785) ### What and why The graphics bind point still laid root arguments out with `pack()` (from s0, two dwords per table), while the console starts them at s8 for VS/PS/GS with one dword per table (census in `docs/d3d12_vulkan.md` 3.5, and @DadaCap's live retail measurement in #14, comment 7131556366: the VS of a textured draw reads its tables at s8/s10, the PS at s9). So on the retail frame loop no root argument reached a graphics shader. Compute already used the console layout (D3D-448, 7c225260); graphics was held back because a mesh shader (s16) and a pixel shader (s8) share one push-constant block. This adds the per-stage window that was missing and switches graphics over. - **Translator** (`tools/rdna2spirv.py`): `user_data_dword()` — a mesh shader loads s16..s31 from push dwords 8..23 (root dword k sits at push dword 8 + k for every graphics stage), s8..s15 (below its base, not root data) as 0, s0..s7 unchanged. VS/PS/GS/CS are unchanged (SGPR i = push dword i). The index records `"root_window": {"sgpr": 16, "dword": 8}` on mesh shaders. - **Runtime**: `CreateRootSignature` builds the graphics layout with `pack_stage(Stage::Vertex)` and checks `Stage::Mesh` (`RootArgumentLayout::mesh_ok`); `address()` writes a table as one dword at both bind points; `DispatchMesh` with a signature past the 16-dword mesh window invalidates the list; a mesh PSO whose mesh shader has no `root_window` in the index (translated before this) is refused with a log line asking for the shaders stage. - **Test fixtures**: the GLSL stand-ins read the root arguments at push dword 8 + k; the M1.5/M2/M3 asm fixtures read their tables as one 32-bit dword from s8 (a short prologue rebuilds the 64-bit pair with a zero high half, as game shaders do; `ps_m15`/`vs_m15` rewritten since `s_getpc_b64` must stay first). - **Docs**: `docs/d3d12_vulkan.md` 3.5 and the CreateRootSignature bullet, the user-data row of `docs/design.md`, `d3d12_com.h` and `root_signature.h` comments. Retail evidence: @DadaCap's `boot-prototype` branch (not for merge) switches the graphics layout to the same `pack_stage(Stage::Vertex)` when its title window is active, and with it the title's first-run menu appears on screen (@DesertGamer, RTX 5070, #14 comment 7134166197). This PR makes that layout unconditional, with tests, and adds what the prototype does not have: the mesh window (there a mesh shader still reads its s16.. from push dword 16 while the arguments sit at 8..) and the refusals for a signature or a mesh shader the window cannot serve. Compatible with the spill block of ROOT-SIG-SPILL-MODEL (@djrolfes, #14 comments 7135596787 / 7135760764): every graphics stage, mesh included, still reads s0..s7 from push dwords 0..7, so the block pointer in `s[0:1]` can be written there for graphics as it will be for compute. Open, not guessed: what a mesh shader reads in s8..s15 (it now reads 0). `python -I tools/user_sgpr_census.py <spirv/index.json> --base ms=16` on a corpus lists any read below s16 — a run from someone with the package would settle it. Visibility is still not modelled (D3D-318 measured one block in root order for VS/PS). Coordination: touches `CreateRootSignature` and `address()` next to ROOT-SIG-SPILL-MODEL (@djrolfes, spill area for compute); `pack_stage` and the spill refusal are unchanged here, so either rebases cleanly on the other. If #424 (indirect mesh dispatch) lands, its path should check `mesh_ok` like `DispatchMesh` does. ### Tested - Translator: `python -I scripts/run_semantic_tests.py tests/semantic` — 470 files, 6,147 tests, 1 file failed: `test_image_cube_store_glc`, the Windows `LLVM_MC` path split reported as TEST-CUBE-WINPATH (claimed by TimIdle; that file and the code it tests are untouched here). New `tests/semantic/test_ms_root_window.py` (4 tests: the dword mapping, a mesh shader as MeshEXT and with `--mesh-compute` run by the CPU interpreter, no window on other stages); it fails on `main`. - Runtime (Windows 11, MSVC 2022 Build Tools, RelWithDebInfo): `ctest` on `main` 1504c1af + this: 301 of 305 pass. The 4 failures are the same as on `main` here (`d3d12_clear`, `d3d12_execute_indirect_validation`, `d3d12_texture_tiles`, `d3d12_pipeline_library_host`, all already reported in #14); `vk_queue_query_sync` is flaky here on `main` too. `d3d12_draw_test`, `d3d12_translated_draw_test` (M1.5), `d3d12_m2_textured_test`, `d3d12_m2_formats_test`, `d3d12_m3_frame_test`, `d3d12_mesh_test`, `d3d12_geometry_test`, `d3d12_depth24_draw_test` and `d3d12_bundle_test` run on the GPU and match pixel-exact. `d3d12_mesh_test` adds the two refusals; `root_signature_test` adds the graphics-window cases. - `scripts/check_no_game_data.py` on every changed file, `tests/test_docs_links.py`, `tests/test_text_write_line_endings.py`, `python -m compileall -q make_game.py tools tests`. - Not tested: a retail boot (no game files here). A check on the frame-loop stack (#321 / #432) by someone who has it would show whether the black frame moves. GPUs tested: AMD Radeon RX 9070 XT (RDNA4), AMD Windows driver 32.0.32029.2010 (Vulkan 1.4.359), Windows 11 26200 AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:19:47 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#1011
No description provided.