Skip to content

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

Merged
aslan2142 merged 7 commits into
ProjectLeonida:mainfrom
iFeyz:feat/d3d448-graphics-root-layout
Nov 25, 2026
Merged

aslan2142 merged 7 commits into
ProjectLeonida:mainfrom
iFeyz:feat/d3d448-graphics-root-layout

Conversation

@iFeyz

@iFeyz iFeyz commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: D3D-448-GRAPHICS (#14 (comment))

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, 7c22526); 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 1504c1a + 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 Coordinating who works on what #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 ([draft, integration] retail boot to the frame loop on current main (RT-BOOT-INTEGRATION) #321 / d3d12_xs: fence slot 12 returns the address of a live completed value, again; the retail boot reaches its frame loop (RT-FENCE12) #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.

… shaders through a window

The graphics bind point 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 (the corpus census, and the retail frame loop reading
its tables at s8..s10). Compute already took the console layout (D3D-448);
graphics waited because a mesh shader (s16) and a pixel shader (s8) share
one push-constant block.

- translator: user_data_dword() - a mesh shader loads s16..s31 from push
  dwords 8..23, s8..s15 as 0, s0..s7 unchanged, so root dword k is push
  dword 8 + k for every graphics stage; index.json records the window as
  "root_window" on mesh shaders. VS/PS/GS/CS are unchanged.
- runtime: CreateRootSignature lays graphics out with
  pack_stage(Stage::Vertex) and checks Stage::Mesh (mesh_ok); a table is
  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 (translated before) is refused with a log line.
- fixtures: the GLSL stand-ins read the root arguments at push dword 8 + k;
  the M1.5/M2/M3 asm read their tables as one dword from s8.
- tests: tests/semantic/test_ms_root_window.py (MeshEXT and --mesh-compute
  on the CPU interpreter), graphics-window cases in root_signature_test,
  the two refusals in d3d12_mesh_test.
- docs: d3d12_vulkan.md 3.5, design.md user-data row.
@madhyn

madhyn commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Tested cherry-picking 5fdd6abbc onto our local frame-loop stack (Wine 11.22, RTX 3060 Ti, retail 1.0.2.1).

Before #974, CreateRootSignature succeeded on the title's startup root signatures (logging root signature usable for graphics only: root parameter 8 does not fit in the user SGPRs from s4 (spill array not modelled)) and the run reached the frame loop (1,675 PresentX ok in 60s).

With 5fdd6abbc applied, CreateRootSignature now refuses one of the startup root signatures:
[rt] d3d12: root signature refused: root parameter 8 does not fit in the user SGPRs from s8 (spill array not modelled) (compute: root parameter 8 does not fit in the user SGPRs from s4 (spill array not modelled))
followed immediately by an unhandled C++ exception (0xe06d7363, exit 99) before reaching the frame loop.

