startup: bind a compute input behind a memory view token in its own resource #2625

Manually merged
github merged 82 commits from gh-pr/2625/head into gh-pr/2625/base 2026-11-27 01:08:44 +00:00
Owner

@⁠NiiRoZz on GitHub · 2026-11-25 23:30 UTC · original
NiiRoZz:startup/compute-dispatch-view-token-range → main · +40 −3 · 3 files · 82 commits · merged 2026-11-26 07:00 UTC

Depends on #2624 (stacked on #2580). Refs #1723.

What changed

A buffer view published through device slot 70 over memory that no buffer is placed over gets a stand-in buffer placed in the title's own heap (opened from the address). That resource has title memory but no placement record, and its heap type is custom. indirect_table_buffer resolved such a token through the placement index, found no owner for the range and refused with an input buffer view token's resource does not hold its range.

The desktop resource of that buffer is the memory itself, so the token is now bound in its own resource at the view offset when the resource is on a custom heap and outside the placement index. Everything after that is unchanged: alignment, released resource, initial state, device, description and range checks still apply.

Still refused, with the same reason as before: a token whose resource is an indexed placement while the range resolves to another owner, and a token whose resource is the upload copy the memory view path falls back to (that copy is not the memory).

indirect_table_buffer is shared with the draw path, so a draw input of this form is accepted the same way. No draw of this form was measured.

Tests

Windows 11, at this branch's head:

ctest --test-dir out/build/dev --no-tests=error -j4 -R "^startup_compute_dispatch"   -> 10/10 passed (5 warp, 5 hardware)

startup_compute_dispatch_input has a new case, dispatch-input-memory-view: the consumer publishes a structured buffer view (first element 4, 320 elements of 4 bytes) of memory no buffer is placed over through device slot 70, with the token in place of the input descriptor, and writes the input words there after the view exists. All 320 output words match on WARP and on hardware, with the debug layer enabled and no error message. The five refused inputs of that check are unchanged.

Negative control: with the d3d12_draw.inl change reverted, the same case is refused with an input buffer view token's resource does not hold its range and the output keeps the sentinel (observed on WARP with a tolerant version of the assertion; the committed assertion fails there).

Local observation (not reproducible from the repository)

In one local run this reason was the first refusal of 4 compute keys, 1,012,151 dispatches. A once-per-key diagnostic showed for the 3 tokens logged: no placement record, heap type 4, 0x10000 or 0x20000 bytes, one reference, and no placed owner for the view's range.

Measured versus hypothesis

  • Measured: the fixture read-back on both adapters; the negative control; the token shape in the local run.
  • Hypothesis: that the 4 keys translate their dispatches after this change. No run with the change has been made; another input or an output of the same key may be refused next.

Not verified

  • No run of real requests with this change.
  • An adapter without existing-heap support gets the upload copy; that path stays refused and is not exercised by the fixture.
  • The committed-resource form on a custom heap (title memory from the allocation hook, data in the desktop resource) matches the same test and is bound the same way; no fixture creates one.

🤖 Generated with Claude Code

