Skip to content

tracking: fixed mesh pipelines (slot 57) through the native C++ frontend #3416

Backlog

Description

@Leyukaka

Part of #2413. Refs #870, #3091, #3094, #3308.

Goal

Translate fixed mesh pipelines (device slot 57) through the native C++ frontend. On main 0614f68c, the shader cache of a start-up run of about 6 minutes (carried over from earlier runs) holds 543 slot 57 requests, all with a gfx2hlsl.py .fail, and that run refused 1,923,473 indirect DispatchMesh commands (graphics-pipeline bucket).

Done when the 543 requests are ranked by C++ refusal here, and each claimed item below is merged or released.

How a GPU program reaches the screen

application (unmodified x64 code)
  -> console D3D12 / GDK calls -> stand-ins (src/startup_stubs) -> Windows D3D12
       each GPU program is gfx1013 machine code and must be translated to DXIL

  compute (slot 67)        mesh + pixel (slot 57)        vertex + pixel
        \                          |                          /
         translation: gfx2hlsl.py (--pending, or the watcher with -Translate);
         C++ frontend in the stand-in with -NativeShaders;
         if no translation exists, the draw or dispatch is refused
                                   |
         runtime binding: descriptors in guest memory matched to D3D12 resources
         and a manifest

On the native path, a slot 57 pipeline also needs a reviewed <variant>.mesh57-state profile (src/startup_stubs/native_mesh57.inl:251-257), so today every captured request stops there before translation. Offline, compile_dxil --refusals reads req_<key>.m57 requests with their .ps57 and .root files (tools/startup/compile_dxil.cpp:548-629); each needs an entry layout, a .mslayout file beside the request or --mesh-layout FILE, and fails with mesh request has no entry layout otherwise.

Where things stand

First gfx2hlsl.py refusals of the 543: s_cbranch_execz skips code with effects outside active lanes 398, v_readfirstlane_b32 outside the group-index read is not covered 91, exchange shapes 37, loops 17. The C++ frontend handles execz blocks differently, so its ranking is still to be measured.

