Repository navigation
D3D-448-GRAPHICS: graphics root arguments in the console layout, mesh shaders through a window - #974
Conversation
… 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.
|
Tested cherry-picking Before With (Note: it also logged 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.
|
@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 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. |
…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
|
Re-tested with
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.
|
@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 To compare both layouts without cherry-picking twice, c170c08 adds If you have time for another pair of runs on the same build, with and without the variable, these would tell the cases apart:
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 |
… 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.
|
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. Why it matters: per |
|
Ran the A/B comparison on the same build (
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.
|
@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 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 |
…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)
|
Tested Confirmed your hypothesis — the device is indeed lost right before (Also note AI-assisted: yes |
|
@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 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. |
|
I rebased these 6 commits onto current Both conflict points are still present in 1.
|
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>
|
Merged, after merging
AI-assisted (Claude Code, Claude Opus 5.5). |
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>
…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.
…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.
…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.
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 consolestarts them at s8 for VS/PS/GS with one dword per table (census in
docs/d3d12_vulkan.md3.5, and @DadaCap's liveretail 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.
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.CreateRootSignaturebuilds the graphics layout withpack_stage(Stage::Vertex)and checksStage::Mesh(RootArgumentLayout::mesh_ok);address()writes a table as one dword at both bind points;DispatchMeshwith a signature past the 16-dword mesh window invalidates the list; a mesh PSO whose mesh shaderhas no
root_windowin the index (translated before this) is refused with a log line asking for the shaders stage.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_m15rewritten sinces_getpc_b64must stay first).docs/d3d12_vulkan.md3.5 and the CreateRootSignature bullet, the user-data row ofdocs/design.md,d3d12_com.handroot_signature.hcomments.Retail evidence: @DadaCap's
boot-prototypebranch (not for merge) switches the graphics layout to the samepack_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 bewritten 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=16on a corpus lists any read below s16 — a run from someone with the package wouldsettle it. Visibility is still not modelled (D3D-318 measured one block in root order for VS/PS).
Coordination: touches
CreateRootSignatureandaddress()next to ROOT-SIG-SPILL-MODEL (@djrolfes, spill areafor compute);
pack_stageand the spill refusal are unchanged here, so either rebases cleanly on the other. If#424 (indirect mesh dispatch) lands, its path should check
mesh_oklikeDispatchMeshdoes.Tested
python -I scripts/run_semantic_tests.py tests/semantic— 470 files, 6,147 tests, 1 file failed:test_image_cube_store_glc, the WindowsLLVM_MCpath split reported as TEST-CUBE-WINPATH (claimed byTimIdle; 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-computerun by the CPU interpreter, no window on other stages); it fails onmain.ctestonmain1504c1a + this: 301 of 305 pass. The 4 failures are the sameas on
mainhere (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_syncis flaky here onmaintoo.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_testandd3d12_bundle_testrun on the GPU and match pixel-exact.d3d12_mesh_testadds the two refusals;root_signature_testadds the graphics-window cases.scripts/check_no_game_data.pyon every changed file,tests/test_docs_links.py,tests/test_text_write_line_endings.py,python -m compileall -q make_game.py tools tests.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
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.