Skip to content

shader, runtime: lower and bind mesh format loads from a descriptor-table V# (Part of #3703) - #3770

Merged
R0Y00 merged 4 commits into
R0Y00:mainfrom
mumba17:shader/mesh-table-format-load
Dec 2, 2026
Merged

R0Y00 merged 4 commits into
R0Y00:mainfrom
mumba17:shader/mesh-table-format-load

Conversation

@mumba17

@mumba17 mumba17 commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Part of #3703. Fixes the wall formatted mesh load lacks an R32_UINT resource heap contract (108 programs in my census on the current stack).

Shape

All 108 are buffer_load_format_x vN, vM, s[N:N+3], 0 idxen whose V# is read whole with s_load_dwordx4 from a bound descriptor table. The mesh frontend only accepted the resource-heap form.

Change

Translator (gfx1013_direct_mesh.inl): a format load whose V# is a table descriptor goes through the shared typed-buffer SRV path (alu.memory), the same one vertex and pixel shaders use. It records a typed_buffer_srv binding and checks the table binding and all four descriptor words. The heap route is unchanged.

Runtime (native_mesh86.inl): without this half, the new binding would compile and then fail at draw setup with unsupported native Mesh86 SRV shape.

  • Slot 86 now accepts a one-dword typed_buffer_srv, from a descriptor table only.
  • It binds it as an R32_UINT buffer view through the same checks a typed heap slot already gets. I moved those checks into one lambda shared by both routes; the heap route behaves as before. A view token must be an R32_UINT buffer view; a raw V# must have the identity component map and a 4-byte stride.
  • A raw V# on either route must address elements linearly: SWIZZLE_ENABLE (word 1 bit 31) and ADD_TID_ENABLE (word 3 bit 23) clear.
  • A raw table V# must also name a 32-bit data format (32_UINT, 32_SINT or 32_FLOAT, word 3 bits 18:12), so the view returns the dword the guest format load would. Anything else is refused at bind time.

The V# word checks live in the new src/startup_stubs/mesh86_typed_vsharp.h.

Tests

  • tests/native_direct_mesh_check.py:
    • typed-table (full EXEC) and typed-table-lane-skip (inactive lanes keep the old value through select and phi).
    • Controls: typed-table-lane-skip-undef, typed-table-xy (multi-channel still refused) and typed-table-no-skip (narrowed EXEC without EXECZ still refused).
  • @timbot103's typed-table-in-skip control from shader: lower buffer_load_format_x in mesh EXECZ skips and element zero (Part of #3703) #3720 refused this route under heap tokens. It now checks that the route compiles without a token view (requires_heap_tokens absent). The other shader: lower buffer_load_format_x in mesh EXECZ skips and element zero (Part of #3703) #3720 controls are unchanged.
  • tests/mesh86_typed_vsharp_check.cpp with tests/cmake/mesh86_typed_vsharp.cmake:
    • five cases: the component map, the three 32-bit formats, other formats, linear addressing, and the two word-3 values the title synthesizes for its root SRVs (0x11014fac, 0x31016fac);
    • four WILL_FAIL header mutations: a widened format range, a dropped map check, and a dropped swizzle or thread-ID check.
    • The pr preset filter now includes mesh86_typed_vsharp_[a-z_]+, so CI runs them.
  • Removing the translator route fails typed-table with the old refusal.

Validation (Windows 11, MSVC, Windows SDK 10.0.26100)

@lambirou, this touches native_mesh86.inl: the view-kind check in the root builder, a new typed_buffer_srv branch in the bind loop, and the shared typed check. Happy to rebase onto your open changes there.

AI-assisted.

🤖 Generated with Claude Code

…able V#

The mesh frontend accepted buffer_load_format_x only from a resource heap
slot. Skinned slot 86 programs read the V# whole from a bound descriptor
table instead and were refused with "formatted mesh load lacks an
R32_UINT resource heap contract".

Translator: a format load whose V# comes from a bound table goes through
the shared typed-buffer SRV path, as in vertex and pixel shaders, which
checks the table binding and all four descriptor words. The R0Y00#3720
control that kept this route refused under heap tokens now checks that
it compiles without a token view.

Runtime: slot 86 accepts a one-dword typed_buffer_srv from a descriptor
table and binds it as an R32_UINT buffer view through the same checks as
a typed heap slot (R32_UINT token view, or a raw V# with the identity
component map and a 4-byte stride). A raw table V# must also name a
32-bit format (32_UINT, 32_SINT or 32_FLOAT), so the view returns the
dword the guest load would. Those word 3 checks live in
mesh86_typed_vsharp.h with unit tests and two mutation controls.

Part of R0Y00#3703.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@lukaslw-lab lukaslw-lab left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 8f769c7e by reading the diff; not built or run.

