startup: bind a compute heap record whose index is read from a table buffer #2572
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2580"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by NiiRoZz on 2026-11-25T21:39:32Z.
Depends on #2532 (this branch is stacked on it; review the commits after its head).
What changed
tools/startup/gfx2hlsl.py: the heap-record index may be a word thats_buffer_load_dword(xN)reads from an unmodified table buffer descriptor, at a literal byte offset or at<root constant word> * k + c(s_mul_i32,s_mulk_i32,s_add_u32,s_add_i32,s_addk_i32with literals, plus anyoffset:modifier), dword-aligned, with no branch target between the arithmetic and the load or between the load and the shift. The manifest line issrv <i> buf heap word table <parameter> <byte> at <offset> [rootconst <parameter> <word> times <k>]. Every other buffer-read index keeps a refusal, now worded... whose index is read from a buffer other than a table buffer at a dispatch-constant offset.src/startup_stubs/d3d12_compute_dispatch.inl: parses the two new forms, reads the table record, computes the byte offset in 32-bit arithmetic, reads the index word and binds the heap record through the existing #2532 path. New refusals, each one logged reason and nothing recorded:a heap index word is not in the list's upload memory(view token or memory outside the list's slot 148 upload allocations) anda heap index word is outside its table buffer(word paststride * num_recordsbytes, with a stride of 0 counted as 1).tests/startup_stream_consumer.cpp:dispatch-heap-wordmodes and three controls.tests/startup_gfx2hlsl_heap_record_check.py: the two "index read from a buffer" controls used a literal offset, which is now accepted; they now read the index at a group-ID offset (s14), which stays refused with the same message prefix.tests/startup_gfx2hlsl_heap_word_check.py,tests/startup_compute_dispatch_heap_word_check.py; registered inCMakeLists.txt, the Windows workflow andAGENTS.md.docs/experiments.mdparagraph next to the heap-record text.Why the CPU read is sound
The word is read when the dispatch is recorded, not when the GPU runs. That is only correct if nothing on the GPU writes the word, so the stand-in reads it only from the recording's upload memory, which no GPU command writes, and refuses a placed buffer or a view token. A per-thread or group-ID index can't be read once on the CPU, and neither can a register sum or a modified descriptor, so all of these keep a refusal.
Tests
Commit under test:
ba79c8b0(code; the docs commits5c248dc1and62b5ccc0change no code), on #2532 head1efce194.Results: both translator checks PASS with reassembly,
startup_translator_check.pyreports 0 failed, ctest 10/10 passed, no exit-77 skips.Environment: Windows 10.0.26300.10075. WARP is the Microsoft Basic Render Driver 10.0.26100.10068. The hardware run used an NVIDIA GeForce RTX 5090 on driver 32.0.16.2135. The debug layer was enabled and logged no error message.
Each control was checked against a mutant: apply the mutant, rebuild, rerun, then revert. No mutant was committed.
times)at)-placedcontrol-pastcontrol (output written)Measured vs hypothesis
Measured: one synthetic program, on WARP and on one physical adapter. In a local set of 158 compute requests that hold such a load, 153 stopped first at the buffer-read index. All 153 change their first refusal, and none translates fully yet. 145 now stop at a non-heap instruction, 6 at the narrower buffer refusal and 2 at an 8-dword record. Their next first refusals:
vcclive at ans_cbranch_execzjoinv_fma_mix_f32src_sccins_mul_i32v_mad_u32_u16src_sccins_mov_b32s_and_b32live at an execz joinv_readfirstlane_b32s_buffer_load_dwordx8live at an execz joinCeiling: 145 programs hold a heap load that now lowers, but counting every refusal site, 120 of the 158 still hold a refused heap-record load:
With the branch-target clear disabled in a scratch copy (a diagnostic only, never committed), the programs with a refused x4 buffer-form site drop from 90 to 10. The main shape that stays refused is therefore an offset computed, or a word read, before a branch target. It stays refused because another path into the join may carry a different word. About 97 programs also load an 8-dword (image) heap record, which stays refused regardless.
Hypothesis, not measured:
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-25T23:08:43Z.
These three PRs (#2580, #2585, #2596) are near-identical copies of one change — worth picking one before any of them merges
Not a defect in the code. A merge-order hazard, with the measurements to back it up.
What I found while reviewing this one
I reviewed #2585 (heap-word tracking) and #2596 (entry values) earlier and mutated the same material in each. Opening this
one, the file list is the same 21 files in all three, and the diffs are identical where it matters:
(those are SHA-1 prefixes of
git diff <merge-base> <pr-head> -- <file>, so identical digests mean identical hunks).Where they differ, the difference is additive rather than conflicting:
and exactly one file is unique to a single PR:
So the shape is: one change, three open branches, with #2585 and #2596 each adding a fixture on top of the same base
(
heap_wordin #2585,heap_word+entryin #2596). The 21 shared files mean that whichever merges first will conflictwith the other two on almost every hunk.
What I measured on this branch
Both device-free checks pass here exactly as they do on #2585 and #2596, which follows from the identical hunks.
Earlier rounds, for completeness, with the same content:
heap_word_offsetand the index tracking — all five caught (root-constant scale, thebranch itself, the
rcmark, the join clear, "any write ends a mark").all three caught (
input_word3word index,output_strideshift, the formatted-input refusal).The suggestion
Pick the branch that already carries the fixtures you want — #2596 is a superset of #2585, which is a superset of this one —
and close or rebase the others onto it. Otherwise the first merge leaves two PRs that need a full manual re-resolution of
the same 21 files, and there is no way for a reader to tell from the PR list that they are the same work.
If they are meant to be stacked (this one is the base), saying so in each body would also make the review assignment
obvious: the base needs review once, the add-ons only for their own fixture.
AI-assisted; Windows 11 build 26300, pure Python for the rows above.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T02:31:23Z.
Merged
origin/maininto this branch (merge commite2b58be0, no rebase, no force-push). #2532 landed on main as one squash commit, so the branch conflicted in 9 files. I kept main's version of the #2532 content and re-applied only this PR's own five commits on top (the heap index word change, its two docs commits and the two test-tolerance fixes). The conflicts were list entries inAGENTS.md,CMakeLists.txt, the workflow anddocs/experiments.md, plus the compute dispatch code. The sources were merged by hand, keeping both sides.Commands executed locally:
startup_gfx2hlsl_heap_word_check.pyandstartup_gfx2hlsl_heap_record_check.py(both PASS),docs_links_check.py,bidi_controls_check.py,git diff --check origin/main..HEAD(all clean).c314f36f):startup_gfx2hlsl_heap_word,startup_gfx2hlsl_heap_record,startup_compute_dispatch_heap_word_warpand_hardware,startup_compute_dispatch_heap_{warp,hardware}andstartup_compute_dispatch_{warp,hardware}: Passed.startup_compute_dispatch_texture_{warp,hardware}fail with "an output texture view was not created on the desktop". They fail the same way on current main without this PR's change, so they predate it.startup_gfx2hlsl_scalar_table_arity_checkalso fails on main (fix in #2696).AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T04:12:56Z.
Review: COMMENTED
Merged
origin/maininto the branch (plain merge, no rebase, no force):f56592de.CMakeLists.txt(the compute dispatch test block). Kept both sides: this PR'sstartup_compute_dispatch_heap_word_*and main'sstartup_compute_live_retry_*, both in the sharedset_tests_propertieslist.Verification, run on the merged tree with the diff of #2710 applied on top (so it is tested as it will land):
x2w_pipe.py win2025 2580 --patch <merge diff + gh pr diff 2710> --regex 'startup_compute_dispatch|startup_gfx2hlsl_heap|startup_pixel_uav|startup_compute_live_retry|startup_stream'tests/startup_stream_consumer.cpp) was resolved by keeping both sides. When #2710 lands in main, the merge should be mechanical.Ready to squash-merge once #2710 is in main and CI is green.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T05:47:47Z.
Review: COMMENTED
Win2025 WARP receipt after merging
origin/maininto this branch (new head9f97acc3; the run applied the same merge as a patch onf56592de). Main was merged twice; the only conflict was a comment block intests/startup_stream_consumer.cpp, kept both sides.Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP):
--preset dev) and Release/O2(--preset release), targetsstartup_stream_consumer d3d12_xs_shim, each: 100% tests passed, 8 of 8.startup_compute_dispatch_heap_word_warp,startup_compute_dispatch_heap_word_hardware,startup_compute_dispatch_heap_warp,startup_compute_dispatch_heap_hardware,startup_compute_dispatch_warp,startup_compute_dispatch_hardware,startup_gfx2hlsl_heap_word,startup_gfx2hlsl_heap_record.tests/startup_gfx2hlsl_heap_word_check.pyrc=0,tests/startup_gfx2hlsl_heap_record_check.pyrc=0._hardwaretests ran on the VM's WARP adapter only.Linux:
git diff --check origin/main...HEAD,docs_links_check.py,bidi_controls_check.pyclean.Code review of this PR's own change: reads the index word only from the recording's upload memory and refuses placed buffers, view tokens and out-of-range words, each with a negative control. The author's mutation table covers all of them. No game progress is claimed. @ChazY11's note about #2580, #2585 and #2596 sharing the same hunks still applies: whichever merges first will make the others conflict.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T05:47:46Z.
Win2025 WARP receipt after merging
origin/maininto this branch (new head9f97acc3; the run applied the same merge as a patch onf56592de). Main was merged twice; the only conflict was a comment block intests/startup_stream_consumer.cpp, kept both sides.Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP):
--preset dev) and Release/O2(--preset release), targetsstartup_stream_consumer d3d12_xs_shim, each: 100% tests passed, 8 of 8.startup_compute_dispatch_heap_word_warp,startup_compute_dispatch_heap_word_hardware,startup_compute_dispatch_heap_warp,startup_compute_dispatch_heap_hardware,startup_compute_dispatch_warp,startup_compute_dispatch_hardware,startup_gfx2hlsl_heap_word,startup_gfx2hlsl_heap_record.tests/startup_gfx2hlsl_heap_word_check.pyrc=0,tests/startup_gfx2hlsl_heap_record_check.pyrc=0._hardwaretests ran on the VM's WARP adapter only.Linux:
git diff --check origin/main...HEAD,docs_links_check.py,bidi_controls_check.pyclean.Code review of this PR's own change: reads the index word only from the recording's upload memory and refuses placed buffers, view tokens and out-of-range words, each with a negative control. The author's mutation table covers all of them. No game progress is claimed. @ChazY11's note about #2580, #2585 and #2596 sharing the same hunks still applies: whichever merges first will make the others conflict.
AI-assisted; commands listed were executed locally.