Skip to content

startup: compute input named by a resource heap record a root constant indexes - #2532

Merged
tedin7 merged 60 commits into
R0Y00:mainfrom
NiiRoZz:startup/compute-dispatch-heap-rootconst
Nov 26, 2026
Merged

tedin7 merged 60 commits into
R0Y00:mainfrom
NiiRoZz:startup/compute-dispatch-heap-rootconst

Conversation

@NiiRoZz

@NiiRoZz NiiRoZz commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

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:

s_lshl_b32 R, <root constant word>, 5
s_load_dwordx4 D, s[H:H+1], R        ; s[H] the heap pointer, s[H+1] a constant zero, no offset: modifier

with no write of R and no branch target between the two. D becomes a buffer descriptor and the manifest names it

srv <i> buf heap rootconst <parameter> <word>

Everything else through the heap pointer keeps a refusal that names the form:

form refusal
index read from a buffer (s_buffer_load_* then << 5) s_load of a resource heap record whose index is read from a buffer
other shift, other index, index register written again, branch target in between, unshifted register, m0 ... whose offset is not a root constant shifted left by 5 since the last branch target
eight dwords (an image record) ... of 8 dwords
offset: modifier ... with offset:0x..
high word of the pointer pair not a constant zero ... through a pointer whose high word is not a constant zero
formatted load, store, or a non-buffer kind through such a record refused as before / in the manifest
graphics stages unchanged (s_load with a register offset through ('resheap',))

Dispatch (src/startup_stubs)

  • The list's view heap was not recorded in the general case: slot 32 kept the sampler source and, only for a heap with more logical than physical entries, the heap wrapper. Slot 32 now also records the title memory of the view heap it is given (Pass::title_view_heap, a ViewTable built with resolve_view_table, set and replaced where title_samplers is).
  • srv <i> buf heap rootconst <p> <w> is parsed into the existing slot list. At Dispatch the record address is title_view_heap.record(uint32(word(p, w)) << 5, 16); from there the descriptor is read and bound by the code a table <p> <byte> record uses. No second binding path.
  • A record outside the heap refuses the dispatch with 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 on f67f80a4, the head of #2490; the second only drops one fixture case and adds a sentence to the docs, and the runtime sources are those of f5c3c857, which the dispatch runs below were built from). Windows 10.0.26300, MSVC 14.44, LLVM 15 llvm-mc.

python -B tests/startup_gfx2hlsl_heap_record_check.py --llvm-mc llvm-mc-15

Result: heap record fixture: 45 instructions reassembled to the recorded words, then PASS (manifest and HLSL exact; 19 refused controls; graphics, manifest and translator-mutation checks). Expected: the same.

  • The manifest and the HLSL from the bindings to the end of main are compared whole.
  • 19 controls each change one thing in the program and must be refused with the reason in the table above.
  • Translator mutation: with the write tracking disabled for one instruction, the "index register written again" control translates; the check requires that, then requires the refusal again with the tracking restored.
cmake --build --preset dev --target startup_stream_consumer
ctest --preset dev --no-tests=error -R "^startup_compute_dispatch_|^startup_gfx2hlsl_heap_record$" -V

Result: 7 of 7 passed, no capability skip.

test adapter driver debug layer result
startup_gfx2hlsl_heap_record none pass
startup_compute_dispatch_warp Microsoft Basic Render Driver 10.0.26100.10068 enabled, no error message pass
startup_compute_dispatch_texture_warp Microsoft Basic Render Driver 10.0.26100.10068 enabled, no error message pass
startup_compute_dispatch_heap_warp (new) Microsoft Basic Render Driver 10.0.26100.10068 enabled, no error message pass
startup_compute_dispatch_hardware NVIDIA GeForce RTX 5090 32.0.16.2135 enabled, no error message pass
startup_compute_dispatch_texture_hardware NVIDIA GeForce RTX 5090 32.0.16.2135 enabled, no error message pass
startup_compute_dispatch_heap_hardware (new) NVIDIA GeForce RTX 5090 32.0.16.2135 enabled, no error message pass

