startup: compute entry values from the words of a bound buffer descriptor #2596
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!2596
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2596/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?
@NiiRoZz on GitHub · 2026-11-25 22:17 UTC · original
NiiRoZz:startup/compute-dispatch-entry-values→main· +240 −29 · 6 files · 81 commits · merged 2026-11-26 06:15 UTCDepends on #2580 (stack #2470 -> #2490 -> #2532 -> #2580). Refs #2274.
The branch also merges current
main: the computebuffer_store_format_d16_xlowering of #2478 is what emits the output entry values, and the fixture uses its program.What changed
A translated compute program's manifest can take entry values from the descriptor that a buffer input or output is bound from:
buffer_load_format_*): the input's stride and word 3 (udsrc <i> stride <srv>,udsrc <i> descword3 <srv>);buffer_store_format_d16_xon main,buffer_store_format_xyzwin #2530): the output's word 3, the upper half of word 1 and the record count (uav_descword3,uav_stride,uav_numrecords).Before this change, slot 14 (Dispatch) bound only root-constant entry values. Any other
udsrcline left the pipeline untranslated withan entry value that is not a root constant. Now:indirect_table_bufferalready returns, from a hardware descriptor or from the title's buffer view for a token.formatted_buffer_word3()ind3d12_draw.inl, and draws and Dispatch now both call it. A token's word is built from its view. A FORMAT the program does not decode refuses the dispatch witha formatted input has no word 3 the program decodes.an entry value names a descriptor that is not a buffer input or output).an entry value that is not a root constant or a buffer descriptor word.The test consumer gains two optional inputs:
X2W_TEST_DISPATCH_IN(input words) andX2W_TEST_DISPATCH_FIELDS(stride, record count and word 3 of both table descriptors). Existing modes are unchanged.Tests
New
tests/startup_compute_dispatch_entry_check.py, registered for WARP and hardware like its neighbours. It dispatches two source-built gfx1013 programs through the stand-in's list and reads the 320 output words back from the aliased memory:startup_gfx2hlsl_compute_check.py). Stride 6 with word 3 of L-uint, then of L-unorm on the same translation, each match that case's 320 words. A FORMAT the program does not decode is refused with one reason and leaves every word at its sentinel.buffer_store_format_d16_x(case F ofstartup_compute_store_d16_x_check.py). Four output descriptors give four different expectations: 32_FLOAT with stride 8 and 12 records, 16_FLOAT with the same, 32_FLOAT with stride 12 and 7 records, and SWIZZLE_ENABLE set in word 1 (translated; the program stores nothing).Before translation, both programs are refused with
no translation.Controls per entry-value kind:
descword3: an undecoded FORMAT is refused; the L-uint and L-unorm words give different read-backs on one translation.stride: implicit only. An ignored or zero stride reads one record in every lane and the L runs fail. No separate mutation was run.uav_descword3: two formats give different read-backs.uav_stride: returning a constant 8 fails the stride-12 run (12 words differ). Masking it to 14 bits, as the draw path does, fails the swizzle run (12 words differ).uav_numrecords: cannot be isolated, because the bound range is sized from the same word. Only a value of zero would show.Results:
^startup_compute_dispatch_: 10/10 passed (WARP and hardware for all five fixtures), no skips. The new fixture was rerun on both adapters after the swizzle run was added: 2/2 passed.^startup_formatted_view_draw_: 2/2 passed. This covers the shared word-3 check on the draw side.Environment:
Measured and hypothesis
Measured: the fixtures above, on two synthetic programs.
Local census, counts only: 29 compute programs had this manifest line as their first refusal, about 1.4 million Dispatch calls in one run. Under the new classifier:
soffset.Not measured: which bind-time reason the 27 meet next. That needs a run.
Unverified
soffsetcan land paststride * recordsbytes, outside the bound range, and would be dropped silently. None of the 27 programs does this, and no fixture covers it. The same holds for formatted loads with ansoffset.🤖 Generated with Claude Code
A device slot 67 placeholder keeps the key of its published request. At list slot 14 the stand-in loads the stage cs manifest and compiled program for that key and records the dispatch: raw buffer inputs and outputs from hardware descriptors in the recorded compute tables, entry values from the recorded compute root constants. Other manifest lines leave the pipeline untranslated; a dispatch that cannot be bound completely is refused with one logged reason and records nothing. startup_compute_dispatch_{warp,hardware} drives a source-built program through the stand-in list and reads the output back, with controls before translation, without a Dispatch and for a refused output. Co-Authored-By: Claude Fable 5.2 <[email protected]>The per-call refusal lines share one small budget, so a run cannot rank keys by dispatch count. Each key now keeps its Dispatch count, the calls recorded and the reason and table descriptor of its first refusal; the periodic totals are followed by the refused dispatches per reason and the 40 keys with the most dispatches. A manifest that exists but cannot be bound is counted apart from an absent one ("not modelled"). Co-Authored-By: Claude Fable 5.2 <[email protected]>gfx2hlsl.py lowers one form of a register-offset load through the directly indexed resource heap pointer of a compute root signature: s_lshl_b32 R, <root constant word>, 5 s_load_dwordx4 D, s[H:H+1], R ; s[H+1] a constant zero, no offset: with no write of R and no branch target in between. D is a buffer descriptor and the manifest names it `srv <i> buf heap rootconst <parameter> <word>`. Every other form keeps a refusal that names it, including an index read from a buffer. The stand-in records the title memory of the list's view heap on every slot 32 call (it kept only the sampler heap and, for oversized heaps, the wrapper) and a Dispatch reads the 16-byte descriptor at byte `word << 5` of that memory, then binds it through the path a table record takes. A record outside the heap refuses the dispatch and binds nothing. Checks: tests/startup_gfx2hlsl_heap_record_check.py (manifest and HLSL exact, 19 refused controls, one translator mutation, LLVM 15 reassembly) and tests/startup_compute_dispatch_heap_check.py on WARP and a physical adapter. Refs #2274 Co-Authored-By: Claude Fable 5.2 <[email protected]>8a4df523) d17d2629b89828b5d8); pin the entry-value and refusal controls a20521715af5b03039) into startup/compute-dispatch-textures 190e00a1691991fd08a1' into startup/compute-dispatch-heap-rootconst 63875b31055e185ab7df' into pr2490-fu 1991fd08a163875b3105' into startup/compute-dispatch-heap-bufindex 356b805fd3356b805fd3' into startup/compute-dispatch-entry-values 121d01b48c2221bd8f2f' into startup/compute-dispatch-entry-values 8c8c57920060304f30' into HEAD aa11b13642aa11b13642' into HEAD 550bef9235@tedin7 on GitHub · 2026-11-25 22:21 UTC · original · reviewed
Not merging for now: this PR says it depends on #2580 (stack #2470 -> #2490 -> #2532 -> #2580), and all four are still open. The branch also carries 55 commits and touches
.github/workflows/windows.ymlandAGENTS.md, so it needs a fresh review once the stack lands and the branch is rebased on main.No code review was done on head
2efebc4c. This comment only records that the merge is blocked by the dependency chain. It also changes the startup compute path, so a source-built regression test plus a negative control will be needed at that point.AI-assisted; commands listed were executed locally. Commands:
gh pr view,python3 merge_check.py 2596.@ChazY11 on GitHub · 2026-11-25 23:05 UTC · original
Measured here: 4/4 pass on WARP and the physical GPU, and three mutations of the entry-value extraction are all caught
What I ran
The two device-free checks also pass unchanged:
So the headline claim — an entry value named from the words of a resource heap record, bound at dispatch — is measured on
both backends, not just asserted.
Three mutations of the entry-value extraction (
d3d12_compute_dispatch.inl:338)input_word3readsword[2]instead ofword[3]output_stridestops shifting (view.words[1] >> 16→view.words[1])if (formatted_buffer_word3(…))→if (false))The first two are the ones that would be silent in production:
input_word3copies the four descriptor words and handsword[3]to the program as a constant, andoutput_stridetakeswords[1] >> 16deliberately unmasked (the commentsays the program checks the swizzle bits itself). Off by one word, or unmasked, and the dispatch binds a plausible wrong
number with nothing to show for it — both are caught.
The third is the refusal side: a formatted buffer has no word 3 the program can decode, so it must be refused by name.
Removing the refusal changes the classification, and the entry check notices.
A correction about my own run, because it changes what the first result meant
My first pass used
cmake --build --preset dev --target startup_compute_dispatch_entryand reported three survivors —but the build failed (
build=False) every time, becausestartup_compute_dispatch_entryis the ctest case name, not aCMake target. ctest then ran the stale binary and passed, so those three rows were measuring the unmutated code.
ctest -N -Vshows the real command:startup_compute_dispatch_entry_check.py <startup_stream_consumer.exe> <dxc> warp. Re-runagainst the correct target, all three are caught as shown above.
I have hit this same trap before in this repository with
mesh_xmem,startup_address_srvandstartup_list_copy_texture_warp; the rule that works is "ctest -N -Vfirst, mutate second".AI-assisted; Windows 11 build 26300, WARP plus the installed physical GPU (Intel Arc 140T, driver 32.0.101.8132), MSVC x64
via the Build Tools dev shell, DXC 10.0.26100.0. Each mutation rebuilt
startup_stream_consumer, ran both entry cases,reverted and rebuilt; final state 2/2 green.
@tedin7 on GitHub · 2026-11-26 06:06 UTC · original
Merged main into this branch (the branch still carried the commits of #2580, which main now has as one squash, so the conflicts were duplicates; I applied only this PR's own changes on top of main:
CMakeLists.txt,docs/experiments.md,d3d12_compute_dispatch.inl,d3d12_draw.inl,startup_compute_dispatch_entry_check.py,startup_stream_consumer.cpp). NoAGENTS.mdorgfx2hlsl.pychange remains in the diff.Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) on this content (original head
b6665da6plus the merge as a patch):--preset dev):ctest -R '^(startup_compute_dispatch_entry_warp|startup_compute_dispatch_warp|startup_compute_dispatch_texture_warp|startup_compute_dispatch_heap_warp|startup_compute_dispatch_heap_word_warp|startup_compute_live_retry_warp)$'-> 100% tests passed out of 6--preset release): same regex -> 100% tests passed out of 6startup_compute_dispatch_entry_warp(new),startup_compute_dispatch_warp,startup_compute_dispatch_texture_warp,startup_compute_dispatch_heap_warp,startup_compute_dispatch_heap_word_warp,startup_compute_live_retry_warp.AI-assisted; commands listed were executed locally.
@R0Y00 on GitHub · 2026-11-26 06:15 UTC · original
I checked that your
70d95a1dmerge has the identical Git tree as my independent conflict resolution, so I left your branch as-is. A fresh Windows 11 build 26200 Release build of startup_stream_consumer ran ctest --preset release --no-tests=error -j 1 -R '^startup_compute_dispatch_(entry|heap_word)_(warp|hardware)$' -V. All four tests passed on in-box WARP and RTX 4060 Laptop, with no skips. Each entry test matched six descriptor-word dispatches and kept output untouched for the refused formatted-input case. Both adjacent tests matched all 320 words and retained the three refusal controls.@MasterDomino on GitHub · 2026-11-26 06:25 UTC · original
@NiiRoZz: since this merge (
c8b7b973),tests/startup_vertex_fetch_formats_check.pystops at its source gate:AssertionError: formatted_buffer_supported(. The parentc458bba9runs the check cleanly. That makesstartup_vertex_fetch_formats_controls,_warpand_hardwarefail onmain.The cause: this PR moved the
formatted_buffer_supported(check out of the draw preflight ind3d12_draw.inlinto the shared formatted-buffer helper, but the check'sruntime_gatestill looks for that text in the draw preflight (startup_vertex_fetch_formats_check.py:415and:428). It's a stale text gate, not a runtime bug. Pointing the gate at the shared helper, or at its call site, should fix it.Found while reviewing #2006, whose format-50 readback can't be re-confirmed on a merge with
mainuntil this is fixed.AI-assisted; commands listed were executed locally.