Skip to content

compute: indexed atomic UAV dispatch (takeover of #3417) - #3454

Merged
JohnConnorNPC merged 7 commits into
R0Y00:mainfrom
Leyukaka:takeover-3417-indexed-atomic-uav
Nov 29, 2026
Merged

JohnConnorNPC merged 7 commits into
R0Y00:mainfrom
Leyukaka:takeover-3417-indexed-atomic-uav

Conversation

@Leyukaka

@Leyukaka Leyukaka commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

Takeover of #3417 by @Ammmae0x.

What is merged

e1143678 has one conflict, in src/startup_stubs/d3d12_compute_dispatch.inl, at the slot setup in translate_compute_natively. Both lines are kept: if (atomic) slots.back().atomic = true; from #3417 and slots.back().requires_identity_dst_sel = view.requires_identity_dst_sel; from main. They set different fields. git show --remerge-diff e1143678 shows nothing else.

393b80eb has one conflicting file, tests/native_compute_manifest_reasons.cpp, in two places. Both sides are kept in each:

One line is our edit and comes from neither side: the count in the final printf is + 3 instead of + 2. Each side had raised it from + 1 to + 2 for its own standalone block, and the merged file has both blocks. The count is only printed; the exit code of the test does not depend on it. git show --remerge-diff 393b80eb shows nothing else.

a96d1f6b has one conflicting file, src/startup_stubs/d3d12_compute_dispatch.inl, in the view loop of translate_compute_natively, which #3398 rewrote. Main's side is kept: the Kind alias, texture_output and the dimension switch, the supported list and auto& slot. Three lines carry the atomic UAV:

  • const bool atomic = view.kind == Kind::indexed_atomic_uav;, and || atomic at the end of output;
  • || atomic in supported, after texture_input. Main refuses any kind missing from that list;
  • slot.atomic = atomic; on main's auto& slot, replacing if (atomic) slots.back().atomic = true;.

The volume flag of the branch is dropped: main's dimension switch covers it. git show --remerge-diff a96d1f6b shows nothing else.

Run

Full build of a96d1f6b, dev preset with -DX2W_WITH_OPUS=OFF, in a fresh isolated environment with a hardware adapter (not the one in the PR) and the inbox WARP.

ctest --preset dev --no-tests=error -R '^(startup_compute_indexed_atomic_uav_|native_compute_manifest_reasons|startup_compute_dispatch_native_|startup_compute_dispatch_texture|startup_compute_dispatch_two_mips_|startup_compute_input_view_token|startup_input_view_token)'

native_compute_manifest_reasons                    Passed     0.07 s
native_compute_manifest_reasons_requests           Passed     1.57 s
startup_compute_indexed_atomic_uav_controls        Passed     2.24 s
startup_compute_indexed_atomic_uav_warp            ***Skipped 2.41 s
startup_compute_indexed_atomic_uav_hardware        Passed    10.31 s
startup_compute_dispatch_native_warp               ***Skipped 5.67 s
startup_compute_dispatch_native_hardware           Passed    15.82 s
startup_compute_dispatch_texture_native_warp       ***Skipped 3.64 s
startup_compute_dispatch_texture_native_hardware   Passed     9.25 s
startup_compute_dispatch_texture_warp              Passed    19.27 s
startup_compute_dispatch_texture_hardware          Passed    37.45 s
startup_compute_dispatch_texture_dims_warp         Passed     8.87 s
startup_compute_dispatch_texture_dims_hardware     Passed    19.73 s
startup_compute_dispatch_two_mips_warp             Passed     3.64 s
startup_compute_dispatch_two_mips_hardware         Passed     4.95 s
startup_compute_input_view_token_reference         Passed     0.30 s
startup_compute_input_view_token_controls          Passed     0.31 s
startup_compute_input_view_token_warp              Passed     3.22 s
startup_compute_input_view_token_hardware          Passed     7.78 s
100% tests passed, 0 tests failed out of 27

The eight startup_input_view_token* tests, not listed, pass too. The three skips are the WARP variants that need a 32-lane adapter.

native_compute_manifest_reasons output includes ok UAV kind packed_d16_x_uav, ok publishes uav 0 atomic table 1 32, ok publishes uav 0 packed_d16_x table 1 32 and 0 of 32 manifest reasons wrong.

_hardware output:

raw: 12 adds per addressed dword match on hardware (debug layer unavailable)
raw: 4 token shapes and a hardware descriptor refused, each with its own reason and an untouched output
structured: 12 adds per addressed dword match on hardware (debug layer unavailable)
typed: 12 adds per addressed dword match on hardware (debug layer unavailable)
startup_compute_indexed_atomic_uav: PASS on hardware

The native: line of that output, separately, as asked in the reviews of #3417 and of 393b80eb:

native: the same program translated in-process and matched on hardware

_warp did not reach the dispatch. Its output has native_lane_range=4..4 and ends with:

skip: shader wave32 fixture requires SM 6.6, WaveOps, and a 32-lane wave

_controls output includes indexed atomic UAV published as `uav 0 atomic table 1 32` .

Not covered

  • No passing WARP run: the inbox WARP is 4-lane, so _warp skips before any dispatch and prints no native: line.
  • The red Windows Server 2025 run reported on runtime: bind indexed atomic UAVs in the direct compute runtime path #3417 is not explained by this. Here _controls and _hardware get past compile_dxil at the same commits plus the merges.
  • The u0 root=... bytes=... line asked for on runtime: bind indexed atomic UAVs in the direct compute runtime path #3417 is not in the output of this test when it passes, so it is not posted.
  • The debug layer was unavailable in this run.
  • Adding _controls to the pr preset (SHOULD 1 of the review) is not done here, because it edits CMakePresets.json.
  • The two test gaps from the review of 393b80eb are open: count does not decide the result, and u0 is the only atomic UAV. The test files are unchanged since 393b80eb.

Refs #3417

Ammmae0x and others added 5 commits November 29, 2026 01:57
Publish ComputeViewKind::indexed_atomic_uav in format_compute_runtime_manifest
as 'uav <register> atomic table <parameter> <byte>' for a single 4-byte view,
and bind it in the startup dispatch path from a slot-19 token view, with the
view's {stride, count} as root constants at b(register + 1), matching
NativeComputePipeline. Hardware-descriptor atomics and unsupported token
shapes stay refused by name. Refs R0Y00#3224, R0Y00#2935
…ithout wave32

WIN-VERIFY round 1: on hardware, three negative-control UAV descs were
invalid for D3D12 CreateUnorderedAccessView on the 1280-byte buffer (a
4096-byte structured stride, a RAW-flagged R32_UINT view, a 1284-byte view),
so slot 19 removed the device before the dispatch could refuse them. Keep
every negative view creatable: the 4096-stride view now runs on the 16 MiB +
64 KiB committed buffer, the unaligned view uses WORDS - 1 elements, and
the two uncreatable shapes stay out (a RAW view needs R32_TYPELESS; a view
past the end of its buffer cannot be created). controls() now checks every
negative view fits its buffer and that the two uncreatable shapes fail that
check. On WARP, the --shader-wave32 gate exited 77, skipping the published
raw/structured/typed runs even though only the native translator needs
32-lane waves: main() no longer probes wave32, and native_check() probes
it directly so a skip there does not discard the published results.

Refs R0Y00#3224, R0Y00#2935
Keeps both slot setup lines in d3d12_compute_dispatch.inl.
Keeps both manifest reason cases in native_compute_manifest_reasons.cpp.
src/startup_stubs/d3d12_compute_dispatch.inl (translate_compute_natively view loop): kept main's Kind alias, texture_output/dimension switch, supported flag and slot reference; added the indexed atomic UAV to output, to supported (main's supported list no longer follows from output) and as slot.atomic. The branch's volume flag is dropped in favour of main's dimension switch.
@JohnConnorNPC

