startup: bind compute outputs named by a buffer UAV view token #2961

Open
Miffedrandir wants to merge 3 commits from upstream-pr/2961 into main
Miffedrandir commented 2026-11-26 23:39:47 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Miffedrandir on 2026-11-26T23:39:47Z.


Part of #870

Problem

A translated Dispatch refuses any output whose table entry holds the token of a buffer view the title created (device slot 19). The refusal reads "an output is not an aliased placed buffer range with unordered access". The code calls this out as a shortcut: "view tokens and copied placements are refused, add them with their first user". Inputs already take tokens (slot 18).

To measure it, I split that one refusal reason into its separate conditions locally and ran a 10-minute title run. Counts only:

  • view token: 49 compute programs, 392,332 dispatches
  • size: 3 programs, 53,689 dispatches

Change

src/startup_stubs/d3d12_compute_dispatch.inl: an output named by a token is now bound in that view's desktop resource, over the view's own range. Raw, structured and typed views are accepted; a typed view's range is sized by its format, as typed input tokens already are.

These are still refused, one reason each:

  • the token is not a buffer UAV of a desktop resource with unordered access;
  • the view has no element size;
  • the range is empty, unaligned, over 16 MiB, or outside its resource;
  • an entry value is read from the output's hardware descriptor words, which a token does not have;
  • the output buffer is also an input.

Outputs named by an address are unchanged.

Tests

startup_compute_dispatch gains four cases. In each, the output descriptor is replaced by the token of a buffer view of the output buffer:

  • dispatch-output-token: a raw view;
  • dispatch-output-token-typed: an R32_UINT view;
  • dispatch-output-token-structured: a structured view with stride 8, 160 elements;
  • dispatch-output-token-typed8: an R16G16B16A16_FLOAT view, 160 elements.

The last two were added after review: they describe the same 1280 bytes with 8-byte elements, so they catch an element size taken as 4.

In all four, all 320 output words must match the expected values and nothing may be refused.

Windows 11 26200, MSVC 19.44, release preset, RTX 5070 Laptop and WARP:

cmake --build --preset release --target startup_stream_consumer d3d12_xs.dll offscreen_check
ctest --preset release --no-tests=error -R '^(startup_compute_dispatch|startup_slot67_indirect_dispatch|startup_compute_translate)'

ctest: 100% of 27 passed, with main 429f11d5 merged in (startup_compute_dispatch_native_warp reports itself skipped).

Control: the new cases against main's d3d12_compute_dispatch.inl fail on both adapters with dispatch-output-token: 288 words differ, because the output is refused. With the element size fixed at 4 instead, dispatch-output-token-structured fails on both adapters with 128 words differ.

Title run, counts only

10 minutes each, same settings, translated compute dispatches:

  • before: 52,390
  • after: 253,909

No device removal or debug-layer error was logged. The largest remaining token refusals are the entry-value case (18 programs) and one program whose view range fails the size check.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Sir6Mr49SZWax95VApRPvz

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5518655147 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2961). Originally posted by [Miffedrandir](https://github.com/Miffedrandir) on 2026-11-26T23:39:47Z. --- Part of #870 ## Problem A translated Dispatch refuses any output whose table entry holds the token of a buffer view the title created (device slot 19). The refusal reads "an output is not an aliased placed buffer range with unordered access". The code calls this out as a shortcut: "view tokens and copied placements are refused, add them with their first user". Inputs already take tokens (slot 18). To measure it, I split that one refusal reason into its separate conditions locally and ran a 10-minute title run. Counts only: - **view token:** 49 compute programs, 392,332 dispatches - **size:** 3 programs, 53,689 dispatches ## Change `src/startup_stubs/d3d12_compute_dispatch.inl`: an output named by a token is now bound in that view's desktop resource, over the view's own range. Raw, structured and typed views are accepted; a typed view's range is sized by its format, as typed input tokens already are. These are still refused, one reason each: - the token is not a buffer UAV of a desktop resource with unordered access; - the view has no element size; - the range is empty, unaligned, over 16 MiB, or outside its resource; - an entry value is read from the output's hardware descriptor words, which a token does not have; - the output buffer is also an input. Outputs named by an address are unchanged. ## Tests `startup_compute_dispatch` gains four cases. In each, the output descriptor is replaced by the token of a buffer view of the output buffer: - `dispatch-output-token`: a raw view; - `dispatch-output-token-typed`: an R32_UINT view; - `dispatch-output-token-structured`: a structured view with stride 8, 160 elements; - `dispatch-output-token-typed8`: an R16G16B16A16_FLOAT view, 160 elements. The last two were added after review: they describe the same 1280 bytes with 8-byte elements, so they catch an element size taken as 4. In all four, all 320 output words must match the expected values and nothing may be refused. Windows 11 26200, MSVC 19.44, release preset, RTX 5070 Laptop and WARP: ```powershell cmake --build --preset release --target startup_stream_consumer d3d12_xs.dll offscreen_check ctest --preset release --no-tests=error -R '^(startup_compute_dispatch|startup_slot67_indirect_dispatch|startup_compute_translate)' ``` ctest: 100% of 27 passed, with `main` 429f11d5 merged in (`startup_compute_dispatch_native_warp` reports itself skipped). Control: the new cases against `main`'s `d3d12_compute_dispatch.inl` fail on both adapters with `dispatch-output-token: 288 words differ`, because the output is refused. With the element size fixed at 4 instead, `dispatch-output-token-structured` fails on both adapters with 128 words differ. ## Title run, counts only 10 minutes each, same settings, translated compute dispatches: - before: 52,390 - after: 253,909 No device removal or debug-layer error was logged. The largest remaining token refusals are the entry-value case (18 programs) and one program whose view range fails the size check. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Sir6Mr49SZWax95VApRPvz
thepatrickworld commented 2026-11-27 00:16:42 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-27T00:16:42Z.


Independent AMD RDNA 4 and WARP result on ca96748f: neither case this PR adds can tell the element size from a constant 4

Not a code change; measurements only.

Environment

  • Windows 10.0.26200.9974, MSVC 19.44.35230 (VCToolsVersion 14.44.35207), Windows SDK 10.0.26100
  • dxc.exe 1.9.2602.17, fxc.exe 10.0.26100.9457
  • AMD Radeon RX 9070 XT (1002:7550), driver 32.0.32029.2010 (2026-11-18); WARP (1414:008c), driver 10.0.26100.9818
  • dev preset, worktree at ca96748f, git status --porcelain --untracked-files=no empty before the local edits below and after reverting them. The D3D12 debug layer is not installed on this machine (debug layer: unavailable), so nothing below is a validation-layer result.

Commands

cmake --build out/build/dev --target startup_stream_consumer d3d12_xs.dll offscreen_check
ctest --preset dev --no-tests=error -V -j 1 -R "^(startup_compute_dispatch|startup_compute_dispatch_input|startup_compute_dispatch_entry|startup_compute_dispatch_heap|startup_compute_dispatch_heap_word|startup_compute_dispatch_texture|startup_compute_dispatch_array|startup_compute_dispatch_array_d16)_(warp|hardware)$"

Observed on the unmodified head

16 of 16 entries pass, ctest exit 0, no skip. Across them 15 lines read adapter=AMD Radeon RX 9070 XT driver=32.0.32029.2010 and 15 read adapter=Microsoft Basic Render Driver driver=10.0.26100.9818. The two entries that carry the new cases (#1272 and #1282):

startup_compute_dispatch: PASS on warp (all 320 words match after translation, with the same root set again and with the output named by a raw or typed view token; untouched before translation, without a Dispatch and for 6 refusals)
startup_compute_dispatch: PASS on hardware (all 320 words match after translation, with the same root set again and with the output named by a raw or typed view token; untouched before translation, without a Dispatch and for 6 refusals)

What the two added cases cannot separate

Both describe 320 elements of 4 bytes, i.e. 1280 bytes — the exact size of case A's output buffer. In both, the derivation already yields element = 4 (raw → 4; typed R32_UINT → typed_buffer_format_bytes → 4), so neither can tell the derivation apart from a hard-coded 4. What they do catch is a wrongful refusal, not a wrong size.

Mutation, src/startup_stubs/d3d12_compute_dispatch.inl:365-366:

-            const UINT element = raw ? 4 : structured ? desc.Buffer.StructureByteStride :
-                typed ? x2w_startup::typed_buffer_format_bytes(desc.Format) : 0;
+            const UINT element = (raw || structured || typed) ? 4 : 0;

File sha256 9941c248f60a7602e0a4b9d0294a0b16467eb15ded7294713a522712b5377aeb at the head, 96dac53607486eb2720cd64153caeb566650c5e7db56c773f9697cba42420b91 with the mutation, and 9941c248…7aeb again after git checkout --.

Under that mutation both entries this PR adds still pass, on both adapters, and so does the whole compute family:

100% tests passed out of 2

ctest --preset dev --no-tests=error -R "^startup_compute"     # 151 entries
99% tests passed, 2 tests failed out of 151
    481 - startup_compute_root (Not Run)
   1266 - startup_compute_binding_trace_warp (Failed)     # could not start its process: that executable was not built

Those two only needed their targets. Built and re-run under the same mutation: 100% tests passed out of 2. So every one of the 151 entries passes with the element size fixed at 4 — 149 in one run, the last two once their executables existed.

The mutation is not an equivalent program: it also turns some refusals into acceptances, because the range checks downstream use the same element (with stride 8 and 200 elements over a 1280-byte resource, the head computes 1600 bytes and refuses, the mutation computes 800 and accepts). That is arithmetic on the two expressions, not a run. It is a probe of "is this size derived", not a second implementation.

Two descriptions that do separate it

Same 1280 bytes with 8-byte elements, so the expected table is unchanged (the fixture hard-codes case A):

  • dispatch-output-token-structured: Format UNKNOWN, Flags NONE, StructureByteStride 8, NumElements 160
  • dispatch-output-token-typed8: Format R16G16B16A16_FLOAT, Flags NONE, NumElements 160

Head, both adapters:

MODE dispatch-output-token-structured adapter=hardware differ=0 ranges=(none) refused=[]
MODE dispatch-output-token-typed8 adapter=hardware differ=0 ranges=(none) refused=[]
MODE dispatch-output-token-structured adapter=warp differ=0 ranges=(none) refused=[]
MODE dispatch-output-token-typed8 adapter=warp differ=0 ranges=(none) refused=[]

Same build under the mutation, both adapters:

MODE dispatch-output-token-structured adapter=hardware differ=128 ranges=160..287 first=word=160 got=c5c5c5c5 expected=dca291b6 refused=[]
MODE dispatch-output-token-typed8 adapter=hardware differ=128 ranges=160..287 first=word=160 got=c5c5c5c5 expected=dca291b6 refused=[]

128 and not 160 because the last 32 words of the expected table are the sentinel itself (WORDS=320 EXPECTED_NON_SENTINEL=288): with a 640-byte range the writes stop at word 160. 288 of the 320 words can distinguish "written" from "not written", not 320.

Base control: this fixture on the old translator

main's d3d12_compute_dispatch.inl at 6ee878d8 (still carrying shortcut: view tokens and copied placements are refused), with the consumer and the two modes from this head, same probe, both adapters:

MODE dispatch-output-token adapter=hardware differ=288 ranges=0..287 first=word=0 got=c5c5c5c5 expected=ea74e376 refused=['x2w-draw compute c523c74ce3c788be Dispatch(3, 2, 2) refused: an output is not an aliased placed buffer range with unordered access']

The same 288 words as your own control against main, reached independently. A dispatch baseline on that build still matches (differ=0), so the probe is sensitive to the change itself and not only to my mutation.

What the branch binds

The title's description never becomes a descriptor: for a buffer output, d3d12_compute_dispatch.inl:479-487 always creates a raw R32_TYPELESS UAV over FirstElement = offset / 4, NumElements = bytes / 4. The format and the stride of the title's view therefore only decide the byte range, and both extra modes exercise the same raw binding as the two cases in the PR.

Refusal reasons (reading, not measured)

No case in tests/startup_compute_dispatch_check.py reaches the token branch with a refused view: all six refusal cases name the output by an address. The five reasons that branch can log (not a buffer UAV of a desktop resource, no element size, range is empty, unaligned or outside its resource, an entry value reads the descriptor, also an input) are therefore untested there. I did not sweep the whole suite for an entry that would.

Limits

  • One machine, one AMD adapter and WARP; no debug layer.
  • The two modes and the mutation are local edits, never pushed; both files are back to their head contents (sha256 above) and the two entries are green again on the restored tree.
  • Readback equal to the fixture's table shows consistency with the fixture's model of an 8-byte element, and the mutation shows the probe is sensitive to a wrong size. It is not an independent oracle: the expected table and the lowering share the same hypothesis. That 8 bytes is the right width rests on the D3D12 meaning of StructureByteStride and of a typed format's byte width, not on this run.
  • FirstElement is 0 in every case here, so the alignment check, the resource.Width - offset term and the 16 MiB cap are not exercised; ALLOW_UNORDERED_ACCESS is always set; only three descriptions are covered (raw R32_TYPELESS, R32_UINT, R16G16B16A16_FLOAT).
  • The title's description is never created as a real UAV, so no adapter validates its legality.

If the two extra modes are worth having, I can push them as a patch on top of this branch.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7206326481 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2961#issuecomment-7206326481). Originally posted by [thepatrickworld](https://github.com/thepatrickworld) on 2026-11-27T00:16:42Z. --- **Independent AMD RDNA 4 and WARP result on `ca96748f`: neither case this PR adds can tell the element size from a constant 4** _Not a code change; measurements only._ ### Environment - Windows `10.0.26200.9974`, MSVC 19.44.35230 (`VCToolsVersion 14.44.35207`), Windows SDK 10.0.26100 - `dxc.exe` 1.9.2602.17, `fxc.exe` 10.0.26100.9457 - AMD Radeon RX 9070 XT (`1002:7550`), driver 32.0.32029.2010 (2026-11-18); WARP (`1414:008c`), driver 10.0.26100.9818 - `dev` preset, worktree at `ca96748f`, `git status --porcelain --untracked-files=no` empty before the local edits below and after reverting them. The D3D12 debug layer is not installed on this machine (`debug layer: unavailable`), so nothing below is a validation-layer result. ### Commands ``` cmake --build out/build/dev --target startup_stream_consumer d3d12_xs.dll offscreen_check ctest --preset dev --no-tests=error -V -j 1 -R "^(startup_compute_dispatch|startup_compute_dispatch_input|startup_compute_dispatch_entry|startup_compute_dispatch_heap|startup_compute_dispatch_heap_word|startup_compute_dispatch_texture|startup_compute_dispatch_array|startup_compute_dispatch_array_d16)_(warp|hardware)$" ``` ### Observed on the unmodified head 16 of 16 entries pass, ctest exit 0, no skip. Across them 15 lines read `adapter=AMD Radeon RX 9070 XT driver=32.0.32029.2010` and 15 read `adapter=Microsoft Basic Render Driver driver=10.0.26100.9818`. The two entries that carry the new cases (#1272 and #1282): ``` startup_compute_dispatch: PASS on warp (all 320 words match after translation, with the same root set again and with the output named by a raw or typed view token; untouched before translation, without a Dispatch and for 6 refusals) startup_compute_dispatch: PASS on hardware (all 320 words match after translation, with the same root set again and with the output named by a raw or typed view token; untouched before translation, without a Dispatch and for 6 refusals) ``` ### What the two added cases cannot separate Both describe 320 elements of 4 bytes, i.e. 1280 bytes — the exact size of case A's output buffer. In both, the derivation already yields `element = 4` (raw → 4; typed `R32_UINT` → `typed_buffer_format_bytes` → 4), so neither can tell the derivation apart from a hard-coded 4. What they do catch is a wrongful refusal, not a wrong size. Mutation, `src/startup_stubs/d3d12_compute_dispatch.inl:365-366`: ``` - const UINT element = raw ? 4 : structured ? desc.Buffer.StructureByteStride : - typed ? x2w_startup::typed_buffer_format_bytes(desc.Format) : 0; + const UINT element = (raw || structured || typed) ? 4 : 0; ``` File sha256 `9941c248f60a7602e0a4b9d0294a0b16467eb15ded7294713a522712b5377aeb` at the head, `96dac53607486eb2720cd64153caeb566650c5e7db56c773f9697cba42420b91` with the mutation, and `9941c248…7aeb` again after `git checkout --`. Under that mutation both entries this PR adds still pass, on both adapters, and so does the whole compute family: ``` 100% tests passed out of 2 ctest --preset dev --no-tests=error -R "^startup_compute" # 151 entries 99% tests passed, 2 tests failed out of 151 481 - startup_compute_root (Not Run) 1266 - startup_compute_binding_trace_warp (Failed) # could not start its process: that executable was not built ``` Those two only needed their targets. Built and re-run under the same mutation: `100% tests passed out of 2`. So every one of the 151 entries passes with the element size fixed at 4 — 149 in one run, the last two once their executables existed. The mutation is not an equivalent program: it also turns some refusals into acceptances, because the range checks downstream use the same `element` (with stride 8 and 200 elements over a 1280-byte resource, the head computes 1600 bytes and refuses, the mutation computes 800 and accepts). That is arithmetic on the two expressions, not a run. It is a probe of "is this size derived", not a second implementation. ### Two descriptions that do separate it Same 1280 bytes with 8-byte elements, so the expected table is unchanged (the fixture hard-codes case A): - `dispatch-output-token-structured`: `Format UNKNOWN`, `Flags NONE`, `StructureByteStride 8`, `NumElements 160` - `dispatch-output-token-typed8`: `Format R16G16B16A16_FLOAT`, `Flags NONE`, `NumElements 160` Head, both adapters: ``` MODE dispatch-output-token-structured adapter=hardware differ=0 ranges=(none) refused=[] MODE dispatch-output-token-typed8 adapter=hardware differ=0 ranges=(none) refused=[] MODE dispatch-output-token-structured adapter=warp differ=0 ranges=(none) refused=[] MODE dispatch-output-token-typed8 adapter=warp differ=0 ranges=(none) refused=[] ``` Same build under the mutation, both adapters: ``` MODE dispatch-output-token-structured adapter=hardware differ=128 ranges=160..287 first=word=160 got=c5c5c5c5 expected=dca291b6 refused=[] MODE dispatch-output-token-typed8 adapter=hardware differ=128 ranges=160..287 first=word=160 got=c5c5c5c5 expected=dca291b6 refused=[] ``` 128 and not 160 because the last 32 words of the expected table are the sentinel itself (`WORDS=320 EXPECTED_NON_SENTINEL=288`): with a 640-byte range the writes stop at word 160. 288 of the 320 words can distinguish "written" from "not written", not 320. ### Base control: this fixture on the old translator `main`'s `d3d12_compute_dispatch.inl` at `6ee878d8` (still carrying `shortcut: view tokens and copied placements are refused`), with the consumer and the two modes from this head, same probe, both adapters: ``` MODE dispatch-output-token adapter=hardware differ=288 ranges=0..287 first=word=0 got=c5c5c5c5 expected=ea74e376 refused=['x2w-draw compute c523c74ce3c788be Dispatch(3, 2, 2) refused: an output is not an aliased placed buffer range with unordered access'] ``` The same 288 words as your own control against `main`, reached independently. A `dispatch` baseline on that build still matches (`differ=0`), so the probe is sensitive to the change itself and not only to my mutation. ### What the branch binds The title's description never becomes a descriptor: for a buffer output, `d3d12_compute_dispatch.inl:479-487` always creates a raw `R32_TYPELESS` UAV over `FirstElement = offset / 4`, `NumElements = bytes / 4`. The format and the stride of the title's view therefore only decide the byte range, and both extra modes exercise the same raw binding as the two cases in the PR. ### Refusal reasons (reading, not measured) No case in `tests/startup_compute_dispatch_check.py` reaches the token branch with a refused view: all six refusal cases name the output by an address. The five reasons that branch can log (`not a buffer UAV of a desktop resource`, `no element size`, `range is empty, unaligned or outside its resource`, `an entry value reads the descriptor`, `also an input`) are therefore untested there. I did not sweep the whole suite for an entry that would. ### Limits - One machine, one AMD adapter and WARP; no debug layer. - The two modes and the mutation are local edits, never pushed; both files are back to their head contents (sha256 above) and the two entries are green again on the restored tree. - Readback equal to the fixture's table shows consistency with the fixture's model of an 8-byte element, and the mutation shows the probe is sensitive to a wrong size. It is not an independent oracle: the expected table and the lowering share the same hypothesis. That 8 bytes is the right width rests on the D3D12 meaning of `StructureByteStride` and of a typed format's byte width, not on this run. - `FirstElement` is 0 in every case here, so the alignment check, the `resource.Width - offset` term and the 16 MiB cap are not exercised; `ALLOW_UNORDERED_ACCESS` is always set; only three descriptions are covered (raw `R32_TYPELESS`, `R32_UINT`, `R16G16B16A16_FLOAT`). - The title's description is never created as a real UAV, so no adapter validates its legality. If the two extra modes are worth having, I can push them as a patch on top of this branch. _AI-assisted._
KelboLive commented 2026-11-27 04:29:52 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-27T04:29:52Z.

Review: COMMENTED


PR #2961 fills the gap: compute outputs now accept buffer UAV view tokens (slot 19), not just address-based naming.

What works

  • Symmetric design: inputs already accepted view tokens (slot 18); outputs now do the same (slot 19).
  • Three view types handled: raw (R32_TYPELESS + RAW flag), structured (UNKNOWN format + StructureByteStride),
    and typed (typed buffer, element size from typed_buffer_format_bytes). Each correctly rejects mismatched flags.
  • Locking: AcquireSRWLockShared/ReleaseSRWLockShared around view_records() lookup. Shared lock allows concurrency
    while the map grows during a title run.
  • Validation chain covers all cases: unknown token, non-buffer resources, missing element size, empty/unaligned
    ranges, ranges over 16 MiB or outside the resource, and entry-value outputs.
  • Test fixture creates raw and typed UAVs at slot 19 over the output buffer; dispatches them and checks all 320
    output words match with zero refusals.
  • 49 programs / 392K dispatches measured in a title run were previously refused; this unblocks them.

Issues

  1. view_records growth during idle: the SRW lock is acquired during dispatch but view_records can grow during
    the title run. Since it is a std::vector, concurrent access from multiple dispatch threads could cause issues.
    The AcquireSRWLockShared helps with reader concurrency but vector pushes (from the view creation path, slot 19)
    need an exclusive writer. Verify that the slot 19 path uses AcquireSRWLockExclusive when appending.
  2. typed_buffer_format_bytes() dependency: the code calls x2w_startup::typed_buffer_format_bytes(desc.Format) for
    typed UAVs. Ensure this function covers all formats that compute outputs use; missing formats would fall through
    to element=0 and get refused. A comment listing supported formats would help.
  3. desc.Format = desktop_format(desc.Format): this converts DXGI formats for desktop. But typed views of buffers
    rarely use typed formats (they use UNKNOWN). The conversion may be unnecessary for structured views.
    Worth keeping but verify it does not mis-convert UINT formats during the typed path.
  4. The 16 MiB cap: the code also caps at 16 MiB for output tokens. This means a large compute output written
    through a view token would be refused. Consistent with address-based naming but limits applicability.

Recommendations

  • Add an assertion near view_records push that the writer holds the SRW lock in exclusive mode.
  • Document the set of typed_buffer_format_bytes() supported formats near its use site.
  • Consider a dev-build diagnostic log when view tokens are accepted (e.g. a once-per-frame counter).

Overall: clean, correct. Fills a real gap and adds good test coverage.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6083498846 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2961#pullrequestreview-6083498846). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-11-27T04:29:52Z. **Review:** COMMENTED --- PR #2961 fills the gap: compute outputs now accept buffer UAV view tokens (slot 19), not just address-based naming. ## What works - Symmetric design: inputs already accepted view tokens (slot 18); outputs now do the same (slot 19). - Three view types handled: raw (R32_TYPELESS + RAW flag), structured (UNKNOWN format + StructureByteStride), and typed (typed buffer, element size from typed_buffer_format_bytes). Each correctly rejects mismatched flags. - Locking: AcquireSRWLockShared/ReleaseSRWLockShared around view_records() lookup. Shared lock allows concurrency while the map grows during a title run. - Validation chain covers all cases: unknown token, non-buffer resources, missing element size, empty/unaligned ranges, ranges over 16 MiB or outside the resource, and entry-value outputs. - Test fixture creates raw and typed UAVs at slot 19 over the output buffer; dispatches them and checks all 320 output words match with zero refusals. - 49 programs / 392K dispatches measured in a title run were previously refused; this unblocks them. ## Issues 1. view_records growth during idle: the SRW lock is acquired during dispatch but view_records can grow during the title run. Since it is a std::vector, concurrent access from multiple dispatch threads could cause issues. The AcquireSRWLockShared helps with reader concurrency but vector pushes (from the view creation path, slot 19) need an exclusive writer. Verify that the slot 19 path uses AcquireSRWLockExclusive when appending. 2. typed_buffer_format_bytes() dependency: the code calls x2w_startup::typed_buffer_format_bytes(desc.Format) for typed UAVs. Ensure this function covers all formats that compute outputs use; missing formats would fall through to element=0 and get refused. A comment listing supported formats would help. 3. desc.Format = desktop_format(desc.Format): this converts DXGI formats for desktop. But typed views of buffers rarely use typed formats (they use UNKNOWN). The conversion may be unnecessary for structured views. Worth keeping but verify it does not mis-convert UINT formats during the typed path. 4. The 16 MiB cap: the code also caps at 16 MiB for output tokens. This means a large compute output written through a view token would be refused. Consistent with address-based naming but limits applicability. ## Recommendations - Add an assertion near view_records push that the writer holds the SRW lock in exclusive mode. - Document the set of typed_buffer_format_bytes() supported formats near its use site. - Consider a dev-build diagnostic log when view tokens are accepted (e.g. a once-per-frame counter). Overall: clean, correct. Fills a real gap and adds good test coverage.
R0Y00 commented 2026-11-27 04:41:55 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T04:41:55Z.

Review: COMMENTED


The independent fixed-stride mutation passes the current raw and R32_UINT cases, so those fixtures cannot distinguish the new element-size calculation from a constant 4. Please bring in the tested 8-byte structured and typed cases from the review, and add a refused token-range case with untouched sentinels. An out-of-bounds range using the 8-byte stride would exercise the validation that the existing address-based controls miss.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6083572906 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2961#pullrequestreview-6083572906). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-27T04:41:55Z. **Review:** COMMENTED --- The independent fixed-stride mutation passes the current raw and R32_UINT cases, so those fixtures cannot distinguish the new element-size calculation from a constant 4. Please bring in the tested 8-byte structured and typed cases from the review, and add a refused token-range case with untouched sentinels. An out-of-bounds range using the 8-byte stride would exercise the validation that the existing address-based controls miss.
KelboLive commented 2026-11-27 05:36:13 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-27T05:36:13Z.

Review: COMMENTED


What works

  1. The new path mirrors the existing input-token handling, reusing
    the same view_records() lookup, the shared
    AcquireSRWLockShared/ReleaseSRWLockShared pattern, and
    desktop_format() -- consistent and safe.
  2. It correctly restricts to raw (R32_TYPELESS with RAW flag) and
    typed (R32_UINT) buffer views, matching the input side's narrowness.
  3. The test harness adds raw and typed view modes with expected-match
    validation in the same harness.

Issues

  1. record_transferred_dispatch refuses tokens outright for copies;
    this PR only touches dispatch. The refusal TODO
    (view tokens and copied placements are refused, add them with their first user) should be addressed in a follow-up PR.
  2. The shared lock guards the view_records() read but not the
    as_wrapper() call. If view_records() can grow between the size
    check and the as_wrapper() lookup, recompute the index under the
    lock.
  3. No new tests for malformed tokens (e.g. a non-buffer resource with
    no Buffer.Flags).

Recommendations

  • Recompute the index under the lock before as_wrapper() to avoid a
    racy lookup as view_records grows.
  • Add a small refusal test to confirm the out-of-range path works.

Overall

Solid change that aligns output binding with input handling already in
the codebase. Approvable with the lock scope adjustment noted above.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6083916064 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2961#pullrequestreview-6083916064). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-11-27T05:36:13Z. **Review:** COMMENTED --- ## What works 1. The new path mirrors the existing input-token handling, reusing the same `view_records()` lookup, the shared `AcquireSRWLockShared/ReleaseSRWLockShared` pattern, and `desktop_format()` -- consistent and safe. 2. It correctly restricts to raw (`R32_TYPELESS` with `RAW` flag) and typed (`R32_UINT`) buffer views, matching the input side's narrowness. 3. The test harness adds raw and typed view modes with expected-match validation in the same harness. ## Issues 1. `record_transferred_dispatch` refuses tokens outright for copies; this PR only touches dispatch. The refusal TODO (`view tokens and copied placements are refused, add them with their first user`) should be addressed in a follow-up PR. 2. The shared lock guards the `view_records()` read but not the `as_wrapper()` call. If `view_records()` can grow between the size check and the `as_wrapper()` lookup, recompute the index under the lock. 3. No new tests for malformed tokens (e.g. a non-buffer resource with no `Buffer.Flags`). ## Recommendations - Recompute the index under the lock before `as_wrapper()` to avoid a racy lookup as view_records grows. - Add a small refusal test to confirm the out-of-range path works. ## Overall Solid change that aligns output binding with input handling already in the codebase. Approvable with the lock scope adjustment noted above.
tedin7 commented 2026-11-27 09:36:18 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-27T09:36:18Z.


This PR now conflicts with main. Conflicting files:

  • src/startup_stubs/d3d12_compute_dispatch.inl
  • tests/startup_compute_dispatch_check.py
  • tests/startup_stream_consumer.cpp

Could you merge main into your branch (a merge commit, no force push needed) and resolve these? Thank you.

AI-assisted; commands listed were executed locally. (git merge-tree origin/main <head>)

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7214877004 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2961#issuecomment-7214877004). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-27T09:36:18Z. --- This PR now conflicts with `main`. Conflicting files: - `src/startup_stubs/d3d12_compute_dispatch.inl` - `tests/startup_compute_dispatch_check.py` - `tests/startup_stream_consumer.cpp` Could you merge `main` into your branch (a merge commit, no force push needed) and resolve these? Thank you. AI-assisted; commands listed were executed locally. (`git merge-tree origin/main <head>`)
Miffedrandir commented 2026-11-27 18:37:00 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Miffedrandir on 2026-11-27T18:37:00Z.


@tedin7 Merged main (429f11d5) in as 66b03bf0. Only the header comment of d3d12_compute_dispatch.inl needed hand resolution. In the two test files, main's root SRV and table cases stay and the token cases come after them.

Sorry about the force pushes. I first rebased instead of merging, which dropped ca96748f, the commit thepatrickworld reviewed. I've pushed once more to put it back:

383ffaeb test: cover 8-byte elements in compute output view tokens
66b03bf0 Merge main into startup/compute-output-view-token
ca96748f startup: bind translated compute outputs named by a buffer UAV view token

That push was a force push, the last one; any further updates will be normal pushes. The tree at 66b03bf0 is identical to the rebased one that was tested.

@thepatrickworld Thanks, you're right: raw and R32_UINT both give 4-byte elements, so neither case could tell a derived size from a fixed 4. 383ffaeb adds your two descriptions as dispatch-output-token-structured (stride 8, 160 elements) and dispatch-output-token-typed8 (R16G16B16A16_FLOAT, 160 elements). Same 1280 bytes, so the expected table is unchanged.

Windows 11 26200, MSVC 19.44, release preset, RTX 5070 Laptop and WARP:

cmake --build --preset release --target startup_stream_consumer d3d12_xs.dll offscreen_check
ctest --preset release --no-tests=error -R '^(startup_compute_dispatch|startup_slot67_indirect_dispatch|startup_compute_translate)'
  • Head: 100% of 27 passed (startup_compute_dispatch_native_warp reports itself skipped). All four token cases match all 320 words on both adapters.
  • Your mutation (const UINT element = (raw || structured || typed) ? 4 : 0;): startup_compute_dispatch fails on both adapters with dispatch-output-token-structured: 128 words differ from the CPU reference, the same 128 you measured.

You're also right that the five refusal reasons in the token branch aren't covered yet, and that FirstElement is always 0 here. I've left them out of this PR to keep it to one behavior, and can follow up if wanted.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7225678931 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2961#issuecomment-7225678931). Originally posted by [Miffedrandir](https://github.com/Miffedrandir) on 2026-11-27T18:37:00Z. --- @tedin7 Merged `main` (429f11d5) in as 66b03bf0. Only the header comment of `d3d12_compute_dispatch.inl` needed hand resolution. In the two test files, main's root SRV and table cases stay and the token cases come after them. Sorry about the force pushes. I first rebased instead of merging, which dropped ca96748f, the commit thepatrickworld reviewed. I've pushed once more to put it back: ``` 383ffaeb test: cover 8-byte elements in compute output view tokens 66b03bf0 Merge main into startup/compute-output-view-token ca96748f startup: bind translated compute outputs named by a buffer UAV view token ``` That push was a force push, the last one; any further updates will be normal pushes. The tree at 66b03bf0 is identical to the rebased one that was tested. @thepatrickworld Thanks, you're right: raw and R32_UINT both give 4-byte elements, so neither case could tell a derived size from a fixed 4. 383ffaeb adds your two descriptions as `dispatch-output-token-structured` (stride 8, 160 elements) and `dispatch-output-token-typed8` (R16G16B16A16_FLOAT, 160 elements). Same 1280 bytes, so the expected table is unchanged. Windows 11 26200, MSVC 19.44, release preset, RTX 5070 Laptop and WARP: ```powershell cmake --build --preset release --target startup_stream_consumer d3d12_xs.dll offscreen_check ctest --preset release --no-tests=error -R '^(startup_compute_dispatch|startup_slot67_indirect_dispatch|startup_compute_translate)' ``` - **Head:** 100% of 27 passed (`startup_compute_dispatch_native_warp` reports itself skipped). All four token cases match all 320 words on both adapters. - **Your mutation** (`const UINT element = (raw || structured || typed) ? 4 : 0;`): `startup_compute_dispatch` fails on both adapters with `dispatch-output-token-structured: 128 words differ from the CPU reference`, the same 128 you measured. You're also right that the five refusal reasons in the token branch aren't covered yet, and that `FirstElement` is always 0 here. I've left them out of this PR to keep it to one behavior, and can follow up if wanted. _AI-assisted; commands listed were executed locally._
thepatrickworld commented 2026-11-27 19:18:42 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-27T19:18:42Z.


Independent AMD RDNA 4 run on 383ffaeb: the four token cases pass, and three one-line mutants of the same block pass with them

Not a code change; measurements only.

Environment

  • Windows 10.0.26200.9974, MSVC 19.44.35230 (toolset 14.44.35207), DXC 10.0.26100.0
  • AMD Radeon RX 9070 XT (RDNA 4), driver 32.0.32029.2010, preset dev, debug layer: unavailable
  • head 383ffaeb0a65dd37b873f83a4de3ce91a76b65c4, git status --porcelain --untracked-files=no empty

Commands

Run from the repository root:

git rev-parse HEAD
cmake --preset dev "-DINTAKE_PYTHON=C:/Users/walde/Downloads/x2w-pr641/out/pe-env/Scripts/python.exe"
cmake --build --preset dev --target startup_stream_consumer offscreen_check
set "XBOX2WINDOWS_ADAPTER=AMD Radeon RX 9070 XT"
ctest --preset dev --no-tests=error -R "^startup_compute_dispatch_hardware$" -V
ctest --preset dev --no-tests=error -R "^startup_compute_dispatch"

d3d12_xs.dll in your command block is not a build target here (ninja: error: unknown target 'd3d12_xs'); startup_stream_consumer links d3d12_xs_shim, so the shim is built as a dependency.

Observed

1311: adapter=AMD Radeon RX 9070 XT driver=32.0.32029.2010
1311: dispatch-output-token: all 320 words match the CPU reference
1311: dispatch-output-token-typed: all 320 words match the CPU reference
1311: dispatch-output-token-structured: all 320 words match the CPU reference
1311: dispatch-output-token-typed8: all 320 words match the CPU reference
1311: startup_compute_dispatch: PASS on hardware
1/1 Test #1311: startup_compute_dispatch_hardware ...   Passed    6.09 sec

Mutations of the token block

One line each, built and run against the same entry; git checkout -- between runs, and the file hashes back to 481cc91c… (sha256 of the head blob with CRLF, verified equal).

  1. element = (raw || structured || typed) ? 4 : 0 (yours) → fails at dispatch-output-token-structured: 128 words differ. The fixture asserts per mode inside the loop, so it stops there and -typed8 never runs.
  2. structured ? 4 → fails at the same case; with the entry's mode tuple narrowed to -typed8 alone, the same build passes. The typed8 case does not see the structured branch.
  3. typed ? 4 → -token, -typed and -structured pass, -typed8 fails with 128 words. The structured case does not see the typed branch.

So each 8-byte case catches a mutant of its own branch and is blind to the other's, and your mutant (1) cannot stand in for (3).

Three mutants of the same block that all four cases still pass:

  1. structured ? 8 instead of desc.Buffer.StructureByteStride → the only structured case is stride 8, so the field's value is never read. A case at stride 16 with 80 elements describes the same 1280 bytes, keeps the expected table, and dies here.
  2. bytes = resource.Width - offset instead of u64{NumElements} * element → every case covers the whole buffer at offset 0, so the element count is never read. A view covering half the buffer (stride 8, 80 elements) separates it; its expectation is not the plain table, the second half must stay at the sentinel.
  3. removing if (desc.Format) desc.Format = desktop_format(desc.Format); from the token block → none of the four formats is in the range that function rewrites (116..120, src/startup_stubs/d3d12_xs_device.cpp:765). A token whose format maps, e.g. 116 → R10G10B10A2_UNORM with 4-byte elements, would see it.

(4) and (5) are the ones the two new cases look like they cover and do not; each is one line, and each is killed by a case that keeps the 1280-byte span.

Regression

^startup_compute_dispatch: 19 passed / 1 skipped (native_warp) / 0 failed. CTest prints 100% tests passed out of 20 because the skipped entry stays in the percentage.

Conclusion

On this adapter the four token cases bind the view's own range and the readback matches all 320 words; each 8-byte case pins one of the two non-raw branches of the element derivation. What none of them pins is the stride value, the element count, and the desktop-format mapping.

Limits

  • 128, not 160: 32 of the 320 expected words already hold the sentinel (indices 288..319 of the fixture's expected('A'), last written index 287), so a 160-word bound range differs on 128.
  • One machine, one adapter, no debug layer: no validation output.
  • The runner stops at the first failing mode, so one mutant never names the other branches.
  • The five refusal reasons of the token branch and FirstElement are not exercised, as you said.
  • No base-tree run: the four modes do not exist there.

AI-assisted; runs executed on the machine above.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7226400674 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2961#issuecomment-7226400674). Originally posted by [thepatrickworld](https://github.com/thepatrickworld) on 2026-11-27T19:18:42Z. --- **Independent AMD RDNA 4 run on `383ffaeb`: the four token cases pass, and three one-line mutants of the same block pass with them** Not a code change; measurements only. ### Environment - Windows 10.0.26200.9974, MSVC 19.44.35230 (toolset 14.44.35207), DXC 10.0.26100.0 - AMD Radeon RX 9070 XT (RDNA 4), driver 32.0.32029.2010, preset `dev`, `debug layer: unavailable` - head `383ffaeb0a65dd37b873f83a4de3ce91a76b65c4`, `git status --porcelain --untracked-files=no` empty ### Commands Run from the repository root: ``` git rev-parse HEAD cmake --preset dev "-DINTAKE_PYTHON=C:/Users/walde/Downloads/x2w-pr641/out/pe-env/Scripts/python.exe" cmake --build --preset dev --target startup_stream_consumer offscreen_check set "XBOX2WINDOWS_ADAPTER=AMD Radeon RX 9070 XT" ctest --preset dev --no-tests=error -R "^startup_compute_dispatch_hardware$" -V ctest --preset dev --no-tests=error -R "^startup_compute_dispatch" ``` `d3d12_xs.dll` in your command block is not a build target here (`ninja: error: unknown target 'd3d12_xs'`); `startup_stream_consumer` links `d3d12_xs_shim`, so the shim is built as a dependency. ### Observed ``` 1311: adapter=AMD Radeon RX 9070 XT driver=32.0.32029.2010 1311: dispatch-output-token: all 320 words match the CPU reference 1311: dispatch-output-token-typed: all 320 words match the CPU reference 1311: dispatch-output-token-structured: all 320 words match the CPU reference 1311: dispatch-output-token-typed8: all 320 words match the CPU reference 1311: startup_compute_dispatch: PASS on hardware 1/1 Test #1311: startup_compute_dispatch_hardware ... Passed 6.09 sec ``` ### Mutations of the token block One line each, built and run against the same entry; `git checkout --` between runs, and the file hashes back to `481cc91c…` (`sha256` of the head blob with CRLF, verified equal). 1. `element = (raw || structured || typed) ? 4 : 0` (yours) → fails at `dispatch-output-token-structured: 128 words differ`. The fixture asserts per mode inside the loop, so it stops there and `-typed8` never runs. 2. `structured ? 4` → fails at the same case; with the entry's mode tuple narrowed to `-typed8` alone, the same build **passes**. The typed8 case does not see the structured branch. 3. `typed ? 4` → `-token`, `-typed` and `-structured` pass, `-typed8` fails with 128 words. The structured case does not see the typed branch. So each 8-byte case catches a mutant of its own branch and is blind to the other's, and your mutant (1) cannot stand in for (3). Three mutants of the same block that all four cases still pass: 4. `structured ? 8` instead of `desc.Buffer.StructureByteStride` → the only structured case is stride 8, so the field's **value** is never read. A case at stride 16 with 80 elements describes the same 1280 bytes, keeps the expected table, and dies here. 5. `bytes = resource.Width - offset` instead of `u64{NumElements} * element` → every case covers the whole buffer at offset 0, so the element count is never read. A view covering half the buffer (stride 8, 80 elements) separates it; its expectation is not the plain table, the second half must stay at the sentinel. 6. removing `if (desc.Format) desc.Format = desktop_format(desc.Format);` from the token block → none of the four formats is in the range that function rewrites (116..120, `src/startup_stubs/d3d12_xs_device.cpp:765`). A token whose format maps, e.g. 116 → `R10G10B10A2_UNORM` with 4-byte elements, would see it. (4) and (5) are the ones the two new cases look like they cover and do not; each is one line, and each is killed by a case that keeps the 1280-byte span. ### Regression `^startup_compute_dispatch`: 19 passed / 1 skipped (`native_warp`) / 0 failed. CTest prints `100% tests passed out of 20` because the skipped entry stays in the percentage. ### Conclusion On this adapter the four token cases bind the view's own range and the readback matches all 320 words; each 8-byte case pins one of the two non-raw branches of the element derivation. What none of them pins is the stride value, the element count, and the desktop-format mapping. ### Limits - 128, not 160: 32 of the 320 expected words already hold the sentinel (indices 288..319 of the fixture's `expected('A')`, last written index 287), so a 160-word bound range differs on 128. - One machine, one adapter, no debug layer: no validation output. - The runner stops at the first failing mode, so one mutant never names the other branches. - The five refusal reasons of the token branch and `FirstElement` are not exercised, as you said. - No base-tree run: the four modes do not exist there. _AI-assisted; runs executed on the machine above._
JohnConnorNPC commented 2026-11-28 07:33:32 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-28T07:33:32Z.


Thanks for adding the 8-byte structured and typed cases. The branch is now 135 commits behind main (c3204a9c) and has conflicts. Three things that landed on main since then interact with the token branch, and a plain conflict resolution won't catch them. Could you look at these when you merge?

  1. Conflicts. git merge-tree --write-tree --name-only c3204a9c 383ffaeb exits 1 with CONFLICT (content) in src/startup_stubs/d3d12_compute_dispatch.inl and tests/startup_compute_dispatch_check.py. Both sides add docstring item 8, so yours could become item 9.
  2. An existing control goes red. On main, tests/startup_compute_dispatch_output_check.py expects ('dispatch-output-texture-token', None, 'an output buffer descriptor is a view token'). In the trial-merged tree (git show <tree>:src/startup_stubs/d3d12_compute_dispatch.inl | grep -n 'view token'), the new branch comes first and refuses a texture token with an output view token is not a buffer UAV of a desktop resource. Reason 1 is never reached. docs/experiments/compute-output-buffer-reasons.md already says "with it, reason 1 is not reached". Could you repoint that control at the new reason, drop the dead reason-1 line and update the doc?
  3. desc_bytes uses the desktop size. git grep -n desc_bytes 383ffaeb -- src/startup_stubs/d3d12_compute_dispatch.inl shows record.desc_bytes >= sizeof(desc) and < sizeof(desc) on D3D12_UNORDERED_ACCESS_VIEW_DESC. #3223 replaced that comparison with ViewRecord::uav_desc_bytes (40). The reason is in docs/experiments/agility-compute-views.md: the Agility SDK 1.620.2 header "reports 40 for an SRV and 48 for a" UAV. With Agility headers, every output token would be refused as "not a buffer UAV". Using ViewRecord::uav_desc_bytes, as main's texture branch does, would fix it.
  4. A half-buffer output named by a token gets a raw view. #3302 added uav <i> bufhalf ... outputs (slot.half_buffer_bytes), which bind a typed UAV with views[i].described = true. The token branch runs before that and sets views[i] = {buffer, offset, bytes, true}, so described stays false. The binder then creates a DXGI_FORMAT_R32_TYPELESS / D3D12_BUFFER_UAV_FLAG_RAW view for a typed half store. Today main refuses this case at reason 1. Refusing half_bytes in the token branch, or describing the view, would keep that behavior.
  5. The maintainer's refused token-range request is still open. None of the five token-branch refusals is exercised (your reply: "I've left them out of this PR"). One out-of-bounds range with the 8-byte stride and untouched sentinels would cover the request. A half-range view would also catch the bytes = resource.Width - offset mutant from the RDNA 4 run on 383ffaeb.

Items 2–4 come from reading the trial-merged blobs. Nothing was built or run for this comment.

This comment was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7236016961 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2961#issuecomment-7236016961). Originally posted by [JohnConnorNPC](https://github.com/JohnConnorNPC) on 2026-11-28T07:33:32Z. --- Thanks for adding the 8-byte structured and typed cases. The branch is now 135 commits behind `main` (`c3204a9c`) and has conflicts. Three things that landed on `main` since then interact with the token branch, and a plain conflict resolution won't catch them. Could you look at these when you merge? 1. **Conflicts.** `git merge-tree --write-tree --name-only c3204a9c 383ffaeb` exits 1 with `CONFLICT (content)` in `src/startup_stubs/d3d12_compute_dispatch.inl` and `tests/startup_compute_dispatch_check.py`. Both sides add docstring item 8, so yours could become item 9. 2. **An existing control goes red.** On `main`, `tests/startup_compute_dispatch_output_check.py` expects `('dispatch-output-texture-token', None, 'an output buffer descriptor is a view token')`. In the trial-merged tree (`git show <tree>:src/startup_stubs/d3d12_compute_dispatch.inl | grep -n 'view token'`), the new branch comes first and refuses a texture token with `an output view token is not a buffer UAV of a desktop resource`. Reason 1 is never reached. `docs/experiments/compute-output-buffer-reasons.md` already says "with it, reason 1 is not reached". Could you repoint that control at the new reason, drop the dead reason-1 line and update the doc? 3. **`desc_bytes` uses the desktop size.** `git grep -n desc_bytes 383ffaeb -- src/startup_stubs/d3d12_compute_dispatch.inl` shows `record.desc_bytes >= sizeof(desc)` and `< sizeof(desc)` on `D3D12_UNORDERED_ACCESS_VIEW_DESC`. #3223 replaced that comparison with `ViewRecord::uav_desc_bytes` (40). The reason is in `docs/experiments/agility-compute-views.md`: the Agility SDK 1.620.2 header "reports 40 for an SRV and 48 for a" UAV. With Agility headers, every output token would be refused as "not a buffer UAV". Using `ViewRecord::uav_desc_bytes`, as `main`'s texture branch does, would fix it. 4. **A half-buffer output named by a token gets a raw view.** #3302 added `uav <i> bufhalf ...` outputs (`slot.half_buffer_bytes`), which bind a typed UAV with `views[i].described = true`. The token branch runs before that and sets `views[i] = {buffer, offset, bytes, true}`, so `described` stays false. The binder then creates a `DXGI_FORMAT_R32_TYPELESS` / `D3D12_BUFFER_UAV_FLAG_RAW` view for a typed half store. Today `main` refuses this case at reason 1. Refusing `half_bytes` in the token branch, or describing the view, would keep that behavior. 5. **The maintainer's refused token-range request is still open.** None of the five token-branch refusals is exercised (your reply: "I've left them out of this PR"). One out-of-bounds range with the 8-byte stride and untouched sentinels would cover the request. A half-range view would also catch the `bytes = resource.Width - offset` mutant from the RDNA 4 run on `383ffaeb`. Items 2–4 come from reading the trial-merged blobs. Nothing was built or run for this comment. This comment was AI-assisted.
RonLogic commented 2026-11-28 12:09:58 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by RonLogic on 2026-11-28T12:09:58Z.


@Miffedrandir I reproduced a separate compiler-side gap on 052abe6f with a source-built one-component buffer_store_format_x. The native compiler validates the DXIL (u0, one 4-byte element), then reports unsupported startup runtime manifest bindings: UAV kind typed_buffer_uav. There is no published manifest for the runtime to consume.

The natural follow-up is one native published R32_UINT UAV with a nonzero FirstElement, a shifted-window control, and unchanged guards on wrong-format or out-of-range refusals. I'd like to use your slot-19 token path for that fixture once the interface lands. Are you planning to cover this native case in #2961, or should I keep it for a dependent follow-up? I can also run the refreshed token tests on RTX 4070 and WARP.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7239038190 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2961#issuecomment-7239038190). Originally posted by [RonLogic](https://github.com/RonLogic) on 2026-11-28T12:09:58Z. --- @Miffedrandir I reproduced a separate compiler-side gap on `052abe6f` with a source-built one-component `buffer_store_format_x`. The native compiler validates the DXIL (`u0`, one 4-byte element), then reports `unsupported startup runtime manifest bindings: UAV kind typed_buffer_uav`. There is no published manifest for the runtime to consume. The natural follow-up is one native published `R32_UINT` UAV with a nonzero `FirstElement`, a shifted-window control, and unchanged guards on wrong-format or out-of-range refusals. I'd like to use your slot-19 token path for that fixture once the interface lands. Are you planning to cover this native case in #2961, or should I keep it for a dependent follow-up? I can also run the refreshed token tests on RTX 4070 and WARP.
Leyukaka commented 2026-11-29 06:14:59 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T06:14:59Z.

Review: COMMENTED


383ffaeb against main (212d4b5f), by reading both sides; nothing built or run.

  • main already binds outputs named by a slot-19 buffer view token. 71844ba0 added compute_token_output (now src/startup_stubs/d3d12_compute_dispatch.inl:471-563, called at :828), with the same raw/structured/typed element sizes as this PR (:520-526) and the same entry-value and output-also-input refusals (:849-853). 89b1a3a2 gave each refused interval its own reason (:532-537).
  • main is stricter than this PR: the view must be materialized and counterless (:506), and its backing must uniquely alias the guest byte interval or sit on the default heap (:538-557). Tokens this PR would bind outside those conditions stay refused on main.
  • Tests on main: dispatch-uav-token-{raw,structured,typed} bound and {wrong-slot,copied} refused in tests/native_compute_pack_check.py:77-91 (structured: stride 8, FirstElement 2, half the elements); three refused intervals with an untouched output in tests/startup_compute_token_interval_check.py.
  • git merge-tree --write-tree origin/main 383ffaeb exits 1 with conflicts in src/startup_stubs/d3d12_compute_dispatch.inl and tests/startup_compute_dispatch_check.py. main's branch at :828 ends in continue for every token, so a second token branch has nothing left to handle.
  • Not on main: a bound typed view with elements wider than 4 bytes. Its typed cases are R32_UINT bound (tests/startup_stream_consumer.cpp:425-428) and a one-element R16_UINT refused. dispatch-output-token-typed8 (R16G16B16A16_FLOAT) would add it as a dispatch-uav-token-* mode.

Superseded by 71844ba0. Suggest closing, or reducing this to the 8-byte typed case on top of main's token modes.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6101716716 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2961#pullrequestreview-6101716716). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-29T06:14:59Z. **Review:** COMMENTED --- `383ffaeb` against `main` (`212d4b5f`), by reading both sides; nothing built or run. - `main` already binds outputs named by a slot-19 buffer view token. `71844ba0` added `compute_token_output` (now `src/startup_stubs/d3d12_compute_dispatch.inl:471-563`, called at `:828`), with the same raw/structured/typed element sizes as this PR (`:520-526`) and the same entry-value and output-also-input refusals (`:849-853`). `89b1a3a2` gave each refused interval its own reason (`:532-537`). - `main` is stricter than this PR: the view must be materialized and counterless (`:506`), and its backing must uniquely alias the guest byte interval or sit on the default heap (`:538-557`). Tokens this PR would bind outside those conditions stay refused on `main`. - Tests on `main`: `dispatch-uav-token-{raw,structured,typed}` bound and `{wrong-slot,copied}` refused in `tests/native_compute_pack_check.py:77-91` (structured: stride 8, FirstElement 2, half the elements); three refused intervals with an untouched output in `tests/startup_compute_token_interval_check.py`. - `git merge-tree --write-tree origin/main 383ffaeb` exits 1 with conflicts in `src/startup_stubs/d3d12_compute_dispatch.inl` and `tests/startup_compute_dispatch_check.py`. `main`'s branch at `:828` ends in `continue` for every token, so a second token branch has nothing left to handle. - Not on `main`: a bound typed view with elements wider than 4 bytes. Its typed cases are R32_UINT bound (`tests/startup_stream_consumer.cpp:425-428`) and a one-element R16_UINT refused. `dispatch-output-token-typed8` (R16G16B16A16_FLOAT) would add it as a `dispatch-uav-token-*` mode. Superseded by `71844ba0`. Suggest closing, or reducing this to the 8-byte typed case on top of `main`'s token modes.
JohnConnorNPC commented 2026-11-29 12:40:49 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-29T12:40:49Z.


Update to my 11-28 comment on 383ffaeb. I checked against main 77d1ba4d.

I agree with the 06:14 review: main already binds token-named outputs. compute_token_output is called at reason = compute_token_output(self, words, token); in record_translated_dispatch, from 71844ba0 (git merge-base --is-ancestor 71844ba0 origin/main → true). Its branch covers raw, structured and typed element sizes, and it uses ViewRecord::uav_desc_bytes. So items 2–4 of my earlier comment (the dispatch-output-texture-token control, the sizeof(desc) comparison and the half-buffer raw view) no longer need work here. Please disregard them.

MUST

  1. The branch still conflicts. git merge-tree --write-tree --name-only origin/main 383ffaeb exits 1 in src/startup_stubs/d3d12_compute_dispatch.inl and tests/startup_compute_dispatch_check.py, and the second token branch would never be reached. The new part is the bound 8-byte typed case (dispatch-output-token-typed8, R16G16B16A16_FLOAT). Please reduce the PR to that case as a dispatch-uav-token-* mode on main's path, or close it.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7255986087 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2961#issuecomment-7255986087). Originally posted by [JohnConnorNPC](https://github.com/JohnConnorNPC) on 2026-11-29T12:40:49Z. --- Update to my 11-28 comment on `383ffaeb`. I checked against `main` `77d1ba4d`. I agree with the 06:14 review: `main` already binds token-named outputs. `compute_token_output` is called at `reason = compute_token_output(self, words, token);` in `record_translated_dispatch`, from `71844ba0` (`git merge-base --is-ancestor 71844ba0 origin/main` → true). Its branch covers raw, structured and typed element sizes, and it uses `ViewRecord::uav_desc_bytes`. So items 2–4 of my earlier comment (the `dispatch-output-texture-token` control, the `sizeof(desc)` comparison and the half-buffer raw view) no longer need work here. Please disregard them. **MUST** 1. The branch still conflicts. `git merge-tree --write-tree --name-only origin/main 383ffaeb` exits 1 in `src/startup_stubs/d3d12_compute_dispatch.inl` and `tests/startup_compute_dispatch_check.py`, and the second token branch would never be reached. The new part is the bound 8-byte typed case (`dispatch-output-token-typed8`, R16G16B16A16_FLOAT). Please reduce the PR to that case as a `dispatch-uav-token-*` mode on `main`'s path, or close it. AI-assisted.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2961:upstream-pr/2961'
git switch 'upstream-pr/2961'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2961'
git switch 'upstream-pr/2961'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2961'
git switch 'upstream-pr/2961'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2961'
git switch 'main'
git merge --squash 'upstream-pr/2961'
git switch 'main'
git merge --ff-only 'upstream-pr/2961'
git switch 'main'
git merge 'upstream-pr/2961'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!2961
No description provided.