Repository navigation
shader, runtime: lower and bind mesh format loads from a descriptor-table V# (Part of #3703) - #3770
Conversation
…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
left a comment
There was a problem hiding this comment.
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_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:
- Result type. The table binding is declared
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. - Word 3 constants. Identity
DST_SEL4/5/6/7 packs to0xfac, andBUF_FMT20–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.
- Result type. The table binding is declared
Tests:
typed-tableand-lane-skipreach the new branch.-lane-skip-undef,-xyand-no-skippin 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>
|
@lukaslw-lab Thanks. Agreed: the PR promises fail-closed, so a non-linear V# should not bind. Fixed in
Tests:
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
left a comment
There was a problem hiding this comment.
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_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.- Mutants
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). - 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.
|
Pushed merge resolution |
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 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_tokensabsent). 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.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.s_bitset1_b32, then stop at a scalar loop #3703) onmain+ shader: lower s_not_b32, s_brev_b32 and s_bfe_i32 in the mesh frontend #3708 + shader: lower v_rcp_iflag_f32 and v_ashrrev_i32 in the mesh frontend #3709 + shader: keep a mesh lane limit across a nested CMPX skip that closes at the same restore (Part of #3703) #3710 + shader: lower v_cmpx_lg_f32, v_cmpx_gt_f32 and per-lane v_cmpx_gt_u32 in the mesh frontend (Part of #3703) #3729 + shader: carry exact mesh lanes through nested CMPX skips to an EXEC restore (Part of #3703) #3760 + shader: merge mesh writes under one CMPX inside a lane skip and restore the guard (Part of #3703) #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 shader: lower nested mesh SAVEEXEC regions (Part of #3703) #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