shader: accept cache policies on read-only graphics scalar loads (Part of #3814) #3833

Merged
timbot103 merged 2 commits from upstream-pr/3833 into main 2026-12-03 01:50:53 +00:00
timbot103 commented 2026-12-02 08:02:16 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-02T08:02:16Z.


Accepts GFX10 read-only scalar load cache policy bits (DLC bit 14, GLC bit 16, or both) in direct graphics (s_load_dword* opcodes 0..4 and s_buffer_load_dword* opcodes 8..12) while enforcing ISA alignment/range checks and keeping reserved bits, negative immediates, special SOFFSET registers, non-load opcodes, and direct compute cache policies fail-closed (Part of #3814 "unsupported scalar memory addressing").

Part of #3814. Refs #3640, #3641, #3703.
(Opened as Draft per #3514 until an active review slot frees; will reconcile the optional --startup-pixel-words root SRV argument cleanly if #3828 lands first.)

Summary

  • src/gfx1013_compute_native.cpp (decode, Encoding::Smem):
    • Accepts DLC (1 << 14) and GLC (1 << 16) on direct && graphics read-only SMEM load opcodes ((i.op & ~8u) <= 4).
    • Explicitly rejects reserved first-word bits (0x2a000u: bits 13, 15, 17) in graphics mode, enforces i.dst + count <= limit for direct graphics too, and validates DWORD-aligned immediates ((i.b & 3u) == 0), aligned/in-range sbase, and aligned dst (dst % min(count, 4) == 0) on flagged loads.
    • Preserves all existing refusals for negative 21-bit immediates, reserved second-word bits (21..24), special SOFFSET registers (VCC, M0, EXEC), non-load SMEM opcodes, and direct compute cache policies.
  • tests/native_graphics_smem_addressing_check.py + tests/cmake/native_graphics_smem_addressing.cmake + docs/experiments/native-graphics-smem-addressing.md + README.md:
    • native_graphics_smem_addressing_controls (runs in the pr CTest preset): verifies identical DXIL IR with and without DLC/GLC/DLC|GLC across all 10 load opcodes, 36 pixel refusal controls, and compute refusal controls.
    • native_graphics_smem_addressing_warp & native_graphics_smem_addressing_hardware: draws all 10 load opcodes on WARP and RTX 5080 (160 pixels verified per backend + swapped-channel mismatch control).
  • tests/offscreen_check.cpp, tests/startup_flat_param.cpp, tests/desktop_gpu.h:
    • Optional binary root-SRV file argument for --startup-pixel-words bound at t0.

Verification

Host: Windows 11 (10.0.26200.9974), MSVC C++20 /W4 (zero warnings on edited lines), inbox WARP (10.0.26100.9818), NVIDIA GeForce RTX 5080 (32.0.16.2140; D3D12 debug layer unavailable). Base origin/main f365f125.

  • ctest --preset pr --no-tests=error -R "^native_graphics_smem_addressing_controls$": 1/1 passed.
  • Debug (dev) & Release (release): 28/28 passed (2 unrelated LLVM-15 skips, 0 failures) in both configs, plus offscreen_check --self-test passed in both configs.
  • tests/bidi_controls_check.py, tests/docs_links_check.py, git diff --check origin/main..HEAD: all clean.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5602349251 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3833). Originally posted by [timbot103](https://github.com/timbot103) on 2026-12-02T08:02:16Z. --- Accepts GFX10 read-only scalar load cache policy bits (`DLC` bit 14, `GLC` bit 16, or both) in direct graphics (`s_load_dword*` opcodes 0..4 and `s_buffer_load_dword*` opcodes 8..12) while enforcing ISA alignment/range checks and keeping reserved bits, negative immediates, special `SOFFSET` registers, non-load opcodes, and direct compute cache policies fail-closed (Part of #3814 `"unsupported scalar memory addressing"`). Part of #3814. Refs #3640, #3641, #3703. *(Opened as Draft per #3514 until an active review slot frees; will reconcile the optional `--startup-pixel-words` root SRV argument cleanly if #3828 lands first.)* ## Summary - **`src/gfx1013_compute_native.cpp` (`decode`, `Encoding::Smem`):** - Accepts `DLC` (`1 << 14`) and `GLC` (`1 << 16`) on `direct && graphics` read-only SMEM load opcodes (`(i.op & ~8u) <= 4`). - Explicitly rejects reserved first-word bits (`0x2a000u`: bits 13, 15, 17) in graphics mode, enforces `i.dst + count <= limit` for direct graphics too, and validates DWORD-aligned immediates (`(i.b & 3u) == 0`), aligned/in-range `sbase`, and aligned `dst` (`dst % min(count, 4) == 0`) on flagged loads. - Preserves all existing refusals for negative 21-bit immediates, reserved second-word bits (`21..24`), special `SOFFSET` registers (`VCC`, `M0`, `EXEC`), non-load SMEM opcodes, and direct compute cache policies. - **`tests/native_graphics_smem_addressing_check.py` + `tests/cmake/native_graphics_smem_addressing.cmake` + `docs/experiments/native-graphics-smem-addressing.md` + `README.md`:** - `native_graphics_smem_addressing_controls` (runs in the `pr` CTest preset): verifies identical DXIL IR with and without `DLC`/`GLC`/`DLC|GLC` across all 10 load opcodes, 36 pixel refusal controls, and compute refusal controls. - `native_graphics_smem_addressing_warp` & `native_graphics_smem_addressing_hardware`: draws all 10 load opcodes on WARP and RTX 5080 (160 pixels verified per backend + swapped-channel mismatch control). - **`tests/offscreen_check.cpp`, `tests/startup_flat_param.cpp`, `tests/desktop_gpu.h`:** - Optional binary root-SRV file argument for `--startup-pixel-words` bound at `t0`. ## Verification Host: Windows 11 (`10.0.26200.9974`), MSVC C++20 `/W4` (zero warnings on edited lines), inbox WARP (`10.0.26100.9818`), NVIDIA GeForce RTX 5080 (`32.0.16.2140`; D3D12 debug layer unavailable). Base `origin/main` `f365f125`. - `ctest --preset pr --no-tests=error -R "^native_graphics_smem_addressing_controls$"`: **1/1 passed**. - **Debug (`dev`) & Release (`release`):** 28/28 passed (2 unrelated LLVM-15 skips, 0 failures) in both configs, plus `offscreen_check --self-test` passed in both configs. - `tests/bidi_controls_check.py`, `tests/docs_links_check.py`, `git diff --check origin/main..HEAD`: all clean.
lukaslw-lab commented 2026-12-02 08:07:15 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-02T08:07:15Z.

Review: APPROVED


Reviewed 374011e6 (draft) by reading the diff; not built or run.

Verdict: approve. DLC and GLC only change caching. On a load that the read-only binding proof already covers, dropping them gives the same value. No MUST.

  • SHOULD Reuse #3828's harness argument. #3828 adds the same optional 6th --startup-pixel-words argument as comma-separated hex words, and this PR adds it as a file path at the same position (offscreen_check.cpp:1552). Two meanings for one CLI slot will conflict whichever merges second. Taking #3828's form (or the reverse) keeps one contract for startup_flat_param.
  • SHOULD No measured stage count. "Part of" the 116 unsupported scalar memory addressing stages: a ps86 census on f365f125 would show how many of them were only DLC/GLC (follow-up is fine).
  • Checked, no finding:
    • cache_policy is accepted only for direct && graphics (gfx1013_compute_native.cpp:230). Compute keeps the refusal, and so do the non-load opcodes ((i.op & ~8u) > 4).
    • The two new refusals in graphics only refuse more: the reserved first-word bits 13, 15 and 17, and dst + count > limit (a load into VCC). Neither changes a load that translated before.
    • For loads with DLC/GLC: the offset is dword-aligned, sbase is aligned and in range for buffer loads, and sdst is aligned to min(count, 4), as the ISA requires.
    • Harness safety: reads a local file only. The root SRV is added only when the file is given, so the old root signature is unchanged.

Tests: _controls (identical IR with and without DLC/GLC on all 10 opcodes, 36 pixel and the compute refusals) is in the pr filter. _warp/_hardware ran only locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6146866866 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3833#pullrequestreview-6146866866). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-12-02T08:07:15Z. **Review:** APPROVED --- Reviewed `374011e6` (draft) by reading the diff; not built or run. **Verdict: approve.** DLC and GLC only change caching. On a load that the read-only binding proof already covers, dropping them gives the same value. No MUST. - **SHOULD** Reuse #3828's harness argument. #3828 adds the same optional 6th `--startup-pixel-words` argument as comma-separated hex words, and this PR adds it as a file path at the same position (`offscreen_check.cpp:1552`). Two meanings for one CLI slot will conflict whichever merges second. Taking #3828's form (or the reverse) keeps one contract for `startup_flat_param`. - **SHOULD** No measured stage count. "Part of" the 116 `unsupported scalar memory addressing` stages: a `ps86` census on `f365f125` would show how many of them were only DLC/GLC (follow-up is fine). - Checked, no finding: - `cache_policy` is accepted only for `direct && graphics` (`gfx1013_compute_native.cpp:230`). Compute keeps the refusal, and so do the non-load opcodes (`(i.op & ~8u) > 4`). - The two new refusals in graphics only refuse more: the reserved first-word bits 13, 15 and 17, and `dst + count > limit` (a load into VCC). Neither changes a load that translated before. - For loads with DLC/GLC: the offset is dword-aligned, `sbase` is aligned and in range for buffer loads, and `sdst` is aligned to `min(count, 4)`, as the ISA requires. - Harness safety: reads a local file only. The root SRV is added only when the file is given, so the old root signature is unchanged. Tests: `_controls` (identical IR with and without DLC/GLC on all 10 opcodes, 36 pixel and the compute refusals) is in the `pr` filter. `_warp`/`_hardware` ran only locally.
lukaslw-lab commented 2026-12-02 10:34:40 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-02T10:34:40Z.


Census follow-up for the SHOULD in my review: f365f125 + this PR alone, same capture and method as #3814 (6,436 distinct pixel stages). Counts only. None lost, no validation failures.

Build Pixel translated Moved
f365f125 272 —
f365f125 + #3833 272 3

The 116 unsupported scalar memory addressing stages do not move, so on this capture they are not DLC/GLC loads. 3 stages (2 from DPP8, 1 from the wave-mask wall) now stop earlier at the new unsupported scalar memory destination range check. They were refused before too, so this is not a loss. The check is the direct && dst + count > limit test that now also applies to graphics.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7342673834 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3833#issuecomment-7342673834). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-12-02T10:34:40Z. --- Census follow-up for the SHOULD in my review: `f365f125` + this PR alone, same capture and method as #3814 (6,436 distinct pixel stages). Counts only. **None lost**, no validation failures. | Build | Pixel translated | Moved | |---|---:|---:| | `f365f125` | 272 | — | | `f365f125` + #3833 | 272 | 3 | The 116 `unsupported scalar memory addressing` stages do not move, so on this capture they are not DLC/GLC loads. 3 stages (2 from DPP8, 1 from the wave-mask wall) now stop earlier at the new `unsupported scalar memory destination range` check. They were refused before too, so this is not a loss. The check is the `direct && dst + count > limit` test that now also applies to graphics.
lukaslw-lab commented 2026-12-02 20:27:29 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-02T20:27:29Z.

Review: APPROVED


Re-review on 67375f33 (rebased on 5770f14e; the test now passes the root SRV words inline instead of a file).

Verdict: approve.

Census, same capture and method as before (6,436 distinct pixel stages), main 5770f14e vs this head:

Stages
Translate, main / with this PR 272 / 272
Lost / gained 0 / 0
First refusal moved 3 → unsupported scalar memory destination range (2 from DPP8, 1 from graphics branch on a wave mask)

Same as the earlier head. The only change since my review is the test harness: check_startup_flat_param now takes srv_words/srv_count from main, and the fixture data shrank to 64 words with the offsets adjusted to match.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6158376581 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3833#pullrequestreview-6158376581). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-12-02T20:27:29Z. **Review:** APPROVED --- Re-review on `67375f33` (rebased on `5770f14e`; the test now passes the root SRV words inline instead of a file). **Verdict: approve.** Census, same capture and method as before (6,436 distinct pixel stages), main `5770f14e` vs this head: | | Stages | |---|---:| | Translate, main / with this PR | 272 / 272 | | Lost / gained | 0 / 0 | | First refusal moved | 3 → `unsupported scalar memory destination range` (2 from DPP8, 1 from `graphics branch on a wave mask`) | Same as the earlier head. The only change since my review is the test harness: `check_startup_flat_param` now takes `srv_words`/`srv_count` from main, and the fixture data shrank to 64 words with the offsets adjusted to match. AI-assisted.
timbot103 commented 2026-12-02 23:20:53 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-02T23:20:53Z.


Merged main (67862ee4) into this branch. The reviewed commit is unchanged, and no follow-up fix was needed. It keeps this PR's graphics SMEM cache-policy checks and main's named NULL register.

Tests, Windows 11 26200 with RTX 5080 and WARP. The filter was native_pixel_|native_graphics_|native_direct_container plus this PR's own tests. There were 0 failures and 0 skips, with 15 WARP and 12 RTX 5080 tests per configuration. A full Debug build of every target, including the C++17 native_compute_pack_refusal_check, succeeded.

  • Debug passed 39/39 and Release 39/39. The PR preset passed 1/1.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7361879224 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3833#issuecomment-7361879224). Originally posted by [timbot103](https://github.com/timbot103) on 2026-12-02T23:20:53Z. --- Merged `main` (`67862ee4`) into this branch. The reviewed commit is unchanged, and no follow-up fix was needed. It keeps this PR's graphics SMEM cache-policy checks and main's named NULL register. Tests, Windows 11 26200 with RTX 5080 and WARP. The filter was `native_pixel_|native_graphics_|native_direct_container` plus this PR's own tests. There were 0 failures and 0 skips, with 15 WARP and 12 RTX 5080 tests per configuration. A full Debug build of every target, including the C++17 `native_compute_pack_refusal_check`, succeeded. - Debug passed 39/39 and Release 39/39. The PR preset passed 1/1.
timbot103 commented 2026-12-03 01:14:53 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-03T01:14:53Z.


Marked Ready for review now that the previous batch (#3832, #3838, #3839, #3844, #3847) has merged. This keeps us within 5 non-draft PRs per #3514. The branch merges cleanly into current main, and CI is green at this head.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7364124503 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3833#issuecomment-7364124503). Originally posted by [timbot103](https://github.com/timbot103) on 2026-12-03T01:14:53Z. --- Marked Ready for review now that the previous batch (#3832, #3838, #3839, #3844, #3847) has merged. This keeps us within 5 non-draft PRs per #3514. The branch merges cleanly into current main, and CI is green at this head.
R0Y00 commented 2026-12-03 01:50:50 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T01:50:50Z.

Review: APPROVED


Independent MSVC Debug on e9d799c1, Windows 11 build 26300. ctest --preset dev --no-tests=error -j 1 -R '^native_graphics_smem_addressing_(controls|warp|hardware)$' passed 3/3, zero skips. WARP and RTX 4060 Laptop (616.56), debug layer enabled, each matched 10 draws of 16 pixels and rejected the swapped-channel reference. IR is unchanged with DLC/GLC on the supported loads. Temporarily allowing cache flags in compute failed the compute refusal control. The restored binary passed.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6162325534 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3833#pullrequestreview-6162325534). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-03T01:50:50Z. **Review:** APPROVED --- Independent MSVC Debug on e9d799c1, Windows 11 build 26300. `ctest --preset dev --no-tests=error -j 1 -R '^native_graphics_smem_addressing_(controls|warp|hardware)$'` passed 3/3, zero skips. WARP and RTX 4060 Laptop (616.56), debug layer enabled, each matched 10 draws of 16 pixels and rejected the swapped-channel reference. IR is unchanged with DLC/GLC on the supported loads. Temporarily allowing cache flags in compute failed the compute refusal control. The restored binary passed.
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!3833
No description provided.