shader: lower image_sample_lz in the sampled coverage translator #1284

Merged
tedin7 merged 1 commit from upstream-pr/1291 into main 2026-11-24 08:36:00 +00:00
tedin7 commented 2026-11-24 06:58:32 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T06:58:32Z.


What

tools/sampled_coverage_aot.py accepts image_sample_lz with exactly the operand pattern of image_sample (one 2D coordinate pair, one single-channel dmask, the fixture sampler) and lowers it to texN.SampleLevel(samp,uv,0).<channel> instead of texN.Sample(samp,uv).<channel>. The regex is unchanged, so every modifier that is not modelled is refused as before. All other conditions (quad mask, wait counts, one sample per program) are unchanged and shared by both opcodes; an image_sample and an image_sample_lz in one program are refused like two plain samples.

Why

The explicit-level zero variant is the same sample without an implicit derivative, and was refused with Unsupported coverage instruction image_sample_lz.

Tested

Linux (LLVM 19, no D3D12):

  • python3 -B tests/sampled_coverage_check.py binary llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so: passed. It assembles the lz program with gfx1013, runs the translator command on both textures and compares with lower. It also assembles and refuses tfe, a16, lwe, d16, r128, unorm, glc, slc, dlc, a two-channel dmask, a 3D dimension, image_sample_o, image_sample_lz_o and image_sample_l for both opcodes. da and a 2D array dimension are refused at the translator-level check only (LLVM 19 does not assemble them).
  • The same file's controls check that the lz lowering equals the implicit lowering with only the call replaced (both textures, red channel), and that a lowering using .Sample fails the check. I also ran it with the lz entry temporarily mapped to Sample(samp,uv): the controls failed, then I restored it.
  • python3 -B tests/docs_links_check.py, python3 -B tests/bidi_controls_check.py, py_compile.

Windows (not run locally):

ctest --preset dev --no-tests=error -R '^sampled_coverage_' -V

The WARP/hardware draw was NOT run locally: no Windows here. The new draw repeats the first readback with the lz program on texture 0. The textures have one mip and the draw is one-to-one, so the draw cannot tell SampleLevel(0) from Sample; only the Linux checks distinguish them. The CTest timeout (150 s) was not re-measured with the extra six renderer runs.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6576437695 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1291). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T06:58:32Z. --- ## What `tools/sampled_coverage_aot.py` accepts `image_sample_lz` with exactly the operand pattern of `image_sample` (one 2D coordinate pair, one single-channel dmask, the fixture sampler) and lowers it to `texN.SampleLevel(samp,uv,0).<channel>` instead of `texN.Sample(samp,uv).<channel>`. The regex is unchanged, so every modifier that is not modelled is refused as before. All other conditions (quad mask, wait counts, one sample per program) are unchanged and shared by both opcodes; an `image_sample` and an `image_sample_lz` in one program are refused like two plain samples. ## Why The explicit-level zero variant is the same sample without an implicit derivative, and was refused with `Unsupported coverage instruction image_sample_lz`. ## Tested Linux (LLVM 19, no D3D12): - `python3 -B tests/sampled_coverage_check.py binary llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so`: passed. It assembles the lz program with gfx1013, runs the translator command on both textures and compares with `lower`. It also assembles and refuses tfe, a16, lwe, d16, r128, unorm, glc, slc, dlc, a two-channel dmask, a 3D dimension, image_sample_o, image_sample_lz_o and image_sample_l for both opcodes. `da` and a 2D array dimension are refused at the translator-level check only (LLVM 19 does not assemble them). - The same file's controls check that the lz lowering equals the implicit lowering with only the call replaced (both textures, red channel), and that a lowering using `.Sample` fails the check. I also ran it with the lz entry temporarily mapped to `Sample(samp,uv)`: the controls failed, then I restored it. - `python3 -B tests/docs_links_check.py`, `python3 -B tests/bidi_controls_check.py`, py_compile. Windows (not run locally): ``` ctest --preset dev --no-tests=error -R '^sampled_coverage_' -V ``` The WARP/hardware draw was NOT run locally: no Windows here. The new draw repeats the first readback with the lz program on texture 0. The textures have one mip and the draw is one-to-one, so the draw cannot tell SampleLevel(0) from Sample; only the Linux checks distinguish them. The CTest timeout (150 s) was not re-measured with the extra six renderer runs.
tedin7 commented 2026-11-24 07:07:42 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T07:00:53Z.


Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207, D3D12 WARP) at 50430a15:

  • Debug (--preset dev): ctest --preset dev -R "^sampled_coverage_warp$" — 1/1 PASS (10.30s)
  • Release /O2 (--preset release): ctest --preset release -R "^sampled_coverage_warp$" — 1/1 PASS (9.97s, build 0.35s)
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7124522498 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1291#issuecomment-7124522498). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T07:00:53Z. --- Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207, D3D12 WARP) at `50430a15`: - Debug (`--preset dev`): `ctest --preset dev -R "^sampled_coverage_warp$"` — **1/1 PASS** (`10.30s`) - Release `/O2` (`--preset release`): `ctest --preset release -R "^sampled_coverage_warp$"` — **1/1 PASS** (`9.97s`, build `0.35s`)
chatgpt-codex-connector[bot commented 2026-11-24 07:07:43 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T07:01:03Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T07:04:07.170716Z 50430a1 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7124525524 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1291#issuecomment-7124525524). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T07:01:03Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"50430a1505333b48e8a3a5ca72771e3ab941e2ac","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-24T07:04:07.170716Z">2026-11-24T07:04:07.170716Z</relative-time> | `50430a1` | Draft marked ready | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
upstream-sync closed this pull request 2026-11-24 09:04:23 +00:00
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!1284
No description provided.