**@⁠NiiRoZz** on GitHub · 2026-11-25 23:30 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2625) `NiiRoZz:startup/compute-dispatch-view-token-range` → `main` · +40 −3 · 3 files · 82 commits · merged 2026-11-26 07:00 UTC Depends on #2624 (stacked on #2580). Refs #1723. ## What changed A buffer view published through device slot 70 over memory that no buffer is placed over gets a stand-in buffer placed in the title's own heap (opened from the address). That resource has title memory but no placement record, and its heap type is custom. `indirect_table_buffer` resolved such a token through the placement index, found no owner for the range and refused with `an input buffer view token's resource does not hold its range`. The desktop resource of that buffer is the memory itself, so the token is now bound in its own resource at the view offset when the resource is on a custom heap and outside the placement index. Everything after that is unchanged: alignment, released resource, initial state, device, description and range checks still apply. Still refused, with the same reason as before: a token whose resource is an indexed placement while the range resolves to another owner, and a token whose resource is the upload copy the memory view path falls back to (that copy is not the memory). `indirect_table_buffer` is shared with the draw path, so a draw input of this form is accepted the same way. No draw of this form was measured. ## Tests Windows 11, at this branch's head: ``` ctest --test-dir out/build/dev --no-tests=error -j4 -R "^startup_compute_dispatch" -> 10/10 passed (5 warp, 5 hardware) ``` `startup_compute_dispatch_input` has a new case, `dispatch-input-memory-view`: the consumer publishes a structured buffer view (first element 4, 320 elements of 4 bytes) of memory no buffer is placed over through device slot 70, with the token in place of the input descriptor, and writes the input words there after the view exists. All 320 output words match on WARP and on hardware, with the debug layer enabled and no error message. The five refused inputs of that check are unchanged. Negative control: with the `d3d12_draw.inl` change reverted, the same case is refused with `an input buffer view token's resource does not hold its range` and the output keeps the sentinel (observed on WARP with a tolerant version of the assertion; the committed assertion fails there). ## Local observation (not reproducible from the repository) In one local run this reason was the first refusal of 4 compute keys, 1,012,151 dispatches. A once-per-key diagnostic showed for the 3 tokens logged: no placement record, heap type 4, 0x10000 or 0x20000 bytes, one reference, and no placed owner for the view's range. ## Measured versus hypothesis - Measured: the fixture read-back on both adapters; the negative control; the token shape in the local run. - Hypothesis: that the 4 keys translate their dispatches after this change. No run with the change has been made; another input or an output of the same key may be refused next. ## Not verified - No run of real requests with this change. - An adapter without existing-heap support gets the upload copy; that path stays refused and is not exercised by the fixture. - The committed-resource form on a custom heap (title memory from the allocation hook, data in the desktop resource) matches the same test and is bound the same way; no fixture creates one. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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 #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 #870. Forward Dispatch only with a desktop compute pipeline and root
bound and group counts within 65535 per axis; refuse otherwise.
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 #870. Forward Dispatch only with a desktop compute pipeline and root
bound and group counts within 65535 per axis; refuse otherwise.
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 <[email protected]>
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 <[email protected]>
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]>
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 <[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]>
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 <[email protected]>
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 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
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 <[email protected]>
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 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[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]>
The second positive case of startup_gfx2hlsl_heap_record_check.py branched to
the second dword of the two-dword heap load. The case with a branch target
before the shift already covers the form outside the entry block. The
experiments entry now says that WARP's descriptor increment is not 32 bytes.

Refs #2274

Co-Authored-By: Claude Fable 5.2 <[email protected]>
A check added on main calls op_s_load_dwordx8 on a stage built without a
kind; the heap record branch read self.kind directly.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Slot 40 keeps the graphics words of main. The dispatch refuses an entry value no slot 37 or 39 call
wrote since the compute root was set. Controls: both slots feed the readback, missing word, root
changed, same root, list reset, wrong root, one buffer as input and output.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The slot 67 cache owns desktop COM objects until module teardown. During process termination, the driver can already be shut down when static destructors run. Keep normal reference release on explicit unload and skip driver calls only during process termination.

AI-assisted with Codex (GPT-6.2 Astra, xhigh).
sampled_state gives pixel-shader (and depth-read) states, which a compute list rejects at Close.
dispatch-sampled-compute records the sampling fixture on a compute list and queue. The smp manifest
line no longer scans two fields into one variable.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
A compute program that reads its heap record index with s_buffer_load from an unmodified table buffer, at a
literal byte offset or at a root constant word times a literal plus a literal (dword-aligned), then shifts it
left by 5 for the heap s_load, is translated: the manifest names the word as
`srv <i> buf heap word table <param> <byte> at <offset> [rootconst <param> <word> times <scale>]`. At Dispatch
the runtime reads that word from the recording's upload memory, where no GPU command writes, and binds the
record it indexes. A word outside the buffer or outside upload memory refuses the dispatch with one reason.
Every other index source keeps the buffer refusal.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	docs/experiments.md
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
list_compute_root cleared compute_srv_bound and recomputed
compute_root_has_arguments twice; the second copy came from the second
#1974 snapshot merge and changed nothing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	docs/experiments.md
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Three existing checks build a stage on a bare pipe object without it.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
indirect_table_buffer takes an optional out-parameter and names, for every empty result, the condition that
failed: zero records, a range over 16 MiB, one crossing a placed buffer or upload allocation, an address outside
any placed buffer, a placed buffer that does not alias title memory, a view token that is not a buffer view, and
the resource checks. The translated compute Dispatch uses it as its refusal reason in place of "an input is not a
complete GPU-backed buffer range", and logs once per key which input failed and where its descriptor was read.
The draw callers do not ask for the reason; nothing bound or refused changes.

