Skip to content

cpp-migration: pass captured heap view types into the in-runtime native compute route (#2958) #3023

Backlog

Description

@JB2WIN

Target branch cpp-migration. Follow-up to #2908 (#2972), part of #2935.

Problem. The in-process native compute route of #2958 (X2W_NATIVE_SHADERS, src/startup_stubs/d3d12_compute_dispatch.inl) translates slot 67 requests with x2w::translate_compute(read_compute_request(path), 0, true). That call takes no HeapViewContract, so a request that reads a GPU-selected global SRV heap slot is refused on this route, although #2972 can translate it offline when the view types are known.

Plan.

  1. Record each heap slot's view type when the stand-in creates the SRV (classify_global_srv_view from src/startup_stubs/native_global_srv.h).
  2. At Dispatch, resolve the slots the request can select and build the contract from the recorded types.
  3. Pass the contract into the translation of the slot 67 request (today prepare_direct_compute refuses a contract for non-container requests, and translate_compute has no contract parameter).
  4. Before the Dispatch, check that the live heap still matches the contract; otherwise refuse and keep the gfx2hlsl.py fallback.

Test. A source-built compute workload through the stand-in that reads a buffer, a 2D texture and an empty slot through a GPU-selected index, _warp (capability skip where needed) and _hardware, plus a negative control that indexes one slot off.

I'm taking it; a PR follows. Environment: Windows 11 build 26200, NVIDIA GeForce RTX 3080, plus WARP.

AI-assisted.

Activity

  1. JB2WIN commented on Nov 27, 2026

    @JB2WIN
    ContributorAuthor

    Update: the first step is #3025.

    A census over a local start-up capture (compile_dxil --refusals, 2,689 slot 67 requests, counts only) gives 941 first refusals of this kind. In those programs the heap index is read from buffer data per wave, so the runtime cannot resolve it at Dispatch. Behind the contract there are more walls:

    1. The byte-address rewrite of the loaded heap descriptor (stride, byte count, raw out-of-bounds mode): native: read the byte-address rewrite of a GPU-selected heap descriptor #3025, compiler only.
    2. Typed loads (buffer_load_format_*) through the heap descriptor. With 1 done in a local prototype, 906 requests stop here.
    3. Runtime: a shader-visible heap with title slot k at desktop index k as raw views, plus a contract check over all selectable slots at Dispatch (one captured slot is not enough for per-wave selection).

    I'll continue with 2 next unless someone else is on it.

    AI-assisted.

  2. JB2WIN commented on Nov 27, 2026

    @JB2WIN
    ContributorAuthor

    Runtime acceptance criteria for stage 3 (from R0Y00's review of #3025). Before the runtime supplies a raw-view contract for GPU-selected slots, its fixture must check both of these:

    • a selectable slot whose guest descriptor has a stride above 1 (byte count num_records * stride), read through the byte-address rewrite;
    • a slot whose guest byte count does not match the desktop view: the dispatch must refuse it before the shader runs, not read past or short of the view.

    #3025 does not cover either: its descriptor words stay symbolic.

    AI-assisted.

  3. JB2WIN commented on Nov 27, 2026

    @JB2WIN
    ContributorAuthor

    Step 2a is #3034 (builds on #3025): formatted loads (tbuffer_load_format_*) through the byte-address rewritten descriptor, table or GPU-selected heap slot, now read the same raw view as the raw load.

    Additions to the stage-3 runtime acceptance criteria from that change:

    • A formatted load bounds its whole element with the desktop raw view's size (getDimensions), not with the guest window's byte count. The runtime must create the raw view for a GPU-selected heap window with exactly the guest window's byte count (num_records * max(stride, 1)). The startup manifest route already sizes a table window that way.
    • The descriptor's DST_SEL (word 3) is not applied; only the identity channel order is translated. The runtime contract should either check identity DST_SEL on every selectable slot or the translator has to apply it.

    Typed heap loads (buffer_load_format_*) are the next step and need their own view contract.

    AI-assisted.

  4. JB2WIN commented on Nov 27, 2026

    @JB2WIN
    ContributorAuthor

    Typed heap loads: #3042 adds HeapViewContract::typed_dword for one-channel 32-bit typed buffer slots (buffer_load_format_x with an idxen index through the GPU-selected heap descriptor), with .views channel metadata and a fixture section.

    On the local capture (counts only) the 906 typed heap loads all have that one-channel shape, but with typed_dword forced, 895 of those programs then stop at a raw read of another heap slot: they read the heap raw and typed through different selectors. Covering them needs more than one captured selection per dispatch (raw and typed contracts per load class), which I plan as the next step before the runtime contract.

    AI-assisted.

  5. added a commit that references this issue on Nov 27, 2026
  6. JB2WIN commented on Nov 27, 2026

    @JB2WIN
    ContributorAuthor

    Translator side of the mixed case is in #3063: HeapViewContract::raw_and_typed_dword lets one program read some GPU-selected heap slots raw and others with one-channel typed loads (the kind of each load picks the path). .views gains also <slot> <type> lines for further selections of the same dispatch (selector word k = selection k).

    For stage 3 (runtime), additional acceptance points from this step:

    • the runtime must produce one selection per selector word (also lines), deduplicated; a slot named twice is refused;
    • for every slot a raw load can select the raw_buffer conditions hold, for every slot a typed load can select the typed_dword conditions; the translator cannot check which index feeds which load.

    AI-assisted.

  7. RonLogic commented on Nov 28, 2026

    @RonLogic
    Contributor

    @JB2WIN I’m checking the ordered compiler prerequisites for retargeting #3063. I’ll start with a narrowly scoped carry of your merged #3034 byte-window MTBUF change onto main, preserving authorship and rerunning its own controls. I found no open main carry in the PR search. The in-process heap contract stays with your existing work here.

  8. RonLogic commented on Nov 28, 2026

    @RonLogic
    Contributor

    The first prerequisite is ready for review in #3232. Release and Debug passed the RTX 4070 replay, and the same four tests passed with Agility 1.620.2 and WARP 1.0.22. I have #3042 applied locally on top with its typed-slot replay passing in Release, and will hold its main PR until #3232 lands.

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