Skip to content

shader: translate mesh image_load through a full table descriptor - #3758

Open
lambirou wants to merge 2 commits into
R0Y00:mainfrom
lambirou:codex/mesh-image-load
Open

lambirou wants to merge 2 commits into
R0Y00:mainfrom
lambirou:codex/mesh-image-load

Conversation

@lambirou

@lambirou lambirou commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

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. That is a complete guest V#, not a texture heap slot-map record, so the slot-map branch refuses it.

This adds a mesh image branch for the full-V# form when !layout.texture_heap_slot_map: op 0, 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 words stay symbolic; the fetch is identified by heap_fetches or heap_descriptor_slots. createHandleFromHeap(slot) is annotated Texture1D { 1, 1033 } and textureLoad.f32 reads mip 0 at the VGPR coordinate. Four channels, other dimensions, missing UNORM and an overwritten word keep refusing.

Boundary. On the real capture, #3754's corrected head refuses at +0x69c: unbound numeric SGPR s57: s_bfe_u32 s22, s57, 0x2001e reads descriptor word 1 to build the image coordinate. The full-V# branch is covered by source-built fixtures with a constant coordinate; reaching +0x700 needs a contract that supplies the real V# field bits. The earlier +0x7c0 observation belonged to the slot-materialising draft and no longer applies.

Tests: mesh-image-full-descriptor (root selector), mesh-image-full-descriptor-root, -gpu, mesh-image-four-channel-without-map and mesh-image-unsupported-dimension; the descriptor-word reads still refuse as unbound numeric SGPR s33 / s37.

Validation on b4c5697a (based on #3754 6102db88):

  • cmake --build --preset release --target compile_dxil
  • python -B tests/native_direct_mesh_check.py ... — pass.
  • ctest --preset release --no-tests=error -R '^native_direct' — 2/2 passed.
  • Real capture: +0x69c: unbound numeric SGPR s57.

Refs #3497

R0Y00 commented Dec 1, 2026

Copy link
Copy Markdown
Owner

The current head's Windows build/test job failed in Configure, build and run PC tests, while both Linux jobs passed. This also depends on #3754. Please refresh the branch after the descriptor-load change is resolved and rerun Windows CI.

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
@lambirou

lambirou commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto #3754's corrected head 6102db88.

The descriptor words stay symbolic: #3754 records only bytes >> 5 for an op 3 fetch, and this branch identifies the fetch through heap_fetches (root-proven) or heap_descriptor_slots (GPU-selected). The image branch no longer requires projected_numeric, and the eight-word equality check keeps offsets 0, 4, ..., 28 without inventing field bits.

The dmask-0x7 root and GPU-selected forms now lower (mesh-image-full-descriptor, -root, -gpu); four channels, 2D and an overwritten word keep refusing. Descriptor-word reads still refuse as unbound numeric SGPR s33 / s37.

Validation on 92b0a153:

  • python -B tests/native_direct_mesh_check.py ... — pass.
  • ctest --preset release --no-tests=error -R '^native_direct' — 2/2 passed.
  • The head is based on 6102db88, not the old 4dd116c4.

The Windows job should now run against the corrected stack; I'll check the result.

AI-assisted.

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

R0Y00 commented Dec 2, 2026

Copy link
Copy Markdown
Owner

Current CI is green. Before merging this stack, please add a runtime binding control for the unmapped createHandleFromHeap path. The GPU-derived selector path records no mesh_heap_reads; slot 57's direct-heap path currently requires a nonempty guard list. The root-derived path records a slot guard, but the fixture needs to establish that the runtime supplies a compatible Texture1D descriptor rather than only validating offline DXIL.

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.

2 participants