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

Manually merged
github merged 2 commits from github-bot/gh-3833 into gh-pr/3833/base 2026-12-03 01:53:29 +00:00 AGit
Owner

@⁠timbot103 on GitHub · 2026-12-02 08:02 UTC · original
timbot103:shader/graphics-smem-addressing → main · +214 −2 · 5 files · 2 commits · merged 2026-12-03 01:50 UTC

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 #3816 "unsupported scalar memory addressing").

Part of #3816. Refs #3642, #3643, #3705.
(Opened as Draft per #3516 until an active review slot frees; will reconcile the optional --startup-pixel-words root SRV argument cleanly if #3830 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.
**@⁠timbot103** on GitHub · 2026-12-02 08:02 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3833) `timbot103:shader/graphics-smem-addressing` → `main` · +214 −2 · 5 files · 2 commits · merged 2026-12-03 01:50 UTC 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 #3816 `"unsupported scalar memory addressing"`). Part of #3816. Refs #3642, #3643, #3705. *(Opened as Draft per #3516 until an active review slot frees; will reconcile the optional `--startup-pixel-words` root SRV argument cleanly if #3830 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 08:04:15 +00:00
Author
Owner

@⁠lukaslw-lab on GitHub · 2026-12-02 08:07 UTC · original · approved these changes

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 #3830's harness argument. #3830 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 #3830'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** on GitHub · 2026-12-02 08:07 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3833#pullrequestreview-6146866866) · **approved these changes** 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 #3830's harness argument. #3830 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 #3830'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.
Author
Owner

@⁠lukaslw-lab on GitHub · 2026-12-02 10:34 UTC · original

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

Build Pixel translated Moved
f365f125 272 —
f365f125 + #3835 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** on GitHub · 2026-12-02 10:34 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3833#issuecomment-7342673834) Census follow-up for the SHOULD in my review: `f365f125` + this PR alone, same capture and method as #3816 (6,436 distinct pixel stages). Counts only. **None lost**, no validation failures. | Build | Pixel translated | Moved | |---|---:|---:| | `f365f125` | 272 | — | | `f365f125` + #3835 | 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.
Resolve conflicts in tests/desktop_gpu.h, tests/offscreen_check.cpp, and tests/startup_flat_param.cpp with upstream PR #3828 by keeping #3828's comma-separated hex words contract for --startup-pixel-words and adapting tests/native_graphics_smem_addressing_check.py to use it.
github-bot force-pushed github-bot/gh-3833 from 1f672d8eb2 to 67375f335b 2026-12-02 12:37:33 +00:00 Compare
Author
Owner

@⁠lukaslw-lab on GitHub · 2026-12-02 20:27 UTC · original · approved these changes

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.

**@⁠lukaslw-lab** on GitHub · 2026-12-02 20:27 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3833#pullrequestreview-6158376581) · **approved these changes** 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.
Author
Owner

@⁠timbot103 on GitHub · 2026-12-02 23:20 UTC · original

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** on GitHub · 2026-12-02 23:20 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3833#issuecomment-7361879224) 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.
Author
Owner

@⁠timbot103 on GitHub · 2026-12-03 01:14 UTC · original

Marked Ready for review now that the previous batch (#3834, #3840, #3841, #3846, #3849) has merged. This keeps us within 5 non-draft PRs per #3516. The branch merges cleanly into current main, and CI is green at this head.

**@⁠timbot103** on GitHub · 2026-12-03 01:14 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3833#issuecomment-7364124503) Marked Ready for review now that the previous batch (#3834, #3840, #3841, #3846, #3849) has merged. This keeps us within 5 non-draft PRs per #3516. The branch merges cleanly into current main, and CI is green at this head.
github-bot changed target branch from main to gh-pr/3833/base 2026-12-03 01:53:27 +00:00
github manually merged commit e9d799c1f9 into gh-pr/3833/base 2026-12-03 01:53:29 +00:00
Author
Owner

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

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.

**@⁠R0Y00** on GitHub · 2026-12-03 01:50 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3833#pullrequestreview-6162325534) · **approved these changes** 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.
This discussion has been locked. Commenting is limited to contributors.
No description provided.