The new dispatch test runs a source-built gfx1013 program (case A of startup_gfx2hlsl_compute_check.py with 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:

  • before translation: refused: no translation, every word keeps its sentinel;
  • root constant 0x07ffffff (a record past the heap): one refused: 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;
  • runtime mutations, each rebuilt and run once on WARP, then reverted: shift by 4 instead of 5, and index ignored. Both failed the test with word=0 got=c5c5c5c5 expected=ea74e376 (288 words differ) and refused: 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 two startup_stream_depth_* tests passed once their executable was built), no capability skip.

Pure-Python checks: every check listed in AGENTS.md plus every tests/startup_gfx2hlsl_*_check.py and tests/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 --check is clean.

Measured and not measured

Measured:

  • the translation and the dispatch of one synthetic program, on WARP and one physical adapter;
  • in a local set of 184 compute programs that hold a register-offset load through the heap pointer: every such load now lowers in 4 programs; 151 programs hold a load whose index is read from a buffer and 57 hold a load with another unmodelled offset (a program can hold both). None of the 184 translates with this change: the 4 stop at other instructions (s_pack_ll_b32_b16 in 3 of them, then v_fma_mix_f32, an SDWA v_cndmask_b32, buffer_store_format_xyzw and others).

Not measured, or a hypothesis:

  • no real program reaches a Dispatch through this path yet, so nothing is claimed about frames or startup;
  • the record offset is a literal byte offset into the title's heap memory, as a table offset is. The fixture writes its descriptors at those bytes itself. A caller that places records by the adapter's descriptor increment on an adapter whose increment is not 32 bytes is not covered (WARP is such an adapter, so its run covers the literal offset only); the same holds for table offsets today;
  • that the heap pointer SGPR follows the root parameters is the translator's existing inference for compute entry registers, not something this change verifies;
  • only a buffer read is modelled through a heap record. Image records (eight dwords), stores and formatted loads stay refused;
  • the translator cache revision is unchanged, so a cache that already holds a .fail for such a request keeps it until the request is translated again.

🤖 Generated with Claude Code

tedin7 and others added 30 commits November 24, 2026 19:53
…33 and 35)

Header-only state in list_compute_root.h with a Linux-testable check. Dispatch (slot 14) is not handled here; the state is exposed through ready() and table() for it. Refs R0Y00#870.
Compute root constants are kept per list next to the graphics ones, in a shared 16 x 8 word store that refuses parameter >= 16 and offset >= 8. A new compute root signature clears them.
Part of R0Y00#870. Forward Dispatch only with a desktop compute pipeline and root
bound and group counts within 65535 per axis; refuse otherwise.
…t against the bound root

Slot 43 clears a parameter's binding when a replacement is rejected, slot 33 clears all bindings, and the compute pipeline records its root so a mismatched pair is refused.
Compute root constants are kept per list next to the graphics ones, in a shared 16 x 8 word store that refuses parameter >= 16 and offset >= 8. A new compute root signature clears them.
Part of R0Y00#870. Forward Dispatch only with a desktop compute pipeline and root
bound and group counts within 65535 per axis; refuse otherwise.
…t against the bound root

Slot 43 clears a parameter's binding when a replacement is rejected, slot 33 clears all bindings, and the compute pipeline records its root so a mismatched pair is refused.
Conflicts in d3d12_xs_device.cpp and docs/experiments.md resolved by keeping both sides: the pipeline root
out-parameter of the stream builder next to the cached-mesh root, the bound root SRV mask next to the recorded
upload SRV addresses, and both table entries and document sections.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Conflicts in d3d12_draw.inl and d3d12_xs_device.cpp resolved by keeping both sides: graphics root constants
go through the shared store and still mark the words a slot 40 call set.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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 <noreply@anthropic.com>
Dispatches that arrive before the offline translation no longer use up
the lines kept for refusals at bind time.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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 <noreply@anthropic.com>
A `uav <i> tex2d float table <param> <byte> channels 4` manifest line is
bound from the token of the unordered access view the title created in
its descriptor memory. Everything else is refused with its own reason: an
entry that is no such token, a view the desktop did not create, a view
that is not 2D, a format a float4 store cannot target, and a texture
bound to two slots of one dispatch. Programs without entry values, inputs
or outputs load too: the translated root no longer emits an empty range
or drops the table when only outputs exist.

