d3d12: graphics draws supply the directly indexed heaps after their root arguments (RT-DIRECT-HEAP-GRAPHICS) #1232
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!1232
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1232/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@iFeyz on GitHub · 2026-11-24 20:39 UTC · original
iFeyz:feat/direct-heap-graphics→main· +401 −18 · 6 files · 6 commits · merged 2026-11-25 03:26 UTCClaimed in the coordination issue as: RT-DIRECT-HEAP-GRAPHICS (#14)
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 #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 #1064's compute paragraph.Tested
d3d12_mesh_test(RX 9070 XT), throughrt::d3d12::recorded_commands:d3d12_compute_test(#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 #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.@tiguan26 on GitHub · 2026-11-24 21:30 UTC · original
Checked
9b8707cmerged into currentmain(6293c1c). Cross-built with clang-cl 19 + xwin (MSVC CRT / SDK 10.0.26100) and run under Wine 11.22 on llvmpipe (Mesa 25.2.8), so no hardware driver.Conflict with main:
runtime/shims/d3d12_com.cppconflicts with the multi-viewport change (#510) inDispatchMeshandrecord_draw. The resolution that built for me keeps main'sany_nonempty_viewport()anddraw.viewports, keeps this PR'smesh_okcheck andgraphics_user_data(), and drops main's separatenote_direct_heap_indexing(graphics_.layout)inrecord_draw, sincegraphics_user_data()now makes that call (with the two-argument signature from #1064).Tests on that merge:
d3d12_mesh,d3d12_computeandroot_signaturepass. The new checks did run on llvmpipe:direct heaps on graphics draws: resource heap at s12, sampler heap at s13, plus the s31 note ("no inline SGPR for the sampler heap") and the spilled-signature note.One question on mesh draws: a mesh shader reads push dword i as s(i+8), and
mesh_okaccepts a signature that fills its 16-dword window, which means graphics root arguments ending at push dword 24. Then the heap dwords go to push dwords 24 and 25, which a mesh shader would read as s32/s33, past its last user SGPR. The range check ingraphics_user_data()isslot < data.size()(the VS/PS numbering), so for that mesh draw both addresses are written but unreadable, with no note. The resource heap is visible to a mesh shader only up tographics_arguments_end <= 23, and the sampler heap up to<= 22. If the retail library never has such a mesh signature this is moot, but a note inDispatchMeshwhengraphics_arguments_end + 8(+1 with both flags) passes s31 would say so the same way the VS/PS case does.AI-assisted (Claude).
@aslan2142 on GitHub · 2026-11-25 03:26 UTC · original
Merged, after merging
mainand #1064 into it (3ee0037fd). Thanks.mainalready supplies the graphics heaps (#984'sgraphics_user_data()andd3d12_graphics_direct_heaps_test), somain's form stays and what this adds is the mesh case:RT-DIRECT-HEAP-GRAPHICS, valid, before this PR.main: this PR's owngraphics_user_data()and itsSpill::block-based end (mainkeeps the s0 fallback, see #974).d3d12_mesh_testchecks (a vertex and a mesh draw record the same dwords, a resource-only rebind, 23 and 30 constants);docs/d3d12_vulkan.mdsection 3.4 no longer say the mesh stage gets nothing: through #974's window a mesh shader reads the heaps at s(16 + end − 8). This cites issue #14 comment 7143020922 as a report not yet reproduced here.DispatchMeshlogs once when a heap falls past the mesh window (push dword 24 or above), where a mesh shader would read it as s32 or higher.DispatchMeshrecording no heap dwords,d3d12_meshfails on llvmpipe, so the test guards the path.main. The translator suite passes.main98efc22ca+3ee0037fd: it merges cleanly; the semantic suite passes (487 files, 6,279 tests, 0 files failed); the 14 docs and writer tests pass;check_no_game_data.pyis clean on the 3 changed files.AI-assisted (Claude Code, Claude Opus 5.5).