shader: accept gathers in the SPIR-V sampler split #1325

Merged
tedin7 merged 3 commits from upstream-pr/1332 into main 2026-11-24 09:06:57 +00:00
tedin7 commented 2026-11-24 08:24:07 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T08:24:07Z.


What

split_comparison_sampler() now accepts OpImageGather (an ordinary use: it moves to the new plain sampler) and OpImageDrefGather (a comparison use: it stays on the comparison sampler) on a sampler shared by comparison and ordinary sampling. Accepted only without image operands, only on 2D, 2D array, cube and cube array images, and the OpImageGather component must be an integer OpConstant from 0 to 3. Everything else, including the checks for the existing sample ops, is unchanged.

Why

A module that gathers on a shared sampler was refused as an unsupported use. D3D12 has Gather and GatherCmp for exactly these image forms, so the split can route each gather to the sampler kind it needs.

Tested

Windows (not run locally): ctest --preset pr --no-tests=error -R spirv_compare_sampler_warp. The Windows/WARP run was NOT done locally. The GPU stage was not extended: it does not read gathered texels, so a gather reading the wrong component or texel would not be caught there, and DXC acceptance of the gather calls is not checked.

Linux (ran): python3 -B tests/spirv_window/compare_sampler.py spirv-as spirv-val spirv-cross (split, spirv-val, spirv-cross: GatherRed/Green/Blue/Alpha on the plain sampler, GatherCmp on the comparison sampler; negative controls for image operands, 1D/3D gathers, non-float32, bad component, mixed kinds; the unsplit gather is rejected by the HLSL check; a temporary mutation routing the ordinary gather to the comparison kind failed the test), tests/spirv_window/check.py, tests/docs_links_check.py, tests/bidi_controls_check.py, py_compile.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6577652456 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1332). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T08:24:07Z. --- ## What `split_comparison_sampler()` now accepts `OpImageGather` (an ordinary use: it moves to the new plain sampler) and `OpImageDrefGather` (a comparison use: it stays on the comparison sampler) on a sampler shared by comparison and ordinary sampling. Accepted only without image operands, only on 2D, 2D array, cube and cube array images, and the `OpImageGather` component must be an integer `OpConstant` from 0 to 3. Everything else, including the checks for the existing sample ops, is unchanged. ## Why A module that gathers on a shared sampler was refused as an unsupported use. D3D12 has Gather and GatherCmp for exactly these image forms, so the split can route each gather to the sampler kind it needs. ## Tested Windows (not run locally): `ctest --preset pr --no-tests=error -R spirv_compare_sampler_warp`. The Windows/WARP run was NOT done locally. The GPU stage was not extended: it does not read gathered texels, so a gather reading the wrong component or texel would not be caught there, and DXC acceptance of the gather calls is not checked. Linux (ran): `python3 -B tests/spirv_window/compare_sampler.py spirv-as spirv-val spirv-cross` (split, spirv-val, spirv-cross: GatherRed/Green/Blue/Alpha on the plain sampler, GatherCmp on the comparison sampler; negative controls for image operands, 1D/3D gathers, non-float32, bad component, mixed kinds; the unsplit gather is rejected by the HLSL check; a temporary mutation routing the ordinary gather to the comparison kind failed the test), `tests/spirv_window/check.py`, `tests/docs_links_check.py`, `tests/bidi_controls_check.py`, py_compile.
R0Y00 commented 2026-11-24 09:04:34 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T08:36:29Z.

Review: CHANGES_REQUESTED


The new revision keeps assembly and SPIR-V validation on Linux and isolates the known older SPIRV-Cross limitation. The protected Windows job passes, but compile_dxil still enumerates only the old sample modules, and draw never runs a gather module. Please require both a plain gather and a comparison gather on the supported Windows path. Use a source-built 2x2 fixture whose four texels and at least two channels differ, check all four returned values, and include a wrong component or comparison reference. Keep the current SPIR-V controls on Linux; those cannot show DXC acceptance or readback order.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6036013122 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1332#pullrequestreview-6036013122). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T08:36:29Z. **Review:** CHANGES_REQUESTED --- The new revision keeps assembly and SPIR-V validation on Linux and isolates the known older SPIRV-Cross limitation. The protected Windows job passes, but compile_dxil still enumerates only the old sample modules, and draw never runs a gather module. Please require both a plain gather and a comparison gather on the supported Windows path. Use a source-built 2x2 fixture whose four texels and at least two channels differ, check all four returned values, and include a wrong component or comparison reference. Keep the current SPIR-V controls on Linux; those cannot show DXC acceptance or readback order.
tedin7 commented 2026-11-24 09:04:45 +00:00 (Migrated from github.com)

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


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

  • Debug (--preset dev):
    • Build (cmake --build --preset dev --target offscreen_check -- -j 6): 3.62s (configure 1.48s)
    • Test (ctest --preset dev -R '^spirv_compare_sampler_warp$' --no-tests=error --output-on-failure): 1/1 passed (3.19s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release --target offscreen_check -- -j 6): 0.94s (configure 1.59s)
    • Test (ctest --preset release -R '^spirv_compare_sampler_warp$' --no-tests=error --output-on-failure): 1/1 passed (3.16s)
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7126146099 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1332#issuecomment-7126146099). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T08:26:54Z. --- Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `2cb2312ab870ae616b0daadcf59dab86622e192b`: - **Debug (`--preset dev`)**: - Build (`cmake --build --preset dev --target offscreen_check -- -j 6`): `3.62s` (configure `1.48s`) - Test (`ctest --preset dev -R '^spirv_compare_sampler_warp$' --no-tests=error --output-on-failure`): **1/1 passed** (`3.19s`) - **Release `/O2` (`--preset release`)**: - Build (`cmake --build --preset release --target offscreen_check -- -j 6`): `0.94s` (configure `1.59s`) - Test (`ctest --preset release -R '^spirv_compare_sampler_warp$' --no-tests=error --output-on-failure`): **1/1 passed** (`3.16s`)
R0Y00 commented 2026-11-24 09:04:45 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T08:28:32Z.


