shader: read the split Texture2DArray comparison sampler back on the GPU #1100

Merged
Jess-Doit merged 2 commits from upstream-pr/1107 into main 2026-11-24 02:20:34 +00:00
Jess-Doit commented 2026-11-24 01:07:27 +00:00 (Migrated from github.com)

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


Change

Follow-up to #1079, which split shared comparison samplers on Texture2DArray images and left the arrayed module's DXC compile and GPU readback for a Windows run.

  • tests/spirv_window/compare_sampler.cpp: 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 (both comparisons pass), ordinary 0.3125, mip 1 0.5625.
  • tests/spirv_window/compare_sampler.py: a layer-1 copy of the arrayed module (coordinate (0.25, 0.25, 1)). DXC must still reject the unsplit arrayed module and compile both split ones. Readbacks of layer 0, layer 1, layer 1 against layer 0's reference, and the comparison and ordinary sampler controls on layer 1.
  • docs/experiments.md: describe the arrayed GPU stage.

The existing Texture2D draws and their controls are unchanged.

Verification

Tested f38773dc (on ea0e838e) on Windows 10 22H2 19045.6456 with a GTX 1060 6GB (10de:1c03, driver 32.0.15.6094) and in-box WARP (1414:008c, 10.0.19041.5794). The D3D12 debug layer was enabled on both.

. .\tools\dev.ps1
$env:XBOX2WINDOWS_ADAPTER = '1060'
foreach ($preset in 'dev', 'release') {
    cmake --preset $preset
    cmake --build --preset $preset --target offscreen_check -j 2
    ctest --preset $preset --no-tests=error -R '^spirv_compare_sampler_' -V
}

Each preset passed 2/2 (spirv_compare_sampler_hardware, spirv_compare_sampler_warp) with zero skips. Results were identical on both adapters:

Stage Result
spirv-val --target-env vulkan1.2, arrayed shared + split, layers 0 and 1 pass
DXC, unsplit arrayed module rejected: no matching member function for call to 'SampleLevel' (expected)
DXC cs_6_0, split arrayed module, layers 0 and 1 compiles
Layer 0 vs the Texture2D reference 3f800000,00000000,3ec00000, 0/16 mismatches
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 GREATER only words 0 and 1 change (00000000,00000000)
Layer 1, ordinary sampler MinLOD 1 only word 2 changes, to layer 1's mip (3f100000, not layer 0's 3f200000)