(Note: it also logged root signature too large for a mesh shader's root window: root parameter 2/5/7 does not fit in the user SGPRs from s16 on earlier root signatures.)

AI-assisted: yes

…the PC layout instead of being refused

Measured by madhyn on the retail title with this pull request (ProjectLeonida#974
review): one of its start-up root signatures is past the console's
inline graphics window (24 dwords from s8) and the compute one (28 from
s4), so CreateRootSignature refused it outright and the title stopped
with an unhandled exception before the frame loop it reached without
this change.

On the console such a signature goes to the argument block behind
s[0:1], modelled for compute only (ROOT-SIG-SPILL-MODEL, ProjectLeonida#1009). Until
it is for graphics, the graphics bind point keeps pack()'s layout for
it (from s0, two dwords per table), what the layer did before the
console layout, so no signature is worse off than on main. The new
RootArgumentLayout::graphics_console tells address() which layout the
table is in; a mesh shader still refuses such a signature.

d3d12_mesh_test: a 30-constant signature is created and DispatchMesh
with it invalidates the list.
@iFeyz

iFeyz commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

@madhyn thank you, that is exactly the run this needed. Fixed in 74e55ac: a root signature past the console's inline graphics window (24 dwords from s8) is no longer refused. On the console such a signature goes to the argument block behind s[0:1], which is modelled for compute only so far (ROOT-SIG-SPILL-MODEL, #1009); until it is for graphics, the graphics bind point keeps pack()'s layout for that signature (from s0, two dwords per table), which is what main does today, so no signature is worse off than without this PR. The log line is now root signature past the console's graphics window (...): graphics keeps the PC layout from s0 ..., and a mesh shader still refuses such a signature. d3d12_mesh_test covers a 30-constant signature (past both the graphics and the compute window): created, DispatchMesh with it invalidates the list. Full ctest on an RX 9070 XT: 301/305, the same four failures as on main.

If you can run the same cherry-pick of the new head on your stack, the question is whether it reaches the frame loop again, and how the PresentX / draw counts compare with your run before #974.

iFeyz added a commit to iFeyz/leonida that referenced this pull request Nov 24, 2026
…console window keep the PC layout)

# Conflicts:
#	runtime/shims/d3d12_com.h
… the corpus (ProjectLeonida#14 comment 7138532347): 3 of 9,282, one 32-bit constant each
@madhyn

madhyn commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Re-tested with 5fdd6abbc + 74e55acfb cherry-picked onto the same local frame-loop stack (Arch Linux, Wine 11.22, RTX 3060 Ti, retail 1.0.2.1; note: does not yet include RT-TITLE-HOST-REGION).

  1. CreateRootSignature is no longer refused: 74e55acfb logs root signature past the console's graphics window (root parameter 8 does not fit in the user SGPRs from s8 (spill array not modelled)): graphics keeps the PC layout from s0... and reaches the frame loop again (50,468 CreatePipelineState ok, 0 failed).
  2. Comparison vs. before #974:
    • Before #974 (60 s timeout, EXIT=124): 1,675 PresentX ok, 5,020 DrawInstanced, 3,350 ExecuteCommandLists ok (0 failed).
    • With 5fdd6abbc + 74e55acfb (EXIT=3): 2 PresentX ok, 2 DrawInstanced, 6 ExecuteCommandLists ok (0 failed), 0 DispatchMesh, then stops at the title's int3 (0x142474606 / 0x80000003) right after #62740 XboxID3D12CommandQueue::Slot31 unsupported.

AI-assisted: yes

… signature back in the PC layout (diagnostic)

One build can then compare the console layout with the layout used before it on the retail title, as the
ProjectLeonida#974 review needs (madhyn's frame-loop stack stops after 2 presents with the console layout, runs with
the PC one). Mesh draws are refused in that mode: a mesh shader translated with the root window reads
the console layout only. Compute is unchanged. d3d12_mesh_test checks both sides with one signature.
@iFeyz

iFeyz commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

@madhyn thank you, that is a clear regression on your stack and the counts make it easy to follow.

One thing that may narrow it: the int3 you stop at (exe+0x2474606) is the same one @DesertGamer reaches on DadaCap's boot-prototype, at 77–90 s, with and without #974 (RTX 5070, Windows, #14 comment 7138889766). Your run before #974 was cut at 60 s, so it may simply not have got there yet. What #974 changes on your stack would then be how soon the title gets there (2 presents instead of 1,675+), not where it stops.

To compare both layouts without cherry-picking twice, c170c08 adds LEONIDA_GRAPHICS_ROOT_LAYOUT=pc (diagnostic). It gives every graphics root signature the layout used before #974 (from s0, two dwords per table) in the same build. Mesh draws are refused in that mode, and compute is unchanged. d3d12_mesh_test checks both sides.

If you have time for another pair of runs on the same build, with and without the variable, these would tell the cases apart:

  1. the time of the stop in both, and whether the pc run reaches the same int3 when given 120 s or more;
  2. any VK_ERROR_DEVICE_LOST / device-lost / fence-timeout line before the stop in the console-layout run;
  3. the last few [d3d12-trace] call names before Slot31 unsupported (names only).

My working guess, not checked: with the console layout the VS/PS read the title's real tables from s8, where before they read whatever pack() had put there. A draw that now does real work could fault the GPU or write data the title checks right after its first frames. A device-lost line in (2) would point that way. If (1) shows the pc run also stopping at that int3 later, the layout only moves the title faster to a stop that exists either way.

iFeyz added a commit to iFeyz/leonida that referenced this pull request Nov 24, 2026
… signature back in the PC layout (diagnostic)

One build can then compare the console layout with the layout used before it on the retail title, as the
ProjectLeonida#974 review needs (madhyn's frame-loop stack stops after 2 presents with the console layout, runs with
the PC one). Mesh draws are refused in that mode: a mesh shader translated with the root window reads
the console layout only. Compute is unchanged. d3d12_mesh_test checks both sides with one signature.

