shader: split shared comparison samplers on Texture2DArray images #1072

Merged
tedin7 merged 1 commit from upstream-pr/1079 into main 2026-11-24 00:47:39 +00:00
tedin7 commented 2026-11-24 00:28:05 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T00:28:05Z.


Change

split_comparison_sampler() in tools/spirv_sampler_split.py now accepts arrayed 2D images (Texture2DArray) as well as Texture2D, so a standalone sampler shared by depth-comparison and ordinary sampling can be split when the images are arrays. Previously the pass rejected any arrayed image with "only non-array float32 Texture2D sampling is supported". The pass does not touch the coordinate operand, so no other logic changes. Multisampled and 3D images are still rejected.

Follow-up to the merged sampler split work (#681, #960, #978). No overlapping open PR found (searched open PRs for sampler and Texture2DArray).

This change was AI-assisted.

Verification

Linux, SPIRV-Tools and SPIRV-Cross from apt:

  • python3 -B tests/spirv_window/compare_sampler.py spirv-as spirv-val spirv-cross prints shared and lowered SPIR-V validated; comparison s2, ordinary s5; controls passed.
  • python3 -B tests/spirv_window/check.py passes.
  • Negative control: on origin/main without the tools/ change, the new controls fail with %34: only non-array float32 Texture2D sampling is supported. With the change they pass.
  • The lowered arrayed module passes spirv-val --target-env vulkan1.2, and SPIRV-Cross emits Texture2DArray, two SampleCmpLevelZero calls on the comparison sampler and one SampleLevel on the new ordinary sampler.

Not run: DXC compile and the GPU readback (Windows only). The GPU stage still runs only the Texture2D module.

Evidence and follow-up

  • New fixture tests/spirv_window/shared_sampler_array.spvasm is synthetic: the existing source-built shared-sampler module edited by hand so both images are arrayed and the coordinate is a float3 at layer 0. The equivalent HLSL is in its header. Same license as the repo.
  • The old control that expected an arrayed image to be rejected is replaced by controls that reject multisampled, 3D and arrayed-multisampled images, since arrayed images are now intended behavior.
  • Docs updated in docs/experiments.md.
  • Follow-up for anyone with Windows: add a GPU readback of the arrayed module.

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.
  • I did not include game files, dumps, distribution links or secrets.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6571778265 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1079). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T00:28:05Z. --- ## Change `split_comparison_sampler()` in `tools/spirv_sampler_split.py` now accepts arrayed 2D images (`Texture2DArray`) as well as `Texture2D`, so a standalone sampler shared by depth-comparison and ordinary sampling can be split when the images are arrays. Previously the pass rejected any arrayed image with "only non-array float32 Texture2D sampling is supported". The pass does not touch the coordinate operand, so no other logic changes. Multisampled and 3D images are still rejected. Follow-up to the merged sampler split work (#681, #960, #978). No overlapping open PR found (searched open PRs for sampler and Texture2DArray). This change was AI-assisted. ## Verification Linux, SPIRV-Tools and SPIRV-Cross from apt: - `python3 -B tests/spirv_window/compare_sampler.py spirv-as spirv-val spirv-cross` prints `shared and lowered SPIR-V validated; comparison s2, ordinary s5; controls passed`. - `python3 -B tests/spirv_window/check.py` passes. - Negative control: on `origin/main` without the `tools/` change, the new controls fail with `%34: only non-array float32 Texture2D sampling is supported`. With the change they pass. - The lowered arrayed module passes `spirv-val --target-env vulkan1.2`, and SPIRV-Cross emits `Texture2DArray`, two `SampleCmpLevelZero` calls on the comparison sampler and one `SampleLevel` on the new ordinary sampler. Not run: DXC compile and the GPU readback (Windows only). The GPU stage still runs only the `Texture2D` module. ## Evidence and follow-up - New fixture `tests/spirv_window/shared_sampler_array.spvasm` is synthetic: the existing source-built shared-sampler module edited by hand so both images are arrayed and the coordinate is a float3 at layer 0. The equivalent HLSL is in its header. Same license as the repo. - The old control that expected an arrayed image to be rejected is replaced by controls that reject multisampled, 3D and arrayed-multisampled images, since arrayed images are now intended behavior. - Docs updated in `docs/experiments.md`. - Follow-up for anyone with Windows: add a GPU readback of the arrayed module. ## 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. - [x] I did not include game files, dumps, distribution links or secrets.
upstream-sync closed this pull request 2026-11-24 06:46:11 +00:00
chatgpt-codex-connector[bot commented 2026-11-24 06:49:57 +00:00 (Migrated from github.com)

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


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-24T00:30:43.032954Z e7a90c1 PR opened
ℹ️ 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:7118103741 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1079#issuecomment-7118103741). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T00:28:22Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"e7a90c15f1256e3cb0e18a992322155f500a6e15","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-24T00:30:43.032954Z">2026-11-24T00:30:43.032954Z</relative-time> | `e7a90c1` | PR opened | <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>
Jess-Doit commented 2026-11-24 06:49:58 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-24T00:56:56Z.


Tested e7a90c15 on Windows 10 19045.6456, on a GTX 1060 6 GB (driver 32.0.15.6094) and in-box WARP (10.0.19041.5794), with the debug layer enabled, plus a follow-up for the GPU readback you left open.

At this head: ctest --preset dev --no-tests=error -R '^spirv_compare_sampler_' -V passes 2/2 (_hardware on the 1060, _warp). The arrayed module validates (spirv-val --target-env vulkan1.2), and SPIRV-Cross emits Texture2DArray here as well. The GPU stage still reads back only the Texture2D module.

Array readback: one commit on top of your head, Jess-Doit:test/claude-1079-array-readback (8f76ad4e). It only touches tests/spirv_window/compare_sampler.{cpp,py} and docs/experiments.md. Feel free to cherry-pick it.

  • Harness: an array / array-<variant> descriptor variant makes t0 and t1 two-layer Texture2DArray resources with explicit array SRVs. Layer 1 differs from layer 0 in every texel the shader reads: depth 0.875, so both comparisons pass; ordinary 0.3125; mip 1 0.5625.
  • Driver: it adds a layer-1 copy of the arrayed module, with coordinate (0.25, 0.25, 1).

Results, Debug and Release, identical on the 1060 and on WARP:

Stage Result
spirv-val, arrayed shared + split, layers 0 and 1 pass
DXC, unsplit arrayed module rejected: no matching member function for call to 'SampleLevel' (expected)
DXC, split arrayed module, layers 0 and 1 compiles (cs_6_0)
Readback, layer 0 vs the Texture2D reference 3f800000,00000000,3ec00000, 0/16 mismatches
Readback, layer 1 vs its own reference 3f800000,3f800000,3ea00000, 0/16 mismatches
Layer 1 vs layer 0's reference (control) 2 mismatches, exactly words 1 and 2
Layer 1, comparison sampler set to GREATER words 0 and 1 change only (00000000,00000000)
Layer 1, ordinary sampler at MinLOD 1 word 2 changes only, to layer 1's mip (3f100000, not layer 0's 3f200000)

The existing Texture2D draws and their controls are unchanged and still pass. git diff --check and tests/docs_links_check.py are clean.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7118599776 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1079#issuecomment-7118599776). Originally posted by [Jess-Doit](https://github.com/Jess-Doit) on 2026-11-24T00:56:56Z. --- Tested `e7a90c15` on Windows 10 `19045.6456`, on a GTX 1060 6 GB (driver `32.0.15.6094`) and in-box WARP (`10.0.19041.5794`), with the debug layer enabled, plus a follow-up for the GPU readback you left open. **At this head:** `ctest --preset dev --no-tests=error -R '^spirv_compare_sampler_' -V` passes 2/2 (`_hardware` on the 1060, `_warp`). The arrayed module validates (`spirv-val --target-env vulkan1.2`), and SPIRV-Cross emits `Texture2DArray` here as well. The GPU stage still reads back only the `Texture2D` module. **Array readback:** one commit on top of your head, [`Jess-Doit:test/claude-1079-array-readback`](https://github.com/Jess-Doit/Xbox2Windows/commits/test/claude-1079-array-readback) (`8f76ad4e`). It only touches `tests/spirv_window/compare_sampler.{cpp,py}` and `docs/experiments.md`. Feel free to cherry-pick it. - **Harness:** an `array` / `array-<variant>` descriptor variant makes t0 and t1 two-layer `Texture2DArray` resources with explicit array SRVs. Layer 1 differs from layer 0 in every texel the shader reads: depth 0.875, so both comparisons pass; ordinary 0.3125; mip 1 0.5625. - **Driver:** it adds a layer-1 copy of the arrayed module, with coordinate (0.25, 0.25, 1). Results, Debug and Release, identical on the 1060 and on WARP: | Stage | Result | |---|---| | `spirv-val`, arrayed shared + split, layers 0 and 1 | pass | | DXC, unsplit arrayed module | rejected: `no matching member function for call to 'SampleLevel'` (expected) | | DXC, split arrayed module, layers 0 and 1 | compiles (`cs_6_0`) | | Readback, layer 0 vs the `Texture2D` reference | `3f800000,00000000,3ec00000`, 0/16 mismatches | | Readback, layer 1 vs its own reference | `3f800000,3f800000,3ea00000`, 0/16 mismatches | | Layer 1 vs layer 0's reference (control) | 2 mismatches, exactly words 1 and 2 | | Layer 1, comparison sampler set to `GREATER` | words 0 and 1 change only (`00000000,00000000`) | | Layer 1, ordinary sampler at `MinLOD` 1 | word 2 changes only, to layer 1's mip (`3f100000`, not layer 0's `3f200000`) | The existing `Texture2D` draws and their controls are unchanged and still pass. `git diff --check` and `tests/docs_links_check.py` are clean. AI-assisted (Claude Code).
Jess-Doit commented 2026-11-24 06:50:00 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-24T01:07:41Z.


This merged just before my comment above, so the array readback is now its own PR: #1107 (rebased on main, re-tested on the GTX 1060 and WARP).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7118782387 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1079#issuecomment-7118782387). Originally posted by [Jess-Doit](https://github.com/Jess-Doit) on 2026-11-24T01:07:41Z. --- This merged just before my comment above, so the array readback is now its own PR: #1107 (rebased on main, re-tested on the GTX 1060 and WARP).
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!1072
No description provided.