Copy link
Copy Markdown
Collaborator

Review of 393b80eb against main c3cae611. Verdict: hold (one MUST). This checks the points from the #3417 review and the default native path.

MUST

  1. It conflicts with main again. runtime: bind four-channel and half4 texture UAVs on the native compute route #3398 (merged as dc936253) rewrote the view classification in translate_compute_natively: git merge-tree --write-tree origin/main 393b80eb → CONFLICT (content): Merge conflict in src/startup_stubs/d3d12_compute_dispatch.inl, and gh shows CONFLICTING. Restoring atomic in output isn't enough:

    • main now refuses any kind that is missing from its new supported list ("is not bound for a natively translated program"), so indexed_atomic_uav has to be added there too;
    • slot.atomic = true has to move onto main's auto& slot = slots.back();.

    If supported is missed, the in-process path still refuses the kind. Only native_check() on a 32-lane adapter would catch that: CI doesn't run it, and the inbox WARP skips. Please post the native: line of _hardware again after the resolution.

What this PR settles from the #3417 review

  • The old conflict is resolved in e1143678. git show --remerge-diff of both merges shows only the resolutions in the description, and the + 3 count is right (21 cases[] + 4 published[] + 3 standalone blocks = 28).

  • The default native path is tested. native_check() sets X2W_NATIVE_SHADERS in a fresh work directory with no published manifest, so if the in-process translation refused, the readback check would fail. It asserts translated natively: 2 entry values, 0 inputs, 1 outputs. It doesn't set X2W_NATIVE_SHADERS_ONLY=1 the way the launchers do. That makes no difference here: after a successful in-process translation, load_compute_translation never runs. Your hardware run at 393b80eb has the native: line, so with the author's RTX 4050 that's two adapters.

  • The Server 2025 red is still unexplained, but this code can't produce it:

    • At both 10d7d41b and 393b80eb, the formatter publishes indexed_atomic_uav when array_count == 1 && required_bytes == 4.
    • The translator creates the kind in one place, with 4 bytes (indexed ? ComputeViewKind::indexed_atomic_uav : ComputeViewKind::raw_buffer_uav, 4, &reg).
    • Your fresh build passes _controls, which is the same compile_dxil step that failed there.

    My guess is stale binaries, but I haven't measured it. Binaries built from main would match both results: main's compile_dxil prints exactly UAV kind indexed_atomic_uav for this binding (view_shape), and main's native_compute_manifest_reasons has none of the new cases, so it passes. Also, the full SHA quoted in that report (10d7d41b7740…) is not this commit's (10d7d41b77d4…).