The fixture stores through the stand-in's own list into a 32x8
RGBA16_FLOAT texture and reads it back with CopyTextureRegion.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A `srv <i> tex2d table <param> <byte>` manifest line is bound from the
token of the shader resource view the title created, through the texture
the draw path samples for that resource, uploaded first when the title
filled it in memory. `smp` lines become static samplers of the translated
root. A dispatch is refused, never bound to a null view, when the entry
is no such token, the resource has no desktop texture, the view is not 2D
or names a packed format, or the upload fails. Sampler heaps, comparison
samplers and other texture kinds keep the translation unavailable.

The fixture samples a 1x1 texture into the stored words of the raw buffer
case; without a view the dispatch is refused and the output is untouched.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…s test

The device check drains the debug layer; a draw runs it on every 64th call
and the queue's execute drains the rest. A view token whose resource the
caller released is the caller's misuse, as on the draw path.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…puts, print every census key

A texture is refused only when the same call reads and writes it; two
outputs of one texture share the unordered access state. A packed output
view format gets its own refusal reason. The census prints every
dispatched key instead of the first 40, and the wording on refused calls
says what may already be recorded (an input texture upload).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Makto94

Makto94 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

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, dev preset (MSVC). The runs were serial (-j1).

  1. Command: 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, 3 startup_compute_dispatch*_hardware, and the 9 other tests the diff adds (startup_root_constant_store, startup_list_dispatch and its 5 _control tests, startup_compute_root, startup_gfx2hlsl_heap_record). 0 capability skips (77).

  • startup_compute_dispatch_hardware, startup_compute_dispatch_texture_hardware and startup_compute_dispatch_heap_hardware print adapter=NVIDIA GeForce RTX 3070 Ti driver=32.0.16.2101 and debug 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) ... and texture 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)
  • The WARP tests print adapter=Microsoft Basic Render Driver with the same debug-layer line.
  1. Repeat run. A comment on startup: dispatch translated compute programs with raw table buffers #2470 reported an intermittent process-exit failure in the direct Dispatch case on an RTX 4060 (3 failures in 5 repetitions) and isolated it to the release of the cached desktop PSO. The startup: dispatch translated compute programs with raw table buffers #2470 thread says the fix (7a8d9c89) is on the branch as c821b4b2; 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 hardware lines, 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.

NiiRoZz and others added 7 commits November 25, 2026 23:50
Upstream now records the compute root and tables (slots 33 and 35) and has its own
DllMain with x2w_startup::d3d12_process_terminating, so this branch's flag and DllMain go.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…tch-translated

# Conflicts:
#	docs/experiments.md
… into startup/compute-dispatch-heap-rootconst
NiiRoZz and others added 4 commits November 26, 2026 01:05
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@tedin7

tedin7 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

@NiiRoZz #2532 is now in conflict with main (merge state DIRTY at head 28c44d5f). 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 main on 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.

@tedin7

tedin7 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

@NiiRoZz I merged current main into this branch (merge commit 29ee504, no rebase, no force). One conflict in src/startup_stubs/d3d12_xs_device.cpp (main added the E_OUTOFMEMORY check after wrap); 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:

  • Linux: 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.
  • Win2025 (WARP + hardware adapters), dev and release: 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, including startup_compute_dispatch_{warp,hardware}, startup_compute_dispatch_heap_* and startup_compute_dispatch_texture_*.

AI-assisted; commands listed were executed locally.

@tedin7
tedin7 enabled auto-merge (squash) November 26, 2026 02:16
@tedin7
tedin7 merged commit de75613 into R0Y00:main Nov 26, 2026
5 checks passed
tedin7 added a commit to NiiRoZz/Xbox2Windows that referenced this pull request Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants