Skip to content

shader: supply mesh57 descriptor words from the guest V# - #3801

Draft
lambirou wants to merge 5 commits into
R0Y00:mainfrom
lambirou:codex/mesh57-descriptor-words
Draft

lambirou wants to merge 5 commits into
R0Y00:mainfrom
lambirou:codex/mesh57-descriptor-words

Conversation

@lambirou

@lambirou lambirou commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

The slot 57 MS req_72e1909e13df6f66 reads words 1..3 of its V# numerically at +0x69c/+0x6a8/+0x6b4. #3754/#3758 keep those words symbolic, which is correct but leaves the real capture refusing at +0x69c: unbound numeric SGPR s57.

The compiler lowers numeric reads of an eight-dword indexed_descriptor fetch to a bounds-checked load from a 1024-entry, eight-dword guest descriptor table. Four-word typed descriptors and every other numeric read still refuse. The runtime builds the table from the title view heap: a raw V# is copied, a token SRV is projected to the dimensional V# fields plus its guest base address, and a missing or non-SRV entry stays zero.

Runtime binding (head ad7a54d0): the table is bound as one R32_UINT SRV of 8192 dwords in a descriptor table at t0,space2. prepare_native_mesh57 creates a versioned 1.1 host root with the guest constants and the optional read table; the guest root parameter remains the validation key. A descriptor-word-only stage does not declare the unused resource-heap root flag. Profiles without descriptor words keep the previous path. The fixture creates a Texture1D through slot 133 at guest address 0x100000000, so V# word 5 is nonzero.

Observed on the real MS: +0x69c, +0x6a8 and +0x6b4 pass; the next refusal is +0x7c0: unproven mesh entry register 287 (the f16 pair), as expected without #3762.

Remaining red: the runtime descriptor-words case forwards the dispatch (dispatchmesh 1) and builds the table with the expected CPU words, but the shader still reads zero:

descriptor words: pixel (2, 2) expected c04000ff, got 000000ff

Tests:

  • ctest --preset release --no-tests=error -R '^native_direct' — 2/2 passed.
  • Real MS: +0x7c0: unproven mesh entry register 287.
  • startup_mesh57_runtime_check.py <consumer> <dxc> warp — all prior cases pass; descriptor words is the red above.

Build: compile_dxil, d3d12_xs_shim, startup_indirect_draw_indexed on release.

Stack: #3754 (#3758 branch) -> #3758 -> this PR. Refs #3497.

AI-assisted.

The stable slot 57 profile 9482ea4411e1e03f reaches the mesh frontend with
req_72e1909e13df6f66.m57 and refused at +0x614. The decoded instruction there
is s_load_dwordx8 s[56:63], s[12:13], s22: SMEM op 3, immediate offset 0, an
SGPR offset proven as a multiple of 32, and the base copied from heap SGPR 23
with a constant zero high word. It feeds image_load v[19:21], v11, s[56:63]
at +0x700.

- The mesh heap branch behind validate_uint_heap_reads accepted only op 2
  (s_load_dwordx4); it now also accepts op 3 (s_load_dwordx8) with the same
  immediate-offset, high-word, destination-range and provenance rules.
- A root-provided selector still records heap_fetches. A GPU-selected selector
  that is a proven multiple of 32 keeps the fetch opaque: it records the heap
  slot (bytes >> 5) by pc, but leaves all eight destination words symbolic.
  Their field bits are not available here, so a numeric read keeps refusing
  (unbound numeric SGPR s33 or s37) until a consumer supplies the fields.
- With texture_heap_slot_map the texture branch keeps priority and words 1..3
  remain the guest descriptor metadata from the remap record.
- The write loop no longer indexes a fixed eight-word array for wider loads;
  it writes texture metadata only, so a sixteen-dword table or heap load
  cannot read past the record.

Observed on the captured MS with the exact profile layout:
- before: native compute +0x614: unsupported mesh heap descriptor address
- now:    native compute +0x69c: unbound numeric SGPR s57

That refusal is the intended boundary: the image consumer and its V# fields
belong to the separate image-load change.

tests/native_direct_mesh_check.py adds the eight-dword heap fetch feeding a
typed load, a sixteen-dword table refusal, a sixteen-dword heap write-loop
control, the GPU-selected typed/image/numeric refusals, and the texture
fixture's masked and unmasked selectors. The slot-map form is the only one
that reads descriptor word 1 numerically.

Verified:
- cmake --build --preset release --target compile_dxil
- python -B tests/native_direct_mesh_check.py <compile_dxil.exe> <dxc dir>:
  exit 0, "mesh allocation, indexed outputs, group exchange and negative
  controls passed"
- ctest --preset release --no-tests=error -R '^native_direct': 2/2 passed

Refs R0Y00#3497
The slot 57 capture req_72e1909e13df6f66.m57 contains
  image_load v[19:21], v11, s[56:63] dmask:0x7 dim:SQ_RSRC_IMG_1D unorm
at +0x700, fed by the eight-dword resource-heap fetch at +0x614. This is a
complete guest V#, not a texture heap slot-map record, so the slot-map branch
refuses it.

- A mesh image branch handles the full-V# form when
  !layout.texture_heap_slot_map: image_load (op 0), dim 1D, dmask 0x7, UNORM,
  no LWE/TFE/R128/reserved bits, eight contiguous descriptor words sharing one
  fetch pc and a destination inside the VGPR range.
- The eight words stay symbolic. The fetch is identified by heap_fetches (a
  root-proven selector) or heap_descriptor_slots (a GPU-selected selector);
  no projected_numeric flag is needed.
- createHandleFromHeap(slot) is annotated Texture1D { 1, 1033 } and
  textureLoad.f32 reads mip 0 at the VGPR coordinate, writing the three
  integer channels.
- Four-channel loads, other dimensions, missing UNORM or an unmatched
  descriptor keep refusing.

Observed on the captured MS with the exact profile layout:
- before: native compute +0x700: unsupported mesh instruction or EXEC state: image_load
- now:    native compute +0x69c: unbound numeric SGPR s57

The capture reads descriptor word 1 numerically at +0x69c
(s_bfe_u32 s22, s57, 0x2001e) to build the image coordinate. After R0Y00#3754's
correction the words stay symbolic, which is the accurate refusal: this
branch needs a contract that supplies the real V# field bits before the
+0x700 image is reachable. The source-built fixtures use a constant
coordinate and cover the translation itself; the earlier +0x7c0 observation
belonged to the slot-materialising draft and no longer applies.

tests/native_direct_mesh_check.py adds mesh-image-full-descriptor (root
selector), mesh-image-full-descriptor-root/-gpu, the four-channel and 2D
controls, and keeps the symbolic descriptor-word refusals.

Verified:
- cmake --build --preset release --target compile_dxil
- python -B tests/native_direct_mesh_check.py <compile_dxil.exe> <dxc dir>:
  exit 0, "mesh allocation, indexed outputs, group exchange and negative
  controls passed"
- ctest --preset release --no-tests=error -R '^native_direct': 2/2 passed
- real capture: native compute +0x69c: unbound numeric SGPR s57

Refs R0Y00#3497
The slot 57 MS req_72e1909e13df6f66 reads words 1..3 of its V# numerically
(s_bfe_u32 s22,s57,0x2001e ; s_and_b32 s26,s58,0x3fff ;
s_bfe_u32 s27,s59,0x4000c). R0Y00#3754/R0Y00#3758 keep those words symbolic, which is
correct but leaves the real capture at +0x69c.

- The mesh frontend binds a 1024-entry, eight-dword guest descriptor table as
  a root SRV in space 2. Numeric reads of indexed_descriptor words from an
  eight-dword fetch lower to a bounds-checked bufferLoad; other numeric reads
  still refuse.
- The runtime builds the table from the title view heap: a raw V# is copied,
  a token SRV is projected to the dimensional V# fields, and a missing or
  non-SRV entry stays zero.
- The mesh57 revision is bumped to 5 because the profile now carries the
  extra root binding.

Observed on the real MS: +0x69c/+0x6a8/+0x6b4 pass; the next refusal is
+0x7c0: unproven mesh entry register 287 (f16), as expected without R0Y00#3762.

The runtime root-signature/binding path is not yet proven by a fixture; the
PR is a draft for that follow-up.

Tests: native_direct 2/2, native_direct_mesh_check pass.

Refs R0Y00#3497
The slot 57 shader already asked for t<guest>,space2, but the runtime did not
store the host root parameter and the draw path rebuilt the table without a
validated binding. The host root is now a versioned 1.1 signature with the
guest constants, the optional read table, and a root SRV in space 2. The
parameter is stored in IndirectGraphicsPipeline and checked at draw.

The numeric fetch also keeps the fetch's constant byte index so a fixed
s_load's destination symbols, whose offsets include that base, still resolve
to words 1..7. A token SRV projects its guest base address into words 4/5.

Adds a source-built runtime fixture with a Texture1D SRV in the title view
heap. Red exports word 1 and green is 64 only when word 5 is nonzero.

Build: compile_dxil, d3d12_xs_shim, startup_indirect_draw_indexed.
Tests: native_direct_mesh_check passes. Real MS still refuses at
+0x7c0: unproven mesh entry register 287. The new runtime case remains red:
pixel (2,2) expected 0xc04000ff, got 0x000000ff; the draw is forwarded and
the table has the expected V# words on the CPU side, so the remaining issue
is the root SRV read at draw.

Refs R0Y00#3497
The root-SRV form validated but read zero on WARP. Bind the 1024-entry
table as one R32_UINT SRV of 8192 dwords in a descriptor table at t0,space2
instead. The host root keeps the guest constants and the optional read table,
and the guest root parameter remains the validation key.

A descriptor-word-only stage no longer declares the resource-heap root flag:
the V# fetch is consumed to select the table entry and the module has no
createHandleFromHeap, so DXIL validation refused the unused flag.

The runtime fixture creates the Texture1D through slot 133 at guest address
0x100000000 so word 5 is nonzero and green proves it.

Build: compile_dxil, d3d12_xs_shim, startup_indirect_draw_indexed.
Tests: native_direct 2/2 passes. Real MS still refuses at +0x7c0: unproven
mesh entry register 287. The runtime descriptor-words case still reads zero:
pixel (2,2) expected 0xc04000ff, got 0x000000ff, with dispatchmesh 1.

Refs R0Y00#3497
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.

1 participant