SHOULD

  1. There is still no WARP dispatch at any head: the inbox WARP gives native_lane_range=4..4 and exit 77. If the Server 2025 run was at 10d7d41b, its _warp and _hardware got past main()'s --shader-wave32 probe and only then failed in compile_dxil. That environment may be the only one so far that can dispatch this test, so a re-run there by tedin7 at the resolved head would close this.

  2. The hardware report doesn't name the adapter, driver or Windows build, which AGENTS.md asks for in GPU reports.

  3. CI still selects none of the four tests: a re.search of the pr filter gives False for _controls, _warp and native_compute_manifest_reasons. The description already says so.

  4. Two gaps from the runtime: bind indexed atomic UAVs in the direct compute runtime path #3417 approval review are still open:

    • count never decides the result. The largest index is 124 and the smallest count is 160, so atomic_count = ~0u passes.
    • Only u0 is atomic, so atomic_registers.push_back(i) → push_back(0) survives.

    A wrapped stride-8 index and a u0-raw/u1-atomic layout would cover both.

NIT

  1. Two comments say the constants are bound at "parameter 2 + its UAV index": the one on the ViewRecord fields and the one above the SetComputeRoot32BitConstants loop. The code uses 2 plus the view's rank among the atomic UAVs, which is correct. The comments are wrong when a non-atomic UAV comes first.
  2. The in-process path accepts indexed_atomic_uav without the formatter's required_bytes == 4 check, and the record path hard-codes 4 (ComputeViewBinding{..., 0, 0, 0, 4}). This can't happen today, since the translator always records 4, but a matching check would keep the two routes aligned.
  3. The docs page says the four token negatives each refuse "with their own reason". Three of them share an indexed atomic output view has an unsupported stride or range.

Not run here: build, ctest, WARP or GPU. This is a read-only review on Linux.

AI-assisted.

@Leyukaka

Copy link
Copy Markdown
Collaborator Author

