shader: bound OFFEN-only raw loads in the mesh frontend (Part of #3703) #3721
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3721"
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 timbot103 on 2026-12-01T10:53:05Z.
Refs #3703.
Summary
Lowers
offen-only (idxenclear) raw buffer loads (buffer_load_dword,dwordx2,dwordx3,dwordx4) in the C++ mesh frontend (src/gfx1013_direct_mesh.inl, sharing the root-descriptor predicate helper withsrc/gfx1013_direct_compute.inl):raw_vector_srv), rewritten byte windows (byte_window_srv), and the three existing unbounded root-SRV descriptor forms (root_buffer_srv), all of whichnative_mesh86.inlalready binds as bounded desktop raw SRVs.soffsetwith unsigned 32-bit wrap checks, aligns down to 4 bytes, queriesgetDimensionsfor the raw SRV byte length, and checks bounds per DWORD so reads straddling the view end keep each in-range DWORD and zero-fill out-of-range components.partial_writesinside openEXECZskips (including whenvaddraliases a destination VGPR).idxenon root SRVs, literal/symbolicsoffset, LDS, TFE, and VGPR overflow strictly refused.Verification
Windows 11 (26200), MSVC 19.44, Ninja, Windows SDK 10.0.26100. Source-built tests only; added 42 positive cases (
dword..dwordx4, all 5 descriptor variants, zero & unaligned immediate offsets, SGPRsoffsetinside a lane skip) and 10 refusal controls intests/native_direct_mesh_check.py.devpreset):ctest --preset dev --no-tests=error -R '^native_direct_|^startup_mesh57_real_shape$' -V-> 3/3 passed (native_direct_container,native_direct_mesh,startup_mesh57_real_shape)releasepreset):ctest --preset release --no-tests=error -R '^native_direct_|^startup_mesh57_real_shape$' -V-> 3/3 passedgit diff --check HEAD^ HEADclean.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-01T19:03:05Z.
Review: APPROVED
Reviewed
e443d01aby reading the diff; not built or run.Verdict: approve. The
offen-only load computes the guest byte address with wrap guards, then checks each DWORD against the view'sgetDimensionslength. Every descriptor it accepts is one that Mesh86 already binds as a sized table view. No MUST.raw_root_descriptorrefactor. It accepts exactly the three forms the compute path accepted before: stride-one high with0x11014facor0x31016fac, and root-address high with0x31016fac. It still requiresNUM_RECORDS = 0xffffffffand no address offset, so the compute path is unchanged.soffsetnever reachmesh_offen_raw_load. The graphics branch of the raw-load decoder refuses them first (gfx1013_compute_native.cpp:281). Thelds,tfeandliteral-soffsetcontrols pin that.getDimensionson a root SRV.native_mesh86.inl:70createsroot_buffer_srvas a table view (root SRV/CBV source, zero byte offset), not as a root descriptor, so the dimension query is defined. The4-byte span (compute asks4*n) is covered by the per-DWORD check, as the comment says.available = bytes - alignedis taken only wherealigned < bytes, andavailable >= 4*(j+1)cannot wrap. An invalid address loads atbytes, which reads 0, and every component is then zeroed by its own predicate.0x0c/0x0d/0x0f/0x0emap to 1/2/3/4 DWORDs throughcounts[op & 3], anddst + count > 256refuses overflow.partial_writes. The*-scalar-execcases check themesh_emptyphi, includingvaddraliasingv1.Tests: 40 positives across five descriptor forms, four widths and two immediate offsets each pin the DXIL bound sequence (
and -4,ult,sub, per-componentugeplusselect 0). The two lane-skip cases add a numeric SGPRsoffset. The 10 controls cover the descriptor and modifier refusals.native_direct_meshis in theprpreset filter, and CI ran it green at this head.