shader: treat OpImageQueryLod as an ordinary sampler use in the sampler bridge #1355

Merged
tedin7 merged 1 commit from upstream-pr/1362 into main 2026-11-24 09:44:45 +00:00
tedin7 commented 2026-11-24 09:16:54 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T09:16:54Z.


What

read_module in tools/spirv_sampler_views.py now lists OpImageQueryLod next to the OpImageSample*, OpImageGather* and sparse forms as an ordinary use of its sampled image (the sampled image is word 4, as for a sample). tests/spirv_window/sampler.py gains a fragment module with an implicit-derivative OpImageQueryLod and a depth-reference sample on one table. Docs in docs/experiments.md are updated.

Why

HLSL CalculateLevelOfDetail needs a SamplerState. A table used by a query and a comparison sample but by no ordinary sample was returned unchanged, and SPIRV-Cross wrote the query against SamplerComparisonState _3[2] (invalid HLSL). With the change the table is split: the query keeps the SamplerState table and the comparison sample uses the set 3 view. Existing modules produce the same output as before (24 fixture variants compared against origin/main).

Tested

Windows: ctest --preset pr --no-tests=error -R spirv_sampler_views -V (spirv_sampler_views_hardware, spirv_sampler_views_warp). The new module is also compiled with DXC as ps_6_0.

Linux (ran): python3 -B tests/spirv_window/sampler.py spirv-as spirv-val spirv-cross, tests/spirv_window/compare_sampler.py with the same tools, py_compile, tests/docs_links_check.py, tests/bidi_controls_check.py, git diff --check. With the OpImageQueryLod line removed from the tool the new check fails.

NOT run locally: DXC, WARP and hardware readback. No LOD value is drawn (needs a mip-chain texture and a draw case), so that part stays Windows-only. Only the SPIRV-Cross on this machine was used; CI's 2021.01.15 was not. The check accepts any CalculateLevelOfDetail* spelling.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6578507133 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1362). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T09:16:54Z. --- ## What `read_module` in `tools/spirv_sampler_views.py` now lists `OpImageQueryLod` next to the `OpImageSample*`, `OpImageGather*` and sparse forms as an ordinary use of its sampled image (the sampled image is word 4, as for a sample). `tests/spirv_window/sampler.py` gains a fragment module with an implicit-derivative `OpImageQueryLod` and a depth-reference sample on one table. Docs in `docs/experiments.md` are updated. ## Why HLSL `CalculateLevelOfDetail` needs a `SamplerState`. A table used by a query and a comparison sample but by no ordinary sample was returned unchanged, and SPIRV-Cross wrote the query against `SamplerComparisonState _3[2]` (invalid HLSL). With the change the table is split: the query keeps the `SamplerState` table and the comparison sample uses the set 3 view. Existing modules produce the same output as before (24 fixture variants compared against `origin/main`). ## Tested Windows: `ctest --preset pr --no-tests=error -R spirv_sampler_views -V` (`spirv_sampler_views_hardware`, `spirv_sampler_views_warp`). The new module is also compiled with DXC as `ps_6_0`. Linux (ran): `python3 -B tests/spirv_window/sampler.py spirv-as spirv-val spirv-cross`, `tests/spirv_window/compare_sampler.py` with the same tools, py_compile, `tests/docs_links_check.py`, `tests/bidi_controls_check.py`, `git diff --check`. With the `OpImageQueryLod` line removed from the tool the new check fails. NOT run locally: DXC, WARP and hardware readback. No LOD value is drawn (needs a mip-chain texture and a draw case), so that part stays Windows-only. Only the SPIRV-Cross on this machine was used; CI's 2021.01.15 was not. The check accepts any `CalculateLevelOfDetail*` spelling.
upstream-sync closed this pull request 2026-11-24 10:02:30 +00:00
tedin7 commented 2026-11-24 10:02:40 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T09:22:13Z.


Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit e9a84c0dca01bd514503040787007e28a0a67d78:

  • Debug (--preset dev): offscreen_check build 25.63s; ctest --preset dev -R '^spirv_sampler_views_warp$' --no-tests=error --output-on-failure: 1/1 passed (0.78s)
  • Release /O2 (--preset release): offscreen_check build 39.87s; ctest --preset release -R '^spirv_sampler_views_warp$' --no-tests=error --output-on-failure: 1/1 passed (0.68s)
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7127318033 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1362#issuecomment-7127318033). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T09:22:13Z. --- Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `e9a84c0dca01bd514503040787007e28a0a67d78`: - **Debug (`--preset dev`)**: `offscreen_check` build `25.63s`; `ctest --preset dev -R '^spirv_sampler_views_warp$' --no-tests=error --output-on-failure`: **1/1 passed** (`0.78s`) - **Release `/O2` (`--preset release`)**: `offscreen_check` build `39.87s`; `ctest --preset release -R '^spirv_sampler_views_warp$' --no-tests=error --output-on-failure`: **1/1 passed** (`0.68s`)
chatgpt-codex-connector[bot commented 2026-11-24 10:02:40 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T09:22:26Z.


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-24T09:25:35.452449Z e9a84c0 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:7127323033 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1362#issuecomment-7127323033). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T09:22:26Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"e9a84c0dca01bd514503040787007e28a0a67d78","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-24T09:25:35.452449Z">2026-11-24T09:25:35.452449Z</relative-time> | `e9a84c0` | 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>
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!1355
No description provided.