The Linux check fails in the pinned Ubuntu SPIRV-Cross when it emits HLSL for the comparison gather: “GatherCmp does not exist in HLSL.” Please keep all generated modules assembled and validated on Linux. Separate the backend capability from SPIR-V validation and keep the comparison gather HLSL compile and readback required on the supported Windows toolchain. CI should still fail for any other compile error or if comparison gather unexpectedly stops working on that Windows path.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7126179648 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1332#issuecomment-7126179648). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T08:28:32Z. --- The Linux check fails in the pinned Ubuntu SPIRV-Cross when it emits HLSL for the comparison gather: “GatherCmp does not exist in HLSL.” Please keep all generated modules assembled and validated on Linux. Separate the backend capability from SPIR-V validation and keep the comparison gather HLSL compile and readback required on the supported Windows toolchain. CI should still fail for any other compile error or if comparison gather unexpectedly stops working on that Windows path.
tedin7 commented 2026-11-24 09:04:45 +00:00 (Migrated from github.com)

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


Re-verified at ce8d9d00746d855b3a73e4a54d10fc602626bc78 on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP):

  • Debug (--preset dev): offscreen_check build 9.20s; ctest --preset dev -R '^spirv_compare_sampler_warp$' --no-tests=error --output-on-failure: 1/1 passed (3.23s)
  • Release /O2 (--preset release): offscreen_check build 6.53s; ctest --preset release -R '^spirv_compare_sampler_warp$' --no-tests=error --output-on-failure: 1/1 passed (3.14s)
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7126252486 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1332#issuecomment-7126252486). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T08:32:07Z. --- Re-verified at `ce8d9d00746d855b3a73e4a54d10fc602626bc78` on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP): - **Debug (`--preset dev`)**: `offscreen_check` build `9.20s`; `ctest --preset dev -R '^spirv_compare_sampler_warp$' --no-tests=error --output-on-failure`: **1/1 passed** (`3.23s`) - **Release `/O2` (`--preset release`)**: `offscreen_check` build `6.53s`; `ctest --preset release -R '^spirv_compare_sampler_warp$' --no-tests=error --output-on-failure`: **1/1 passed** (`3.14s`)
chatgpt-codex-connector[bot commented 2026-11-24 09:04:46 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T08:27:02Z.


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-24T08:38:03.635641Z ce8d9d0 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:7126148875 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1332#issuecomment-7126148875). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T08:27:02Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"ce8d9d00746d855b3a73e4a54d10fc602626bc78","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-24T08:38:03.635641Z">2026-11-24T08:38:03.635641Z</relative-time> | `ce8d9d0` | 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>
tedin7 commented 2026-11-24 09:04:47 +00:00 (Migrated from github.com)

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


@R0Y00 Addressed in f26519a5aa03efacffb77fdb5031be7047ff7814: compile_dxil and draw now require both a plain gather and a comparison gather on the supported Windows path against a source-built 2x2 fixture with four distinct texels and multiple channels, verifying all four returned values plus a negative control, while keeping SPIR-V assembly/validation on Linux.

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

  • Debug (--preset dev): offscreen_check build 10.18s; ctest --preset dev -R '^spirv_compare_sampler_warp$' --no-tests=error --output-on-failure: 1/1 passed (4.10s)
  • Release /O2 (--preset release): offscreen_check build 7.51s; ctest --preset release -R '^spirv_compare_sampler_warp$' --no-tests=error --output-on-failure: 1/1 passed (4.09s)
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7126556301 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1332#issuecomment-7126556301). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T08:46:58Z. --- @R0Y00 Addressed in `f26519a5aa03efacffb77fdb5031be7047ff7814`: `compile_dxil` and `draw` now require both a plain gather and a comparison gather on the supported Windows path against a source-built 2x2 fixture with four distinct texels and multiple channels, verifying all four returned values plus a negative control, while keeping SPIR-V assembly/validation on Linux. Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at `f26519a5aa03efacffb77fdb5031be7047ff7814`: - **Debug (`--preset dev`)**: `offscreen_check` build `10.18s`; `ctest --preset dev -R '^spirv_compare_sampler_warp$' --no-tests=error --output-on-failure`: **1/1 passed** (`4.10s`) - **Release `/O2` (`--preset release`)**: `offscreen_check` build `7.51s`; `ctest --preset release -R '^spirv_compare_sampler_warp$' --no-tests=error --output-on-failure`: **1/1 passed** (`4.09s`)
upstream-sync closed this pull request 2026-11-24 10:02:21 +00:00
R0Y00 commented 2026-11-24 10:02:21 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T09:05:03Z.

Review: APPROVED


Verified the Windows CI run executes the comparison-sampler CTest. This head requires DXC for both gathers, checks every returned word, and detects a wrong component, comparison reference and texel order. Linux still assembles and validates the modules with its older emitter.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6036371267 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1332#pullrequestreview-6036371267). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T09:05:03Z. **Review:** APPROVED --- Verified the Windows CI run executes the comparison-sampler CTest. This head requires DXC for both gathers, checks every returned word, and detects a wrong component, comparison reference and texel order. Linux still assembles and validates the modules with its older emitter.
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!1325
No description provided.