shader: accept idxen offen raw loads through a reflected table record #3707

Manually merged
github merged 1 commit from github-bot/gh-3705 into main 2026-12-01 08:47:19 +00:00 AGit
Owner

@⁠lukaslw-lab on GitHub · 2026-12-01 06:38 UTC · original
lukaslw-lab:shader/mesh-idxen-offen-raw-load → main · +26 −1 · 4 files · 1 commits · merged 2026-12-01 08:45 UTC

Change

Graphics raw buffer loads (buffer_load_dword*) accepted IDXEN or OFFEN, not both. With both set, the second address VGPR is a byte offset inside the indexed record:

address = index * stride + (voffset & ~3) + immediate offset

The stride comes from the reflected table SRV, as it already does for IDXEN alone. The offset is dword-aligned like the unindexed raw path. A load reads zero when the index is past the view or the access does not end inside the record, as a structured-buffer read does.

The mesh lowerer now passes its reflected container stage to the shared ALU (alu.graphics_interface), which VS and PS already do. Without it, a mesh IDXEN load always stopped at indexed raw load needs a reflected table SRV. Nothing else reads that field.

This is item 3 of #3705. On the 6 captured slot 86 requests that stopped at raw buffer load needs offen with zero scalar offset and no modifiers, with #3704 and #3706 also applied, all 6 now pass the load. Their next refusal is a lane-mask block, s_xor_b64 s[20:21], vcc, -1 followed by s_and_saveexec_b64. Refs #3705, #3643.

Not in this PR: binding the view in the slot 86 runtime.

  • native_mesh86.inl accepts only buffer_srv, raw_vector_srv, byte_window_srv and root_buffer_srv for a mesh SRV. A pipeline that uses indexed_raw_srv would still be refused at creation (unsupported native Mesh86 SRV shape).
  • The VS/PS draw path also checks that the guest descriptor's stride matches the reflected one (d3d12_draw.inl, expected_stride). The slot 86 binder needs the same check.
  • That change is in the material binder that #3641 is changing, so I left it out. I'll follow up after #3641, or the #3641 work can take it. It only matters once the SAVEEXEC block above is lowered.

Verification

Build release at this branch (Windows 10 19045, MSVC 2022, DXC 1.9.2609):

python -B tests/native_direct_container_check.py <compile_dxil.exe> <dxc dir>  -> passed
python -B tests/native_direct_mesh_check.py <compile_dxil.exe> <dxc dir>       -> passed
ctest --test-dir out/build/release -R "native_direct|native_scalar|mesh|native_.*root|indexed|pixel_aot|startup_draw|compute_desc|descriptor_scc"
  -> 481 tests: 338 passed, 100 capability skips (77), 43 failed

42 of the 43 also fail on this host with main's sources (Windows 10 without the Agility SDK; NVIDIA RTX 3080 Ti, driver 32.0.16.1047, debug layer on; pixel_aot_* use the local LLVM tools). The 43rd, pixel_aot_core_vector_warp, failed once in the parallel run and passed 3 of 3 alone with this change; it does not use the native lowerer.

New cases in native_direct_container_check.py, next to indexed-pixel-record-*:

  • indexed-offset-pixel-record-16: record 1, byte 8, immediate 4. Checks the dword mask, the ule 8 in-record bound (16 − 4 − 4) and the added offset.
  • indexed-offset-pixel-record-4 and -0: refused, outside a verified dword-aligned record.

Controls:

  • Without the source change, the new case fails with raw buffer load needs offen with zero scalar offset and no modifiers.
  • With the in-record bound removed, the IR assertion fails.

Evidence and follow-up

Source-built words only. The counts on captured requests are local and offline (compile_dxil ... gfx1013-container-ms-texture-heap).

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted.

🤖 Generated with Claude Code

**@⁠lukaslw-lab** on GitHub · 2026-12-01 06:38 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3705) `lukaslw-lab:shader/mesh-idxen-offen-raw-load` → `main` · +26 −1 · 4 files · 1 commits · merged 2026-12-01 08:45 UTC ## Change Graphics raw buffer loads (`buffer_load_dword*`) accepted IDXEN or OFFEN, not both. With both set, the second address VGPR is a byte offset inside the indexed record: ``` address = index * stride + (voffset & ~3) + immediate offset ``` The stride comes from the reflected table SRV, as it already does for IDXEN alone. The offset is dword-aligned like the unindexed raw path. A load reads zero when the index is past the view or the access does not end inside the record, as a structured-buffer read does. The mesh lowerer now passes its reflected container stage to the shared ALU (`alu.graphics_interface`), which VS and PS already do. Without it, a mesh IDXEN load always stopped at `indexed raw load needs a reflected table SRV`. Nothing else reads that field. This is item 3 of #3705. On the 6 captured slot 86 requests that stopped at `raw buffer load needs offen with zero scalar offset and no modifiers`, with #3704 and #3706 also applied, all 6 now pass the load. Their next refusal is a lane-mask block, `s_xor_b64 s[20:21], vcc, -1` followed by `s_and_saveexec_b64`. Refs #3705, #3643. **Not in this PR: binding the view in the slot 86 runtime.** - `native_mesh86.inl` accepts only `buffer_srv`, `raw_vector_srv`, `byte_window_srv` and `root_buffer_srv` for a mesh SRV. A pipeline that uses `indexed_raw_srv` would still be refused at creation (`unsupported native Mesh86 SRV shape`). - The VS/PS draw path also checks that the guest descriptor's stride matches the reflected one (`d3d12_draw.inl`, `expected_stride`). The slot 86 binder needs the same check. - That change is in the material binder that #3641 is changing, so I left it out. I'll follow up after #3641, or the #3641 work can take it. It only matters once the SAVEEXEC block above is lowered. ## Verification Build `release` at this branch (Windows 10 19045, MSVC 2022, DXC 1.9.2609): ``` python -B tests/native_direct_container_check.py <compile_dxil.exe> <dxc dir> -> passed python -B tests/native_direct_mesh_check.py <compile_dxil.exe> <dxc dir> -> passed ctest --test-dir out/build/release -R "native_direct|native_scalar|mesh|native_.*root|indexed|pixel_aot|startup_draw|compute_desc|descriptor_scc" -> 481 tests: 338 passed, 100 capability skips (77), 43 failed ``` 42 of the 43 also fail on this host with `main`'s sources (Windows 10 without the Agility SDK; NVIDIA RTX 3080 Ti, driver 32.0.16.1047, debug layer on; `pixel_aot_*` use the local LLVM tools). The 43rd, `pixel_aot_core_vector_warp`, failed once in the parallel run and passed 3 of 3 alone with this change; it does not use the native lowerer. New cases in `native_direct_container_check.py`, next to `indexed-pixel-record-*`: - `indexed-offset-pixel-record-16`: record 1, byte 8, immediate 4. Checks the dword mask, the `ule 8` in-record bound (16 − 4 − 4) and the added offset. - `indexed-offset-pixel-record-4` and `-0`: refused, `outside a verified dword-aligned record`. Controls: - Without the source change, the new case fails with `raw buffer load needs offen with zero scalar offset and no modifiers`. - With the in-record bound removed, the IR assertion fails. ## Evidence and follow-up Source-built words only. The counts on captured requests are local and offline (`compile_dxil ... gfx1013-container-ms-texture-heap`). ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Graphics raw buffer loads accepted IDXEN or OFFEN, not both. With both,
the second address VGPR is a byte offset inside the indexed record:
address = index * stride + offset + immediate, with the stride from the
reflected table SRV as for IDXEN alone. The offset is dword-aligned like
the unindexed raw path, and an access that does not end inside the
record or whose index is past the view reads zero, as a structured
buffer read does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 06:44:09 +00:00
github manually merged commit 1cf631398c into main 2026-12-01 08:47:19 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-01 08:43 UTC · original · approved these changes

Reviewed reflected record stride validation and the within-record byte offset guard. The native_direct_container and native_direct_mesh fixtures passed in the integration. Slot 86 runtime view binding remains a follow-up.

**@⁠R0Y00** on GitHub · 2026-12-01 08:43 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3705#pullrequestreview-6127741962) · **approved these changes** Reviewed reflected record stride validation and the within-record byte offset guard. The native_direct_container and native_direct_mesh fixtures passed in the integration. Slot 86 runtime view binding remains a follow-up.
This discussion has been locked. Commenting is limited to contributors.
No description provided.