(cherry picked from commit c170c08)
…ts dwords per shader visibility

No VS or PS reads s[0:1] as an address (root_spill_census), so a 29..32-dword start-up signature may fit
each stage once a parameter takes SGPRs only in the stages it is visible to. The fallback now logs the
console-layout dwords per D3D12_SHADER_VISIBILITY and the per-stage sums, counts a retail run can report.
@iFeyz

iFeyz commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

One more line worth copying from that run, if you can: b2da1c0 makes the fallback print the start-up signature's size per shader visibility, counts only, e.g.

[rt] d3d12: root signature dwords by visibility: all A, vertex V, ..., pixel P, ...; per stage with visibility: vertex A+V, pixel A+P, ...

Why it matters: per root_spill_census no VS or PS reads s[0:1] as an address, so graphics shaders never read a spill array. If the per-stage sums come out at 24 or less, the 29–32-dword signature fits each stage on the console because a parameter only takes SGPRs in the stages it is visible to. Then the fix is to model visibility, not a spill block, and the fallback goes away.

@madhyn

madhyn commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Ran the A/B comparison on the same build (b2da1c0ad cherry-picked onto our local frame-loop stack, Arch Linux, Wine 11.22, RTX 3060 Ti, retail 1.0.2.1; no RT-TITLE-HOST-REGION):

  1. Timing & stop:
    • Console layout (default): stops at int3 (0x142474606 / 0x80000003) right after #62740 (2 PresentX ok, 2 DrawInstanced, 6 ExecuteCommandLists ok).
    • LEONIDA_GRAPHICS_ROOT_LAYOUT=pc (130 s timeout): reaches the full 130 s limit (EXIT=124, no int3, no exception) with 4,252 PresentX ok, 12,749 DrawInstanced, 8,504 ExecuteCommandLists ok, and passes Slot31 unsupported twice (#68087, #80138).
  2. Device-lost / fence-timeout lines: 0 VK_ERROR_DEVICE_LOST / device lost / fence-timeout lines in the console-layout log (note: RT-DEVICE-LOST-LOG vulkan: say once when the device is lost (RT-DEVICE-LOST-LOG) #980 is not in this build).
  3. Last [d3d12-trace] calls before Slot31 unsupported in console-layout: #62727–#62739 are all ID3D12Device2::CreatePipelineState ok, followed by #62740 XboxID3D12CommandQueue::Slot31 unsupported and the int3.
  4. Root signature dwords by visibility (b2da1c0ad):
    [rt] d3d12: root signature dwords by visibility: all 30, vertex 0, hull 0, domain 0, geometry 0, pixel 0, amplification 0, mesh 0; per stage with visibility: vertex 30, pixel 30, geometry 30, mesh 30
    [rt] d3d12: root signature dwords by visibility: all 25, vertex 0, hull 0, domain 0, geometry 0, pixel 0, amplification 0, mesh 0; per stage with visibility: vertex 25, pixel 25, geometry 25, mesh 25
    

AI-assisted: yes

…its inline part; the rest goes to the argument block

On the console the parameter that does not fit and every one after it go to the argument block behind
s[0:1], the ones before stay inline. No VS, PS or GS of 1.0.2.1 reads s[0:1] as an address
(root_spill_census), so the graphics bind point now lays the inline part out from s8 and stores nothing
for the rest (rt::rootsig::Spill::block), instead of giving the whole signature the PC layout. A write
to such a parameter is dropped before kNoSgpr plus an offset could wrap to dword 0. The retail start-up
signatures (25 and 30 dwords, every parameter visible to every stage, ProjectLeonida#974 review) are the case; the
per-visibility log line is gone, LEONIDA_GRAPHICS_ROOT_LAYOUT=pc stays. Compute still refuses a spill.
@iFeyz

iFeyz commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

@madhyn thank you, that settles both questions.

Visibility: ruled out. Both start-up signatures (25 and 30 dwords) have every parameter visible to every stage, so they do not fit any stage by visibility.

What stops your run: read together with @DesertGamer's finding in #14 (the int3 at +0x2474606 is the title's answer to a fence that reads UINT64_MAX, i.e. a lost device the layer does not notice without #1028), the A/B says that with the console layout the draws now read the title's own tables, and on your stack one of them faults the GPU right after the first frames. With the PC layout they read the wrong dwords and do nothing the GPU minds, so the title keeps presenting. On DadaCap's boot-prototype, which also lays graphics out from s8, the same layout runs 76–90 s on DesertGamer's RTX 5070 before a later fault. So #974 is what exposes the fault, and the prototype carries something your stack does not. @DadaCap's slots 70/71 descriptor writes and RT-TITLE-HOST-REGION are the first candidates. A run with #1028 (and #980) on your console-layout build would show which resource faults.

One change from your numbers (00fc23b): those 25/30-dword signatures no longer fall back to the PC layout. On the console, only the parameter that does not fit and the ones after it go to the argument block behind s[0:1], and no VS/PS/GS of 1.0.2.1 reads s[0:1] as an address (root_spill_census). So the inline part is now laid out from s8 like every other signature, and the rest stores nothing (rt::rootsig::Spill::block, logged once; compute still refuses a spill until #1009). Before this, shaders bound with those two signatures read a shifted layout. It is unlikely to change your stop (those signatures were PC-laid in both of your runs), but it removes the last mixed layout. The visibility log line is gone, and LEONIDA_GRAPHICS_ROOT_LAYOUT=pc stays as the diagnostic switch.

iFeyz added a commit to iFeyz/leonida that referenced this pull request Nov 24, 2026
…its inline part; the rest goes to the argument block

On the console the parameter that does not fit and every one after it go to the argument block behind
s[0:1], the ones before stay inline. No VS, PS or GS of 1.0.2.1 reads s[0:1] as an address
(root_spill_census), so the graphics bind point now lays the inline part out from s8 and stores nothing
for the rest (rt::rootsig::Spill::block), instead of giving the whole signature the PC layout. A write
to such a parameter is dropped before kNoSgpr plus an offset could wrap to dword 0. The retail start-up
signatures (25 and 30 dwords, every parameter visible to every stage, ProjectLeonida#974 review) are the case; the
per-visibility log line is gone, LEONIDA_GRAPHICS_ROOT_LAYOUT=pc stays. Compute still refuses a spill.

(cherry picked from commit 00fc23b)
@madhyn

madhyn commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Tested 00fc23b9a stacked with #980 (RT-DEVICE-LOST-LOG) and #1028 (RT-DEVICE-FAULT-INFO) on the same local frame-loop stack (Arch Linux, Wine 11.22, RTX 3060 Ti, retail 1.0.2.1; no RT-TITLE-HOST-REGION / no boot-prototype):

Confirmed your hypothesis — the device is indeed lost right before queue slot 31 and the 0x142474606 int3, and VK_EXT_device_fault reports an invalid read in the 0xe7... title-memory range:

[rt] vulkan: the device was lost (vkWaitSemaphores in the fence dispatcher returned VK_ERROR_DEVICE_LOST); its fences now read UINT64_MAX and device calls return DXGI_ERROR_DEVICE_REMOVED
[rt] vulkan: the driver's fault report (VK_EXT_device_fault): no description
[rt] vulkan:   address fault 0: instruction pointer of a fault, address 0xdf7e44e0e0, precision 0x10
[rt] vulkan:   address fault 1: read of an invalid address, address 0xe797d1f000, precision 0x1000

(Also note list slot 70 was called right before with 0xe78a614420 / 0xe75dc4f880 / 0xe78a5d44e0.)

AI-assisted: yes

@iFeyz

iFeyz commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

@madhyn thank you, that closes the question: with the console layout the first draws read through the title's own tables and the GPU faults on a read in the 0xe7… title-memory range, an address that stack does not map for the GPU (no RT-TITLE-HOST-REGION, no boot-prototype arena rebasing). So #974 makes the shaders read the right arguments. What they point at needs the title-memory side, which DadaCap's boot-prototype already carries (and which explains why the same layout runs there). The clean-main stop you saw at 0x14247af2d right after slots 127 and 20 is the earlier span-check assert measured in #14, not a #974 effect.

Unless someone sees a reason otherwise, I will leave #974 as it is: the layout matches every measurement we have, and it should land with or after the title-memory work.

@ohshitwaddup

Copy link
Copy Markdown
Contributor

I rebased these 6 commits onto current main locally to find out what a rebase actually costs you. It's two conflicts, both mechanical — here they are so you don't have to rediscover them. I am deliberately not pushing a branch: main is moving at ~15 commits/hour (136 in the last 6h), so any branch I push is behind before you read this. This note is structural and won't go stale; the branch would.

Both conflict points are still present in main at b4b7756e, so they will recur on any rebase.

1. runtime/shims/d3d12_com.cpp → DispatchMesh

main refactored the viewport test into a helper (any_nonempty_viewport()), and your commit adds the mesh_ok window guard at the same spot. Keep both — the guard first, the helper second:

// A mesh shader reads the root arguments from s16 through a 16-dword window (RootArgumentLayout::mesh_ok).
if (!graphics_.layout->mesh_ok) {
    stub("DispatchMesh(root signature larger than a mesh shader's root window)");
    return check(false);
}
if (!any_nonempty_viewport()) return;  // as record_draw: nothing is rasterized

Your version's hand-rolled !(viewport_.width > 0) || !(viewport_.height > 0) is superseded by any_nonempty_viewport(), which now covers the multi-viewport arrays.

2. runtime/test/d3d12_mesh_test.cpp — two unrelated tests collide

Not a real conflict: main gained the DISPATCH_MESH command-signature test (from #377 / #1066 — D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH_MESH, 12-byte stride, short stride refused) and your commit adds the wide_root_signature test, and both land between the same two EXPECT lines. Keep both, each in its own brace scope:

{   // main's: DISPATCH_MESH command signature
    ...
    EXPECT(list->Close() == S_OK);
}
{   // yours: a signature the graphics bind point places (s8..s27) but a mesh window cannot (s16..s31)
    Ref<ID3D12RootSignature> wide;
    EXPECT(wide_root_signature(device.p, wide));
    ...
    EXPECT(list->Close() == E_INVALIDARG);
}

The trap is that both blocks open a { and the diff shows only one closing } after them — merging naively drops one test's body into the other and neither runs.

What I verified after resolving those

Linux (Nobara, GCC 16.2.1) on a main within 28 commits of current:

  • cmake -S runtime + full build: clean
  • root_signature_test: PASS
  • ctest: 72/72 passed, 0 failed
  • Translator suite: 477 files, 6227 tests, 0 files failed (78 s)

Windows (MSVC 14.44.35207, -DLEONIDA_BUILD_WINDOWS_RUNTIME=ON) — because the two conflicted files are Windows-only and Linux never compiles them:

  • full Windows runtime build: OK, so both resolutions compile
  • ctest: 3 failures, and I confirmed all three are pre-existing by reverting the whole patch, rebuilding and re-running on pristine main:
    • gameinput_host — create hr=0xD000003A, no GameInput runtime on that box
    • xgameruntime_offline, xgameruntime_offline_hdr — XDisplayAcquireTimeoutDeferral needs a display power request the test host can't grant; this patch provably does not touch xgameruntime at all

Nothing in main since your base changed the meaning of your 6 commits — the rebase was purely these two collisions, so your content survives intact (mesh_ok, root_window, user_data_dword, LEONIDA_GRAPHICS_ROOT_LAYOUT, tests/semantic/test_ms_root_window.py all verified present).

One thing from your thread worth carrying forward

madhyn's A/B (19:03) found that with the console layout the first draws read through the title's own tables and then the GPU faults on a read in the 0xe7… title-memory range — which is RT-TITLE-HOST-REGION (#1273), not this PR. So this PR looks necessary-but-not-sufficient for a visible frame; worth saying so in the PR description so a reviewer doesn't read "still black" as a regression from this change.

Happy to do the rebase for real and push it to my fork if you'd rather not spend the time on the conflicts — just say so and tell me which main you want it based on. Otherwise the two resolutions above should take a few minutes.

AI-assisted (Hermes Agent) — the rebase, both platform builds and the pre-existing-failure control were run here.

main already lays graphics root arguments out in the console layout (from s8, one dword per table: ProjectLeonida#939's
graphics-root-layout patch in ProjectLeonida#984's form, pack_stage(Stage::Pixel), RootArgumentLayout::graphics_console,
graphics_arguments_end, LEONIDA_GRAPHICS_STAGE_LAYOUT=0 for pack()). That form stays. What this pull request adds
beyond it is carried onto it: the mesh-shader root window (translator, index "root_window", mesh_ok, the two
refusals) and its tests. Its own graphics spill handling (Spill::block) and LEONIDA_GRAPHICS_ROOT_LAYOUT=pc are not
carried: main keeps pack()'s s0 layout for a graphics signature past s31, and its switch does what =pc did.

Conflicts:
- runtime/src/root_signature.h, root_signature.cpp: main's pack_stage (compute spill array, spill_dword); the
  Spill enum, first_spilled and spilled_dwords dropped. The header keeps the PR's evidence note, with Stage::Pixel.
- runtime/shims/d3d12_com.h: main's comment and members, with the mesh window described; mesh_ok added (false by
  default, set only for a console-layout signature that Stage::Mesh also places); the PR's second graphics_console
  dropped.
- runtime/shims/d3d12_vulkan_device.cpp (CreateRootSignature): main's pixel/packed form; the PR's Stage::Mesh pack
  and its log line added, mesh_ok = pixel.ok && mesh.ok. The mesh-shader refusal without "root_window" (no
  conflict) stays.
- runtime/shims/d3d12_com.cpp: DispatchMesh keeps main's any_nonempty_viewport() and graphics_user_data() after the
  PR's mesh_ok check; address() keeps main's comment. The PR's kNoSgpr guard in constants()/address() stays,
  reworded: in main a spilled compute parameter has first_sgpr kNoSgpr, and kNoSgpr + offset wrapped round to s0.
- runtime/src/shader_library.h: both (main's wave64_graphics, the PR's root_window).
- runtime/test/d3d12_mesh_test.cpp: main's mesh shader-kind byte on both containers (also the PR's ms_old); the
  PR's two-parameter signature replaces main's 25-dword padding onto the s0 layout; both test blocks kept (the
  PR's window refusals, main's DISPATCH_MESH command signature), each in its own scope. The =pc case is dropped
  (main's switch is read once per process).
- runtime/CMakeLists.txt (no conflict): the mesh test uses ps_draw.spv again; the ps_draw_s0.spv rule is gone.
- runtime/test/glsl/ps_draw.frag, vs_depth.vert, vs_draw.vert, vs_draw_int.vert, ps_depth_write.frag and
  runtime/test/shaders/ps_m15, ps_m2, ps_m2_array, ps_m2_literal, ps_m2_uoff, ps_m3, ps_m3_post, ps_m3_query,
  vs_m15, vs_m3 (.asm): main's (the same s8 rewrite done twice); ps_draw.frag's mesh-test note updated.
- runtime/test/root_signature_test.cpp (no conflict): the Spill::block cases dropped, the window cases kept.
- docs/design.md: main's rows (loop guard, direct resource heap) and the PR's user-data row.
- docs/d3d12_vulkan.md (no conflict): section 3.5 and the CreateRootSignature bullet rewritten for main's form.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aslan2142
aslan2142 merged commit b07b9ec into ProjectLeonida:main Nov 25, 2026
@aslan2142

Copy link
Copy Markdown
Collaborator

Merged, after merging main into it. main already had the graphics console layout through #939/#984, so what this adds is the mesh root window. Thanks.

  • Claim: D3D-448-GRAPHICS, valid, before this PR.
  • Kept from main: the graphics layout (pack_stage(Stage::Pixel), graphics_console, LEONIDA_GRAPHICS_STAGE_LAYOUT=0). LEONIDA_GRAPHICS_ROOT_LAYOUT=pc is dropped as a duplicate of =0.
  • Carried from this PR: user_data_dword, the translator's root_window in index.json, mesh_ok, both refusals and their tests. Mesh shaders now read their root arguments from s16 through the graphics window, instead of 8 dwords early, and d3d12_mesh_test no longer pads its signature onto s0.
  • Not carried: Spill::block. A graphics signature over 24 dwords keeps main's s0 fallback, under which both measured boots ran (AMD to the first-run screens, NVIDIA to the story load). It would also skip main's direct heaps, which are placed only when pack_stage succeeds. A follow-up can make the case for it with a run.
  • Kept the kNoSgpr guard: on main, a spilled compute parameter wrapped round to s0.
  • For everyone after this merge: mesh shaders translated before it are refused with a log line; run make_game.py --stages shaders again.
  • Tests: Windows suite under Wine (llvmpipe and an RDNA2 iGPU): nothing goes from pass to fail against main. root_signature_test 77 pass; test_ms_root_window 4 of 4.
  • Checked on main 0eeb1e663 + b8563e949: it merges cleanly; the 14 docs and writer tests pass; check_no_game_data.py is clean on the 15 changed files.

AI-assisted (Claude Code, Claude Opus 5.5).

aslan2142 added a commit to iFeyz/leonida that referenced this pull request Nov 25, 2026
This merges ProjectLeonida#1064 as prepared (its head + a merge of main), so it brings ProjectLeonida#1232 up to date with main and
with ProjectLeonida#1064. ProjectLeonida#1232's branch carried ProjectLeonida#974 (merged into main since) and an older head of ProjectLeonida#1064 (7c47fd9).

main already supplies the directly indexed heaps to graphics draws (integration ProjectLeonida#984):
graphics_user_data() on DrawInstanced, DrawIndexedInstanced and DispatchMesh, at
RootArgumentLayout::graphics_arguments_end (pack_stage(Stage::Pixel)'s end_sgpr, set when the console
layout places the signature), LEONIDA_GRAPHICS_DIRECT_HEAPS=0, its notes for a signature on the s0
layout or one that fills s31, and d3d12_graphics_direct_heaps_test (recorded draws and the VS/PS GPU
reads). That form stays. What this pull request adds beyond it is carried onto it: the mesh case.

Conflicts (all taken from ProjectLeonida#1064's merged branch, then the PR's mesh parts carried over):
- runtime/shims/d3d12_com.cpp: main's graphics_user_data()/with_direct_heaps() and notes. The PR's own
  graphics_user_data(), GetEnvironmentVariableA switch and no-room notes are main's in another form and
  dropped. Carried: the comment says a mesh shader reads push dword d as s(d + 8) through ProjectLeonida#974's window,
  so it gets the heaps after its arguments from s16 (main's comment still said the mesh stage gets none);
  and DispatchMesh reports once when a heap falls past the mesh window (push dword 24 and up, s32 for the
  mesh shader), the case raised in the review of ProjectLeonida#1232 (mesh_ok accepts arguments up to push dword 24).
- runtime/shims/d3d12_com.h, runtime/shims/d3d12_vulkan_device.cpp: main's (graphics_arguments_end from
  pixel.end_sgpr; the PR set it from its Spill::block form, which main did not take from ProjectLeonida#974).
- runtime/test/glsl/cs_user_data.comp: main's (identical direct-indexing mode).
- docs/d3d12_vulkan.md: main's section 3.4 with ProjectLeonida#1064's compute paragraph; the graphics paragraph's
  "a mesh shader ... is not modelled" replaced by the mesh window position, cited to issue ProjectLeonida#14 comment
  7143020922 as a report not reproduced here, the window-overflow note and the mesh test.
- runtime/test/d3d12_mesh_test.cpp (no conflict): the PR's recorded-argument checks kept (vertex and mesh
  draw with 4 constants, resource-only rebind, 23 constants, 30 constants); the 30-constant comment now
  says it keeps pack()'s s0 layout on main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
aslan2142 pushed a commit that referenced this pull request Nov 25, 2026
…eaps after their root arguments

With CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED / SAMPLER_HEAP_DIRECTLY_INDEXED a console program reads the
resource heap's address in the dword after its root arguments and the sampler heap's in the next,
from s8 in VS/PS/GS and s16 in mesh shaders (DadaCap, issue #14 comment 7143020922), as #1064 does
for compute. DrawInstanced, DrawIndexedInstanced and DispatchMesh now record them at
RootArgumentLayout::graphics_arguments_end; a mesh shader reads the same push dwords through the
#974 window. Nothing is written for a signature with parameters in the argument block or under
LEONIDA_GRAPHICS_ROOT_LAYOUT=pc (no slot is measured there); LEONIDA_GRAPHICS_DIRECT_HEAPS=0 restores
the previous arguments. d3d12_mesh_test checks a vertex and a mesh draw, a rebind, a signature ending
at s30 and a spilled one.
clquwu added a commit to clquwu/leonida-ultimate that referenced this pull request Nov 27, 2026
…ex (#162), and Wave40B CS soundness

Adapted with GPL-3.0 attribution:
- ProjectLeonida/mandy#974 (iFeyz, GPL-3.0): add GRAPHICS_ROOT_DWORD=8, MS_ROOT_SGPR=16, user_data_dword(stage, sgpr), and mesh root_window metadata so mesh shaders read s16..s31 from graphics push-constant dwords 8..23 (s8..s15 zeroed, s0..s7 unchanged).
- ProjectLeonida/mandy#162 (Andretuta / tedin7, GPL-3.0): add export_misc_pos1 for mesh exp pos1 Layer/ViewportIndex per-primitive outputs in %ms_cull_blk, skipping ShaderLayer/ShaderViewportIndex capabilities on mesh shaders since MeshShadingEXT provides them.
- Wave40B CS soundness (tools/wave64_emulate_opt.py): flag acyclic barrier-free non-GLC vector buffer R+W hazards in can_promote_wave64_cs_to_wave32 (while preserving disjoint s_buffer_load_* CBV/SRV slots), and fix s_andn2_wrexec_b64 / *_wrexec_b64 destination single-lane mask tracking in find_single_lane_exec_blocks.
clquwu added a commit to clquwu/leonida-ultimate that referenced this pull request Nov 27, 2026
…bber fix

- Adapt ProjectLeonida/mandy#974 (D3D-448-GRAPHICS, Author: iFeyz, GPL-3.0)
  for runtime/ and docs/:
  - Parse index.json root_window ({sgpr: 16, dword: 8}) into
    ShaderEntry::graphics_root_window in shader_library.h and jit_shader_cache.h.
  - Add RootArgumentLayout::mesh_ok; check Stage::Mesh (16-dword window,
    s16..s31 = push dwords 8..23) in CreateRootSignature under
    LEONIDA_GRAPHICS_STAGE_LAYOUT=1, invalidate DispatchMesh and DISPATCH_MESH
    ExecuteIndirect when !mesh_ok, and log cleanly if direct heap pointers
    (RT-DIRECT-HEAP-GRAPHICS) land past push dword 23 on mesh draws.
  - Refuse stale pre-#974 mesh shaders lacking root_window at PSO creation with
    E_INVALIDARG and an actionable re-translate message.
  - Parameterize ms_draw.mesh and ps_draw.frag with ROOT_BASE (default 0 so
    legacy s0 tests stay untouched; -DROOT_BASE=8 for d3d12_mesh_stage_layout),
    add ms_old refusal + wide/huge/fits_mesh checks to d3d12_mesh_test, add
    root_window to d3d12_conservative_raster_test, add graphics root window
    checks to root_signature_test, and document in docs/d3d12_vulkan.md and
    docs/design.md.
- Fix slot-133 placed RT/DS CPU-upload clobber in d3d12_xs_device.cpp:
  - Track immutable XsUploadHistory::is_rt_or_ds for placed textures with
    ALLOW_RENDER_TARGET or ALLOW_DEPTH_STENCIL, initialize gpu_written = true,
    never clear gpu_written in xs_invalidate_placed_range, and skip them in
    xs_refresh_placed_textures (sync and async) while keeping UAV-only textures
    and note_placed_texture_gpu_written (LEONIDA_MAP_READBACK) intact.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs rebase Conflicts with the base branch: rebase it on main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants