shader: allow several samples of one bound texture in pixel_aot #1695

Merged
henriazz10 merged 2 commits from upstream-pr/1702 into main 2026-11-24 17:43:47 +00:00
henriazz10 commented 2026-11-24 17:24:51 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by henriazz10 on 2026-11-24T17:24:51Z.


Change

Refs #730. Per the latest comment, tools/pixel_aot.py requires the number of samples to equal the number of bound textures. With one shadow map, that rules out multi-tap PCF. This PR relaxes only that rule.

  • lower() now records which bound textures were sampled. The final check requires every bound texture (tex, plus tex1 with a second descriptor) to be sampled at least once, instead of samples == len(bindings). A texture may therefore take more than one sample.
  • These rules are unchanged:
    • --no-texture still requires zero samples.
    • A gather is still the program's only sample. A sample before it is refused when the gather is lowered, and a sample after it fails with Expected one gather for the declared view.
    • Comparison and ordinary samples still cannot be mixed.
    • A declared second texture that is never sampled is refused.

Verification

Commit a4a0b1c7, rebased onto cb6f71d4. The GPU draws and the LLVM 15 run below were measured with the same change on 80f413a7. Between the two bases, only other sections of docs/experiments.md changed among the touched files, and both control scripts were re-run on a4a0b1c7. Windows 11 build 26300, VS 2019 Build Tools 16.11 (MSVC 14.29), DXC 1.8.2502.11, Python 3.12, D3D12 debug layer enabled. offscreen_check was built from main; this PR does not change it.

python -B tests/pixel_compare_sample_check.py draw <dxc> <offscreen_check> warp
python -B tests/pixel_compare_sample_check.py draw <dxc> <offscreen_check> hardware
python -B tests/pixel_aot_check.py draw-core <dxc> <offscreen_check> warp
python -B tests/pixel_aot_check.py draw-core <dxc> <offscreen_check> hardware
python -B tests/pixel_aot_check.py
python -B tests/pixel_compare_sample_check.py
Backend Adapter / driver pixel_compare_sample_check.py draw pixel_aot_check.py draw-core
WARP Microsoft Basic Render Driver exit 0, debug_errors=0 exit 0
hardware NVIDIA GeForce RTX 5080, 32.0.16.1692 exit 0, debug_errors=0 exit 0

No capability skips. Both control modes (no arguments) exit 0.

The LLVM 15 round trip ran in Ubuntu 22.04 with llvm-15 15.0.7 from apt, as in the Linux CI job:

python3 -B tests/pixel_compare_sample_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1   # exit 0
python3 -B tests/pixel_aot_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1              # exit 0

These run the new PCF program (gfx1030) and the two new gfx1013 multi-tap fixtures.

Evidence

  • Two-tap PCF (gfx1030), tests/pixel_compare_sample_check.py.
    • The program takes an image_sample_c_lz tap and an image_sample_c_lz_o tap at (1, -2) from the same depth texture and exports their mean.
    • The CPU reference is the mean of the two existing per-tap references, which compare each texel before filtering.
    • The draw covers point and bilinear sampling, at 8×8 and 16×16.
    • Two controls must produce pixel_mismatch, and do on both adapters:
      • the one-tap expectation: point at (3, 0) and (6, 0), bilinear at (3, 0) and (5, 0);
      • a shader whose second tap lost its offset.
    • It runs inside the existing pixel_aot_compare_sample_{warp,hardware} CTest entries, so CMakeLists.txt does not change.
  • Two taps on one texture (gfx1013), tests/pixel_aot_check.py.
    • A two-tap image_sample_lz draw is part of draw-core and checks all 64 pixels. A one-tap expectation must mismatch at (8, 0).
    • It also adds an image_sample_c_lz two-tap translation control and a dual-texture program that samples tex twice and tex1 once.
    • Refusals:
      • the multi-tap program with a second texture declared but never sampled;
      • the same program with --no-texture;
      • an ordinary sample before or after a gather.
  • Negative control. With tools/pixel_aot.py reverted to main, both control scripts fail on the new fixtures with Unexpected sample count or missing color export.

docs/experiments.md records the rule change next to the comparison-sample section.

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 (docs/experiments.md).
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted (Gemini CLI wrote the translator change and the pixel_aot_check.py fixtures; Claude Code, Claude Opus 5.5, added the PCF draw, the docs, rebased and ran the checks). The measurements above come from the machine described in Verification.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6587549447 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1702). Originally posted by [henriazz10](https://github.com/henriazz10) on 2026-11-24T17:24:51Z. --- ## Change Refs #730. Per [the latest comment](https://github.com/R0Y00/Xbox2Windows/issues/730), `tools/pixel_aot.py` requires the number of samples to equal the number of bound textures. With one shadow map, that rules out multi-tap PCF. This PR relaxes only that rule. - `lower()` now records which bound textures were sampled. The final check requires every bound texture (`tex`, plus `tex1` with a second descriptor) to be sampled at least once, instead of `samples == len(bindings)`. A texture may therefore take more than one sample. - These rules are unchanged: - `--no-texture` still requires zero samples. - A gather is still the program's only sample. A sample before it is refused when the gather is lowered, and a sample after it fails with `Expected one gather for the declared view`. - Comparison and ordinary samples still cannot be mixed. - A declared second texture that is never sampled is refused. ## Verification Commit `a4a0b1c7`, rebased onto `cb6f71d4`. The GPU draws and the LLVM 15 run below were measured with the same change on `80f413a7`. Between the two bases, only other sections of `docs/experiments.md` changed among the touched files, and both control scripts were re-run on `a4a0b1c7`. Windows 11 build 26300, VS 2019 Build Tools 16.11 (MSVC 14.29), DXC 1.8.2502.11, Python 3.12, D3D12 debug layer enabled. `offscreen_check` was built from `main`; this PR does not change it. ```powershell python -B tests/pixel_compare_sample_check.py draw <dxc> <offscreen_check> warp python -B tests/pixel_compare_sample_check.py draw <dxc> <offscreen_check> hardware python -B tests/pixel_aot_check.py draw-core <dxc> <offscreen_check> warp python -B tests/pixel_aot_check.py draw-core <dxc> <offscreen_check> hardware python -B tests/pixel_aot_check.py python -B tests/pixel_compare_sample_check.py ``` | Backend | Adapter / driver | `pixel_compare_sample_check.py draw` | `pixel_aot_check.py draw-core` | |---|---|---|---| | WARP | Microsoft Basic Render Driver | exit 0, `debug_errors=0` | exit 0 | | hardware | NVIDIA GeForce RTX 5080, 32.0.16.1692 | exit 0, `debug_errors=0` | exit 0 | No capability skips. Both control modes (no arguments) exit 0. The LLVM 15 round trip ran in Ubuntu 22.04 with `llvm-15` 15.0.7 from apt, as in the Linux CI job: ```sh python3 -B tests/pixel_compare_sample_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1 # exit 0 python3 -B tests/pixel_aot_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1 # exit 0 ``` These run the new PCF program (gfx1030) and the two new gfx1013 multi-tap fixtures. ## Evidence - **Two-tap PCF (gfx1030), `tests/pixel_compare_sample_check.py`.** - The program takes an `image_sample_c_lz` tap and an `image_sample_c_lz_o` tap at `(1, -2)` from the same depth texture and exports their mean. - The CPU reference is the mean of the two existing per-tap references, which compare each texel before filtering. - The draw covers point and bilinear sampling, at 8×8 and 16×16. - Two controls must produce `pixel_mismatch`, and do on both adapters: - the one-tap expectation: point at (3, 0) and (6, 0), bilinear at (3, 0) and (5, 0); - a shader whose second tap lost its offset. - It runs inside the existing `pixel_aot_compare_sample_{warp,hardware}` CTest entries, so `CMakeLists.txt` does not change. - **Two taps on one texture (gfx1013), `tests/pixel_aot_check.py`.** - A two-tap `image_sample_lz` draw is part of `draw-core` and checks all 64 pixels. A one-tap expectation must mismatch at (8, 0). - It also adds an `image_sample_c_lz` two-tap translation control and a dual-texture program that samples `tex` twice and `tex1` once. - Refusals: - the multi-tap program with a second texture declared but never sampled; - the same program with `--no-texture`; - an ordinary sample before or after a gather. - **Negative control.** With `tools/pixel_aot.py` reverted to `main`, both control scripts fail on the new fixtures with `Unexpected sample count or missing color export`. `docs/experiments.md` records the rule change next to the comparison-sample section. ## 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 (`docs/experiments.md`). - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted (Gemini CLI wrote the translator change and the `pixel_aot_check.py` fixtures; Claude Code, Claude Opus 5.5, added the PCF draw, the docs, rebased and ran the checks). The measurements above come from the machine described in Verification. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
upstream-sync closed this pull request 2026-11-24 18:02:38 +00:00
tedin7 commented 2026-11-24 18:02:39 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T17:30:17Z.

Review: COMMENTED


Review of head a4a0b1c761128c408dee85fa2d4b133b277fd05f. Verdict: 0 P1, 0 P2 for the translator change; the draw-level claims are unverified here.

Linux limits. Linux x86_64, llvm-mc-19 / libLLVM-19 (CI pins 15), Python 3.14. No Windows, no DXC, no GPU: I could NOT run check_multitap_sample_draw or draw_pcf, so the PCF average, the one-tap controls and the mutant-offset controls are not executed by me, and neither is any pixel result.

The change. tools/pixel_aot.py replaces samples != len(bindings) with sampled_textures != set(bindings.values()) or (not bindings and samples): every bound texture must be sampled at least once instead of exactly once. Sample, get_lod, comparison and gather all record the texture. I read this as correct: a texture that is bound but never sampled is still refused, and the gather/comparison/plain mixing rules are unchanged.

What I ran

  • pixel_aot_check._check_controls_inline (the function holding the new asserts): passes in 2.6 s, 102 MB.
  • python3 -B tests/pixel_compare_sample_check.py (controls): passes. ... binary llvm-mc-19 llvm-objcopy-19 libLLVM-19.so: passes, three comparison forms plus the PCF fixture assemble and decode back to the same image_* lines.
  • The two new pixel_aot_check fixtures (two image_sample_lz taps; two image_sample_c_lz taps) assembled with llvm-mc-19 -mcpu=gfx1030 -mattr=+wavefrontsize64 and decoded back with the in-tree decoder: identical text. check_binary() as a whole stops earlier, at check_f16_cvt_int16_binary (an 0xfff0 literal encoding differs under LLVM 19); that fixture is unrelated to this PR and I did not check main.
  • Hazards, probed by hand: two taps with s_waitcnt vmcnt(1) that read both results are refused (Sample used before vmcnt wait); reading only the first tap after vmcnt(1) is accepted; no wait at all is refused. RDNA2 returns sample results in order, so the second behavior is right.
  • git diff --check clean; docs_links_check and bidi_controls_check pass. The diff has one non-ASCII character (× in docs/experiments.md).
  • Mutations on tools/pixel_aot.py (inline controls + compare controls, restored with git checkout -- .):
    • sampled_textures != set(bindings.values()) -> not sampled_textures (any one sample is enough): FAILED (the dual-texture "second texture never sampled" control).
    • comparison path stops recording "tex": FAILED (PCF and multi-tap fixtures refused).
    • or (not bindings and samples) removed: PASSED, not caught. I believe the clause is unreachable, since a sample with no bound texture is refused earlier (offset not in bindings); it is harmless but untested.

Notes

  • The one-tap and mutant controls in draw_pcf and the multi-tap draw only prove anything on a GPU run; please run them on Windows (pixel_compare_sample_check.py draw, check_render) before relying on the PCF numbers.
  • Offset byte 0x3e01 decodes to x=+1, y=-2, matching the int2(1, -2) the check asserts.

Not approving (comment only).

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6044214223 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1702#pullrequestreview-6044214223). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T17:30:17Z. **Review:** COMMENTED --- Review of head `a4a0b1c761128c408dee85fa2d4b133b277fd05f`. **Verdict: 0 P1, 0 P2** for the translator change; the draw-level claims are unverified here. **Linux limits.** Linux x86_64, `llvm-mc-19` / libLLVM-19 (CI pins 15), Python 3.14. No Windows, no DXC, no GPU: I could NOT run `check_multitap_sample_draw` or `draw_pcf`, so the PCF average, the one-tap controls and the mutant-offset controls are not executed by me, and neither is any pixel result. **The change.** `tools/pixel_aot.py` replaces `samples != len(bindings)` with `sampled_textures != set(bindings.values()) or (not bindings and samples)`: every bound texture must be sampled at least once instead of exactly once. Sample, get_lod, comparison and gather all record the texture. I read this as correct: a texture that is bound but never sampled is still refused, and the gather/comparison/plain mixing rules are unchanged. **What I ran** - `pixel_aot_check._check_controls_inline` (the function holding the new asserts): passes in 2.6 s, 102 MB. - `python3 -B tests/pixel_compare_sample_check.py` (controls): passes. `... binary llvm-mc-19 llvm-objcopy-19 libLLVM-19.so`: passes, three comparison forms plus the PCF fixture assemble and decode back to the same `image_*` lines. - The two new `pixel_aot_check` fixtures (two `image_sample_lz` taps; two `image_sample_c_lz` taps) assembled with `llvm-mc-19 -mcpu=gfx1030 -mattr=+wavefrontsize64` and decoded back with the in-tree decoder: identical text. `check_binary()` as a whole stops earlier, at `check_f16_cvt_int16_binary` (an `0xfff0` literal encoding differs under LLVM 19); that fixture is unrelated to this PR and I did not check `main`. - Hazards, probed by hand: two taps with `s_waitcnt vmcnt(1)` that read both results are refused (`Sample used before vmcnt wait`); reading only the first tap after `vmcnt(1)` is accepted; no wait at all is refused. RDNA2 returns sample results in order, so the second behavior is right. - `git diff --check` clean; `docs_links_check` and `bidi_controls_check` pass. The diff has one non-ASCII character (`×` in `docs/experiments.md`). - Mutations on `tools/pixel_aot.py` (inline controls + compare controls, restored with `git checkout -- .`): - `sampled_textures != set(bindings.values())` -> `not sampled_textures` (any one sample is enough): FAILED (the dual-texture "second texture never sampled" control). - comparison path stops recording `"tex"`: FAILED (PCF and multi-tap fixtures refused). - `or (not bindings and samples)` removed: PASSED, not caught. I believe the clause is unreachable, since a sample with no bound texture is refused earlier (`offset not in bindings`); it is harmless but untested. **Notes** - The one-tap and mutant controls in `draw_pcf` and the multi-tap draw only prove anything on a GPU run; please run them on Windows (`pixel_compare_sample_check.py draw`, `check_render`) before relying on the PCF numbers. - Offset byte `0x3e01` decodes to x=+1, y=-2, matching the `int2(1, -2)` the check asserts. Not approving (comment only). AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-24 18:02:39 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T17:43:12Z.

Review: COMMENTED


Verified head 6dbe718da5840b5b6fae6cb97554af487348cd8c (docs/experiments.md, tests/pixel_aot_check.py, tests/pixel_compare_sample_check.py, tools/pixel_aot.py; 0 P1, 0 P2).

Linux checks

  • git diff --check origin/main...HEAD: clean.
  • python3 tests/docs_links_check.py: pass (17 Markdown files, 364 links).
  • python3 tests/bidi_controls_check.py: pass (1288 files).
  • python3 -B tests/pixel_compare_sample_check.py: pass.
  • python3 -B tests/pixel_compare_sample_check.py binary llvm-mc-19 llvm-objcopy-19 libLLVM-19.so: pass (all 3 comparison forms + two-tap PCF fixture assembled and decoded).
  • pixel_aot_check._check_controls_inline: pass (multi-tap image_sample_lz, multi-tap image_sample_c_lz, dual-texture multi-tap, unsampled second-texture refusal, gather mixing refusals).
  • Local mutations on tools/pixel_aot.py (each tested and reverted with git checkout -- .):
    • sampled_textures != set(bindings.values()) -> (bindings and not sampled_textures): FAIL in pixel_aot_check._check_controls_inline (dual-texture unsampled-second control).
    • drop sampled_textures.add("tex") in comparison sample path: FAIL in tests/pixel_compare_sample_check.py (Unexpected sample count or missing color export).

Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP)

  • Windows Python check tests/pixel_compare_sample_check.py: pass (3.26s).
  • Debug (--preset dev): build offscreen_check ok (3.34s), ctest --preset dev -R '^(pixel_aot_warp|pixel_aot_compare_sample_warp)$': 2/2 passed (pixel_aot_compare_sample_warp 10.76s, pixel_aot_warp 13.51s).
  • Release /O2 (--preset release): build offscreen_check ok (0.97s), ctest --preset release -R '^(pixel_aot_warp|pixel_aot_compare_sample_warp)$': 2/2 passed (pixel_aot_compare_sample_warp 10.87s, pixel_aot_warp 13.35s).

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6044395895 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1702#pullrequestreview-6044395895). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T17:43:12Z. **Review:** COMMENTED --- Verified head `6dbe718da5840b5b6fae6cb97554af487348cd8c` (`docs/experiments.md`, `tests/pixel_aot_check.py`, `tests/pixel_compare_sample_check.py`, `tools/pixel_aot.py`; 0 P1, 0 P2). **Linux checks** - `git diff --check origin/main...HEAD`: clean. - `python3 tests/docs_links_check.py`: pass (17 Markdown files, 364 links). - `python3 tests/bidi_controls_check.py`: pass (1288 files). - `python3 -B tests/pixel_compare_sample_check.py`: pass. - `python3 -B tests/pixel_compare_sample_check.py binary llvm-mc-19 llvm-objcopy-19 libLLVM-19.so`: pass (all 3 comparison forms + two-tap PCF fixture assembled and decoded). - `pixel_aot_check._check_controls_inline`: pass (multi-tap `image_sample_lz`, multi-tap `image_sample_c_lz`, dual-texture multi-tap, unsampled second-texture refusal, gather mixing refusals). - Local mutations on `tools/pixel_aot.py` (each tested and reverted with `git checkout -- .`): - `sampled_textures != set(bindings.values())` -> `(bindings and not sampled_textures)`: FAIL in `pixel_aot_check._check_controls_inline` (dual-texture unsampled-second control). - drop `sampled_textures.add("tex")` in comparison sample path: FAIL in `tests/pixel_compare_sample_check.py` (`Unexpected sample count or missing color export`). **Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP)** - Windows Python check `tests/pixel_compare_sample_check.py`: pass (`3.26s`). - Debug (`--preset dev`): build `offscreen_check` ok (`3.34s`), `ctest --preset dev -R '^(pixel_aot_warp|pixel_aot_compare_sample_warp)$'`: **2/2 passed** (`pixel_aot_compare_sample_warp` `10.76s`, `pixel_aot_warp` `13.51s`). - Release `/O2` (`--preset release`): build `offscreen_check` ok (`0.97s`), `ctest --preset release -R '^(pixel_aot_warp|pixel_aot_compare_sample_warp)$'`: **2/2 passed** (`pixel_aot_compare_sample_warp` `10.87s`, `pixel_aot_warp` `13.35s`). AI-assisted; commands listed were executed locally.
henriazz10 commented 2026-11-24 18:02:59 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by henriazz10 on 2026-11-24T17:40:42Z.


Thanks for the review and the mutation runs.

  • or (not bindings and samples): removed in 6dbe718d. It was redundant as well as unreachable: with no binding, any recorded sample already makes sampled_textures differ from the empty set. Both control scripts still pass after the change.
  • GPU draws: these ran on Windows before the PR was opened, on 80f413a7 with the same translator change. The results are in the Verification table. The debug layer was enabled, and no run was skipped for a missing capability.
    • pixel_compare_sample_check.py draw (including draw_pcf): exit 0 on WARP and on an RTX 5080 (driver 32.0.16.1692), with debug_errors=0. The PCF matched the averaged CPU reference for point and bilinear sampling, at 8×8 and 16×16. The controls failed at their first mismatching pixel:
      • the one-tap expectation, on both filters: point at (3, 0) at 8×8 and (6, 0) at 16×16; bilinear at (3, 0) and (5, 0);
      • the second tap without its offset: the same pixels.
    • pixel_aot_check.py draw-core (including check_multitap_sample_draw): exit 0 on both adapters. The one-tap expectation mismatched at (8, 0).
  • check_f16_cvt_int16_binary under LLVM 19: I ran pixel_aot_check.py binary only with LLVM 15.0.7, as pinned by CI, where it exits 0. I have not looked at the LLVM 19 0xfff0 difference, and it is outside this PR.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7139544944 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1702#issuecomment-7139544944). Originally posted by [henriazz10](https://github.com/henriazz10) on 2026-11-24T17:40:42Z. --- Thanks for the review and the mutation runs. - **`or (not bindings and samples)`:** removed in `6dbe718d`. It was redundant as well as unreachable: with no binding, any recorded sample already makes `sampled_textures` differ from the empty set. Both control scripts still pass after the change. - **GPU draws:** these ran on Windows before the PR was opened, on `80f413a7` with the same translator change. The results are in the Verification table. The debug layer was enabled, and no run was skipped for a missing capability. - `pixel_compare_sample_check.py draw` (including `draw_pcf`): exit 0 on WARP and on an RTX 5080 (driver 32.0.16.1692), with `debug_errors=0`. The PCF matched the averaged CPU reference for point and bilinear sampling, at 8×8 and 16×16. The controls failed at their first mismatching pixel: - the one-tap expectation, on both filters: point at (3, 0) at 8×8 and (6, 0) at 16×16; bilinear at (3, 0) and (5, 0); - the second tap without its offset: the same pixels. - `pixel_aot_check.py draw-core` (including `check_multitap_sample_draw`): exit 0 on both adapters. The one-tap expectation mismatched at (8, 0). - **`check_f16_cvt_int16_binary` under LLVM 19:** I ran `pixel_aot_check.py binary` only with LLVM 15.0.7, as pinned by CI, where it exits 0. I have not looked at the LLVM 19 `0xfff0` difference, and it is outside this PR. AI-assisted (Claude Code).
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!1695
No description provided.