shader: accept the slot 57 heap descriptor load form #3754
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3754"
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 lambirou on 2026-12-01T16:00:53Z.
The fixed slot 57 mesh shader for
req_72e1909e13df6f66loads a 32-bytetexture descriptor with
s_load_dwordx8 s[56:63], s[12:13], s22(SMEM op 3)from a resource-heap table and then reads
s57,s58ands59as numericdescriptor fields. The mesh frontend only accepted the four-dword op 2 form, so
the request stopped at
+0x614: unsupported mesh heap descriptor address;after op 3 alone, it stopped at
+0x69c: unbound numeric SGPR s57because theeight words stayed indexed descriptors.
The heap descriptor branch now accepts op 3 with the same checks (zero
immediate offset, constant high word, destination bounds, proven 32-byte
selector). A GPU-proven selector materializes all eight words as the heap slot
(
bytes >> 5) withprojected_numeric, so a guest numeric read sees adefined value; the texture slot map keeps priority and keeps words 1..3 as the
guest descriptor metadata. Consumers still require
heap_fetches,token_fetchesortexture_heap_fetches.Validation (Windows, Release):
+0x700: unsupported mesh instruction or EXEC state: image_load; the nextchain is the texture heap slot map, not the descriptor address.
python -B tests/native_direct_mesh_check.py out\\build\\release\\compile_dxil.exe "<DXC dir>"— pass, including the x8 fetch, x16 refusal and unaligned-offset control.
ctest --preset release --no-tests=error -R '^native_direct'— 2/2 pass.ctest --preset release --no-tests=error -R '^native_fixed_mesh57_warp$'— pass.
Refs #3497
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-01T17:05:16Z.
Review blocker in
lower_mesh: the newdescriptor_words[j]read runs for all SMEM table-load paths withi.op < 8.memory_count(i)is1u << (i.op & 7), so a valid non-global 16-dword table load (op == 4) can read beyond the eight-element array. The new x16 refusal covers only the validated global heap branch. Please bound the lookup bydescriptor_words.size()and add a source-built non-global wide table control. Also please identify which descriptor bits are actually consumed numerically in the unmapped path so the synthetic slot value does not silently stand in for unrelated guest metadata.Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-12-01T18:09:45Z.
Review: COMMENTED
Accepting
s_load_dwordx8(op 3) on the validated heap branch with the same address checks looks right, and the x16 and unaligned refusals are useful. The problem is the second half of the change: it turns the descriptor words into numeric values that the guest never wrote.MUST: the eight words get a made-up numeric value (
src/gfx1013_direct_mesh.inl:1475-1485,1505)For every op 3 fetch on this branch, whether the selector comes from the root or from the GPU, all eight destination words are written as
bytes >> 5and markedprojected_numeric.require_numeric(src/gfx1013_compute_native.cpp:1382-1384) checks onlySymbol::numeric(), so any later numeric read of s[dst+0..7] now compiles to the heap slot index. On hardware these words hold the image base address, width/height, mip and format fields, and words 4..7 hold depth/pitch/array state. No mapping supplies those values here. The slot-map branch (:1424-1449) is the only place on main that setsprojected_numericon heap words, and it sets it only on words 1..3, which it loads from the remap record. The pixel/compute heap path keeps the slot as the register's identity, butnumeric()stays false there ("Numeric consumption still requires real bits",src/gfx1013_compute_native.cpp:730-731). So the code comment's and doc's "as the pixel heap path does" does not match the code on main.This is the same concern as the last point of the maintainer's comment above. The first option below also removes
descriptor_words, and with it the out-of-bounds read reported there.In the slot 57 MS this is hidden only because the
image_loadat+0x700still refuses. A shader that uses s57..s59 (or any of words 0..7) for an address, a bound or a branch, without reaching a refusing consumer, would now produce valid DXIL with wrong values instead of refusing atunbound numeric SGPR. Two options:+0x69c: unbound numeric SGPR s57. That refusal is accurate: the next requirement is the slot map either way.MUST: no fixture covers the new GPU-selected branch (
src/gfx1013_direct_mesh.inl:1468-1472,tests/native_direct_mesh_check.py:728)The real MS takes
i.op==3 && heap_entry_offsets.count(bytes)withheap_tokensoff. No test reaches that branch:typed-heap-descriptor-x8(:659) usestyped[:5], a masked root selector, so it recordsheap_fetches.typed-heap-descriptor-unproven(:664) shifts by 4, so it never entersheap_entry_offsets.mesh-texture-heap-without-mapwould reach this branch through its former unmaskeds21 << 5. The new mask at:728moves it onto the root branch.As a result, deleting lines 1468-1472 or changing it to accept any offset would probably still pass. Please add GPU-selected op 3 cases in the style of
token-no-contract(gpu_layout, selector fromtable 16 1, noheap_tokens):buffer_load_formatthrough the eight words must still refuse withformatted mesh load lacks an R32_UINT resource heap contract.image_loadmust still refuse without the slot map.s_bfe_u32on word 1 and on word 5 feeding an export (assuming the first finding is fixed).Keep one unmasked texture fixture so the old path stays covered.
SHOULD: alignment proof and scope of the opaque branch (
:1468)heap_entry_offsetsgets an entry from anys_lshl_b32by an immediate of 5 or more (:2070-2071), so it does prove that the offset is a multiple of 32. The branch records nothing: noheap_fetches, notoken_fetches, nomesh_heap_reads. Its only effect is to let the destination words exist. That holds only while no consumer accepts anindexed_descriptorwithout a fetch record. Please say this in the comment at:1469-1471, so that a later consumer change cannot pick up these words by accident. As written, the comment says the words feed only a descriptor consumer, and the numeric marking makes that untrue.Note: interaction with #3712
#3712 changes
lower_meshnear line 1295 and the test file near line 439. Those are different hunks from this PR, so I expect no textual conflict. Its new image path requiresSymbol::Type::descriptor(table words). Heap words here areindexed_descriptor, somesh-texture-heap-without-mapshould keep itsunsupported mesh instruction or EXEC state: image_loadrefusal after both PRs merge. Whichever PR merges second should rerunnative_direct_meshon the combined tree.The doc (
docs/experiments/native-mesh-heap-descriptor.md:31-33) repeats the "as the pixel heap path already does" claim. It needs updating together with the first finding.Verdict: changes requested (the two MUST items).
Reviewed
4dd116c42by reading the diff; not built or run.Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-12-01T22:36:16Z.
Thanks — both MUSTs are addressed in
6102db88.The eight words are no longer materialised. An op 3 fetch records only
bytes >> 5by its pc; the destination words stayindexed_descriptorwith noprojected_numericflag. A numeric read now keeps the accurate refusal (unbound numeric SGPR s33for word 1,s37for word 5). The slot-map branch is unchanged and still fills words 1..3 from the remap record.The write loop no longer indexes a fixed array: it writes only
texture_metadata, so a 16-dword load (op 4) cannot run past the eight-word record.mesh-table-wide-loadcovers a non-global table x16 andmesh-heap-wide-loadcovers a heap x16 that reaches the write loop.GPU-selected op 3 is now covered in the
gpu_layout/token-no-contractstyle:gpu-heap-descriptor-x8-typedrefusesformatted mesh load lacks an R32_UINT resource heap contract;gpu-heap-descriptor-x8-imagerefusesunsupported mesh instruction or EXEC state: image_load;gpu-heap-descriptor-word-1and-word-5refuseunbound numeric SGPR s33/s37.The texture fixture keeps both a masked and an unmasked selector; only the slot-map form reads descriptor word 1 numerically. The alignment/opaque comment now says the fetch records only the slot and adds no
heap_fetches,token_fetchesormesh_heap_readsentry.Mutation check: restoring
4dd116c4:src/gfx1013_direct_mesh.inlmakesmesh-descriptor-word-1fail.Validation on the pushed head:
python -B tests/native_direct_mesh_check.py ...— pass.ctest --preset release --no-tests=error -R '^native_direct'— 2/2 passed.git diff --checkclean.The image consumer is the separate #3758 stack; I'll rebase it to use the recorded slot and drop its
projected_numericrequirement. The observed refusal for this PR alone is+0x69c: unbound numeric SGPR s57, which is the intended boundary.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-12-02T07:02:31Z.
Review: COMMENTED
Re-review of
6102db88. Read the diff; not built or run.Both MUST items from my earlier review are addressed:
projected_numeric, anddescriptor_wordsis gone. The write loop now fills only words 1..3 fromtexture_metadata, which stays empty outside the slot-map branch. A numeric read of any of the eight words therefore still refuses atunbound numeric SGPR, and a 16-dword load can no longer index past the record (the maintainer's bounds point).mesh-descriptor-word-1/-word-5cover the root-selected case, and the doc no longer claims parity with the pixel heap path.gpu-heap-descriptor-x8-typed,-x8-image,-word-1and-word-5reachi.op==3 && heap_entry_offsets.count(bytes)withoutheap_tokens. Removing that branch would change all four refusals tomesh heap slot lacks masked root constant provenance. Accepting any offset would maketyped-heap-descriptor-unproventranslate. Both mutations are now caught.mesh-texture-heap-gpu-without-map/-gpu-slot-mapkeep the unmasked texture path covered.The SHOULD item is handled too. The comment at the opaque branch now says it adds no
heap_fetches,token_fetchesormesh_heap_readsentry.Two small points:
heap_descriptor_slots(src/gfx1013_direct_mesh.inl:100, written at:1482) is never read in this PR, so each accepted op 3 fetch emits an unusedlshr. That is harmless. If #3758 is the consumer, keeping it is fine; otherwise the map could be dropped until something reads it.src/gfx1013_direct_mesh.inlandtests/native_direct_mesh_check.py. Please rebase it, rerunnative_direct_meshandnative_direct_container, and check that the GPU-selected cases still produce the same refusals.I'll approve once the rebased head is up.
Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-12-02T14:47:13Z.
Review: COMMENTED
Re-reviewed
6102db88after the two MUST fixes.Verdict: approve the code; rebase required before merge. The op-3 heap branch no longer sets
projected_numericand no longer fills descriptor words with the slot index, so a numeric read still refuses atunbound numeric SGPR. The GPU-selected cases now cover the typed/image and word reads, and the opaque branch comment states that it records no fetch.heap_descriptor_slotsis written but only read by the later #3758 consumer; keeping it is fine, but a comment at the write would explain why it is not dead.descriptor_words.src/gfx1013_direct_mesh.inlandtests/native_direct_mesh_check.py; rebase and rerunnative_direct_meshandnative_direct_containerbefore merge.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T15:40:38Z.
Review: APPROVED
Reviewed
f0bc8402on updated main. The recognized heap form preserves symbolic descriptor identity and still refuses a numeric read of an unbound word. The source-built controls exercise the root and GPU-selected forms, plus the malformed or wider cases. Independent Windows/MSVC Debugctest --preset dev --no-tests=error -j 1 -R '^native_direct_mesh$' --output-on-failurepassed 1/1.