Verdict: approve. The table route lowers to the same U32 typed buffer the heap route uses, and the runtime binds an R32_UINT view only for identity-mapped 32-bit formats with a 4-byte stride. No MUST.

  • SHOULD The raw-V# checks don't cover the two fields that change addressing:

    • ADD_TID_ENABLE (word 3 bit 23);
    • SWIZZLE_ENABLE (word 1 bit 31).

    typed_dword checks word 3's component map and format. indirect_table_buffer (d3d12_draw.inl:2834) then reads only the address, stride and record count. A table V# with either bit set passes and binds a linear R32_UINT view, so lanes read the wrong elements. The heap route had the same gap before this PR, but the description promises fail-closed for the table route. A check in mesh86_typed_vsharp.h (bit 23 clear, word 1 bit 31 clear) would cover both routes. The title's own word 3 values, 0x11014fac and 0x31016fac, have neither bit set, so nothing seen today changes.

  • Checked, no finding:

    • Result type. The table binding is declared Buffer<uint4> (component type 5) and read with bufferLoad.i32, so the R32_UINT view matches. 32_FLOAT and 32_SINT data return the same dword bits.
    • Word 3 constants. Identity DST_SEL 4/5/6/7 packs to 0xfac, and BUF_FMT 20–22 in bits 18:12 are the three 32-bit formats.
    • The refactor. The heap route's checks move unchanged into typed_dword. Only the table route adds the format check.
    • Root and bind time. The root builder requires a descriptor-table source for typed_buffer_srv. The bind loop reads the record from that table and refuses outside it.
    • Translator. Only idxen or no-index forms with zero offset reach the new branch, and partial writes are marked under a lane skip, as in the existing buffer branches.

Tests:

  • typed-table and -lane-skip reach the new branch.
  • -lane-skip-undef, -xy and -no-skip pin the refusals.
  • The header unit and mutation tests cover the word 3 checks.
  • No test reaches the bind loop: the description says so.

CI ran native_direct_mesh (pr preset filter), but not mesh86_typed_vsharp_*, which the filter doesn't match. Those rest on the author's local 216/216. The branch merges cleanly with main 158ef794.

A raw V# with SWIZZLE_ENABLE (word 1 bit 31) or ADD_TID_ENABLE (word 3
bit 23) set addresses elements differently from the linear R32_UINT view
slot 86 binds, so refuse it on both the heap and the table route. Add a
linear_addressing unit case with two header mutation controls, and run
the mesh86_typed_vsharp tests in the pr preset.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mumba17

mumba17 commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

@lukaslw-lab Thanks. Agreed: the PR promises fail-closed, so a non-linear V# should not bind.

Fixed in b445b8cd:

  • mesh86_typed_linear(word1, word3) in mesh86_typed_vsharp.h requires SWIZZLE_ENABLE (word 1 bit 31) and ADD_TID_ENABLE (word 3 bit 23) clear.
  • typed_dword applies it to every raw V#, on both the heap and the table route, and refuses with native Mesh86 typed buffer descriptor is swizzled or adds the thread ID. View tokens are unchanged.

Tests:

  • New linear_addressing case: it accepts a stride-4 V# and ignores the other bits, and refuses either bit alone. guest_words now also checks that the title's word 3 values add no thread ID.
  • Two new WILL_FAIL header mutations: any_swizzle and any_tid, one for each dropped check.
  • The pr preset filter now includes mesh86_typed_vsharp_[a-z_]+, so CI runs the unit and mutation tests too.

ctest -R "native_direct_mesh|mesh": 219/219 (210 existing, 9 unit and mutation tests; the two mesh_two_exits hardware tests skip as usual). d3d12_xs.dll builds. The translator is unchanged, so the census stays at 845.

AI-assisted.

The pr test filter runs mesh86_typed_vsharp_*, but the pr build preset
only builds its listed targets, so CI reported the tests as not run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@lukaslw-lab lukaslw-lab left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 49ec2911 (delta since 8f769c7e: b445b8cd, 49ec2911) by reading the diff; not built or run.

Verdict: approve. Both open points from the last pass are fixed; no new findings.

  • Raw V# addressing: mesh86_typed_linear refuses SWIZZLE_ENABLE (word 1 bit 31) and ADD_TID_ENABLE (word 3 bit 23), the same positions tools/startup/gfx2hlsl.py:179-184 decodes. It sits in typed_dword under words[0] != view_token_magic, so it covers the heap-slot and the table path alike (native_mesh86.inl:413). CACHE_SWIZZLE (bit 30) and INDEX_STRIDE stay unchecked; neither changes which element a linear, non-swizzled load reads, so that is fine.
  • linear_addressing pins both refusals and checks that all other word 1 / word 3 bits are ignored. guest_words adds that the two guest word 3 values have ADD_TID clear.
  • Mutants any_swizzle / any_tid: each anchor occurs once in the header, the FATAL_ERROR guard catches a lost anchor, and each one reaches a refusal in linear_addressing (WILL_FAIL).
  • No MUST, SHOULD or NIT.

Tests: the five mesh86_typed_vsharp_* cases and four _mut controls are now in the pr build targets and the test regex, so the Windows job will run them. That job is still pending at this head.

R0Y00 commented Dec 2, 2026

Copy link
Copy Markdown
Owner

The latest reviewed head 49ec2911 has green CI and approval, but GitHub reports a merge conflict. Please rebase while retaining the indexed raw SRV path from #3807 and the EXEC restore fixes from #3765, and rerun the typed V# controls and native mesh fixtures.

R0Y00 commented Dec 2, 2026

Copy link
Copy Markdown
Owner

Pushed merge resolution 89e6dc03 to this PR's maintainer-editable branch, preserving the original commits. The resolved root check retains both the typed table view and #3807's indexed raw view, including its stride checks. git merge-tree --write-tree review-latest HEAD succeeds against main 2b870868. The isolated MSVC /O2 fixture passed all five V# cases. Integrated CI on the new head is pending.

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.

3 participants