test: cover slot 57 mesh buffer reads (soffset, structured stride, out of range) #2786
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!2786
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2786/head"
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?
@tedin7 on GitHub · 2026-11-26 09:03 UTC · original
tedin7:x2w-mesh57-buffer-read→main· +198 −0 · 4 files · 1 commits · closed without mergingPart of #2413
What this unblocks: a picture-level guard for the buffer reads of translated slot 57 mesh programs (offset from an SGPR, structured loads with the descriptor stride, reads past the view), so a wrong buffer-view read can no longer hide geometry or colour unnoticed.
What changed
tests/startup_mesh57_buffer_read_check.py, built on the slot 57 fixture ofstartup_mesh57_skeleton_check.py(its words are edited, nothing new is translated; no change togfx2hlsl.py).offen) + index * stride (idxen) + instruction offset; a read outside the bound view returns 0):soffset: the colour load takes its offset from an SGPR instead of the instruction offset (same picture as the plain fixture);structured: position and colour loads useidxen, the stride comes from the descriptor (16: same picture);out of range: the colour load starts past the 512-byte view (every colour channel reads 0).binarycompares the embedded words with llvm-mc;drawruns the cases throughoffscreen_check --mesh-indexed.startup_mesh57_buffer_read_draw_<adapter>),windows.yml(binary list and Python list) andAGENTS.md.What stays untested: typed (
buffer_load_format_*) reads are covered by theformattedmode ofstartup_mesh57_skeleton_check.py; a raw load that straddles the end of the view and the structured index/offset bounds (OOB_SELECT modes) are not covered, because the draw harness binds one fixed 512-byte view.Source: AMD "RDNA 2" Instruction Set Architecture reference guide, chapter 8 (vector memory buffer instructions: address calculation and range checking); DirectX-Specs, Mesh Shader spec (output counts, indexed primitives).
Verification:
python3 -B tests/startup_mesh57_buffer_read_check.py-> okpython3 -B tests/startup_mesh57_buffer_read_check.py binary llvm-mc-19-> okpython3 -B tests/startup_mesh57_skeleton_check.py binary llvm-mc-19-> ok (unchanged)python3 -B tests/docs_links_check.pyandtests/bidi_controls_check.py-> pass;git diff --check origin/main...HEAD-> cleanAI-assisted; commands listed were executed locally.
@tedin7 on GitHub · 2026-11-26 09:17 UTC · original
Independent review of head
0092b6f510: PASS.Verification:
ctest -R '^startup_mesh57_buffer_read': dev 3/3 and release 3/3 (startup_mesh57_buffer_read,startup_mesh57_buffer_read_draw_warp,startup_mesh57_buffer_read_draw_hardware).python3 -B tests/startup_mesh57_buffer_read_check.pyok;... binary llvm-mc-19ok;tests/startup_mesh57_skeleton_check.py binary llvm-mc-19ok (unchanged);git diff --check origin/main...HEADclean.One open point for a follow-up, not blocking: the structured case loads with
idxen offset:192and stride 16 and expects the same picture. The range rule the repo already uses for the compute stores (RDNA 2 ISA, buffer out-of-range table: a structured access is out of range when voffset + instruction offset + element size exceeds the stride) would count that load as out of range on hardware. The base is better carried in soffset, with a control for an instruction offset larger than the stride.AI-assisted; commands listed were executed locally.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-26 09:18 UTC · original · edited 2026-11-26 09:22 UTC
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
0092b6fℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-26 09:22 UTC · original · reviewed
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
0092b6f510ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
@ -0,0 +113,4 @@('soffset', SOFFSET_COLOUR, None, RIGHT, RIGHT),('soffset one vertex too far', SOFFSET_WRONG, None,model_image(lambda slot: 16 * slot, lambda slot: 208 + 16 * slot), RIGHT),('out of range', SOFFSET_OUT_OF_RANGE, None, model_image(lambda slot: 16 * slot, lambda slot: 1024 + 16 * slot), RIGHT),@chatgpt-codex-connector[bot] on GitHub · 2026-11-26 09:22 UTC · original
In draw mode on a mesh-capable adapter, the harness binds the vertex buffer using
SetGraphicsRootShaderResourceView(tests/mesh_entry_draw.cpp:160,334), not a sized descriptor-table SRV. Root descriptors carry no 512-byte view bound, and the generated shader emits uncheckedr0.Loadcalls at1024 + v4, beyond the upload resource's logical size. These accesses are not guaranteed to return zero, so this case relies on undefined out-of-range reads rather than validating the CPU model's view-bounds rule. Bind a sized raw SRV before exercising this case.Useful? React with 👍 / 👎.
@ -0,0 +154,4 @@struct.pack_into('<I', constants, 4 * uds['stride', '0'], stride)expected = sum(a != b for a, b in zip(drawn, compared))path = Path(tmp) / 'case.bin'path.write_bytes(bytes(constants) + VIEW + b'\xcd' * 80 + b''.join(map(bytes, compared)))@chatgpt-codex-connector[bot] on GitHub · 2026-11-26 09:22 UTC · original
For all three non-reference cases,
expectedis 259 mismatches againstRIGHT. Using the fixture's CPU rasterizer, both a completely clear frame and solid-red triangles also produce exactly 259 mismatches, so either incorrect output passes these checks. In particular, the out-of-range load can return red instead of zero without failing, and the shifted-colour case can emit no geometry at all. Because onlycomparedis serialized, the modeleddrawnimage is never actually verified. Render each case against its owndrawnimage with zero expected mismatches before retaining the wrong-reference comparisons as negative controls.Useful? React with 👍 / 👎.
@RavenCurseBurg on GitHub · 2026-11-26 09:56 UTC · original
I will check exact mesh colour readbacks at the last complete vector of the view and at a vector crossing its end. I will fill the final words with distinguishable colours and compare each complete reference image plus a deliberately wrong image on the local mesh-capable adapters. This extends the existing wholly out-of-range case.
@tedin7 on GitHub · 2026-11-26 10:25 UTC · original
Withdrawn: shader translation is moving to the native C++ frontend (see #870), so we are not continuing this change to the Python translator. The branch stays available if any part is useful later. Thank you to everyone who reviewed and tested it.
@RavenCurseBurg on GitHub · 2026-11-26 10:32 UTC · original
Closing out the view-boundary test claim. The existing root SRV has no descriptor length. I added a raw descriptor-table SRV of exactly 128 dwords for the native indexed colour draw, then compared full 32×32 images. The guest mesh words and all input data are synthetic. The C++ binding change and image oracle are available together in the reproduction commit, based on
0092b6f5.The provoking vertex starts its four-channel load at byte 496, 500, 504, 508 or 512. Distinct colours occupy the end of the 512-byte view. The five CPU images expect 4, 3, 2, 1 and 0 in-range channels respectively. WARP and RTX 4060 each matched all 1,024 pixels in all five images. Each reference shifted by one dword gave exactly 56 differing pixels. Intel UHD 770 returned skip 77 (mesh tier unavailable). An initial RTX pass stopped after pipeline creation at byte 508 without a readback; a separate complete run recorded the expected status and pixel count for all ten draws.
To repeat, build
offscreen_checkat the linked revision, then run:For the physical run select
hardwarewithXBOX2WINDOWS_ADAPTER=NVIDIA. I used the modified repository mesh draw path in a local Zig/Clang build restricted to the indexed operation. Windows 11 26100.9711, WARP 10.0.26100.9711, NVIDIA driver 32.0.15.9579, no debug layer. The descriptor binding and expected images can also be used with a native shader frontend. AI-assisted with Codex.Pull request closed