git diff --check and tests/docs_links_check.py are clean.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6572258040 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1107). Originally posted by [Jess-Doit](https://github.com/Jess-Doit) on 2026-11-24T01:07:27Z. --- ## Change Follow-up to #1079, which split shared comparison samplers on `Texture2DArray` images and left the arrayed module's DXC compile and GPU readback for a Windows run. - `tests/spirv_window/compare_sampler.cpp`: 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 (both comparisons pass), ordinary 0.3125, mip 1 0.5625. - `tests/spirv_window/compare_sampler.py`: a layer-1 copy of the arrayed module (coordinate `(0.25, 0.25, 1)`). DXC must still reject the unsplit arrayed module and compile both split ones. Readbacks of layer 0, layer 1, layer 1 against layer 0's reference, and the comparison and ordinary sampler controls on layer 1. - `docs/experiments.md`: describe the arrayed GPU stage. The existing `Texture2D` draws and their controls are unchanged. ## Verification Tested `f38773dc` (on `ea0e838e`) on Windows 10 22H2 `19045.6456` with a GTX 1060 6GB (`10de:1c03`, driver `32.0.15.6094`) and in-box WARP (`1414:008c`, `10.0.19041.5794`). The D3D12 debug layer was enabled on both. ```powershell . .\tools\dev.ps1 $env:XBOX2WINDOWS_ADAPTER = '1060' foreach ($preset in 'dev', 'release') { cmake --preset $preset cmake --build --preset $preset --target offscreen_check -j 2 ctest --preset $preset --no-tests=error -R '^spirv_compare_sampler_' -V } ``` Each preset passed 2/2 (`spirv_compare_sampler_hardware`, `spirv_compare_sampler_warp`) with zero skips. Results were identical on both adapters: | Stage | Result | |---|---| | `spirv-val --target-env vulkan1.2`, arrayed shared + split, layers 0 and 1 | pass | | DXC, unsplit arrayed module | rejected: `no matching member function for call to 'SampleLevel'` (expected) | | DXC `cs_6_0`, split arrayed module, layers 0 and 1 | compiles | | Layer 0 vs the `Texture2D` reference | `3f800000,00000000,3ec00000`, 0/16 mismatches | | 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 `GREATER` | only words 0 and 1 change (`00000000,00000000`) | | Layer 1, ordinary sampler `MinLOD` 1 | only word 2 changes, to layer 1's mip (`3f100000`, not layer 0's `3f200000`) | `git diff --check` and `tests/docs_links_check.py` are clean. AI-assisted (Claude Code).
upstream-sync closed this pull request 2026-11-24 06:46:21 +00:00
tedin7 commented 2026-11-24 06:46:21 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T02:15:40Z.

Review: COMMENTED


Reviewed at 18ef8ce7a760c46eb78d623cf6740298536eea94.

  • Code & structure: tests/spirv_window/compare_sampler.cpp cleanly extends check_spirv_compare_sampler with array / array-<variant> using two-layer Texture2DArray SRVs whose layer 1 differs in every sampled texel (depth 0.875, ordinary 0.3125, mip 1 0.5625). tests/spirv_window/compare_sampler.py verifies DXC still rejects the unsplit shared_array HLSL, compiles lowered_array and lowered_array_layer1, and checks layer 0 vs layer 1 readback plus comparison-greater (words 0–1) and ordinary-min-lod1 (word 2 on layer 1's mip 1).
  • Linux checks run: python3 -B tests/docs_links_check.py (15 files, 253 links), python3 -B tests/bidi_controls_check.py (939 files), python3 -B tests/gpu_report_format_check.py (10 tests), python3 -B tests/xgameruntime_table_check.py, python3 -B tests/spirv_window/check.py, and python3 -m py_compile tests/spirv_window/compare_sampler.py — all passed.
  • CI / Windows: Linux Python checks and Assemble and translate gfx1013 fixtures passed; the 2 Windows build/test checks are currently pending, so Windows DXC/WARP/hardware readback relies on CI.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6032633296 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1107#pullrequestreview-6032633296). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T02:15:40Z. **Review:** COMMENTED --- Reviewed at `18ef8ce7a760c46eb78d623cf6740298536eea94`. - **Code & structure**: `tests/spirv_window/compare_sampler.cpp` cleanly extends `check_spirv_compare_sampler` with `array` / `array-<variant>` using two-layer `Texture2DArray` SRVs whose layer 1 differs in every sampled texel (depth `0.875`, ordinary `0.3125`, mip 1 `0.5625`). `tests/spirv_window/compare_sampler.py` verifies DXC still rejects the unsplit `shared_array` HLSL, compiles `lowered_array` and `lowered_array_layer1`, and checks layer 0 vs layer 1 readback plus `comparison-greater` (words 0–1) and `ordinary-min-lod1` (word 2 on layer 1's mip 1). - **Linux checks run**: `python3 -B tests/docs_links_check.py` (15 files, 253 links), `python3 -B tests/bidi_controls_check.py` (939 files), `python3 -B tests/gpu_report_format_check.py` (10 tests), `python3 -B tests/xgameruntime_table_check.py`, `python3 -B tests/spirv_window/check.py`, and `python3 -m py_compile tests/spirv_window/compare_sampler.py` — all passed. - **CI / Windows**: Linux Python checks and `Assemble and translate gfx1013 fixtures` passed; the 2 Windows build/test checks are currently pending, so Windows DXC/WARP/hardware readback relies on CI.
Toons29 commented 2026-11-24 06:50:07 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Toons29 on 2026-11-24T02:04:25Z.


Tested 18ef8ce7 on an AMD Radeon RX 9070 (RDNA 4, 1002:7550), driver 32.0.32029.2010, Windows 11 build 26300, dev preset, debug layer unavailable: pass

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

spirv_compare_sampler_hardware and spirv_compare_sampler_warp both pass, with no skips. On the RX 9070, the baseline, the comparison descriptor (00000000,3f800000,3ec00000), the ordinary MinLOD-1 descriptor (3f800000,00000000,3f200000) and array layers 0 and 1 all read back with mismatches=0 over 16 words. Every control is caught: the wrong reference (1), comparison vs baseline (2), ordinary vs baseline (1), layer 1 vs layer 0 (2), array comparison vs layer 1 (2) and array ordinary vs layer 1 (1). The array layer 1 comparison readback is 00000000,00000000,3ea00000.

I first ran it at f38773dc, before the main merge, and every readback above is the same at both commits.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7119727667 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1107#issuecomment-7119727667). Originally posted by [Toons29](https://github.com/Toons29) on 2026-11-24T02:04:25Z. --- Tested 18ef8ce7 on an AMD Radeon RX 9070 (RDNA 4, `1002:7550`), driver `32.0.32029.2010`, Windows 11 build 26300, `dev` preset, debug layer unavailable: pass ```powershell ctest --preset dev --no-tests=error -R '^spirv_compare_sampler_' -V ``` `spirv_compare_sampler_hardware` and `spirv_compare_sampler_warp` both pass, with no skips. On the RX 9070, the baseline, the comparison descriptor (`00000000,3f800000,3ec00000`), the ordinary MinLOD-1 descriptor (`3f800000,00000000,3f200000`) and array layers 0 and 1 all read back with `mismatches=0` over 16 words. Every control is caught: the wrong reference (1), comparison vs baseline (2), ordinary vs baseline (1), layer 1 vs layer 0 (2), array comparison vs layer 1 (2) and array ordinary vs layer 1 (1). The array layer 1 comparison readback is `00000000,00000000,3ea00000`. I first ran it at f38773dc, before the main merge, and every readback above is the same at both commits.
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!1100
No description provided.