shader: extend mesh heap and scalar memory proofs (Part of #3703) #3835
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3835"
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-02T08:10:12Z.
Extends mesh resource-heap root-constant provenance beyond #3719 (
"mesh heap slot lacks masked root constant provenance", 544 programs) and lowers verified root-SRV / fixed-tables_load_dword*scalar memory forms ("mesh scalar memory needs a verified guest root mapping: s_load_dwordx4", 77 programs) insrc/gfx1013_direct_mesh.inl.Part of #3703. Refs #3641, #3719.
(Opened as Draft per #3514 until an active review slot frees.)
Summary
src/gfx1013_direct_mesh.inl:RootBits(((root >> shift) & mask) + base) throughv_bfe_u32/s_bfe_u32,v_and_b32/s_and_b32(both operand orders),v_lshrrev_b32/s_lshr_b32,v_lshlrev_b32/s_lshl_b32,v_add_nc_u32/s_add_{u32,i32},v_or_b32/s_or_b32(disjoint bit add),s_mul_i32,v_readfirstlane_b32(at full EXEC),s_cselect_b32/v_cndmask_b32(identical proofs on both inputs), and CFGphijoins (matching proofs on both edges). Allows 4- and 8-dword typed heap fetches to fold aligned immediate byte offsets intoMeshHeapRead::base.s_load_dword*from verifiedSymbol::Type::root_addresspairs (with matching high half) at immediate or proven constant SGPR offsets, ands_load_dwordx4from declared root descriptor tables at aligned constant SGPR offsets validated against the table's descriptor ranges. Keeps GPU buffer words ineligible for CPU root-constant selectors and refuses unproven/unaligned/out-of-range offsets.tests/native_mesh_heap_provenance_smem_check.py+tests/cmake/native_mesh_heap_provenance_smem.cmake:native_mesh_heap_provenance_smem_ir(runs inprCTest preset): 18 accepted cases verified against selector reports and DXIL + 27 fail-closed refusal controls.Verification
Host: Windows 11 (
10.0.26200.9974), MSVC C++20/W4(zero warnings in edited lines). Baseorigin/mainf365f125.ctest --preset pr --no-tests=error -R "^native_mesh_heap_provenance_smem_ir$": 1/1 passed (18 positive + 27 refusals).dev) & Release (release): 3/3 passed in both configs (native_mesh_heap_provenance_smem_ir,native_direct_mesh,native_direct_container).tests/bidi_controls_check.py,tests/docs_links_check.py,git diff --check origin/main..HEAD: all clean.Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-02T08:13:02Z.
Review: APPROVED
Reviewed
5feae82d(draft) by reading the diff; not built or run.Verdict: approve. Each new
RootBitsstep keeps((root >> shift) & mask) + baseexact, and the new scalar loads go through the existing bounded root and table paths. No MUST.m86census onf365f125for the real gain on the 544 + 77. Clearing provenance can expose the next wall, andv_readfirstlane_b32now forwards a root-derived source as-is under full EXEC (gfx1013_direct_mesh.inl:2455), so the census would also show any changed refusal. Follow-up is fine.:235):v_lshrrev/v_lshlrevtake the shift fromsrc[0],v_bfe_u32its width fromsrc[2], and shift amounts use the low 5 bits.base. OR counts as ADD only with no base and no shared mask bits. ADD requires a masked selector, andadd_slot_base(:229) keepsmask + basewithin the slot range. A scaled value accepts only a 32-byte-aligned ADD or OR.s_cselect/v_cndmaskand phi joins carry a proof only when both inputs have identical bits, so the selected value equals either one. Proofs come only from entry constants: loaded words are never added.s_load_dword*(:1736): the high half must match, and the folded constant offset then reaches the shared root path, which refuses spans over 64 KB and passes the span toroot_buffer_handle. A fixed-tables_load_dwordx4needs a 32-byte-aligned slot inside a declared range, with APPEND offsets resolved in order (:1762).immediate >> 5slots to the selector and moves the symbolic word offsets back by the same bytes, so the descriptor words stay relative to the fetched record.Tests:
native_mesh_heap_provenance_smem_ir(18 cases, 27 refusals) is in theprfilter.Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-02T20:27:30Z.
Review: APPROVED
Re-review on
70d66873(rebased on5770f14e:vector_execanduniform_alu_sourcefrom main).Verdict: approve.
Census, same capture and method as before (6,685 distinct mesh programs), main
5770f14evs this head:Same as the earlier head. The range-diff against my reviewed head contains only main's renames. The heap-slot refusal is the first refusal of many programs here, but none of them moves.
Update: the first run was on a main that refused 257 programs early (my #3707, #3892; fixed by #3893). I reran main
5770f14eand this head, both with that fix: 0 moved, 0 lost, 0 gained. 544 programs stop first at the heap-slot refusal there, and none of them moves.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-02T23:04:55Z.
Merged
main(67862ee4) into this branch; the reviewed commit70d66873is unchanged.gfx1013_direct_mesh.inl. The resolution keeps this PR's root-proven slot displacements together with main's opaque GPU-selected texture descriptors.1095b0d4makes the Texture1D consumer apply the shift and displacement recorded in the manifest. A new IR control caught the mismatch.Tests, Windows 11 26200 with RTX 5080 and WARP. The mesh filter was
native_direct_mesh|native_direct_container|native_mesh_plus this PR's own tests. Every branch passed a full Debug build of every target, including the C++17native_compute_pack_refusal_check.accepted=1 refused=0). They also fail on a clean67862ee4, and every one of them passed withX2W_SYNC_MESH_REQUESTS=1.All six mesh PRs (#3832, #3835, #3838, #3842, #3843 and #3846) were also merged together onto
67862ee4. That combined tree passed 47/47 in Debug and 47/47 in Release, plus 8/8 under the PR preset. All 15 pairs merge cleanly.Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-02T23:59:42Z.
705d91abmakes this PR independent of #3833.#3833 allows DLC/GLC cache-policy bits on read-only scalar loads in the shared decoder, and mesh lowering uses that decoder. With both PRs merged, this PR's
root-glc-dlcrefusal control therefore compiled. Accepting those bits on a read-only load is correct, so the control, not the compiler, was out of date.The control now uses a reserved SMEM address bit, which is refused with or without #3833, so it still checks that unsupported addressing fails closed.
Tests on main
c42b7ce3, with and without #3833 merged:native_mesh_heap_provenance_smem_irpasses in Debug and Release.X2W_SYNC_MESH_REQUESTS=1.The RTX 5080 checks pass.
Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-03T01:14:47Z.
Marked Ready for review now that the previous batch (#3832, #3838, #3839, #3844, #3847) has merged. This keeps us within 5 non-draft PRs per #3514. The branch merges cleanly into current main, and CI is green at this head.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T01:47:57Z.
Review: APPROVED
Independently reviewed
705d91ab. At joins the selector survives only when its reaching root and every selector field agree. The byte displacement is folded into the selector once, and the encoded offset and table range are checked before publishing. Built compile_dxil on MSVC Debug and ran ctest --preset dev --no-tests=error -j 1 --output-on-failure -R "^(native_mesh_heap_provenance_smem_ir|native_direct_mesh)$": 2/2 passed. Removing the immediate alignment test made unaligned-heap-immediate translate and failed the fixture. The restored head passed again. This is compiler IR/selector verification.