startup_compute_dispatch_input_check.py refuses five replaced input descriptors, each with its own reason and an
untouched output, after the unchanged recording matches all 320 words.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
# Conflicts:
#	docs/experiments.md
A buffer view token whose resource is on a custom heap outside the placement
index (the memory view path places it in the title's own heap) was refused
because the placement lookup of its range finds no owner. Its desktop resource
is that memory, so the view offset is bound there.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 01:08:42 +00:00
github manually merged commit fdc087f8cd into gh-pr/2625/base 2026-11-27 01:08:44 +00:00
Author
Owner

@⁠tedin7 on GitHub · 2026-11-26 05:56 UTC · original

Not merging yet: this PR says it depends on #2624 (stacked on #2580). #2580 is merged, but #2624 is still open, so this PR cannot land on its own. It is also 124 commits behind main and currently conflicts.

Next step: once #2624 is merged, update this branch with main (merge, keep both sides) and rerun the startup_compute_dispatch* tests on Win2025 dev+release. I did not run Win2025 on the current head, because that run would include #2624's unmerged changes.

Commands executed: gh pr view 2625, python3 merge_check.py 2625 (CONFLICTING, behind=124), gh pr view 2624/2580.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-26 05:56 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2625#issuecomment-7183940189) Not merging yet: this PR says it depends on #2624 (stacked on #2580). #2580 is merged, but #2624 is still open, so this PR cannot land on its own. It is also 124 commits behind main and currently conflicts. Next step: once #2624 is merged, update this branch with main (merge, keep both sides) and rerun the `startup_compute_dispatch*` tests on Win2025 dev+release. I did not run Win2025 on the current head, because that run would include #2624's unmerged changes. Commands executed: `gh pr view 2625`, `python3 merge_check.py 2625` (CONFLICTING, behind=124), `gh pr view 2624/2580`. AI-assisted; commands listed were executed locally.
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-26 06:34 UTC · original

I compared fdc087f8 with my separate projection of the three-file contribution onto main after #2624. The Git trees are identical. Fresh Windows Release built startup_stream_consumer and passed all six input, entry and heap-word CTests serially on WARP and RTX 4060 Laptop. The custom-heap token case matched all 320 words and the five inherited refusal cases still left output untouched. No skips or debug errors.

**@⁠R0Y00** on GitHub · 2026-11-26 06:34 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2625#issuecomment-7184566172) I compared fdc087f8 with my separate projection of the three-file contribution onto main after #2624. The Git trees are identical. Fresh Windows Release built startup_stream_consumer and passed all six input, entry and heap-word CTests serially on WARP and RTX 4060 Laptop. The custom-heap token case matched all 320 words and the five inherited refusal cases still left output untouched. No skips or debug errors.
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-26 06:59 UTC · original · approved these changes

Both upstream dependencies are on main. The final tree matches the independently rebuilt candidate. All six Release input, entry and heap-word CTests passed on WARP and RTX 4060 Laptop. The custom-heap token matched 320 words and all five refusal cases preserved the target. The final diff is confined to the draw consumer and source-built tests.

**@⁠R0Y00** on GitHub · 2026-11-26 06:59 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2625#pullrequestreview-6069773009) · **approved these changes** Both upstream dependencies are on main. The final tree matches the independently rebuilt candidate. All six Release input, entry and heap-word CTests passed on WARP and RTX 4060 Laptop. The custom-heap token matched 320 words and all five refusal cases preserved the target. The final diff is confined to the draw consumer and source-built tests.
This discussion has been locked. Commenting is limited to contributors.
No description provided.