Skip to content

native compute: run wave32 direct modules on WARP (proposal, stage 1 claimed) #3160

Backlog

Description

@Not-Saii

Part of #2935 (item "WARP") and #3074 (stage 4, "Verify wave32/wave64 ... behavior").

Problem. Natively translated compute modules never run on WARP, so CI never runs one.

  • Every direct compute module declares wave size 32 (src/dxil_module.h, the i32 11, i32 32 entry property; [WaveSize(32)] in the HLSL path of src/gfx1013_compute_native.cpp).
  • The in-box WARP reports 4-lane waves (WaveLaneCountMin/Max 4/4, docs/experiments.md, subgroup compaction notes).
  • So the native _warp execution tests skip with 77, and the in-process route refuses the adapter ("the adapter has no 32-lane waves", src/startup_stubs/d3d12_compute_dispatch.inl).
  • Native graphics modules do not declare a wave size and already run on WARP (for example native_graphics_wqm_warp). The gap is compute only.

What is already known.

Proposal.

  1. Stage 1, measurement (I'm taking this). Let the native compute test executables opt into the existing OFFSCREEN_AGILITY_620_DIR + OFFSCREEN_WARP_DIR setup, with the same exports and DLL copies as offscreen_check and no change when the options are unset. Then run the native compute _warp tests on WARP 1.0.22 and record, per test, whether it runs, passes, mismatches or still skips. Any mismatch is checked against the bvh_wave64_warp: WARP 1.0.22 misroutes non-uniform WaveReadLaneAt reads across lane blocks at forced widths above 8 #145 pattern before it is called a translator defect. Deliverable: the opt-in wiring, a docs/experiments/native-compute-warp.md table, and a known-result note for bvh_wave64_warp: WARP 1.0.22 misroutes non-uniform WaveReadLaneAt reads across lane blocks at forced widths above 8 #145-shaped mismatches. No translator change.

  2. Stage 2, CI (decision needed, not claimed). CI uses in-box WARP. The options are:

    (a) is the smallest if stage 1 passes. (b) is translator work: a 4-lane host wave splits each guest wave32, so EXEC/ballot values, s_bcnt1, v_readlane, DPP, scalar values written under a skipped s_cbranch_execz, and the guest-wave index for groups over 32 threads all change meaning. I'd like a maintainer's view before anyone starts stage 2.

Test for stage 1. ctest on the native compute _warp entries with both options set, plus the same entries without the options. Those must still skip with 77, so nothing changes by default. Negative control: one native compute fixture with a deliberately wrong expected word fails on WARP 1.0.22, which shows the run is real and not a skip.

Environment: Windows 11 build 26300, NVIDIA GeForce RTX 4090 (driver 32.0.16.1088), Windows SDK 10.0.26100. WARP 1.0.22 and Agility SDK 1.620.2 app-local, from the Microsoft NuGet packages (not committed).

AI-assisted.

Activity

  1. RonLogic commented on Nov 27, 2026

    @RonLogic
    Contributor

    Independent setup finding on Windows 11 26300.10075 and Visual Studio 2026 18.12.1. With the official 1.620.2 sdk.nupkg present in OFFSCREEN_AGILITY_620_DIR, building offscreen_check stops at the existing static_assert in src/startup_stubs/d3d12_compute_dispatch.inl: it requires both texture view descriptors to have size 40. The same assertion is on main 88cddb09. A trivial x64 probe printing sizeof(D3D12_SHADER_RESOURCE_VIEW_DESC) and sizeof(D3D12_UNORDERED_ACCESS_VIEW_DESC) measured 40/40 with SDK 10.0.26100 headers and 40/48 with the 1.620.2 headers. I am retesting the existing offscreen_check direct atomics/gather fixtures through the DLL-only Agility configuration to isolate runtime behavior. This does not change your test-runner wiring.

  2. RonLogic commented on Nov 27, 2026

    @RonLogic
    Contributor

    Independent readback at ed946ef8 (#3162) using Agility DLLs only with SDK 10.0.26100 headers. Windows 11 26300.10075, DXC 1.9.2602.17, WARP 1.0.22.0, debug layer enabled. In-box WARP 10.0.26100.10068 exposed 4..4 and skipped all four checks below. App-local WARP exposed 4..128.

    Check App-local outcome
    shader_wave32_warp Passed. Forced width 32 and full-group ballot ffffffff were correct.
    wave_shuffle_warp Reproduced #145: forced width 32 affine 0/64 correct and 64/64 block-misrouted, rotation 48/64 correct. Native width 8 passed.
    native_image_atomic_warp The stock check stopped at debug warning 989 (CheckFeatureSupport1) in the DLL-only configuration. A separate replay matched all 336 words in each of the seven fixtures and rejected all three mutations that clear GLC.
    native_gather_lod_cs_warp First readback kept four sentinels (word=0 expected=3f102100 actual=c5c5c5c5). A direct constant-only store reproduced the failure with 1 or 4 threads, and passed with 32.

    The gather failure can be separated from #145 and from the gather lowering. This independent DXC cs_6_6 control stores the entry mask without using WaveReadLaneAt or any texture reads:

    RWByteAddressBuffer outputBuffer : register(u0);
    [WaveSize(32)] [numthreads(1,1,1)]
    void main(uint3 tid : SV_GroupThreadID) {
        uint mask = WaveActiveBallot(true).x;
        uint lane = WaveGetLaneIndex();
        if (tid.x == 0) outputBuffer.Store4(0, uint4(mask, lane, WaveGetLaneCount(), 0x12345678));
    }

    I compiled this with dxc -T cs_6_6 -E main and used native_gather_lod_check.render_compute with expected words [1, 0, 32, 0x12345678] followed by 316 sentinels. On WARP, group sizes 1 and 4 returned a zero ballot, where 1 and 0xf were expected. Group size 32 matched. RTX 4070 with the same Agility runtime matched all three sizes. A plain constant store without the ballot also passed on WARP at sizes 1, 4 and 32.

    Reproduction of the stock checks: ctest --test-dir out/build/warp-1022 --no-tests=error -j 1 -R '^(shader_wave32_warp|wave_shuffle_warp|native_gather_lod_cs_warp|native_image_atomic_warp)$' -V. This uses the existing offscreen runner. Treat partial-wave ballots and per-lane shuffles as separate WARP failure classes when interpreting the upcoming runner results.

  3. RonLogic commented on Nov 27, 2026

    @RonLogic
    Contributor

    I’ll take the pre-existing Agility header build failure as a separate runtime fix. The scope is the temporary descriptor storage used when rebinding published Compute texture views. I’ll verify both SDK header configurations and leave the native WARP runner wiring and stage-2 options to your work.

  4. Not-Saii commented on Nov 27, 2026

    @Not-Saii
    ContributorAuthor

    Stage 1 measurement. It changes the plan above, so this note adds no wiring. The details are in docs/experiments/native-compute-warp.md (#3166).

    The app-local WARP gives 32-lane waves here, not Agility. On Windows 11 build 26300 the in-box D3D12Core.dll is 10.0.26100.9818 (SDK version 616). Loaded by that runtime, with no D3D12SDKVersion export, WARP 1.0.22 reports WaveOps=1, lanes 4 to 128 and SM 6.8. A configure with OFFSCREEN_WARP_DIR already copies d3d10warp.dll beside every test EXE.

    Test In-box runtime + WARP 1.0.22
    native_comparison_pso_warp pass (PSO creation only)
    native_heap_handle_probe_warp pass
    native_global_srv_heap_replay_warp pass. A temporary wrong expected word makes it fail (mismatch word 5).
    startup_compute_dispatch_native_warp fail: translated and dispatched, output keeps its 0xc5c5c5c5 fill (288 words)
    native_startup_request_cache_warp fail: compute dispatch output mismatch (translated branch)
    shader_wave32_warp pass (forced width 32)
    bvh_wave64_warp fail at field 25, the field #145 reports, with a different value: f03aeb40 decodes to source lane 19 (expected 3; the value in #145 decodes to 27, the inverse)

    With the DLL removed, the same binaries of the heap-probe and heap-replay tests report (4..4) lanes and skip with 77. Without the options, the five native tests behave as before.

    The two stand-in failures are not #145-shaped: no word is written at all. startup_compute_dispatch_warp (HLSL module, same stand-in and WARP) passes. On the RTX 4090, startup_compute_dispatch_native_hardware and native_startup_request_cache_hardware pass in the same build. So the failure is WARP-only. Its cause, a WARP 1.0.22 defect or a construct in the native module that hardware tolerates, is not established.

    Agility on this machine.

    Coverage gap. The v_readlane, DPP and v_permlane* fixtures run on native_store_replay, which uses the default adapter and has only _hardware entries. Whether #145 affects native compute is still unmeasured.

    For stage 2, option (a) becomes "fetch the WARP package", with Agility only if a runner's in-box runtime needs it. Before CI can rely on it:

    Environment: Windows 11 build 26300, MSVC 14.44.35207, Windows SDK 10.0.26100, Debug, commit 88cddb09. RTX 4090 (driver 32.0.16.1088) for the two stand-in _hardware runs only. d3d10warp.dll 1.0.22.0.20261027.1 and D3D12Core.dll 1.620.2.0.20261106.5 are Microsoft-signed. Debug layer enabled in offscreen_check; the native fixtures do not enable it.

    AI-assisted.

  5. xiaoqi72665 commented on Nov 27, 2026

    @xiaoqi72665
    Contributor

    Independent Windows 10 / RX 7900 XT result: partial-wave ballots explain the 288 missing stores

    Follow-up to #3166 and @RonLogic's partial-wave control above. Tested the retained local test-only candidate 2485076 (base e0d8375 on cpp-migration); its earlier equivalent candidate bd7a32f supplied the original 57-pass / 1-fail native run. No production lowering changes.

    Environment: Windows 10 22H2 build 19045, AMD RX 7900 XT (1002:744c), driver 32.0.32029.2010, Windows SDK 10.0.26100 DXC, Debug build, signed app-local Agility 1.620.2 and WARP 1.0.22.0. D3D12 debug layer unavailable (0x887a002d).

    Windows 10 difference from #3166: copied the original options-unset offscreen_check.exe and only WARP's d3d10warp.dll into an isolated directory (no Agility exports/D3D12 directory). offscreen_check.exe warp --shader-wave32 reported driver 1.0.22.0, range 4..128, shader model 0x65, then skipped with 77. With app-local Agility 620 DLLs, the earlier wave32 preflight actually passed on both adapters at SM 6.6. For #3165, keeping sdk.nupkg outside the OFFSCREEN_AGILITY_620_DIR and pointing it at a DLL-only directory preserves the desktop 40-byte view structures and builds without modifying the assertion. This is a local workaround, not the descriptor ABI fix already claimed.

    New sweep: independent DXC cs_6_6 source, not the native compiler; same source-built slot67 runtime fixture and descriptor manifest, only the published CSO and group-shape field substituted in a copied cache. Dispatch(3,2,2), write group zero only, complete 320-DWORD readback with untouched sentinel guards.

    RWByteAddressBuffer dst : register(u0);
    [WaveSize(32)]
    [numthreads(24,1,1)] // vary shape as below
    void main(uint3 gid : SV_GroupID, uint tid : SV_GroupIndex) {
        uint mask = WaveActiveBallot(true).x;
        uint count = WaveActiveCountBits(true);
        uint lane = WaveGetLaneIndex();
        uint width = WaveGetLaneCount();
        if (all(gid == 0)) dst.Store4(16*tid, uint4(mask,count,lane,width));
    }

    Compile with dxc -T cs_6_6 -E main -Fo probe.cso probe.hlsl. Replace group dimensions in the source and manifest consistently. Every written record on each adapter was inspected:

    Group shape WARP ballot / count RX 7900 XT ballot / count
    1x1x1 00000000 / 1 00000001 / 1
    4x1x1 00000000 / 4 0000000f / 4
    8x1x1 00000000 / 8 000000ff / 8
    16x1x1 00000000 / 16 0000ffff / 16
    24x1x1 00000000 / 16 00ffffff / 24
    2x3x4 00000000 / 16 00ffffff / 24
    31x1x1 00000000 / 16 7fffffff / 31
    32x1x1 ffffffff / 32 ffffffff / 32

    All 16 runs reported width 32 and lane indices 0..N-1; every guard was intact. This independently confirms the zero low ballot for the tested partial-wave sizes and an additional active-count discrepancy at 24 and 31. Full 32-thread control passes. It does not establish the behavior of every possible group shape or WARP version.

    Connection to #3166's missing writes: on the original 2x3x4 cache fixture, native DXIL on WARP left 288 expected writes at 0xc5c5c5c5, hardware matched all 320 words. Python lowering of the same request on WARP matched all 320; native and Python binding manifests were identical. Independent DXC arithmetic/store shaders using either SV_GroupIndex or WaveGetLaneIndex matched on WARP without the ballot gate, but with (WaveActiveBallot(true).x & (1u << WaveGetLaneIndex())) != 0 all 288 writes were absent. The native DXIL initializes EXEC with the same low ballot and gates stores on it. This explains the observed missing stores without changing the compiler or relaxing the assertion. No WaveReadLaneAt operation is required, so keep this distinct from #145.

    The local test-only environment candidate is retained, not submitted as a competing wiring PR while #3160 and #3165 are owned. Stage 2 CI remains a separate maintainer decision.

    Buhe (@xiaoqi72665). AI-assisted; source-built fixtures executed locally.

  6. RonLogic commented on Nov 27, 2026

    @RonLogic
    Contributor

    The full-header setup fix is ready for review in #3223 (fixes #3165). With Agility 1.620.2 headers and signed DLLs, the four translated texture dispatch cases passed on both backends, including the 3D and swapped-mip controls. On app-local WARP 1.0.22, shader_wave32_warp and the stock native_image_atomic_warp now pass with the debug layer enabled. The earlier warning-989-only failure came from the DLL-only build. All seven atomic readbacks matched and all three GLC mutations were detected.

  7. RonLogic commented on Nov 28, 2026

    @RonLogic
    Contributor

    I ran a source HLSL readback matrix on Windows 11 build 26300.10075, DXC 1.9.2602.17, Agility 1.620.2, and app-local WARP 1.0.22. The same SM 6.6 DXIL ran on RTX 4070 (32.0.16.2124) and WARP. Each invocation recorded its lane index and wave width. The CPU reconstructed the full and sparse masks from those indices, then checked every invocation's ballot, OR, count, and workgroup atomic result.

    • RTX 4070 matched all operations for all 35 shapes: Nx1x1 for N=1..32, plus 2x2x2, 3x2x2, and 4x4x2.
    • WARP reported width 32 and a distinct lane for every invocation. WaveActiveBallot returned zero for both predicates on all 33 shapes with fewer than 32 threads. Both full-width shapes matched.
    • WARP's WaveActiveBitOr and WaveActiveCountBits worked at 1–8, 16, 24, and 32 threads in the linear matrix, but lost the tail at other sizes. At 9 threads, the full mask/count were ff/8 instead of 1ff/9; the sparse mask was 6d instead of 16d. A repeated 9-thread WARP readback was byte-identical and had zero debug errors or warnings. Replacing ballot with either reduction would leave a gap.
    • A group-synchronized groupshared InterlockedOr matched both masks on every shape on both backends. In the 32-thread tiled case both adapters returned sparse mask 799ee779, which also shows why a sparse reference based on flat thread index alone would misreport that case.

    The 9-thread reproducer is below. Compile with dxc -T cs_6_6 -Fo probe.dxil probe.hlsl; then run offscreen_check <hardware|warp> --raw-uav-dump probe.dxil 1 432 probe.bin. Read 12 little-endian uint32s per thread. The 32-thread control uses the same source with numthreads(32,1,1) and 1536 bytes.

    RWByteAddressBuffer output : register(u0);
    groupshared uint fullMask, sparseMask;
    
    [WaveSize(32)] [numthreads(9, 1, 1)]
    void main(uint flat : SV_GroupIndex) {
        uint lane = WaveGetLaneIndex();
        uint bit = 1u << lane;
        bool take = flat % 3u != 1u;
        if (flat == 0) {
            fullMask = 0;
            sparseMask = 0;
        }
        GroupMemoryBarrierWithGroupSync();
        InterlockedOr(fullMask, bit);
        if (take) InterlockedOr(sparseMask, bit);
        GroupMemoryBarrierWithGroupSync();
        output.Store4(flat * 48, uint4(lane, WaveGetLaneCount(),
            WaveActiveBallot(true).x, WaveActiveBallot(take).x));
        output.Store4(flat * 48 + 16, uint4(WaveActiveBitOr(bit),
            WaveActiveBitOr(take ? bit : 0u), WaveActiveCountBits(true),
            WaveActiveCountBits(take)));
        output.Store4(flat * 48 + 32, uint4(fullMask, sparseMask, flat, 0x12345678));
    }

    This confirms a converged, single-workgroup control. The group-shared result depends on every thread reaching both barriers, so it does not establish a replacement for general divergent wave operations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions