test: cover slot 57 mesh buffer reads (soffset, structured stride, out of range) #2778

Closed
tedin7 wants to merge 1 commit from upstream-pr/2786 into main
tedin7 commented 2026-11-26 09:03:34 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T09:03:34Z.


Part 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

  • New tests/startup_mesh57_buffer_read_check.py, built on the slot 57 fixture of startup_mesh57_skeleton_check.py (its words are edited, nothing new is translated; no change to gfx2hlsl.py).
  • Three buffer-read shapes, each drawn on D3D12 and compared with a CPU model of the buffer address rules (byte address = soffset + voffset (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 use idxen, 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).
  • Controls that must fail with exactly the number of pixels the model gives: a colour read one vertex too far (soffset 208), the read past the view drawn against the right picture, and the structured load with stride 0 (every vertex reads slot 0).
  • Default mode checks the translation (only the structured variant asks the runtime for the stride constant, one vertex SRV each); binary compares the embedded words with llvm-mc; draw runs the cases through offscreen_check --mesh-indexed.
  • Registered in CMake (plain test and startup_mesh57_buffer_read_draw_<adapter>), windows.yml (binary list and Python list) and AGENTS.md.

What stays untested: typed (buffer_load_format_*) reads are covered by the formatted mode of startup_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:

  • Linux: python3 -B tests/startup_mesh57_buffer_read_check.py -> ok
  • Linux: python3 -B tests/startup_mesh57_buffer_read_check.py binary llvm-mc-19 -> ok
  • Linux: python3 -B tests/startup_mesh57_skeleton_check.py binary llvm-mc-19 -> ok (unchanged)
  • Linux: python3 -B tests/docs_links_check.py and tests/bidi_controls_check.py -> pass; git diff --check origin/main...HEAD -> clean
  • Win2025 WARP dev+release: pending Stage-2

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6623160531 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2786). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T09:03:34Z. --- Part 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 - New `tests/startup_mesh57_buffer_read_check.py`, built on the slot 57 fixture of `startup_mesh57_skeleton_check.py` (its words are edited, nothing new is translated; no change to `gfx2hlsl.py`). - Three buffer-read shapes, each drawn on D3D12 and compared with a CPU model of the buffer address rules (byte address = soffset + voffset (`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 use `idxen`, 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). - Controls that must fail with exactly the number of pixels the model gives: a colour read one vertex too far (soffset 208), the read past the view drawn against the right picture, and the structured load with stride 0 (every vertex reads slot 0). - Default mode checks the translation (only the structured variant asks the runtime for the stride constant, one vertex SRV each); `binary` compares the embedded words with llvm-mc; `draw` runs the cases through `offscreen_check --mesh-indexed`. - Registered in CMake (plain test and `startup_mesh57_buffer_read_draw_<adapter>`), `windows.yml` (binary list and Python list) and `AGENTS.md`. What stays untested: typed (`buffer_load_format_*`) reads are covered by the `formatted` mode of `startup_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: - Linux: `python3 -B tests/startup_mesh57_buffer_read_check.py` -> ok - Linux: `python3 -B tests/startup_mesh57_buffer_read_check.py binary llvm-mc-19` -> ok - Linux: `python3 -B tests/startup_mesh57_skeleton_check.py binary llvm-mc-19` -> ok (unchanged) - Linux: `python3 -B tests/docs_links_check.py` and `tests/bidi_controls_check.py` -> pass; `git diff --check origin/main...HEAD` -> clean - Win2025 WARP dev+release: pending Stage-2 AI-assisted; commands listed were executed locally.
chatgpt-codex-connector[bot commented 2026-11-26 10:04:00 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T09:22:48Z.

Review: COMMENTED


💡 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

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6071469353 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2786#pullrequestreview-6071469353). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-26T09:22:48Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `0092b6f510` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review". 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". </details>
tedin7 commented 2026-11-26 10:04:04 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T09:17:58Z.


Independent review of head 0092b6f510: PASS.

Verification:

  • Windows Server 2025 (D3D12 WARP), 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).
  • Tested on RTX 3090 through vkd3d-proton (Linux): 3/3 on the same head.
  • Linux: python3 -B tests/startup_mesh57_buffer_read_check.py ok; ... binary llvm-mc-19 ok; tests/startup_mesh57_skeleton_check.py binary llvm-mc-19 ok (unchanged); git diff --check origin/main...HEAD clean.
  • The wrong variants (soffset one vertex too far, read past the view, structured stride 0) fail with exactly the pixel counts the model gives. Merging current main is clean; the translator break-it set is unchanged (173 same).

One open point for a follow-up, not blocking: the structured case loads with idxen offset:192 and 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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7187743924 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2786#issuecomment-7187743924). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T09:17:58Z. --- Independent review of head 0092b6f5100b35936fcc47daf8721efcbe128879: PASS. Verification: - Windows Server 2025 (D3D12 WARP), `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`). - Tested on RTX 3090 through vkd3d-proton (Linux): 3/3 on the same head. - Linux: `python3 -B tests/startup_mesh57_buffer_read_check.py` ok; `... binary llvm-mc-19` ok; `tests/startup_mesh57_skeleton_check.py binary llvm-mc-19` ok (unchanged); `git diff --check origin/main...HEAD` clean. - The wrong variants (soffset one vertex too far, read past the view, structured stride 0) fail with exactly the pixel counts the model gives. Merging current main is clean; the translator break-it set is unchanged (173 same). One open point for a follow-up, not blocking: the structured case loads with `idxen offset:192` and 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 commented 2026-11-26 10:04:04 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T09:18:06Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T09:22:51.456240Z 0092b6f Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7187747674 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2786#issuecomment-7187747674). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-26T09:18:06Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"0092b6f5100b35936fcc47daf8721efcbe128879","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-26T09:22:51.456240Z">2026-11-26T09:22:51.456240Z</relative-time> | `0092b6f` | Draft marked ready | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
RavenCurseBurg commented 2026-11-26 10:04:06 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by RavenCurseBurg on 2026-11-26T09:56:25Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7188682318 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2786#issuecomment-7188682318). Originally posted by [RavenCurseBurg](https://github.com/RavenCurseBurg) on 2026-11-26T09:56:25Z. --- 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.
chatgpt-codex-connector[bot commented 2026-11-26 10:04:07 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T09:22:48Z.

Code review location: tests/startup_mesh57_buffer_read_check.py; line 116

@@ -0,0 +1,188 @@
+"""Buffer reads of a translated slot 57 mesh program follow the AMD MUBUF address rules (R11).
+
+usage: startup_mesh57_buffer_read_check.py
+       startup_mesh57_buffer_read_check.py binary <llvm-mc>
+       startup_mesh57_buffer_read_check.py draw <dxc> <offscreen_check> <warp|hardware>
+
+The mesh fixture of startup_mesh57_skeleton_check.py reads its vertex data with raw `offen` loads. Here the reads change, and the picture the
+translated program draws is compared with a CPU model of the buffer address rules of the AMD RDNA 2 ISA guide (MUBUF: byte address =
+soffset + voffset (offen) + index * stride (idxen) + instruction offset; a read outside the bound view returns 0):
+
+  soffset      the colour load takes its byte offset from an SGPR (`s_mov_b32 s40, 192`) instead of the instruction offset: same picture.
+  structured   position and colour loads use `idxen` (index = the vertex slot) with the stride from the descriptor (16): same picture.
+  out of range the colour load starts past the end of the 512-byte view (`s_mov_b32 s40, 1024`): every colour channel reads 0.
+Each wrong variant is also drawn against the reference of the right address and must fail with exactly the number of pixels the model gives:
+a colour read one vertex too far (soffset 208), a read past the view, and the structured load with stride 0 (every vertex reads slot 0).
+Without arguments only the translation is checked (the variants translate; only the structured one asks the runtime for the stride constant).
+`binary` compares the embedded words with llvm-mc; `draw` compiles the request path's output (ms_6_5, ps_6_0) and draws it.
+"""
+from pathlib import Path
+import re
+import struct
+import subprocess
+import sys
+import tempfile
+
+HERE = Path(__file__).resolve().parent
+sys.path.insert(0, str(HERE))
+import startup_mesh57_skeleton_check as T  # noqa: E402
+
+MESH = T.MESH
+COLOUR_LOAD = 'e03810c0'      # buffer_load_dwordx4 v[20:23], v4, s[16:19], 0 offen offset:192 (first word)
+COLOUR_LOAD_SECOND = '80041404'
+POSITION_SHIFT = '34080884'   # v_lshlrev_b32 v4, 4, v4: the byte offset of the vertex slot
+TABLE_LOAD_LITERAL = 'fa000000'   # second word of s_load_dwordx4 s[16:19], s[10:11], 0
+
+
+def soffset_variant(value):
+    """The colour load takes its offset from s40 (= value) with no instruction offset: `... s[16:19], s40 offen`."""
+    at = MESH.index(TABLE_LOAD_LITERAL) + 1
+    words = MESH[:at] + ['bea803ff', '%08x' % value] + MESH[at:]   # s_mov_b32 s40, <literal>
+    first = words.index(COLOUR_LOAD)
+    return words[:first] + ['e0381000', '28041404'] + words[first + 2:]
+
+
+def structured_variant():
+    """Position and colour loads index the buffer by vertex slot (`idxen`): v4 = slot, byte address = slot * stride + offset."""
+    words = [w for i, w in enumerate(MESH) if not (w == POSITION_SHIFT and i == MESH.index(POSITION_SHIFT))]
+    words[words.index('e0381000')] = 'e0382000'
+    words[words.index(COLOUR_LOAD)] = 'e03820c0'
+    return words
+
+
+SOFFSET_COLOUR = soffset_variant(192)
+SOFFSET_WRONG = soffset_variant(208)
+SOFFSET_OUT_OF_RANGE = soffset_variant(1024)
+STRUCTURED = structured_variant()
+
+LOAD = 's_load_dwordx4 s[16:19], s[10:11], 0\n'
+COLOUR_ASM = 'buffer_load_dwordx4 v[20:23], v4, s[16:19], 0 offen offset:192\n'
+POSITION_ASM = 'buffer_load_dwordx4 v[16:19], v4, s[16:19], 0 offen\n'
+SHIFT_ASM = 'v_lshlrev_b32 v4, 4, v4\n'
+
+
+def soffset_asm(text, value):
+    return (text.replace(LOAD, LOAD + 's_mov_b32 s40, %d\n' % value)
+            .replace(COLOUR_ASM, 'buffer_load_dwordx4 v[20:23], v4, s[16:19], s40 offen\n'))
+
+
+def structured_asm(text):
+    return (text.replace(SHIFT_ASM, '').replace(POSITION_ASM, 'buffer_load_dwordx4 v[16:19], v4, s[16:19], 0 idxen\n')
+            .replace(COLOUR_ASM, 'buffer_load_dwordx4 v[20:23], v4, s[16:19], 0 idxen offset:192\n'))
+
+
+def binary(mc):
+    text = (HERE / 'startup_mesh57_skeleton.s').read_text()
+    T.expect('soffset words match llvm-mc', T.assemble(mc, soffset_asm(text, 192)), SOFFSET_COLOUR)
+    T.expect('wrong soffset words match llvm-mc', T.assemble(mc, soffset_asm(text, 208)), SOFFSET_WRONG)
+    T.expect('out-of-range soffset words match llvm-mc', T.assemble(mc, soffset_asm(text, 1024)), SOFFSET_OUT_OF_RANGE)
+    T.expect('structured words match llvm-mc', T.assemble(mc, structured_asm(text)), STRUCTURED)
+
+
+POINTS, COLOURS, INDICES = T.geometry()
+WORDS = [a | b << 10 | c << 20 for a, b, c in INDICES]
+VIEW = T.buffer(POINTS, COLOURS, WORDS)   # the 512 bytes the draw harness binds as the vertex buffer view
+
+
+def read_u32(address):
+    """The ISA rule for a raw read: outside the bound view it returns 0."""
+    return struct.unpack_from('<I', VIEW, address)[0] if 0 <= address and address + 4 <= len(VIEW) else 0
+
+
+def read_f32(address):
+    return struct.unpack('<f', struct.pack('<I', read_u32(address)))[0]
+
+
+def unorm8(value):
+    return 0 if value != value else int(max(0.0, min(1.0, value)) * 255 + 0.5)
+
+
+def model_image(position_at, colour_at):
+    """What the program draws when vertex slot i is read at byte `position_at(i)` (position) and `colour_at(i)` (colour)."""
+    points, colours = [], []
+    for slot in range(len(POINTS)):
+        x, y = read_f32(position_at(slot)), read_f32(position_at(slot) + 4)
+        points.append((round((x + 1) * 16), round((1 - y) * 16)))
+        colours.append(tuple(unorm8(read_f32(colour_at(slot) + 4 * c)) for c in range(4)))
+    return T.rasterise(points, colours, INDICES, len(POINTS), len(INDICES))
+
+
+RIGHT = model_image(lambda slot: 16 * slot, lambda slot: 192 + 16 * slot)
+# (name, words, stride constant or None, the picture the words must draw, the picture the draw is compared with)
+CASES = (
+    ('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),

P2 Badge Use a bounded SRV for the out-of-range draw

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 unchecked r0.Load calls at 1024 + 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 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4706204048 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2786#discussion_r4706204048). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-26T09:22:48Z. **Code review location:** `tests/startup_mesh57_buffer_read_check.py`; line 116 ~~~~diff @@ -0,0 +1,188 @@ +"""Buffer reads of a translated slot 57 mesh program follow the AMD MUBUF address rules (R11). + +usage: startup_mesh57_buffer_read_check.py + startup_mesh57_buffer_read_check.py binary <llvm-mc> + startup_mesh57_buffer_read_check.py draw <dxc> <offscreen_check> <warp|hardware> + +The mesh fixture of startup_mesh57_skeleton_check.py reads its vertex data with raw `offen` loads. Here the reads change, and the picture the +translated program draws is compared with a CPU model of the buffer address rules of the AMD RDNA 2 ISA guide (MUBUF: byte address = +soffset + voffset (offen) + index * stride (idxen) + instruction offset; a read outside the bound view returns 0): + + soffset the colour load takes its byte offset from an SGPR (`s_mov_b32 s40, 192`) instead of the instruction offset: same picture. + structured position and colour loads use `idxen` (index = the vertex slot) with the stride from the descriptor (16): same picture. + out of range the colour load starts past the end of the 512-byte view (`s_mov_b32 s40, 1024`): every colour channel reads 0. +Each wrong variant is also drawn against the reference of the right address and must fail with exactly the number of pixels the model gives: +a colour read one vertex too far (soffset 208), a read past the view, and the structured load with stride 0 (every vertex reads slot 0). +Without arguments only the translation is checked (the variants translate; only the structured one asks the runtime for the stride constant). +`binary` compares the embedded words with llvm-mc; `draw` compiles the request path's output (ms_6_5, ps_6_0) and draws it. +""" +from pathlib import Path +import re +import struct +import subprocess +import sys +import tempfile + +HERE = Path(__file__).resolve().parent +sys.path.insert(0, str(HERE)) +import startup_mesh57_skeleton_check as T # noqa: E402 + +MESH = T.MESH +COLOUR_LOAD = 'e03810c0' # buffer_load_dwordx4 v[20:23], v4, s[16:19], 0 offen offset:192 (first word) +COLOUR_LOAD_SECOND = '80041404' +POSITION_SHIFT = '34080884' # v_lshlrev_b32 v4, 4, v4: the byte offset of the vertex slot +TABLE_LOAD_LITERAL = 'fa000000' # second word of s_load_dwordx4 s[16:19], s[10:11], 0 + + +def soffset_variant(value): + """The colour load takes its offset from s40 (= value) with no instruction offset: `... s[16:19], s40 offen`.""" + at = MESH.index(TABLE_LOAD_LITERAL) + 1 + words = MESH[:at] + ['bea803ff', '%08x' % value] + MESH[at:] # s_mov_b32 s40, <literal> + first = words.index(COLOUR_LOAD) + return words[:first] + ['e0381000', '28041404'] + words[first + 2:] + + +def structured_variant(): + """Position and colour loads index the buffer by vertex slot (`idxen`): v4 = slot, byte address = slot * stride + offset.""" + words = [w for i, w in enumerate(MESH) if not (w == POSITION_SHIFT and i == MESH.index(POSITION_SHIFT))] + words[words.index('e0381000')] = 'e0382000' + words[words.index(COLOUR_LOAD)] = 'e03820c0' + return words + + +SOFFSET_COLOUR = soffset_variant(192) +SOFFSET_WRONG = soffset_variant(208) +SOFFSET_OUT_OF_RANGE = soffset_variant(1024) +STRUCTURED = structured_variant() + +LOAD = 's_load_dwordx4 s[16:19], s[10:11], 0\n' +COLOUR_ASM = 'buffer_load_dwordx4 v[20:23], v4, s[16:19], 0 offen offset:192\n' +POSITION_ASM = 'buffer_load_dwordx4 v[16:19], v4, s[16:19], 0 offen\n' +SHIFT_ASM = 'v_lshlrev_b32 v4, 4, v4\n' + + +def soffset_asm(text, value): + return (text.replace(LOAD, LOAD + 's_mov_b32 s40, %d\n' % value) + .replace(COLOUR_ASM, 'buffer_load_dwordx4 v[20:23], v4, s[16:19], s40 offen\n')) + + +def structured_asm(text): + return (text.replace(SHIFT_ASM, '').replace(POSITION_ASM, 'buffer_load_dwordx4 v[16:19], v4, s[16:19], 0 idxen\n') + .replace(COLOUR_ASM, 'buffer_load_dwordx4 v[20:23], v4, s[16:19], 0 idxen offset:192\n')) + + +def binary(mc): + text = (HERE / 'startup_mesh57_skeleton.s').read_text() + T.expect('soffset words match llvm-mc', T.assemble(mc, soffset_asm(text, 192)), SOFFSET_COLOUR) + T.expect('wrong soffset words match llvm-mc', T.assemble(mc, soffset_asm(text, 208)), SOFFSET_WRONG) + T.expect('out-of-range soffset words match llvm-mc', T.assemble(mc, soffset_asm(text, 1024)), SOFFSET_OUT_OF_RANGE) + T.expect('structured words match llvm-mc', T.assemble(mc, structured_asm(text)), STRUCTURED) + + +POINTS, COLOURS, INDICES = T.geometry() +WORDS = [a | b << 10 | c << 20 for a, b, c in INDICES] +VIEW = T.buffer(POINTS, COLOURS, WORDS) # the 512 bytes the draw harness binds as the vertex buffer view + + +def read_u32(address): + """The ISA rule for a raw read: outside the bound view it returns 0.""" + return struct.unpack_from('<I', VIEW, address)[0] if 0 <= address and address + 4 <= len(VIEW) else 0 + + +def read_f32(address): + return struct.unpack('<f', struct.pack('<I', read_u32(address)))[0] + + +def unorm8(value): + return 0 if value != value else int(max(0.0, min(1.0, value)) * 255 + 0.5) + + +def model_image(position_at, colour_at): + """What the program draws when vertex slot i is read at byte `position_at(i)` (position) and `colour_at(i)` (colour).""" + points, colours = [], [] + for slot in range(len(POINTS)): + x, y = read_f32(position_at(slot)), read_f32(position_at(slot) + 4) + points.append((round((x + 1) * 16), round((1 - y) * 16))) + colours.append(tuple(unorm8(read_f32(colour_at(slot) + 4 * c)) for c in range(4))) + return T.rasterise(points, colours, INDICES, len(POINTS), len(INDICES)) + + +RIGHT = model_image(lambda slot: 16 * slot, lambda slot: 192 + 16 * slot) +# (name, words, stride constant or None, the picture the words must draw, the picture the draw is compared with) +CASES = ( + ('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), ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Use a bounded SRV for the out-of-range draw** 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 unchecked `r0.Load` calls at `1024 + 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 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot commented 2026-11-26 10:04:07 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T09:22:49Z.

Code review location: tests/startup_mesh57_buffer_read_check.py; line 157

@@ -0,0 +1,188 @@
+"""Buffer reads of a translated slot 57 mesh program follow the AMD MUBUF address rules (R11).
+
+usage: startup_mesh57_buffer_read_check.py
+       startup_mesh57_buffer_read_check.py binary <llvm-mc>
+       startup_mesh57_buffer_read_check.py draw <dxc> <offscreen_check> <warp|hardware>
+
+The mesh fixture of startup_mesh57_skeleton_check.py reads its vertex data with raw `offen` loads. Here the reads change, and the picture the
+translated program draws is compared with a CPU model of the buffer address rules of the AMD RDNA 2 ISA guide (MUBUF: byte address =
+soffset + voffset (offen) + index * stride (idxen) + instruction offset; a read outside the bound view returns 0):
+
+  soffset      the colour load takes its byte offset from an SGPR (`s_mov_b32 s40, 192`) instead of the instruction offset: same picture.
+  structured   position and colour loads use `idxen` (index = the vertex slot) with the stride from the descriptor (16): same picture.
+  out of range the colour load starts past the end of the 512-byte view (`s_mov_b32 s40, 1024`): every colour channel reads 0.
+Each wrong variant is also drawn against the reference of the right address and must fail with exactly the number of pixels the model gives:
+a colour read one vertex too far (soffset 208), a read past the view, and the structured load with stride 0 (every vertex reads slot 0).
+Without arguments only the translation is checked (the variants translate; only the structured one asks the runtime for the stride constant).
+`binary` compares the embedded words with llvm-mc; `draw` compiles the request path's output (ms_6_5, ps_6_0) and draws it.
+"""
+from pathlib import Path
+import re
+import struct
+import subprocess
+import sys
+import tempfile
+
+HERE = Path(__file__).resolve().parent
+sys.path.insert(0, str(HERE))
+import startup_mesh57_skeleton_check as T  # noqa: E402
+
+MESH = T.MESH
+COLOUR_LOAD = 'e03810c0'      # buffer_load_dwordx4 v[20:23], v4, s[16:19], 0 offen offset:192 (first word)
+COLOUR_LOAD_SECOND = '80041404'
+POSITION_SHIFT = '34080884'   # v_lshlrev_b32 v4, 4, v4: the byte offset of the vertex slot
+TABLE_LOAD_LITERAL = 'fa000000'   # second word of s_load_dwordx4 s[16:19], s[10:11], 0
+
+
+def soffset_variant(value):
+    """The colour load takes its offset from s40 (= value) with no instruction offset: `... s[16:19], s40 offen`."""
+    at = MESH.index(TABLE_LOAD_LITERAL) + 1
+    words = MESH[:at] + ['bea803ff', '%08x' % value] + MESH[at:]   # s_mov_b32 s40, <literal>
+    first = words.index(COLOUR_LOAD)
+    return words[:first] + ['e0381000', '28041404'] + words[first + 2:]
+
+
+def structured_variant():
+    """Position and colour loads index the buffer by vertex slot (`idxen`): v4 = slot, byte address = slot * stride + offset."""
+    words = [w for i, w in enumerate(MESH) if not (w == POSITION_SHIFT and i == MESH.index(POSITION_SHIFT))]
+    words[words.index('e0381000')] = 'e0382000'
+    words[words.index(COLOUR_LOAD)] = 'e03820c0'
+    return words
+
+
+SOFFSET_COLOUR = soffset_variant(192)
+SOFFSET_WRONG = soffset_variant(208)
+SOFFSET_OUT_OF_RANGE = soffset_variant(1024)
+STRUCTURED = structured_variant()
+
+LOAD = 's_load_dwordx4 s[16:19], s[10:11], 0\n'
+COLOUR_ASM = 'buffer_load_dwordx4 v[20:23], v4, s[16:19], 0 offen offset:192\n'
+POSITION_ASM = 'buffer_load_dwordx4 v[16:19], v4, s[16:19], 0 offen\n'
+SHIFT_ASM = 'v_lshlrev_b32 v4, 4, v4\n'
+
+
+def soffset_asm(text, value):
+    return (text.replace(LOAD, LOAD + 's_mov_b32 s40, %d\n' % value)
+            .replace(COLOUR_ASM, 'buffer_load_dwordx4 v[20:23], v4, s[16:19], s40 offen\n'))
+
+
+def structured_asm(text):
+    return (text.replace(SHIFT_ASM, '').replace(POSITION_ASM, 'buffer_load_dwordx4 v[16:19], v4, s[16:19], 0 idxen\n')
+            .replace(COLOUR_ASM, 'buffer_load_dwordx4 v[20:23], v4, s[16:19], 0 idxen offset:192\n'))
+
+
+def binary(mc):
+    text = (HERE / 'startup_mesh57_skeleton.s').read_text()
+    T.expect('soffset words match llvm-mc', T.assemble(mc, soffset_asm(text, 192)), SOFFSET_COLOUR)
+    T.expect('wrong soffset words match llvm-mc', T.assemble(mc, soffset_asm(text, 208)), SOFFSET_WRONG)
+    T.expect('out-of-range soffset words match llvm-mc', T.assemble(mc, soffset_asm(text, 1024)), SOFFSET_OUT_OF_RANGE)
+    T.expect('structured words match llvm-mc', T.assemble(mc, structured_asm(text)), STRUCTURED)
+
+
+POINTS, COLOURS, INDICES = T.geometry()
+WORDS = [a | b << 10 | c << 20 for a, b, c in INDICES]
+VIEW = T.buffer(POINTS, COLOURS, WORDS)   # the 512 bytes the draw harness binds as the vertex buffer view
+
+
+def read_u32(address):
+    """The ISA rule for a raw read: outside the bound view it returns 0."""
+    return struct.unpack_from('<I', VIEW, address)[0] if 0 <= address and address + 4 <= len(VIEW) else 0
+
+
+def read_f32(address):
+    return struct.unpack('<f', struct.pack('<I', read_u32(address)))[0]
+
+
+def unorm8(value):
+    return 0 if value != value else int(max(0.0, min(1.0, value)) * 255 + 0.5)
+
+
+def model_image(position_at, colour_at):
+    """What the program draws when vertex slot i is read at byte `position_at(i)` (position) and `colour_at(i)` (colour)."""
+    points, colours = [], []
+    for slot in range(len(POINTS)):
+        x, y = read_f32(position_at(slot)), read_f32(position_at(slot) + 4)
+        points.append((round((x + 1) * 16), round((1 - y) * 16)))
+        colours.append(tuple(unorm8(read_f32(colour_at(slot) + 4 * c)) for c in range(4)))
+    return T.rasterise(points, colours, INDICES, len(POINTS), len(INDICES))
+
+
+RIGHT = model_image(lambda slot: 16 * slot, lambda slot: 192 + 16 * slot)
+# (name, words, stride constant or None, the picture the words must draw, the picture the draw is compared with)
+CASES = (
+    ('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),
+    ('structured, stride 16', STRUCTURED, 16, RIGHT, RIGHT),
+    ('structured, stride 0', STRUCTURED, 0, model_image(lambda slot: 0, lambda slot: 192), RIGHT),
+)
+
+
+def controls():
+    import os
+    os.environ['X2W_FXC'] = ''   # sources and manifest only; the draw mode compiles
+    T.expect('the right picture is the standard draw of the fixture',
+             RIGHT, T.rasterise(POINTS, COLOURS, INDICES, len(POINTS), len(INDICES)))
+    for name, words, stride, drawn, compared in CASES:
+        T.expect(name + ': a wrong read draws another picture than the right one', drawn != RIGHT, words in (SOFFSET_WRONG, SOFFSET_OUT_OF_RANGE) or stride == 0)
+        with tempfile.TemporaryDirectory() as tmp:
+            key, result = T.request(tmp, words)
+            T.expect(name + ' translates', result, 'ok')
+            manifest = (Path(tmp) / ('%016x.ms57.txt' % key)).read_text().splitlines()
+            T.expect(name + ': stride constant requested only by idxen loads',
+                     [line for line in manifest if re.fullmatch(r'udsrc \d+ stride \d+', line)] != [], words is STRUCTURED)
+            T.expect(name + ': one vertex SRV', [line for line in manifest if line.startswith('srv ')], ['srv 0 buf table 1 0'])
+
+
+def draw(dxc, renderer, adapter):
+    import os
+    os.environ['X2W_DXC'] = dxc
+    os.environ.pop('X2W_FXC', None)
+    for name, words, stride, drawn, compared in CASES:
+        with tempfile.TemporaryDirectory() as tmp:
+            key, result = T.request(tmp, words)
+            if result != 'ok':
+                raise AssertionError('%s: %s' % (name, result))
+            base = str(Path(tmp) / ('%016x' % key))
+            manifest = Path(base + '.ms57.txt').read_text().splitlines()
+            uds = {tuple(fields[2:]): int(fields[1]) for fields in map(str.split, manifest) if fields and fields[0] == 'udsrc'}
+            constants = bytearray(1024)
+            struct.pack_into('<I', constants, 4 * uds['rootconst', '0', '0'], len(INDICES))
+            struct.pack_into('<I', constants, 4 * uds['rootconst', '0', '1'], len(POINTS))
+            if stride is not None:
+                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)))

P2 Badge Compare negative-case pixels against their modeled images

For all three non-reference cases, expected is 259 mismatches against RIGHT. 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 only compared is serialized, the modeled drawn image is never actually verified. Render each case against its own drawn image with zero expected mismatches before retaining the wrong-reference comparisons as negative controls.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4706204059 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2786#discussion_r4706204059). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-26T09:22:49Z. **Code review location:** `tests/startup_mesh57_buffer_read_check.py`; line 157 ~~~~diff @@ -0,0 +1,188 @@ +"""Buffer reads of a translated slot 57 mesh program follow the AMD MUBUF address rules (R11). + +usage: startup_mesh57_buffer_read_check.py + startup_mesh57_buffer_read_check.py binary <llvm-mc> + startup_mesh57_buffer_read_check.py draw <dxc> <offscreen_check> <warp|hardware> + +The mesh fixture of startup_mesh57_skeleton_check.py reads its vertex data with raw `offen` loads. Here the reads change, and the picture the +translated program draws is compared with a CPU model of the buffer address rules of the AMD RDNA 2 ISA guide (MUBUF: byte address = +soffset + voffset (offen) + index * stride (idxen) + instruction offset; a read outside the bound view returns 0): + + soffset the colour load takes its byte offset from an SGPR (`s_mov_b32 s40, 192`) instead of the instruction offset: same picture. + structured position and colour loads use `idxen` (index = the vertex slot) with the stride from the descriptor (16): same picture. + out of range the colour load starts past the end of the 512-byte view (`s_mov_b32 s40, 1024`): every colour channel reads 0. +Each wrong variant is also drawn against the reference of the right address and must fail with exactly the number of pixels the model gives: +a colour read one vertex too far (soffset 208), a read past the view, and the structured load with stride 0 (every vertex reads slot 0). +Without arguments only the translation is checked (the variants translate; only the structured one asks the runtime for the stride constant). +`binary` compares the embedded words with llvm-mc; `draw` compiles the request path's output (ms_6_5, ps_6_0) and draws it. +""" +from pathlib import Path +import re +import struct +import subprocess +import sys +import tempfile + +HERE = Path(__file__).resolve().parent +sys.path.insert(0, str(HERE)) +import startup_mesh57_skeleton_check as T # noqa: E402 + +MESH = T.MESH +COLOUR_LOAD = 'e03810c0' # buffer_load_dwordx4 v[20:23], v4, s[16:19], 0 offen offset:192 (first word) +COLOUR_LOAD_SECOND = '80041404' +POSITION_SHIFT = '34080884' # v_lshlrev_b32 v4, 4, v4: the byte offset of the vertex slot +TABLE_LOAD_LITERAL = 'fa000000' # second word of s_load_dwordx4 s[16:19], s[10:11], 0 + + +def soffset_variant(value): + """The colour load takes its offset from s40 (= value) with no instruction offset: `... s[16:19], s40 offen`.""" + at = MESH.index(TABLE_LOAD_LITERAL) + 1 + words = MESH[:at] + ['bea803ff', '%08x' % value] + MESH[at:] # s_mov_b32 s40, <literal> + first = words.index(COLOUR_LOAD) + return words[:first] + ['e0381000', '28041404'] + words[first + 2:] + + +def structured_variant(): + """Position and colour loads index the buffer by vertex slot (`idxen`): v4 = slot, byte address = slot * stride + offset.""" + words = [w for i, w in enumerate(MESH) if not (w == POSITION_SHIFT and i == MESH.index(POSITION_SHIFT))] + words[words.index('e0381000')] = 'e0382000' + words[words.index(COLOUR_LOAD)] = 'e03820c0' + return words + + +SOFFSET_COLOUR = soffset_variant(192) +SOFFSET_WRONG = soffset_variant(208) +SOFFSET_OUT_OF_RANGE = soffset_variant(1024) +STRUCTURED = structured_variant() + +LOAD = 's_load_dwordx4 s[16:19], s[10:11], 0\n' +COLOUR_ASM = 'buffer_load_dwordx4 v[20:23], v4, s[16:19], 0 offen offset:192\n' +POSITION_ASM = 'buffer_load_dwordx4 v[16:19], v4, s[16:19], 0 offen\n' +SHIFT_ASM = 'v_lshlrev_b32 v4, 4, v4\n' + + +def soffset_asm(text, value): + return (text.replace(LOAD, LOAD + 's_mov_b32 s40, %d\n' % value) + .replace(COLOUR_ASM, 'buffer_load_dwordx4 v[20:23], v4, s[16:19], s40 offen\n')) + + +def structured_asm(text): + return (text.replace(SHIFT_ASM, '').replace(POSITION_ASM, 'buffer_load_dwordx4 v[16:19], v4, s[16:19], 0 idxen\n') + .replace(COLOUR_ASM, 'buffer_load_dwordx4 v[20:23], v4, s[16:19], 0 idxen offset:192\n')) + + +def binary(mc): + text = (HERE / 'startup_mesh57_skeleton.s').read_text() + T.expect('soffset words match llvm-mc', T.assemble(mc, soffset_asm(text, 192)), SOFFSET_COLOUR) + T.expect('wrong soffset words match llvm-mc', T.assemble(mc, soffset_asm(text, 208)), SOFFSET_WRONG) + T.expect('out-of-range soffset words match llvm-mc', T.assemble(mc, soffset_asm(text, 1024)), SOFFSET_OUT_OF_RANGE) + T.expect('structured words match llvm-mc', T.assemble(mc, structured_asm(text)), STRUCTURED) + + +POINTS, COLOURS, INDICES = T.geometry() +WORDS = [a | b << 10 | c << 20 for a, b, c in INDICES] +VIEW = T.buffer(POINTS, COLOURS, WORDS) # the 512 bytes the draw harness binds as the vertex buffer view + + +def read_u32(address): + """The ISA rule for a raw read: outside the bound view it returns 0.""" + return struct.unpack_from('<I', VIEW, address)[0] if 0 <= address and address + 4 <= len(VIEW) else 0 + + +def read_f32(address): + return struct.unpack('<f', struct.pack('<I', read_u32(address)))[0] + + +def unorm8(value): + return 0 if value != value else int(max(0.0, min(1.0, value)) * 255 + 0.5) + + +def model_image(position_at, colour_at): + """What the program draws when vertex slot i is read at byte `position_at(i)` (position) and `colour_at(i)` (colour).""" + points, colours = [], [] + for slot in range(len(POINTS)): + x, y = read_f32(position_at(slot)), read_f32(position_at(slot) + 4) + points.append((round((x + 1) * 16), round((1 - y) * 16))) + colours.append(tuple(unorm8(read_f32(colour_at(slot) + 4 * c)) for c in range(4))) + return T.rasterise(points, colours, INDICES, len(POINTS), len(INDICES)) + + +RIGHT = model_image(lambda slot: 16 * slot, lambda slot: 192 + 16 * slot) +# (name, words, stride constant or None, the picture the words must draw, the picture the draw is compared with) +CASES = ( + ('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), + ('structured, stride 16', STRUCTURED, 16, RIGHT, RIGHT), + ('structured, stride 0', STRUCTURED, 0, model_image(lambda slot: 0, lambda slot: 192), RIGHT), +) + + +def controls(): + import os + os.environ['X2W_FXC'] = '' # sources and manifest only; the draw mode compiles + T.expect('the right picture is the standard draw of the fixture', + RIGHT, T.rasterise(POINTS, COLOURS, INDICES, len(POINTS), len(INDICES))) + for name, words, stride, drawn, compared in CASES: + T.expect(name + ': a wrong read draws another picture than the right one', drawn != RIGHT, words in (SOFFSET_WRONG, SOFFSET_OUT_OF_RANGE) or stride == 0) + with tempfile.TemporaryDirectory() as tmp: + key, result = T.request(tmp, words) + T.expect(name + ' translates', result, 'ok') + manifest = (Path(tmp) / ('%016x.ms57.txt' % key)).read_text().splitlines() + T.expect(name + ': stride constant requested only by idxen loads', + [line for line in manifest if re.fullmatch(r'udsrc \d+ stride \d+', line)] != [], words is STRUCTURED) + T.expect(name + ': one vertex SRV', [line for line in manifest if line.startswith('srv ')], ['srv 0 buf table 1 0']) + + +def draw(dxc, renderer, adapter): + import os + os.environ['X2W_DXC'] = dxc + os.environ.pop('X2W_FXC', None) + for name, words, stride, drawn, compared in CASES: + with tempfile.TemporaryDirectory() as tmp: + key, result = T.request(tmp, words) + if result != 'ok': + raise AssertionError('%s: %s' % (name, result)) + base = str(Path(tmp) / ('%016x' % key)) + manifest = Path(base + '.ms57.txt').read_text().splitlines() + uds = {tuple(fields[2:]): int(fields[1]) for fields in map(str.split, manifest) if fields and fields[0] == 'udsrc'} + constants = bytearray(1024) + struct.pack_into('<I', constants, 4 * uds['rootconst', '0', '0'], len(INDICES)) + struct.pack_into('<I', constants, 4 * uds['rootconst', '0', '1'], len(POINTS)) + if stride is not None: + 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))) ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Compare negative-case pixels against their modeled images** For all three non-reference cases, `expected` is 259 mismatches against `RIGHT`. 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 only `compared` is serialized, the modeled `drawn` image is never actually verified. Render each case against its own `drawn` image with zero expected mismatches before retaining the wrong-reference comparisons as negative controls. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
upstream-sync closed this pull request 2026-11-26 11:02:48 +00:00
tedin7 commented 2026-11-26 11:02:59 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T10:25:56Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7189357381 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2786#issuecomment-7189357381). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T10:25:56Z. --- 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 commented 2026-11-26 11:03:00 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by RavenCurseBurg on 2026-11-26T10:32:41Z.


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_check at the linked revision, then run:

python tests/verify_mesh_view_edge.py <dxc> <offscreen_check> warp

For the physical run select hardware with XBOX2WINDOWS_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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7189506843 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2786#issuecomment-7189506843). Originally posted by [RavenCurseBurg](https://github.com/RavenCurseBurg) on 2026-11-26T10:32:41Z. --- 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](https://github.com/RavenCurseBurg/Xbox2Windows/commit/128b2bb1293cf5f1dc816147131f3c3cc3de800c), 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_check` at the linked revision, then run: ```text python tests/verify_mesh_view_edge.py <dxc> <offscreen_check> warp ``` For the physical run select `hardware` with `XBOX2WINDOWS_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

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!2778
No description provided.