d3d12: supply directly indexed heaps to compute dispatches (RT-DIRECT-HEAP-COMPUTE) #1064
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!1064
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1064/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?
@Moriz82 on GitHub · 2026-11-24 17:34 UTC · original
split/rt-direct-heap-compute→main· +306 −9 · 5 files · 2 commits · merged 2026-11-25 03:25 UTCClaimed in the coordination issue as: RT-DIRECT-HEAP-COMPUTE (claim).
Part of the split of #984 into small pull requests.
Depends on: none
Overlaps: #683 serializes the heap-indexing flags and #974 handles graphics-stage root layouts. #1009 changes the same dispatch paths: whichever of this pull request and #1009 lands second must carry
compute_user_data()into the block-based direct and indirect dispatch paths, and spilled signatures still need a measured location for their heap words. This child uses the existing inline compute layout.What and why
On Linux/Proton and native Windows, a compute dispatch could bind a shader-visible heap and still give its shader a zero resource-heap pointer. The shader used that pointer to look up a buffer descriptor.
For an inline signature, direct and indirect dispatches now snapshot each flagged heap's 32-bit byte offset from the arena after the explicit root arguments. An unbound heap contributes zero. Rebinding affects later commands. When the explicit arguments leave no SGPR, they are kept and the heap that cannot fit is reported once per heap kind. A dispatch with a flag set and no heap bound is reported, and a graphics draw with a bound heap reports that its heap-base SGPR is not supplied. Set
LEONIDA_COMPUTE_DIRECT_HEAPS=0to restore the previous arguments.The GPU fixture reads through a descriptor at its original heap index. It also reads a null descriptor and checks the recorded arguments: a direct dispatch, a bundle dispatch that inherits the parent's heaps, an indirect dispatch after rebinding the resource heap only, one with only the sampler heap, and signatures whose explicit arguments end at s30 and s31.
Evidence for the layout
Putting the resource heap in the first SGPR after the explicit arguments, and the sampler heap in the next one when both flags are set, is a hypothesis with partial evidence. The code comment and section 3.4 of
docs/d3d12_vulkan.mdnow say so.tools/compute_heap_layout_census.pycompares role-tagged dynamic descriptor loads with a root layout that is known independently: an embedded RTS0, or a layout recorded in a dispatch log of integration #984. It excludes known explicit table bases and counts ambiguous reads separately.No flagged entry embeds RTS0. The seven paired entries all read the resource heap at the end of the explicit layout. No sampler-indexing entry had a paired layout, so the relative order of the two heaps is not verified on retail code. For the other 2,952 entries the layout is unknown. Counts are per indexed entry, and the carves can contain the same program.
SHADERSandPIPELINE_COMPUTEare local carve directories, and the dispatch logs (13 of them) hold both compute-layout and named compute-input records from a single process each. None of that is in the repository: only the tool and its synthetic test are. The census was run again on the tree before this rebase and gave the counts above (the rebase does not touch the tool). The archive-only counts can be reproduced without a dispatch log.Tested
CachyOS, kernel 7.3.5-2-cachyos, Wine 11.22 (the distribution's package, in a fresh prefix), Ryzen 5 5600X, 16 GB RAM, RTX 4070 12 GB, NVIDIA 620.73.04. Cross-built with clang-cl 23.1.5 and an xwin SDK in a Ninja Release build directory. The configuration used the Linux cross-toolchain in the repository and a cached SDL3 checkout. This head is the previous one rebased onto
main66d4f5aa3(one conflict, inrecord_draw, wheremainnow tests every bound viewport); everything below was run again on it. The previous heads were run under Proton Experimental.All four build targets succeeded. The census test passed (2 tests), as did the two census tests it builds on (13 and 25 tests). The synthetic fixture passed SPIR-V validation. Both runs of the compute test exited zero. The default run matched all 64 buffer reads and 64 null controls and logged the four expected reports (no resource heap bound, no sampler heap bound, no inline SGPR for either heap). The rollback run matched all 128 zero controls. Both runs checked the recorded arguments listed above.
d3d12_bundle_test(14 scenarios, 0 failures) andd3d12_set_descriptor_heaps_testpassed. Wine skipped the existing native D3D12 CachedPSO comparison and the bundle test's host comparisons. CMake could not build the optional XMA decoder (cargo has no Rust Windows MSVC target here), which only silences XMA voices.Not run on this head: the Vulkan validation layer (it is not installed on this machine), native Windows, AMD or Intel, and a game boot with this child alone.
d3d12_indirect_dispatch_count_testwas not run again; on the previous head it exited 1 under Wine on this machine without printing anything, as builds of unrelated trees did. The reviewers' runs were on earlier heads: native Windows on an RTX 5070 Ti (with and without validation) and an RTX 4070 Ti, and an AMD RX 9070 XT on7c47fd946, the head before this rebase.GPUs tested: NVIDIA GeForce RTX 4070 (standalone child). The integration branch also confirmed the resource-heap argument during world loading on Windows 11, i9-13900K, 64 GB, RTX 4070 Ti, NVIDIA 630.20.
AI-assisted: yes. Claude Code and Codex agents contributed to the integration. Codex prepared this child and Claude Code re-ran the tests above on the published tree.
Checklist
66d4f5aa3. Merges cleanly.scripts/check_no_game_data.py.🤖 Generated with Claude Code
@kawaii-shakal on GitHub · 2026-11-24 18:13 UTC · original
Review of #1064 (RT-DIRECT-HEAP-COMPUTE), head 90bbf5e606bc466275342a5e6b6c79e337468580
Environment: Windows 11 Pro 26300, MSVC 19.50 (Visual Studio 18 2026 generator), RelWithDebInfo, NVIDIA GeForce RTX 5070 Ti, driver 617.42 (LEONIDA_VK_DEVICE=5070).
Claim: RT-DIRECT-HEAP-COMPUTE is claimed by the author in #14 (issuecomment-7139398473), and the scope there matches the PR: inline compute layout only, with a GPU test and a rollback switch.
What I ran
All four targets built. The new test code adds one warning: C4996 for
getenvat runtime/test/d3d12_compute_test.cpp:598.Mutation: I changed
record_dispatch(runtime/shims/d3d12_com.cpp:1415) back tocompute_.data, so a direct dispatch gets no heap words, rebuilt and ran with validation. d3d12_compute_test exited 1. I restored the file withgit checkout --, rebuilt, and it passed again.Merge:
git merge-treeagainst origin/main3aa975421shows no conflicts. With #1009 (ROOT-SIG-SPILL-MODEL, head b477602aa) it has a content conflict in runtime/shims/d3d12_com.cpp, and the change toRootArgumentLayoutin d3d12_com.h sits next to #1009's own change. Both PRs changerecord_dispatchand theExecuteIndirectdispatch path. It merges cleanly with #974 (head161314c26). #683 and #990 touch other files. The open-PR searches for "DIRECT-HEAP" and "directly indexed" find only #1064, #683 and the integration branch #984.What the change does
compute_user_data()(d3d12_com.cpp:1396-1410) copies the compute root-argument block for each command and writes the flagged heap bases atcompute_arguments_end, resource heap first.compute_arguments_endispack_stage(...).end_sgpr, set in d3d12_vulkan_device.cpp:6047. A heap that is not bound gives 0.reset_stateclears the heaps. The test checks both of these on recorded commands: a direct dispatch, then a rebind with only the resource heap, then an ExecuteIndirect dispatch.Findings
s10/s11as an example. It does not measure that they come right after the last root parameter, or in that order. The PR body cites a run of the integration branch during world loading, but that is not written down where a reader can check it. AGENTS.md asks to quote the source of a claim or call it a hypothesis. Please do one of these:tools/heap_index_census.py, showing that for each heap-indexing CS the resource and sampler base SGPRs equal the end of its root signature's inline layout, and +1 for the sampler;note_oncethere would make this case easy to see in a game log.A bundle case and an "explicit arguments fill s31" case would each take a few lines in the existing block.
LEONIDA_COMPUTE_DIRECT_HEAPS=0is a rollback switch for a runtime packing change, not a skip list, so I don't read it as breaking fix-don't-disable. The test runs correctly under both settings.compute_user_data()into #1009's block-based dispatch. For spilled signatures, #1009 also needs a decision on where the heap words go. It would help to say this in both PRs.Verdict: approve with comments. The change is small, the snapshot semantics are right (record-time heap capture, rebinding, reset, bundle inheritance by deferral), and it passes on the RTX 5070 Ti with and without validation. The mutation shows the GPU test catches a missing heap word. Before merge I would like finding 1 fixed: a cited count, or the ABI marked as a hypothesis. Findings 2-4 can come in a follow-up.
AI-assisted.
@Plaaasma on GitHub · 2026-11-24 18:29 UTC · original
Native Windows check, AI-assisted (Claude Code). Windows 11, i9-13900K, 64 GB, RTX 4070 Ti 12 GB (NVIDIA 630.20), MSVC 2022 (VS 17 generator, Release), Vulkan.
Head
667dea2ae. Builtd3d12_compute_test, thenctest -C Release -R "^d3d12_compute$" --output-on-failure --timeout 300:d3d12_compute: passed, 1.11 sdirectly indexed compute heap: 64 buffer reads and 64 null controls matched1 passed, 0 failed.
@Luna-OS on GitHub · 2026-11-24 19:04 UTC · original
Independent Windows verification of
90bbf5e60(merge base3295055).Host: Windows 11 Pro 26300, NVIDIA GeForce RTX 5070 Ti (driver 621.24, Resizable BAR), live WARP, MSVC 19.44.35207 (VS 2022 Build Tools), Ninja, RelWithDebInfo,
LEONIDA_VULKAN_HEADERS_FETCH=ON,LEONIDA_SDL3_FETCH=ON. Two full runs per head: without glslang (272 tests), and with glslang (KhronosGroupmain-tot) sod3d12_compute,d3d12_drawandd3d12_meshare built too (298 tests). No game files. AI-assisted (Claude Code).d3d12_compute(needs glslang; not built without it)d3d12_com,d3d12_close_parity,vk_command_replayFailures shared with the merge base
3295055and not caused by this PR:d3d12_execute_indirect_validation(the five rows of #504), and with glslangd3d12_drawSEGFAULTs on the base too (slot-14 false positive, claimed as D3D-SLOT14-TAIL-NULL-PAGE, PR follows).@Moriz82 on GitHub · 2026-11-24 19:13 UTC · original
Thank you for the review, the mutation check and the native Windows runs. The branch is updated; the numbered points follow your findings.
tools/compute_heap_layout_census.pyand a synthetic test for it. Of 5,450 compute entries, 2,959 advertise direct indexing and none of those embeds RTS0. Matching dispatch records of integration #984 to the pipeline library gave seven comparable resource reads. All seven agree with the end of the explicit layout, zero disagree, and zero lack room. The other 2,952 have no paired signature, and no sampler read was paired. So the code comment and section 3.4 now call the general ordering a hypothesis, cite #984 and give the reproduction command. The description has the table per carve.--per-programprints the resource and the sampler result separately.getenvis replaced byGetEnvironmentVariableA, which removes the C4996 warning you saw.compute_user_data()into both block-based dispatch paths, and the placement for spilled signatures stays open.Run on the new head (CachyOS, Proton Experimental, RTX 4070, NVIDIA 620.73.04):
d3d12_compute_testexits 0 in both settings (64 buffer reads and 64 null controls by default, 128 zero controls withLEONIDA_COMPUTE_DIRECT_HEAPS=0),d3d12_bundle_testandd3d12_set_descriptor_heaps_testpass, and the three census tests pass. Not run here: the validation layer (not installed on this machine) and native Windows.d3d12_indirect_dispatch_count_testexits 1 under Wine on this machine with builds of unrelated trees too, so I could not use it. If you rerun your four targets on this head, that would cover both gaps.🤖 Generated with Claude Code
@iFeyz on GitHub · 2026-11-24 19:51 UTC · original
AMD run (the gap the description lists): RX 9070 XT (RDNA4, GFX1201), AMD proprietary Windows driver 26.11.2 (LLPC, Vulkan 1.4.359), Windows 11, MSVC 2022 RelWithDebInfo.
Head
7c47fd946:d3d12_computebuilt from it passes;tests/test_compute_heap_layout_census.py: OK.@Moriz82 on GitHub · 2026-11-24 21:01 UTC · original
Rebased onto
main66d4f5aa3: the branch had started to conflict inruntime/shims/d3d12_com.cpp. The one conflict was inrecord_draw, wheremainnow tests every bound viewport; the resolution keepsmain's test and this change's diagnostic call. Nothing else moved (still 8 files, +422/−14).Run again on the rebased head (CachyOS, Wine 11.22, RTX 4070, NVIDIA 620.73.04):
d3d12_compute_testexits 0 in both settings (64 buffer reads and 64 null controls by default, 128 zero controls withLEONIDA_COMPUTE_DIRECT_HEAPS=0),d3d12_bundle_testandd3d12_set_descriptor_heaps_testpass, and the three census tests pass. Not run here: the validation layer and native Windows.@iFeyz thank you for the AMD run on
7c47fd946; that was the gap in the description. The code is the same after the rebase except for the conflict above.🤖 Generated with Claude Code
@aslan2142 on GitHub · 2026-11-25 03:25 UTC · original
Merged, after merging
maininto it (5115f0887). Thanks, and thanks to everyone who tested it.mainalready took the core of this from #984, somain's form stays and what this adds is carried onto it:RT-DIRECT-HEAP-COMPUTE, valid, before this PR.main:with_direct_heaps()andcompute_user_data()onDispatchand theExecuteIndirectdispatch,compute_arguments_end,LEONIDA_COMPUTE_DIRECT_HEAPS=0and the same mode incs_user_data.comp.compute_user_data()now makes the missing-heap note, so anExecuteIndirectdispatch reports it too.kNoSgpronmain) gets its own note.d3d12_compute_test.tools/compute_heap_layout_census.py, its test and the evidence paragraph (the resource-then-sampler order is marked as a hypothesis).mainsupplies it now) and the separateGetEnvironmentVariableAswitch (mainhasdirect_heaps_enabled).main; the narrow tests pass.main0bc810504+5115f0887: 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 5 changed files.AI-assisted (Claude Code, Claude Opus 5.5).