Repository navigation
d3d12: graphics draws supply the directly indexed heaps after their root arguments (RT-DIRECT-HEAP-GRAPHICS) - #1232
Conversation
…-HEAP-COMPUTE) Compute shaders using direct resource indexing received a zero heap pointer. Snapshot each bound heap offset after the explicit inline root arguments on direct and indirect dispatches, so each command retains the bindings it had when recorded. When the explicit arguments leave no SGPR, keep them and report the missing heap slot once. The placement is a hypothesis with partial evidence. Of 2,959 direct-indexing compute entries, seven could be paired with recorded layouts. All seven resource reads agree with the predicted slot. The other 2,952 have no paired layout, and no paired sampler read establishes the relative heap order. tools/compute_heap_layout_census.py reproduces the count, with synthetic tests for agreement, disagreement and missing evidence. Built gta6rt and d3d12_compute_test with clang-cl. The Proton Vulkan fixture passed 64 buffer reads and 64 null controls on an RTX 4070. With the rollback switch, all 128 controls read zero. Both runs check the recorded arguments for bundle inheritance, indirect heap rebinding and the last inline SGPR. The synthetic SPIR-V fixture passed validation. AI-assisted (Codex and Claude Code agents). Co-authored-by: Plaaasma <47513553+Plaaasma@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ism/leonida into feat/direct-heap-graphics
…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 ProjectLeonida#14 comment 7143020922), as ProjectLeonida#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 ProjectLeonida#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.
…-HEAP-COMPUTE) Compute shaders using direct resource indexing received a zero heap pointer. Snapshot each bound heap offset after the explicit inline root arguments on direct and indirect dispatches, so each command retains the bindings it had when recorded. When the explicit arguments leave no SGPR, keep them and report the missing heap slot once. The placement is a hypothesis with partial evidence. Of 2,959 direct-indexing compute entries, seven could be paired with recorded layouts. All seven resource reads agree with the predicted slot. The other 2,952 have no paired layout, and no paired sampler read establishes the relative heap order. tools/compute_heap_layout_census.py reproduces the count, with synthetic tests for agreement, disagreement and missing evidence. Built gta6rt and d3d12_compute_test with clang-cl. The Proton Vulkan fixture passed 64 buffer reads and 64 null controls on an RTX 4070. With the rollback switch, all 128 controls read zero. Both runs check the recorded arguments for bundle inheritance, indirect heap rebinding and the last inline SGPR. The synthetic SPIR-V fixture passed validation. AI-assisted (Codex and Claude Code agents). Co-authored-by: Plaaasma <47513553+Plaaasma@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Checked 9b8707c merged into current Conflict with main: Tests on that merge: One question on mesh draws: a mesh shader reads push dword i as s(i+8), and AI-assisted (Claude). |
main already supplies the directly indexed heaps to compute dispatches (integration ProjectLeonida#984, the tree this pull request was split from): with_direct_heaps()/compute_user_data() on Dispatch and the ExecuteIndirect dispatch path, RootArgumentLayout::compute_arguments_end (kNoSgpr for a spilled signature), LEONIDA_COMPUTE_DIRECT_HEAPS=0, and the first form of this test (direct dispatch, indirect after a resource-only rebind, the GPU read through the heap). That form stays. What this pull request adds beyond it is carried onto it: the review-round reports, the extra recorded-argument checks, the census tool and its evidence. Conflicts: - runtime/shims/d3d12_com.cpp: main's with_direct_heaps()/compute_user_data() and its one-argument note_direct_heap_indexing(). Carried: compute_user_data() makes the note itself, so an ExecuteIndirect dispatch with no heap bound is reported too (record_dispatch's own call removed), and a heap with no inline dword left is reported once per heap kind ("compute root arguments leave no inline SGPR for the resource/sampler heap"); a spilled signature (main: kNoSgpr) gets one note of its own. Dropped: the PR's GetEnvironmentVariableA switch (main's direct_heaps_enabled) and its "graphics heap-base SGPR is not supplied" notes (main supplies the graphics heaps). - runtime/shims/d3d12_com.h, runtime/shims/d3d12_vulkan_device.cpp: main's (compute_arguments_end and graphics_arguments_end with their comment; compute_arguments_end only when the compute arguments do not spill). - runtime/test/glsl/cs_user_data.comp: main's; its direct-indexing mode (s5 = 0xFFFFFFFC, heap at s9) is this pull request's, byte for byte. - runtime/test/d3d12_compute_test.cpp: the PR's block replaces main's earlier form of it (a superset: adds the bundle dispatch that inherits the parent's heaps, an indirect dispatch with only the sampler heap, signatures ending at s30 and s31, and the LEONIDA_COMPUTE_DIRECT_HEAPS=0 expectations). - docs/d3d12_vulkan.md: main's section 3.4 (the BatchCull s7 and PreSkin s9 evidence), with the PR's census paragraph (tools/compute_heap_layout_census.py, the seven paired layouts, the heap order as a hypothesis) and the no-room and spill reports. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
|
Merged, after merging
AI-assisted (Claude Code, Claude Opus 5.5). |
Claimed in the coordination issue as: RT-DIRECT-HEAP-GRAPHICS (#14 (comment))
Depends on: #974 (graphics root arguments in the console layout), #1064 (RT-DIRECT-HEAP-COMPUTE). This branch is #974 with #1064 merged in; its last commit is this pull request.
What and why
With
CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED/SAMPLER_HEAP_DIRECTLY_INDEXED, a console program finds the descriptor heaps in the dwords right after its root arguments. @DadaCap measured on the retail library that this holds for every stage: from s4 in compute, s8 in VS/PS/GS and s16 in mesh shaders, the resource heap's address in the first dword after the root arguments and the sampler heap's in the next (issue #14, comment 7143020922, item 4). #1064 supplies them for compute. A graphics draw with a bound heap only got a note that its heap-base SGPR was not supplied, so a directly indexed VS/PS/MS read a zero heap base.runtime/shims/d3d12_com.cpp:graphics_user_data(), the graphics side of d3d12: supply directly indexed heaps to compute dispatches (RT-DIRECT-HEAP-COMPUTE) #1064'scompute_user_data(). EachDrawInstanced,DrawIndexedInstancedandDispatchMeshrecords the bound heaps' 32-bit addresses atgraphics_arguments_endand the next dword.LEONIDA_GRAPHICS_DIRECT_HEAPS=0restores the previous arguments.runtime/shims/d3d12_vulkan_device.cpp/d3d12_com.h:RootArgumentLayout::graphics_arguments_end(frompack_stage'send_sgpr). It is not set for a signature with parameters in the argument block, or underLEONIDA_GRAPHICS_ROOT_LAYOUT=pc, because no slot is measured there; nothing is written then, with one note.docs/d3d12_vulkan.mdsection 3.4, next to d3d12: supply directly indexed heaps to compute dispatches (RT-DIRECT-HEAP-COMPUTE) #1064's compute paragraph.Tested
d3d12_mesh_test(RX 9070 XT), throughrt::d3d12::recorded_commands:d3d12_compute_test(d3d12: supply directly indexed heaps to compute dispatches (RT-DIRECT-HEAP-COMPUTE) #1064's checks) androot_signature_testpass on the merge.ctest303 of 307 pass. The 4 failures are the same as onmainhere (d3d12_clear,d3d12_execute_indirect_validation,d3d12_texture_tiles,d3d12_pipeline_library_host, reported in Coordinating who works on what #14).tests/test_docs_env_vars.py,tests/test_docs_links.py,scripts/check_no_game_data.pyon every changed file.Not run here: the retail title. On
main's own address path (noboot-prototypearena), a directly indexed draw now gets the same heap addresses a compute dispatch gets under #1064.GPUs tested: AMD Radeon RX 9070 XT, AMD Adrenalin 26.11.2 (Vulkan 1.4.359), Windows 11
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.