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

Merged
lukaslw-lab merged 1 commit from upstream-pr/3705 into main 2026-12-01 08:45:03 +00:00
lukaslw-lab commented 2026-12-01 06:38:56 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-01T06:38:56Z.


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 #3703. On the 6 captured slot 86 requests that stopped at raw buffer load needs offen with zero scalar offset and no modifiers, with #3702 and #3704 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 #3703, #3641.

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 #3639 is changing, so I left it out. I'll follow up after #3639, or the #3639 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

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5580495092 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3705). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-12-01T06:38:56Z. --- ## 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 #3703. On the 6 captured slot 86 requests that stopped at `raw buffer load needs offen with zero scalar offset and no modifiers`, with #3702 and #3704 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 #3703, #3641. **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 #3639 is changing, so I left it out. I'll follow up after #3639, or the #3639 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)
R0Y00 commented 2026-12-01 08:43:35 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-01T08:43:35Z.

Review: APPROVED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6127741962 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3705#pullrequestreview-6127741962). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-01T08:43:35Z. **Review:** APPROVED --- 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.
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!3705
No description provided.