startup: compute input named by a resource heap record a root constant indexes #2524
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2532"
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-25T20:10:22Z.
Depends on #2490 (compute dispatch with textures and census; this branch is stacked on it). Refs #2274
What changes
One behaviour: a compute program may take a buffer input from the directly indexed resource heap (root flag 0x400) when the record index is a root constant.
Translator (
tools/startup/gfx2hlsl.py) lowers exactly this form:with no write of
Rand no branch target between the two.Dbecomes a buffer descriptor and the manifest names itEverything else through the heap pointer keeps a refusal that names the form:
s_buffer_load_*then<< 5)s_load of a resource heap record whose index is read from a bufferm0... whose offset is not a root constant shifted left by 5 since the last branch target... of 8 dwordsoffset:modifier... with offset:0x..... through a pointer whose high word is not a constant zeros_load with a register offset through ('resheap',))Dispatch (
src/startup_stubs)Pass::title_view_heap, aViewTablebuilt withresolve_view_table, set and replaced wheretitle_samplersis).srv <i> buf heap rootconst <p> <w>is parsed into the existing slot list. At Dispatch the record address istitle_view_heap.record(uint32(word(p, w)) << 5, 16); from there the descriptor is read and bound by the code atable <p> <byte>record uses. No second binding path.a heap record is outside the list's view heap, before anything is bound, like the other refusals in that loop.Tests
Commit under test:
b6bc3c30(two commits onf67f80a4, the head of #2490; the second only drops one fixture case and adds a sentence to the docs, and the runtime sources are those off5c3c857, which the dispatch runs below were built from). Windows 10.0.26300, MSVC 14.44, LLVM 15llvm-mc.Result:
heap record fixture: 45 instructions reassembled to the recorded words, thenPASS (manifest and HLSL exact; 19 refused controls; graphics, manifest and translator-mutation checks). Expected: the same.mainare compared whole.Result: 7 of 7 passed, no capability skip.
startup_gfx2hlsl_heap_recordstartup_compute_dispatch_warpstartup_compute_dispatch_texture_warpstartup_compute_dispatch_heap_warp(new)startup_compute_dispatch_hardwarestartup_compute_dispatch_texture_hardwarestartup_compute_dispatch_heap_hardware(new)The new dispatch test runs a source-built gfx1013 program (case A of
startup_gfx2hlsl_compute_check.pywith its input loaded from the heap) through the stand-in's list. The input descriptor is only in heap record 2; records 0 and 1 hold the output's descriptor. All 320 output words are read back from the aliased memory and compared.Negative controls of the dispatch test:
refused: no translation, every word keeps its sentinel;0x07ffffff(a record past the heap): onerefused: a heap record is outside the list's view heap, the census names that reason, every word keeps its sentinel and the input is unchanged;word=0 got=c5c5c5c5 expected=ea74e376 (288 words differ)andrefused: an output buffer is also an input.Wider groups, same build:
ctest --preset dev --no-tests=error -R "^startup_compute_|^startup_stream_|^startup_gfx2hlsl_heap_record$": 63 of 63 passed (61 in one run; the twostartup_stream_depth_*tests passed once their executable was built), no capability skip.Pure-Python checks: every check listed in
AGENTS.mdplus everytests/startup_gfx2hlsl_*_check.pyandtests/startup_translator_check.py, each run with no argument: 152 exit 0, 1 exit 77 (startup_run_sh_check.py, a POSIX launcher check that skips on Windows; not a pass).git diff --checkis clean.Measured and not measured
Measured:
s_pack_ll_b32_b16in 3 of them, thenv_fma_mix_f32, an SDWAv_cndmask_b32,buffer_store_format_xyzwand others).Not measured, or a hypothesis:
.failfor such a request keeps it until the request is translated again.🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by NiiRoZz on 2026-11-25T20:22:01Z.
The Linux Python job failed at
5bade3c4ontests/startup_gfx2hlsl_sload_const_offset_check.py, a check that landed onmainafter this branch was written. It calls thes_loadhandlers on a stage built without akind, and the heap record branch readself.kinddirectly, so the eight-dword case raisedAttributeErrorinstead of the refusal.Fixed in
fdba7797(with currentmainmerged in, no conflict): the branch now reads the kind withgetattr(self, 'kind', None), as the other handlers in the file do. No behaviour change for a real stage.Run at
fdba7797, Windows 10.0.26300, Python fromout/pe-env:Not rerun after this commit: the dispatch tests (the runtime sources are unchanged) and the heap record check's
--llvm-mcreassembly.Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-25T21:38:18Z.
Seven mutations of the resource-heap record path, all caught — after I fixed two anchors that had matched the wrong function
The device-free check
The other three checks in this PR (
startup_compute_dispatch_check.py,…_heap_check.py,…_texture_check.py) exit 1with no arguments — they want DXC, an adapter and a dispatch mode, so they are the GPU half and I did not run them. The
19 refused controls in the pure-Python one are the part that matters for the new symbolic matcher anyway.
Mutations
heap_record/ the index trackingint(srcs[1], 0) == 5→4(32-byte record becomes 16-byte)rootconstacceptedcount != 4guard removedimm is not None(offset) guard removedTwo of these need a note about my own method, because I reported them wrong the first time and then fixed it: my anchors
if count != 4:andif imm is not None:matched the first occurrences in the file —s_loadat line 3610 and theSMEM literal-offset check at 3574 — not the ones inside
heap_recordat 3634/3636. Those two mutations were edits toother functions, and "survived" said nothing about this PR. Re-running with the anchors that include the surrounding
whatline (which only exists inheap_record) shows both are caught. A single genericif count != 4:is not ausable anchor in a 6 000-line translator; the message text is what makes it unique.
What the shift guard means
index << 5is the byte offset of a 32-byte record, and the fixture refuses the 16-byte reading. That is the one numberin this change whose wrongness would be silent:
<< 5→<< 4still produces a plausible descriptor, just from thewrong half of the record. It is caught.
The other half I did not touch
src/startup_stubs/d3d12_compute_dispatch.inl(+399),d3d12_draw.inl(+70),list_compute_root.h,list_dispatch.h,root_constant_store.hand 229 lines ofstartup_stream_consumer.cppare all on the dispatch/GPU side, exercised bystartup_compute_dispatch_{warp,hardware}— which are the three checks that need arguments. If you want a mutation passover that half too, say so and I will build the targets and run it the way I did for #2491.
AI-assisted; pure Python for the rows above, Windows 11 build 26300.
Imported from R0Y00/Xbox2Windows. Originally posted by Makto94 on 2026-11-25T22:13:51Z.
Hardware run at head
b306d44e(build exit code 0). The PR is stacked on #2490.Environment: NVIDIA GeForce RTX 3070 Ti, driver 32.0.16.2101 (NVIDIA 621.01) and Windows 11 Pro build 26300.9974 as reported by the system,
devpreset (MSVC). The runs were serial (-j1).ctest --preset dev --no-tests=error -j1 -V -R '^(startup_compute_dispatch.*|startup_root_constant_store|startup_list_dispatch.*|startup_compute_root|startup_gfx2hlsl_heap_record)$'Result: 15/15 passed, 0 failed: 3
startup_compute_dispatch*_warp, 3startup_compute_dispatch*_hardware, and the 9 other tests the diff adds (startup_root_constant_store,startup_list_dispatchand its 5_controltests,startup_compute_root,startup_gfx2hlsl_heap_record). 0 capability skips (77).startup_compute_dispatch_hardware,startup_compute_dispatch_texture_hardwareandstartup_compute_dispatch_heap_hardwareprintadapter=NVIDIA GeForce RTX 3070 Ti driver=32.0.16.2101anddebug layer: enabled, no error message.startup_compute_dispatch: PASS on hardware (all 320 words match after translation and with the same root set again; untouched before translation, without a Dispatch and for 6 refusals)startup_compute_dispatch_texture_hardware:texture output: all 1024 halves match after translation (64 changed) ...andtexture input: all 320 words match after translation ...startup_compute_dispatch_heap: PASS on hardware (all 320 words match through heap record 2; untouched before translation and for a record outside the heap)adapter=Microsoft Basic Render Driverwith the same debug-layer line.7a8d9c89) is on the branch asc821b4b2;c821b4b2("startup: avoid calling the compute driver after process termination begins") is an ancestor of this head. I repeated the hardware tests on a different NVIDIA GPU.Command:
ctest --preset dev --no-tests=error -j1 -V --repeat until-fail:20 -R '^startup_compute_dispatch(_texture|_heap)?_hardware$'Result: each of the 3 tests passed 20/20 consecutive runs (60
PASS on hardwarelines,100% tests passed, 0 tests failed out of 3). This does not cover the RTX 4060.This run covers NVIDIA and WARP only. Not covered: any test outside the filters above.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T01:38:11Z.
@NiiRoZz #2532 is now in conflict with
main(merge state DIRTY at head28c44d5f). It is the base of the stack #2580 -> #2585 / #2596 / #2624 / #2625, so none of those can be tested or merged until it is updated.Could you merge (or rebase onto) current
mainon this branch? Once the head changes we will re-run the review and the Windows checks on it.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T02:09:52Z.
@NiiRoZz I merged current
maininto this branch (merge commit29ee504b, no rebase, no force). One conflict insrc/startup_stubs/d3d12_xs_device.cpp(mainadded theE_OUTOFMEMORYcheck afterwrap); I kept both: the check first, then the compute request block. No other change to your code. This unblocks the stack #2580, #2585, #2596, #2624, #2625.Verification:
python3 -B tests/startup_gfx2hlsl_heap_record_check.py,tests/startup_gfx2hlsl_sload_const_offset_check.py,tests/docs_links_check.py,tests/bidi_controls_check.py,git diff --check origin/main...HEAD: all pass.x2w_pipe.py win2025 2532 --patch <merge diff> --targets startup_stream_consumer,d3d12_xs_shim --regex '^(startup_compute_.*|startup_stream_request_warp|startup_stream_adapter_filter)'gave 131/131 passed in each preset, includingstartup_compute_dispatch_{warp,hardware},startup_compute_dispatch_heap_*andstartup_compute_dispatch_texture_*.AI-assisted; commands listed were executed locally.