Repository navigation
Conversation
|
Review blocker in |
Leyukaka
left a comment
There was a problem hiding this comment.
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 >> 5 and marked projected_numeric. require_numeric (src/gfx1013_compute_native.cpp:1382-1384) checks only Symbol::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 sets projected_numeric on 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, but numeric() 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_load at +0x700 still 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 at unbound numeric SGPR. Two options:
- Accept op 3 but leave the words unmaterialised, so the refusal stays at
+0x69c: unbound numeric SGPR s57. That refusal is accurate: the next requirement is the slot map either way. - Or materialise them only when a contract supplies the actual field values.
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) with heap_tokens off. 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 from table 16 1, no heap_tokens):
- A
buffer_load_formatthrough the eight words must still refuse withformatted mesh load lacks an R32_UINT resource heap contract. - The
image_loadmust still refuse without the slot map. - A numeric read of a descriptor word must refuse, for example
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_offsets gets an entry from any s_lshl_b32 by an immediate of 5 or more (:2070-2071), so it does prove that the offset is a multiple of 32. The branch records nothing: no heap_fetches, no token_fetches, no mesh_heap_reads. Its only effect is to let the destination words exist. That holds only while no consumer accepts an indexed_descriptor without 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_mesh near 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 requires Symbol::Type::descriptor (table words). Heap words here are indexed_descriptor, so mesh-texture-heap-without-map should keep its unsupported mesh instruction or EXEC state: image_load refusal after both PRs merge. Whichever PR merges second should rerun native_direct_mesh on 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 4dd116c by reading the diff; not built or run.
The stable slot 57 profile 9482ea4411e1e03f reaches the mesh frontend with req_72e1909e13df6f66.m57 and refused at +0x614. The decoded instruction there is s_load_dwordx8 s[56:63], s[12:13], s22: SMEM op 3, immediate offset 0, an SGPR offset proven as a multiple of 32, and the base copied from heap SGPR 23 with a constant zero high word. It feeds image_load v[19:21], v11, s[56:63] at +0x700. - The mesh heap branch behind validate_uint_heap_reads accepted only op 2 (s_load_dwordx4); it now also accepts op 3 (s_load_dwordx8) with the same immediate-offset, high-word, destination-range and provenance rules. - A root-provided selector still records heap_fetches. A GPU-selected selector that is a proven multiple of 32 keeps the fetch opaque: it records the heap slot (bytes >> 5) by pc, but leaves all eight destination words symbolic. Their field bits are not available here, so a numeric read keeps refusing (unbound numeric SGPR s33 or s37) until a consumer supplies the fields. - With texture_heap_slot_map the texture branch keeps priority and words 1..3 remain the guest descriptor metadata from the remap record. - The write loop no longer indexes a fixed eight-word array for wider loads; it writes texture metadata only, so a sixteen-dword table or heap load cannot read past the record. Observed on the captured MS with the exact profile layout: - before: native compute +0x614: unsupported mesh heap descriptor address - now: native compute +0x69c: unbound numeric SGPR s57 That refusal is the intended boundary: the image consumer and its V# fields belong to the separate image-load change. tests/native_direct_mesh_check.py adds the eight-dword heap fetch feeding a typed load, a sixteen-dword table refusal, a sixteen-dword heap write-loop control, the GPU-selected typed/image/numeric refusals, and the texture fixture's masked and unmasked selectors. The slot-map form is the only one that reads descriptor word 1 numerically. Verified: - cmake --build --preset release --target compile_dxil - python -B tests/native_direct_mesh_check.py <compile_dxil.exe> <dxc dir>: exit 0, "mesh allocation, indexed outputs, group exchange and negative controls passed" - ctest --preset release --no-tests=error -R '^native_direct': 2/2 passed Refs R0Y00#3497
4dd116c to
6102db8
Compare
|
Thanks — both MUSTs are addressed in The eight words are no longer materialised. An op 3 fetch records only The write loop no longer indexes a fixed array: it writes only GPU-selected op 3 is now covered in the
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 Mutation check: restoring Validation on the pushed head:
The image consumer is the separate #3758 stack; I'll rebase it to use the recorded slot and drop its AI-assisted. |
The slot 57 capture req_72e1909e13df6f66.m57 contains
image_load v[19:21], v11, s[56:63] dmask:0x7 dim:SQ_RSRC_IMG_1D unorm
at +0x700, fed by the eight-dword resource-heap fetch at +0x614. This is a
complete guest V#, not a texture heap slot-map record, so the slot-map branch
refuses it.
- A mesh image branch handles the full-V# form when
!layout.texture_heap_slot_map: image_load (op 0), dim 1D, dmask 0x7, UNORM,
no LWE/TFE/R128/reserved bits, eight contiguous descriptor words sharing one
fetch pc and a destination inside the VGPR range.
- The eight words stay symbolic. The fetch is identified by heap_fetches (a
root-proven selector) or heap_descriptor_slots (a GPU-selected selector);
no projected_numeric flag is needed.
- createHandleFromHeap(slot) is annotated Texture1D { 1, 1033 } and
textureLoad.f32 reads mip 0 at the VGPR coordinate, writing the three
integer channels.
- Four-channel loads, other dimensions, missing UNORM or an unmatched
descriptor keep refusing.
Observed on the captured MS with the exact profile layout:
- before: native compute +0x700: unsupported mesh instruction or EXEC state: image_load
- now: native compute +0x69c: unbound numeric SGPR s57
The capture reads descriptor word 1 numerically at +0x69c
(s_bfe_u32 s22, s57, 0x2001e) to build the image coordinate. After R0Y00#3754's
correction the words stay symbolic, which is the accurate refusal: this
branch needs a contract that supplies the real V# field bits before the
+0x700 image is reachable. The source-built fixtures use a constant
coordinate and cover the translation itself; the earlier +0x7c0 observation
belonged to the slot-materialising draft and no longer applies.
tests/native_direct_mesh_check.py adds mesh-image-full-descriptor (root
selector), mesh-image-full-descriptor-root/-gpu, the four-channel and 2D
controls, and keeps the symbolic descriptor-word refusals.
Verified:
- cmake --build --preset release --target compile_dxil
- python -B tests/native_direct_mesh_check.py <compile_dxil.exe> <dxc dir>:
exit 0, "mesh allocation, indexed outputs, group exchange and negative
controls passed"
- ctest --preset release --no-tests=error -R '^native_direct': 2/2 passed
- real capture: native compute +0x69c: unbound numeric SGPR s57
Refs R0Y00#3497
Leyukaka
left a comment
There was a problem hiding this comment.
Re-review of 6102db88. Read the diff; not built or run.
Both MUST items from my earlier review are addressed:
- Descriptor words. The op 3 heap branch no longer sets
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-selected branch coverage.
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_fetches or mesh_heap_reads entry.
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.- The branch now conflicts with main in
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.
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