New head a96d1f6b: merge of main 4b0586d4 (#3398 and #3400 included). git merge-tree --write-tree against current main e3f9a64f is clean.

MUST 1

One conflicting file, src/startup_stubs/d3d12_compute_dispatch.inl, in the view loop of translate_compute_natively. Main's side is kept (the Kind alias, texture_output and the dimension switch, supported, auto& slot). Three lines carry the atomic UAV, from git show --remerge-diff a96d1f6b:

+            const bool atomic = view.kind == Kind::indexed_atomic_uav;
+            const bool output = texture_output || view.kind == Kind::raw_buffer_uav || half_typed || atomic;
-                                   x2w::accepts_cbv_window(view.kind) || texture_input ||
+                                   x2w::accepts_cbv_window(view.kind) || texture_input || atomic ||
                                    dimension != D3D12_UAV_DIMENSION_UNKNOWN;
             slot.packed_d16_x = packed_x;
+            slot.atomic = atomic;

The branch's volume flag is dropped: main's dimension switch covers it. The remerge diff shows nothing else.

Run

Full build of a96d1f6b, dev preset with -DX2W_WITH_OPUS=OFF, in a fresh isolated environment with a hardware adapter and the inbox WARP.

ctest --preset dev --no-tests=error -R '^(startup_compute_indexed_atomic_uav_|native_compute_manifest_reasons|startup_compute_dispatch_native_|startup_compute_dispatch_texture|startup_compute_dispatch_two_mips_|startup_compute_input_view_token|startup_input_view_token)'

100% tests passed, 0 tests failed out of 27

24 passed, 3 skipped. The skips are the WARP variants that need a 32-lane adapter: startup_compute_indexed_atomic_uav_warp, startup_compute_dispatch_native_warp, startup_compute_dispatch_texture_native_warp.

The tests from main that go through the same function pass on hardware:

startup_compute_dispatch_native_hardware           Passed
startup_compute_dispatch_texture_native_hardware   Passed
startup_compute_dispatch_texture_hardware          Passed
startup_compute_dispatch_texture_dims_hardware     Passed
startup_compute_dispatch_two_mips_hardware         Passed
startup_compute_input_view_token_hardware          Passed

startup_compute_dispatch_texture_warp, _texture_dims_warp, _two_mips_warp and startup_compute_input_view_token_warp pass too, as do the eight startup_input_view_token* tests and native_compute_manifest_reasons (0 of 32 manifest reasons wrong).

The native: line of startup_compute_indexed_atomic_uav_hardware at a96d1f6b:

native: the same program translated in-process and matched on hardware

The rest of that output:

raw: 12 adds per addressed dword match on hardware (debug layer unavailable)
raw: 4 token shapes and a hardware descriptor refused, each with its own reason and an untouched output
structured: 12 adds per addressed dword match on hardware (debug layer unavailable)
typed: 12 adds per addressed dword match on hardware (debug layer unavailable)
startup_compute_indexed_atomic_uav: PASS on hardware

SHOULD

  1. No WARP dispatch here either. The inbox WARP is 4-lane, so _warp stops before any dispatch:

    native_lane_range=4..4 shader_model_capped_at_6_6=0x66
    skip: shader wave32 fixture requires SM 6.6, WaveOps, and a 32-lane wave
    

    A run on a 32-lane WARP has to come from another environment.

  2. The run above is on a hardware adapter.

  3. Unchanged: CMakePresets.json is not edited by this PR, so the pr filter still selects none of these tests.

  4. Not addressed in this push. The three test files of the PR are identical at 393b80eb and a96d1f6b: count still does not decide the result, and u0 is still the only atomic UAV.

The NITs are not addressed in this push either.

@Leyukaka

Copy link
Copy Markdown
Collaborator Author

SHOULD 2 on 393b80e: adapter details for the 27-test run on a96d1f6, as printed by the tests.

Backend Adapter Driver
hardware NVIDIA GeForce RTX 5080 32.0.16.2101
WARP Microsoft Basic Render Driver 10.0.26100.9818

Windows Sandbox on a Windows 11 host, build 10.0.26300. The debug layer was unavailable in the Sandbox, on both backends.
The earlier Sandbox runs posted here (e114367, 393b80e) used the same machine.

@JohnConnorNPC

Copy link
Copy Markdown
Collaborator

Re-review of the delta 393b80eb → a96d1f6b (read-only, on Linux; no build or run here). Verdict: merge (0 MUST).

  • MUST 1 is resolved. git show --remerge-diff a96d1f6b touches only src/startup_stubs/d3d12_compute_dispatch.inl. Main's view loop is kept, and the atomic UAV goes into all three places: output (... || half_typed || atomic), main's supported predicate (... || texture_input || atomic ||) and slot.atomic = atomic on main's auto& slot. An atomic view leaves dimension UNKNOWN and slot.texture false, as before. Dropping the branch's volume flag is safe: main's texture_output switch maps dimension 2 to TEXTURE3D.
  • Apart from those three lines, the PR's own diff is the same at 393b80eb and a96d1f6b (7 files, +455/−7).
  • git merge-tree --write-tree origin/main a96d1f6b rc 0. Windows, Linux and gfx1013 CI pass at a96d1f6b. The hardware run at a96d1f6b (27 tests: 24 pass, 3 WARP capability skips) and the adapter table close SHOULD 2.

These earlier SHOULDs remain open but do not block the merge: SHOULD 1 (no 32-lane WARP dispatch), SHOULD 3 (the pr preset selects none of the tests) and SHOULD 4 (count does not decide the result, and u0 is the only atomic UAV). The NITs are unchanged.

AI-assisted review.

@JohnConnorNPC

Copy link
Copy Markdown
Collaborator

Follow-up: the merge didn't go through. #3351 merged first (0ed385dc), and the branch now conflicts with main in one comment-only region. git merge-tree --write-tree origin/main a96d1f6b rc 1 gives CONFLICT (content) … src/startup_stubs/d3d12_compute_dispatch.inl, with one conflict region: the header comment above volume_uav_range_error.

Resolution: keep main's line with texcubearr, then the branch's atomic sentence, then `smp`, `smpl` and `smpc` lines become static samplers. Entry. No code changes. Once that is pushed and CI passes, this is ready to merge. The review above (0 MUST) still holds.

AI-assisted review.

d3d12_compute_dispatch.inl: header comment keeps main's texcubearr line and the indexed atomic UAV sentence.
@JohnConnorNPC

Copy link
Copy Markdown
Collaborator

Re-review of the delta a96d1f6b → d3d0a657 (read-only, on Linux; no build or run here). Verdict: merge (0 MUST).

  • d3d0a657 merges main 0ed385dc (runtime: bind cube texture SRVs for published native compute #3351 included), so the branch is current with main. git show --remerge-diff d3d0a657 touches only the header comment of src/startup_stubs/d3d12_compute_dispatch.inl: it keeps main's texcubearr input list and the PR's indexed atomic UAV sentence.
  • Apart from hunk offsets and that comment line, the PR's own diff is the same at a96d1f6b and d3d0a657 (7 files, +455/−7). The atomic flag still sits in output, in main's supported predicate and in slot.atomic = atomic.
  • Windows, Linux and gfx1013 CI pass at d3d0a657.

The SHOULDs and NITs from the earlier reviews are unchanged and don't block the merge.

AI-assisted review.

@JohnConnorNPC
JohnConnorNPC merged commit c338546 into R0Y00:main Nov 29, 2026
5 checks passed
Ammmae0x added a commit to Ammmae0x/Xbox2Windows that referenced this pull request Nov 29, 2026
Merge origin/main 8a30428 (upstream in this clone is remote origin,
R0Y00/Xbox2Windows), which includes R0Y00#3351 and R0Y00#3454. Conflicts resolved:
tests/startup_stream_consumer.cpp keeps main's
mode.rfind("dispatch-cube", 0) == 0 alongside the
X2W_TEST_RECORDS32=1 output-at-byte-32 clause on the dispatch_slot67
condition; tests/native_compute_manifest_reasons.cpp keeps all of main's
cube_* / indexed_atomic_uav cases and published[] rows (including the
texcubearr row and the indexed atomic publish check) alongside the
d16_sample_srv cases, with published[] in main's (binding, kind, dim,
line) order: 27 cases + 13 published + 3 = 43 checks. The d16 test and
docs note are unchanged in this merge.
Not-Saii added a commit to Not-Saii/Xbox2Windows that referenced this pull request Nov 29, 2026
main added the indexed atomic UAV (R0Y00#3454) parser line and manifest reasons
next to this branch's typed output line and 20-byte reasons row. Keep both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

3 participants