Claimed (Leyukaka, see #2413)

Free

Each needs a source-built positive case and a negative control (#870). Claim in #2413 before starting.

  • pos1 and per-thread export order
  • the rest of tedin7's item 1: inner execz, SCC of a mask op, scalar load with a non-wave-uniform address
  • loops outside the group-memory exchanges
  • v_writelane / v_readlane
  • depth-only pipelines (the native path needs at least one colour target today)
  • a source for the group thread count and topology of a fixed mesh pipeline

Not covered yet

A translated mesh program still needs a profile to draw: thread count, topology, rasterizer state and attachment formats have no automatic source; draft #3413 proposes an opt-in runtime derivation for one allocation shape.

Activity

  1. Leyukaka commented on Nov 29, 2026

    @Leyukaka
    CollaboratorAuthor

    First C++ refusal ranking for the 543 captured slot 57 requests.

    Tool: compile_dxil --refusals <dir> --jobs 8 --json --mesh-layout <file>, built from #3418 (664db4ca on main 0614f68c) plus the root-input change (not opened yet). Caller layouts all used guest_root, wave 64 and a non-zero group_stride. Variants tested: threads 64 and 128, maxima equal to threads, triangle topology, with and without packed_parameters. Every variant gave the same counts:

    First refusal Count
    direct resource-heap load requires the selected GPU slot and its view type 370
    unsupported mesh instruction or EXEC state: v_readfirstlane_b32 147
    unsupported mesh instruction or EXEC state: s_mov_b64 21
    formatted mesh load lacks an R32_UINT resource heap contract 5
    translated 0

    With wave 32 or group_stride 0, all 543 stop at unsupported mesh instruction or EXEC state: s_mov_b64. The exchange is matched only when, among other conditions, !layout.wave32 && layout.group_stride (src/gfx1013_direct_mesh.inl:383), so those runs measure the layout, not the programs.

    These are first refusals only. Fixing one reason can expose later refusals in the same requests.

    The top reason is the same heap-selection refusal that leads the compute family in #3224 (333 of the 882 compute programs at main 8ecd30fe). #3023 covers heap view types on the native compute route.

    Next for #3416: the v_readfirstlane_b32 class (147), then the s_mov_b64 class (21). Whether those 21 are exchange shapes failing another matching condition is not established; #3420 would separate them.

  2. Leyukaka commented on Nov 29, 2026

    @Leyukaka
    CollaboratorAuthor

    Taking the next item from the ranking above: the 147 requests that stop at v_readfirstlane_b32. By disassembly and code reading (the tool does not report the pc), the refused read in each is the 32-bit unsigned-division expansion over SGPR inputs (v_cvt_f32_u32 / v_rcp_f32 / v_mul_f32 / v_cvt_u32_f32), whose result is the same in every lane, but the frontend does not record VALU results as wave-uniform.

    Plan, one PR: record a VALU result as wave-uniform when every source is (no DPP/SDWA, no VCC/EXEC or lane-index source), and accept s_sub_i32 and s_mul_hi_u32, which the shared scalar ALU already implements. A negative control keeps a lane-varying v_cvt_f32_u32 input refused. This moves those requests forward but does not translate them yet: by a static estimate (not measured), the next refusals are v_mul_hi_u32 and s_max_u32.

  3. Leyukaka commented on Nov 29, 2026

    @Leyukaka
    CollaboratorAuthor

    Status of the v_readfirstlane_b32 / 32-bit unsigned-division item, both branches on main 212d4b5f, PRs to follow:

    • v_readfirstlane_b32 of a proven wave-uniform VGPR is accepted. A VALU result counts as uniform only when it is written under full EXEC from uniform sources; for accumulator ops the accumulator is checked, for 64-bit pair sources the high word too; DPP and SDWA forms are excluded. s_sub_i32 and s_mul_hi_u32 join the scalar ALU list.
    • A second, independent branch admits s_max_u32 and v_mul_hi_u32.

    Also taking a soundness bug in the mesh frontend on main 212d4b5f: s_or_b64 exec, exec, s[x:y] inside an open lane-skip block (v_cmpx_* + s_cbranch_execz) widens EXEC, but the rest of the block is still emitted under the narrowed lane condition. The program is accepted and the DXIL is wrong, with no refusal: a VGPR write after the widening reaches only the lanes that passed the compare. Found by reading the DXIL that compile_dxil emits for a source-built fixture; nothing was run on a GPU.

  4. Leyukaka commented on Nov 29, 2026

    @Leyukaka
    CollaboratorAuthor

    Status: five branches on main 212d4b5f, PRs not opened yet.

    • The two above: uniform v_readfirstlane_b32, and s_max_u32 / v_mul_hi_u32.
    • EXEC widening: inside an open lane-skip block, an EXEC write that can widen past the skip's guard is refused (mesh EXEC write inside a lane-skip block). Narrowing s_and_b64 / s_andn2_b64, the gather and signed-CMPX join restores, and the restore right after a nested skip closes stay accepted.
    • The 21 s_mov_b64 first refusals in the ranking are, by disassembly, the group exchange without its EXEC save (60 bytes instead of 64, every other word identical). The matcher accepts that form; a later EXEC restore from a pair that was never saved is still refused. What those 21 requests refuse next is not measured.
    • prepare_native_mesh57: the profile input bytes differ refusal names the first part that differs (length or content). Accepted and refused profiles are unchanged.
  5. Leyukaka commented on Nov 29, 2026

    @Leyukaka
    CollaboratorAuthor

    Still on this. The five changes listed above are committed on top of main 212d4b5f; PRs not opened yet.

  6. Leyukaka commented on Nov 29, 2026

    @Leyukaka
    CollaboratorAuthor

    Still on this. The five changes listed above merge cleanly onto the current main eab7180c; PRs not opened yet.

  7. Leyukaka commented on Nov 29, 2026

    @Leyukaka
    CollaboratorAuthor

    Status on main 1a0120ba:

    Each open PR merges cleanly onto 1a0120ba. Between them (git merge-tree --write-tree, pairwise): #3438 and #3439 conflict in tests/native_direct_mesh_check.py, #3439 and #3445 in src/gfx1013_direct_mesh.inl. No other pair conflicts. I will rebase whichever lands second.

    Left from the plan: mesh entry root inputs from the creation root signature (offline). It is committed locally on 1a0120ba and has no PR yet.

  8. Leyukaka commented on Nov 29, 2026

    @Leyukaka
    CollaboratorAuthor

    #3450 (open, head a87c6f7e, on main e358cf5f) refuses three mesh program shapes that main accepts and translates to wrong DXIL: a VGPR left partial by writes under narrowed EXEC and read after an s_or_b64 / s_and_b64 / s_andn2_b64 EXEC write that can add lanes; a scalar ALU write to exec_lo / exec_hi outside a lane-skip block, which leaves the lane state on the old mask; and a scalar ALU write to vcc_lo / vcc_hi, whose word is then used as the predicate of every lane.

    #3439 will be rebased on it once it is merged: its two added SOP2 opcodes (s_sub_i32, s_mul_hi_u32) go through the same guarded handler.

  9. Leyukaka commented on Nov 29, 2026

    @Leyukaka
    CollaboratorAuthor

    Seven slot 57 PRs are open and ready for review. All are mergeable against main and their PR checks are green. Order that lets each one merge without carrying another:

    1. startup: count native slot 57 preparation outcomes #3483 (78693088): counters for each exit of native slot 57 preparation. Depends on: nothing. CI: green.
    2. shader: SampleLevel(0) for constant-coordinate nonuniform IMAGE_SAMPLE #3496 (6a9d2a02): sampleLevel at level 0 for a constant-coordinate nonuniform IMAGE_SAMPLE, fixes tests: native_fixed_mesh57_waterfall_fine_hardware fails on main (mip 1 colour read where mip 0 is expected) #3489. Depends on: nothing. CI: green.
    3. tooling: build slot 57 mesh profiles from runtime captures #3497 (1014e85f): tool that builds a .mesh57-state profile from a runtime capture. Depends on: nothing. CI: green.
    4. startup: read slot 57 mesh blend words at the shifted offset #3503 (ea3a90c2): mesh-layout blend words read at +0x124 instead of +0xD0. Depends on: nothing. CI: green.
    5. shader: admit PS-less slot 57 mesh pipelines with a reviewed profile #3493 (196adf8c): PS-less (depth-only) slot 57 pipelines admitted with a reviewed profile. Depends on: startup: count native slot 57 preparation outcomes #3483 (contains its commit). CI: green.
    6. startup: record bound slot 57 targets with the creation capture #3502 (4991e866): bound target formats recorded in a .t57 file next to the creation capture. Depends on: shader: admit PS-less slot 57 mesh pipelines with a reviewed profile #3493 (only the last commit is new). CI: green.
    7. tooling: draft reviewed slot 57 profiles from captures #3505 (5b05bac2): depth-only profiles and a draft mode in the profile tool. Depends on: shader: admit PS-less slot 57 mesh pipelines with a reviewed profile #3493, tooling: build slot 57 mesh profiles from runtime captures #3497 and startup: read slot 57 mesh blend words at the shifted offset #3503 (contains their commits). CI: green.

    1 to 4 are independent of each other and can merge in any order. #3493 is the one that unblocks #3502 and #3505; once 1 to 5 are merged, the last two show only their own commits. #3505 reads the .t57 file from #3502 as an input but does not contain its code.

  10. added
    priority: P0
    on Nov 30, 2026
  11. lukaslw-lab commented on Nov 30, 2026

    @lukaslw-lab
    Contributor

    Call-weighted input for the C++ ranking, from a 360 s native run from a saved scene (details and tree in #3541). Each refused DispatchMesh key maps to its .s57 variant and request. Offsets are as compile_dxil prints them, from the start of the .m57:

    Updated 1 Dec: claims and PR states.

    C++ first refusal Requests Refused calls First site Claim
    mesh heap slot lacks masked root constant provenance 77a438d6, 12f152df 1.13 M 77a438d6 +0x2a0: s_load_dwordx4 s[36:39], s[16:17], s23, slot = s_buffer_load_dword s23, s[36:39], 0x7f8 << 5 translator: lukaslw-lab, #3619 (merged; opt-in through the layout's heap_tokens). Runtime binding open, to build on #3023 stage 3 (#2413 note). Until then the runtime still refuses here
    mesh EXEC write inside a lane-skip block f2b3d808, 2319d05e 0.78 M f2b3d808 +0x70c: s_mov_b64 exec, s[20:21] mumba17, #3633 + #3646 (merged). 8 of 454 cached requests remain; they need lane-merge support (free)
    graphics register undefined on an incoming path: 265 3e824362 0.47 M +0x46c: exp pos0 ... done after v_cmpx_gt_i32 + s_cbranch_execz; the pos0 export is skipped on one path mumba17, PR #3671 (open) (#2413)
    unsupported mesh instruction or EXEC state: v_readfirstlane_b32 33f028d7, 88fef298 0.42 M 33f028d7 +0x370: v_readfirstlane_b32 s10, v8, at a branch join SimSalabimse, in progress (#2413)

    Further stops from the 454-request census (request counts, not call-weighted), all mumba17:

    Census with the open PRs stacked: Kawiu, #2413 (392 captured requests).

    These are the top seven slot 57 variants: 2.8 M of the 7.2 M mesh_profile_missing calls. Another 7.5 M refused calls go through slot 55 derived pipelines, which #3413 addresses.

    To reproduce a row, put the three request files in one folder and pass this layout. These are the flags native preparation sets. The vertex and primitive limits are placeholders that do not change these refusals:

    mesh1 128 128 128 2 128 64
    packed_parameters
    validate_uint_heap_reads
    guest_root
    
    compile_dxil --refusals <dir> --json --mesh-layout <layout>
    compile_dxil <sdk> <cache> gfx1013-raw-ms <key>.m57 <out>   # prints the +offset; needs <key>.mslayout and <key>.root beside it
  12. added a commit that references this issue on Nov 30, 2026
  13. Leyukaka commented on Dec 1, 2026

    @Leyukaka
    CollaboratorAuthor

    Next step here: verify one reviewed slot 57 profile end to end.

    The call-weighted census above already identifies the slot 57 variants that account for the most refused indirect DispatchMesh calls. Use its archive mapping to select the first variant that the C++ frontend already translates and that has complete captured state and attachment evidence. If a new run is needed, rank the cumulative DispatchMesh refusals by pipeline and record the unmatched and overflow counts separately.

    Use the draft and validation tools from #3724 to review the captured state and attachment tuple. Start a second process with the reviewed profile present in the cache from startup. This step depends on the profile identity rule from #3748 or #3730, and on one .t57 producer (#3736 or #3502); none is merged. Record profile readiness and indirect DispatchMesh forwards for the selected pipeline. Repeat with that profile removed and the workload held fixed.

    Acceptance requires at least one ready profile and one forwarded indirect DispatchMesh attributed to the selected pipeline with the reviewed profile installed. Record the first lowering or binding refusal if readiness or forwarding remains zero. Use a source-built control to exercise the ready and missing-profile outcomes.

    Related: #2413, #3724, #3736 / #3502 (attachment capture), #3748 / #3730 (profile identity), #3531 (published-pair control).

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

    priority: P0

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions