Skip to content

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

Open
Miffedrandir wants to merge 3 commits into
R0Y00:mainfrom
Miffedrandir:startup/compute-output-view-token
Open

Miffedrandir wants to merge 3 commits into
R0Y00:mainfrom
Miffedrandir:startup/compute-output-view-token

Conversation

@Miffedrandir

@Miffedrandir Miffedrandir commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

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 429f11d 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

…oken

A translated Dispatch refused every output whose table entry holds the token
of a buffer view the title created (device slot 19), with "an output is not
an aliased placed buffer range with unordered access". Such an output is now
bound in that view's desktop resource over the view's own range: raw,
structured, or typed (sized by its format), as input tokens already are.

Still refused, one reason each: a token that is not a buffer UAV of a desktop
resource with unordered access; a view with no element size; a range that is
empty, unaligned, over 16 MiB or outside its resource; an entry value read
from the output's hardware descriptor words, which a token does not have; and
an output buffer that is also an input. Outputs named by an address are
unchanged.

startup_compute_dispatch gains dispatch-output-token and
dispatch-output-token-typed: the output descriptor is replaced by the token of
a raw, or R32_UINT, view of the output buffer, and all 320 words must match.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Sir6Mr49SZWax95VApRPvz
@thepatrickworld

Copy link
Copy Markdown
Contributor

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 KelboLive left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 KelboLive left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

tedin7 commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

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
Miffedrandir force-pushed the startup/compute-output-view-token branch from ca96748 to ee2ab75 Compare November 27, 2026 18:26
Miffedrandir and others added 2 commits November 27, 2026 18:30
Resolve the header comment of d3d12_compute_dispatch.inl (root SRV inputs from
main, output view tokens from this branch) and keep main's root SRV and table
cases next to this branch's two output-token cases in the dispatch test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Sir6Mr49SZWax95VApRPvz
dispatch-output-token-structured (stride 8) and dispatch-output-token-typed8
(R16G16B16A16_FLOAT) describe the output's 1280 bytes as 160 8-byte elements.
The raw and R32_UINT cases both have 4-byte elements, so they could not tell a
derived element size from a fixed 4; these two can. Suggested by the review on
this PR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Sir6Mr49SZWax95VApRPvz
@Miffedrandir
Miffedrandir force-pushed the startup/compute-output-view-token branch from ee2ab75 to 383ffae Compare November 27, 2026 18:36
@Miffedrandir

Copy link
Copy Markdown
Contributor Author

@tedin7 Merged main (429f11d) in as 66b03bf. 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 ca96748, 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 66b03bf 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. 383ffae 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.

@thepatrickworld

Copy link
Copy Markdown
Contributor

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.

Not-Saii added a commit to Not-Saii/Xbox2Windows that referenced this pull request Nov 28, 2026
AI-assisted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
R0Y00 pushed a commit that referenced this pull request Nov 28, 2026
* runtime: name each refused condition of a compute output buffer

The refusal "an output is not an aliased placed buffer range with unordered
access" covered nine conditions. Each now has its own reason in the log and
the census: a view token, zero records, a range over 16 MiB or not whole
dwords, a range crossing a placed buffer's end, memory outside any placed
buffer, a copied placement, a resource not created in the common state, an
offset not 16-byte aligned, and no unordered access. What is bound and what
is refused do not change.

tests/startup_compute_dispatch_output_check.py produces each condition on
case A and checks its reason, the census line and an untouched output.
dispatch-swapped now expects "an output buffer has no unordered access".

AI-assisted.

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

* test: copy the output texture token into its table entry

Creating the view at heap byte 16, which is not a descriptor of the heap,
ends the consumer; the view is created at byte 64 and its token words copied.

AI-assisted.

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

* docs: record the output reason fixture results

AI-assisted.

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

* docs: per-reason counts from one start-up run

AI-assisted.

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

* docs: the token keys with #2961 merged

AI-assisted.

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

* docs: label start-up counts as first-refusal buckets

The census keeps one first refusal per key and counts all of the key's
untranslated dispatches under it, so the run tables are first-refusal
buckets, not counts per condition.

AI-assisted.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@JohnConnorNPC

Copy link
Copy Markdown
Collaborator

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. runtime: preserve Compute texture views with Agility SDK headers #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. runtime: bind published D16 buffer stores to typed UAVs #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.

Copy link
Copy Markdown
Contributor

@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.

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.

7 participants