runtime: bind indexed atomic UAVs in the direct compute runtime path #3417
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3417"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-28T23:57:25Z.
Refs #3224, #2935
ComputeViewKind::indexed_atomic_uavpreviously had no runtime manifest, socompile_dxilreportedcompiled, no runtime manifest: UAV kind indexed_atomic_uavand the dispatch path never bound it. This change publishes and binds it in the direct compute runtime path.src/direct_compute_cache.cpp:format_compute_runtime_manifestpublishes a single 4-byte view asuav <register> atomic table <parameter> <byte>. Any other shape (descriptor array,required_bytes != 4) stays refused by name asUAV kind indexed_atomic_uav.src/startup_stubs/d3d12_compute_dispatch.inl: parses theatomicline and builds a root signature with one extra 32-bit-constants parameter per indexed atomic UAV, after the view table and in UAV order, withShaderRegister = uav register + 1and two values, matchingNativeComputePipeline. The in-process native translation classifies the binding as an output the same way.native_buffer_store_viewcheck derives{stride, count}from that view (structured stride multiple of 4 and at most 2048, rawR32_TYPELESS, typedR32_UINT/R32_SINT) and rewrites it to the rawR32_TYPELESSview the atomic operates on; failures refuse asan indexed atomic output view has an unsupported stride or range. A hardware-descriptor atomic refuses asan indexed atomic output needs a slot-19 token view.src/startup_stubs/translated_sampler_bindings.h:create_translated_roottakes the atomic UAV registers (defaulted, other callers unchanged); the sampler-heap table follows the atomic parameters.tests/startup_compute_indexed_atomic_uav_check.py(_controls,_warp,_hardware,SKIP_RETURN_CODE 77) publishes the synthetic program throughcompile_dxil, dispatches it through the stand-in list (raw, structured stride-8 and typedR32_UINTtoken views, each with its own addressed dwords), checks four token shapes and a hardware descriptor that must each refuse with their own reason and leave the output untouched, and checks the native in-process translation of the same program.tests/native_compute_manifest_reasons.cppgains the accept case and the array/required_bytesrefusals. Contract documented indocs/experiments/compute-indexed-atomic-uav.md.WIN-VERIFY round 1 (
9895ec1c):native_compute_manifest_reasons,native_compute_manifest_reasons_requestsandstartup_compute_indexed_atomic_uav_controlspassed;_warpskipped (77);_hardwarefailed after the raw bound run passed, withdevice removed(DXGI_ERROR_DEVICE_HUNG) in slot 19. Three negative-control UAV descs were invalid for D3D12CreateUnorderedAccessViewon the 1280-byte buffer (a 4096-byte structured stride, a RAW-flaggedR32_UINTview, a 1284-byte view), so the device was removed before the dispatch could refuse them; and the--shader-wave32gate inmain()exited 77 on WARP, skipping the published runs even though only the native translator needs 32-lane waves.Fix in this head (
fa269a85): every negative view is now creatable in D3D12 on its buffer — the 4096-stride view runs on the 16 MiB + 64 KiB committed buffer (dispatch-uav-token-large), the unaligned view usesWORDS - 1elements, and the two uncreatable shapes (RAW with a non-R32_TYPELESSformat, a view past the end of its buffer) stay out.controls()now checks every negative view fits its buffer and that the two uncreatable shapes fail that check.main()no longer probes--shader-wave32;native_check()probes it directly so a skip there does not discard the published results.Linux verification (this host has no Windows toolchain, so the GPU tests are pending below):
python -B tests/startup_compute_indexed_atomic_uav_check.py: controls pass (program encoding, table loads,idxenatomic, per-shape expectations, token views, creatable negative views).python -B tests/form_coverage_check.py,tests/docs_links_check.py,tests/bidi_controls_check.py: pass.py_compileon the touched Python file: pass./tmp(clearedidxen, raw stride 1 to 4, structured stride 8 to 16, mutated refusal reason, droppedglcfrom the expected decode, reintroduced the 1284-byte unaligned view): each fails the controls, unmutated base passes.d3d12_compute_dispatch.inl.Windows Verification (
10d7d41b)Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T04:37:10Z.
Review: APPROVED
Reviewed
10d7d41bby reading the diff againstmain212d4b5f. No local build or run.git merge-treeagainstmainis clean.Formatter (
src/direct_compute_cache.cpp:990-996):indexed_atomic_uavis published only witharray_count == 1andrequired_bytes == 4, which is the width the translator always records for the binding (src/gfx1013_direct_compute.inl:456-457). Other shapes fall through toview_shape, so an array refuses asUAV kind indexed_atomic_uav array(:911), as the new case expects.Runtime (
src/startup_stubs/d3d12_compute_dispatch.inl):gfx1013_direct_compute.inl:323) and, per indexed atomic,{stride, count}from b(register + 1) (:460-468); it creates no other CBV handle.create_translated_rootadds one 2-value constants parameter per atomic UAV atShaderRegister = register + 1after the view table (translated_sampler_bindings.h:146-152), the same asNativeComputePipeline(src/native_compute_pipeline.cpp:92-97). The register is the UAV index, which equals the manifest register because eachuavline must havei == tr.uavs.size()(:229-230); the in-process path has the same check onshader_register.:275,:378), so at most 2 + 8 + 1 = 11 parameters (parameters[11]) and a root cost of at most 32 + 1 + 16 + 1 = 50 DWORDs.:864-871,:889-901): the token view goes throughnative_buffer_store_viewfrommain(src/native_buffer_store_view.h:17-54, unchanged here). That accepts rawR32_TYPELESS, structured with a stride that is a multiple of 4 and at most 2048, or typedR32_UINT/R32_SINT, rejects counters, a range outside the resource and a start that is not 16-byte aligned, then rewrites the view to rawR32_TYPELESS. A hardware descriptor refuses before the hardware path (:898-901). The constants are set in UAV order withatomic_parameter++(:1069-1074), the same ordercreate_compute_pipelinebuilt (:117-119).buffer_atomicalready lowers onmain(gfx1013_direct_compute.inl:443-452). This PR only adds the binding.Tests: no test, tool or doc on
mainexpectsUAV kind indexed_atomic_uavfromcompile_dxil. Reading the tests against the code:native_compute_manifest_reasons: dropping thearray_countorrequired_bytescondition fails a new case. Dropping the clause fails the accept block.startup_compute_indexed_atomic_uav_*: the three positive shapes write different dwords (raw0..31, stride 80,8,..,248, typed0,4,..,124), so a wrong stride constant or a wrong rewrite fails. Dropping the slot-19 refusal failsdispatch-records32. Wrong parameter indices or a wrongShaderRegisterfail the positive runs.Not covered:
countis never the deciding bound: the largest index is 124 and the smallest count is 160. Settingatomic_countto~0uat:894passes every test. A smallerNumElementsalone may not catch it either, since the rewritten raw view has the same extent. Suggestion: an index that wraps under the multiply, which is what the count test guards (gfx1013_direct_compute.inl:461), for example stride 8 with index0x20000000 + lane, expecting an untouched output.push_back(i)->push_back(0)at:119survives. Suggestion: a mixed layout, for example u0 raw and u1 atomic, which reads b2.dispatch-uav-token-large, which views a committed buffer while the readback is of the placed output buffer, so its "untouched output" check does not read the buffer it views. The refusal text still pins that case.prpresets, whose build targets include neithercompile_dxilnorstartup_stream_consumerand whose filter matches none of the new tests. The new controls are not intests/checks/python-linux. The evidence is the log in the description, where_warpskips with 77 and only_hardwaredispatches.:587and:1067say "parameter 2 + its UAV index". The code uses 2 + the rank among atomic UAVs, which is correct. The description still saysmain()no longer probes--shader-wave32; at this head it does (test:256), and the re-probe innative_checkcannot skip.Overlap: #3398 rewrites the same classification block in
translate_compute_nativelyand conflicts here; whichever lands second addsatomictooutputand tosupported. Thetests/native_compute_manifest_reasons.cppchanges merge cleanly with #3427 and #3398.Approve
10d7d41b.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-29T08:28:46Z.
Review: COMMENTED
Reviewed
10d7d41b7740bb176e1cf6c5360cf6e3c9c92a2f:Running the PR's tests on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) failed in both Debug and Release:
ctest --preset dev -R '^(startup_compute_indexed_atomic_uav_|native_compute_manifest_reasons$)' --parallel 3 --no-tests=error --output-on-failure: 1/4 passed, 3 failed (native_compute_manifest_reasonspassed;startup_compute_indexed_atomic_uav_controls,startup_compute_indexed_atomic_uav_warp, andstartup_compute_indexed_atomic_uav_hardwareall failed incompile_dxilwithno_manifest input=req_f05f4f5cbdd73cc3.c67 unsupported startup runtime manifest bindings: UAV kind indexed_atomic_uav).ctest --preset release -R '^(startup_compute_indexed_atomic_uav_|native_compute_manifest_reasons$)' --parallel 3 --no-tests=error --output-on-failure: 1/4 passed, 3 failed (same failure).AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T08:45:10Z.
Review: COMMENTED
Re-checked head
10d7d41bagainst the report above, by reading only; nothing built or run. Our approval stays until the cause is known.format_compute_runtime_manifest(tools/startup/compile_dxil.cpp:328-329,:1561).0614f68cemits for this binding. Without the branch this PR adds, a one-elementindexed_atomic_uavreachesrefuse(view_shape("UAV", b)), which gives exactlyUAV kind indexed_atomic_uav.src/direct_compute_cache.cpp:990-996publishes that kind whenarray_count == 1 && required_bytes == 4. With one element, the same text can then only come fromrequired_bytes != 4. The translator creates this kind in one place, with 4 bytes (src/gfx1013_direct_compute.inl:456-457).native_compute_manifest_reasonslinks the samex2w_shader_compilerlibrary as compile_dxil (CMakeLists.txt:31-32,tests/cmake/native_compute_manifest_reasons.cmake:5-6). Its new block (tests/native_compute_manifest_reasons.cpp:128-143) requiresuav 0 atomic table 1 32for exactly that shape, and the report shows it passing.So either the translated binding is not 4 bytes, or the compile_dxil that ran was not built from this head. Two things would settle it:
u0 root=... bytes=... min_size=...line compile_dxil prints for the request the failing test publishes (tools/startup/compile_dxil.cpp:137-138; the failing assert inpublish()includes its stdout);10d7d41b. The full SHA quoted in the report (10d7d41b7740...) is not this head's (10d7d41b77d4...).Separately, the PR now conflicts with
main(41babe6e), insrc/startup_stubs/d3d12_compute_dispatch.inlonly. At the in-process slot setup, #3409 addedslots.back().requires_identity_dst_sel = view.requires_identity_dst_sel;where this PR addsif (atomic) slots.back().atomic = true;. The two lines set different fields; keeping both resolves it.CI does not run these 4 tests: PR CI uses the
prtest preset, whose filter has neitherstartup_compute_indexed_atomic_uav_*nornative_compute_manifest_reasons.Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T12:49:56Z.
Taking this over since there has been no activity for 2 h; will hand back if you resume.
Plan: merge
main(77d1ba4d) into10d7d41bwith your commits unchanged. The only conflict is insrc/startup_stubs/d3d12_compute_dispatch.inl, at the slot setup; both lines are kept: main'sslots.back().requires_identity_dst_sel = view.requires_identity_dst_sel;and yourif (atomic) slots.back().atomic = true;.Then run
ctest -R '^(startup_compute_indexed_atomic_uav_|native_compute_manifest_reasons$)'in a fresh isolated build and post the result here, in a PR that credits you.Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-29T12:55:23Z.
Review of
10d7d41bagainst main77d1ba4d. Verdict: hold. Leyukaka has taken over the merge of main, so this only adds what affects the default launcher path.MUST
src/startup_stubs/d3d12_compute_dispatch.inl(git merge-tree --write-tree --name-only origin/main 10d7d41b→CONFLICT (content)). Leyukaka's plan above covers the resolution.1/4 passed, 3 failed). This matters more than usual because of where the change lands. The in-process half of the PR,translate_compute_natively(const bool atomic = view.kind == x2w::ComputeViewKind::indexed_atomic_uav;), runs on the default launcher path: since #3449,X2W_NATIVE_SHADERS_ONLY=1unless-Translate. There, programs with an indexed atomic now dispatch instead of being refused.native_check(), andmain()calls it after the threecompile_dxilshapes. So on the failing run the native dispatch never ran.native:line of the_warp/_hardwareoutput separately, along with theu0 root=... bytes=...line Leyukaka asked for.SHOULD
re.searchof theprtest-preset filter at this head againststartup_compute_indexed_atomic_uav_controls,_warpandnative_compute_manifest_reasons→Falsefor all three. The_controlsleg needs onlycompile_dxiland DXC, so adding it to the preset (andcompile_dxilto theprbuild targets) would give the PR a CI signal.What I tried: I cross-built
compile_dxilfrom this head (clang-cl 19) and ran thecompilemode under Wine. It stops earlier, atnative compute +0x0: invalid root layout, because Wine's D3D12 root-signature deserializer returns E_INVALIDARG for the test's root blob. So I couldn't reproduce or rule out the Server 2025 result here, and I'm not counting this as evidence either way.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T13:07:53Z.
The merge of
mainis in #3454: your three commits (9895ec1c,fa269a85,10d7d41b) unchanged, plus two merge commits ofmain(e1143678for77d1ba4d,393b80ebforaf1cab5c). Head is393b80eb. Both conflict resolutions, the run result and thenative:line are in its description.You can take it back at any time: say so here and #3454 gets closed.
Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-29T14:17:29Z.
Thanks @Leyukaka for merging #3417 forward cleanly as #3454 (
c3385469) and @JohnConnorNPC for reviewing! Closing #3417 since its commits (9895ec1c,fa269a85,10d7d41b) have landed inmainvia #3454.