shader, runtime: lower and bind mesh format loads from a descriptor-table V# (Part of #3703) #3770
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3770"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by mumba17 on 2026-12-01T17:50:46Z.
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 idxenwhose V# is read whole withs_load_dwordx4from 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 atyped_buffer_srvbinding 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 withunsupported native Mesh86 SRV shape.typed_buffer_srv, from a descriptor table only.SWIZZLE_ENABLE(word 1 bit 31) andADD_TID_ENABLE(word 3 bit 23) clear.32_UINT,32_SINTor32_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) andtyped-table-lane-skip(inactive lanes keep the old value throughselectandphi).typed-table-lane-skip-undef,typed-table-xy(multi-channel still refused) andtyped-table-no-skip(narrowed EXEC without EXECZ still refused).typed-table-in-skipcontrol from #3720 refused this route under heap tokens. It now checks that the route compiles without a token view (requires_heap_tokensabsent). The other #3720 controls are unchanged.tests/mesh86_typed_vsharp_check.cppwithtests/cmake/mesh86_typed_vsharp.cmake:0x11014fac,0x31016fac);WILL_FAILheader mutations: a widened format range, a dropped map check, and a dropped swizzle or thread-ID check.prpreset filter now includesmesh86_typed_vsharp_[a-z_]+, so CI runs them.typed-tablewith the old refusal.Validation (Windows 11, MSVC, Windows SDK 10.0.26100)
ctest --test-dir out/build/dev -R "native_direct_mesh|mesh": 219/219. That is the existing 210 plus the 9 new unit and mutation tests; the twomesh_two_exitshardware tests skip as usual.d3d12_xs.dllbuilds with the runtime change.X2W_D3D12_TRACE_DIRECT_MESHwould show whether the title's table V#s pass.main+ #3708 + #3709 + #3710 + #3729 + #3760 + #3765 + this: 845 of 1,569 translate, up from 837. 8 gained, none lost.mesh SAVEEXEC then arm depends on EXEC, which rises from 133 to 215 and is partly covered by #3722.@lambirou, this touches
native_mesh86.inl: the view-kind check in the root builder, a newtyped_buffer_srvbranch in the bind loop, and the shared typed check. Happy to rebase onto your open changes there.AI-assisted.
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-01T20:09:24Z.
Review: APPROVED
Reviewed
8f769c7eby 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_dwordchecks 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 inmesh86_typed_vsharp.h(bit 23 clear, word 1 bit 31 clear) would cover both routes. The title's own word 3 values,0x11014facand0x31016fac, have neither bit set, so nothing seen today changes.Checked, no finding:
Buffer<uint4>(component type 5) and read withbufferLoad.i32, so the R32_UINT view matches. 32_FLOAT and 32_SINT data return the same dword bits.DST_SEL4/5/6/7 packs to0xfac, andBUF_FMT20–22 in bits 18:12 are the three 32-bit formats.typed_dword. Only the table route adds the format check.typed_buffer_srv. The bind loop reads the record from that table and refuses outside it.Tests:
typed-tableand-lane-skipreach the new branch.-lane-skip-undef,-xyand-no-skippin the refusals.CI ran
native_direct_mesh(pr preset filter), but notmesh86_typed_vsharp_*, which the filter doesn't match. Those rest on the author's local 216/216. The branch merges cleanly withmain158ef794.Imported from R0Y00/Xbox2Windows. Originally posted by mumba17 on 2026-12-01T20:23:27Z.
@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)inmesh86_typed_vsharp.hrequiresSWIZZLE_ENABLE(word 1 bit 31) andADD_TID_ENABLE(word 3 bit 23) clear.typed_dwordapplies it to every raw V#, on both the heap and the table route, and refuses withnative Mesh86 typed buffer descriptor is swizzled or adds the thread ID. View tokens are unchanged.Tests:
linear_addressingcase: it accepts a stride-4 V# and ignores the other bits, and refuses either bit alone.guest_wordsnow also checks that the title's word 3 values add no thread ID.WILL_FAILheader mutations:any_swizzleandany_tid, one for each dropped check.prpreset filter now includesmesh86_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 twomesh_two_exitshardware tests skip as usual).d3d12_xs.dllbuilds. The translator is unchanged, so the census stays at 845.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-01T20:36:49Z.
Review: APPROVED
Reviewed
49ec2911(delta since8f769c7e:b445b8cd,49ec2911) by reading the diff; not built or run.Verdict: approve. Both open points from the last pass are fixed; no new findings.
mesh86_typed_linearrefuses SWIZZLE_ENABLE (word 1 bit 31) and ADD_TID_ENABLE (word 3 bit 23), the same positionstools/startup/gfx2hlsl.py:179-184decodes. It sits intyped_dwordunderwords[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_addressingpins both refusals and checks that all other word 1 / word 3 bits are ignored.guest_wordsadds that the two guest word 3 values have ADD_TID clear.any_swizzle/any_tid: each anchor occurs once in the header, theFATAL_ERRORguard catches a lost anchor, and each one reaches a refusal inlinear_addressing(WILL_FAIL).Tests: the five
mesh86_typed_vsharp_*cases and four_mutcontrols are now in theprbuild targets and the test regex, so the Windows job will run them. That job is still pending at this head.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T02:10:00Z.
The latest reviewed head
49ec2911has 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.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T02:54:43Z.
Pushed merge resolution
89e6dc03to 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 HEADsucceeds against main2b870868. The isolated MSVC/O2fixture passed all five V# cases. Integrated CI on the new head is pending.