shader: test folded inline sampler masks #1268

Merged
Jess-Doit merged 5 commits from upstream-pr/1275 into main 2026-11-24 08:19:02 +00:00
Jess-Doit commented 2026-11-24 06:28:38 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-24T06:28:38Z.


Refs #1149

Add a source-built gfx1013 pixel fixture for inline sampler words built with
s_bfm_b32. The pure check compares all four words in the smp line against
the assembly's masks, including width and offset masking and a zero-width mask.
Overwriting a folded word with a width from a root constant is refused by the
current translator. In a local mutation that retained the old constant, the
check failed as expected.

The desktop draw feeds the manifest line through the stand-in's shared sampler
parser, decoder, and root-signature builder. At x=1.25 the clamp sampler reads
column 1 (3e800000,3f800000,00000000,00000000). Keeping the shader, texture,
and expected pixel fixed and switching to the folded wrap words must mismatch
and read column 0 (3e000000,00000000,00000000,00000000).

The draw reuses --startup-image-3d, which now takes an optional sampler manifest line. tests/startup_image_3d.cpp builds its root signature with the stand-in's create_translated_root instead of a hand-written point-wrap sampler; without the extra argument it reads smp 0 0x0 0x0 0x0 0x0, which decodes to the same point-wrap sampler, and startup_image_3d_* still pass.

Verification

Tested commit a39c5849e5caab3d9a853e6f6f2b65868c809dc5 on base
f1b16abd266144c4ec3517fb989060a4ee7a50ce. Debug and Release each passed
13 tests with 0 failures and 0 skips, including the existing 3D, explicit LOD,
and sampler heap checks. Both DXC ps_6_0 and FXC ps_5_1 produced the
expected clamp and wrap readbacks on Windows 10 22H2 (19045.6456) with the
GTX 1060 6 GB (32.0.15.6094) and in-box WARP (10.0.19041.5794). The D3D12
debug layer reported zero errors and warnings in all new draw cases. Local
LLVM 23.1.6 reassembled all three programs byte-for-byte. The CI reassembly
step uses LLVM 15.
The follow-up commit c641d1b6 only adds the new check to the pure-Python list in AGENTS.md.

. .\tools\dev.ps1
$env:VULKAN_SDK = 'C:\VulkanSDK\1.4.363.0'
$env:XBOX2WINDOWS_ADAPTER = '1060'
$env:X2W_D3D12_DEBUG = '1'
$venvPython = (Resolve-Path 'out/pe-env/Scripts/python.exe').Path
foreach ($preset in 'dev', 'release') {
    cmake --preset $preset "-DINTAKE_PYTHON:FILEPATH=$venvPython"
    cmake --build --preset $preset --target offscreen_check d3d12_xs_shim -j 2
    ctest --preset $preset --no-tests=error -R '^startup_(inline_sampler_|image_3d_|image_sample_l|sampler_heap_)|^docs_links$' -V
}
python3 -B tests/startup_inline_sampler_check.py
python3 -B tests/startup_inline_sampler_check.py binary llvm-mc-15

AI-assisted (Codex).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6576049874 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1275). Originally posted by [Jess-Doit](https://github.com/Jess-Doit) on 2026-11-24T06:28:38Z. --- Refs #1149 Add a source-built gfx1013 pixel fixture for inline sampler words built with `s_bfm_b32`. The pure check compares all four words in the `smp` line against the assembly's masks, including width and offset masking and a zero-width mask. Overwriting a folded word with a width from a root constant is refused by the current translator. In a local mutation that retained the old constant, the check failed as expected. The desktop draw feeds the manifest line through the stand-in's shared sampler parser, decoder, and root-signature builder. At x=1.25 the clamp sampler reads column 1 (`3e800000,3f800000,00000000,00000000`). Keeping the shader, texture, and expected pixel fixed and switching to the folded wrap words must mismatch and read column 0 (`3e000000,00000000,00000000,00000000`). The draw reuses `--startup-image-3d`, which now takes an optional sampler manifest line. `tests/startup_image_3d.cpp` builds its root signature with the stand-in's `create_translated_root` instead of a hand-written point-wrap sampler; without the extra argument it reads `smp 0 0x0 0x0 0x0 0x0`, which decodes to the same point-wrap sampler, and `startup_image_3d_*` still pass. ### Verification Tested commit `a39c5849e5caab3d9a853e6f6f2b65868c809dc5` on base `f1b16abd266144c4ec3517fb989060a4ee7a50ce`. Debug and Release each passed 13 tests with 0 failures and 0 skips, including the existing 3D, explicit LOD, and sampler heap checks. Both DXC `ps_6_0` and FXC `ps_5_1` produced the expected clamp and wrap readbacks on Windows 10 22H2 (19045.6456) with the GTX 1060 6 GB (32.0.15.6094) and in-box WARP (10.0.19041.5794). The D3D12 debug layer reported zero errors and warnings in all new draw cases. Local LLVM 23.1.6 reassembled all three programs byte-for-byte. The CI reassembly step uses LLVM 15. The follow-up commit `c641d1b6` only adds the new check to the pure-Python list in `AGENTS.md`. ```powershell . .\tools\dev.ps1 $env:VULKAN_SDK = 'C:\VulkanSDK\1.4.363.0' $env:XBOX2WINDOWS_ADAPTER = '1060' $env:X2W_D3D12_DEBUG = '1' $venvPython = (Resolve-Path 'out/pe-env/Scripts/python.exe').Path foreach ($preset in 'dev', 'release') { cmake --preset $preset "-DINTAKE_PYTHON:FILEPATH=$venvPython" cmake --build --preset $preset --target offscreen_check d3d12_xs_shim -j 2 ctest --preset $preset --no-tests=error -R '^startup_(inline_sampler_|image_3d_|image_sample_l|sampler_heap_)|^docs_links$' -V } ``` ```sh python3 -B tests/startup_inline_sampler_check.py python3 -B tests/startup_inline_sampler_check.py binary llvm-mc-15 ``` AI-assisted (Codex).
tedin7 commented 2026-11-24 06:47:30 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Peer review at commit c641d1b6ec6aafaa00beb0e0b69c0d46835c3838:

Findings

  • tests/startup_inline_sampler_check.py: Clean pure translation, binary reassembly, and D3D12 draw coverage for folded s_bfm_b32 inline sampler masks (5-bit width/offset masking, zero-width mask, root-constant overwrite rejection via G.Unsupported, and clamp vs wrap readback control).
  • tests/startup_image_3d.cpp, tests/offscreen_check.cpp, tests/desktop_gpu.h: Reuses --startup-image-3d with an optional sampler manifest line (defaulting to "smp 0 0x0 0x0 0x0 0x0") and switches create_root to x2w_startup::create_translated_root, keeping startup_image_3d_warp passing.
  • CMakeLists.txt, .github/workflows/windows.yml, AGENTS.md, docs/startup-runtime.md: Wires startup_inline_sampler_controls, startup_inline_sampler_{warp,hardware} (SKIP_RETURN_CODE 77), and Linux CI checks cleanly.

Verification

  • Linux:
    • git diff --check origin/main...HEAD: clean
    • /root/.local/share/x2w-rev-venv/bin/python -B tests/docs_links_check.py: passed (Checked 16 Markdown files and 284 links)
    • /root/.local/share/x2w-rev-venv/bin/python -B tests/bidi_controls_check.py: passed (Checked 1066 tracked source, script and build/CI files: no bidirectional controls)
    • /root/.local/share/x2w-rev-venv/bin/python -B tests/startup_inline_sampler_check.py: passed (clamp, wrap, and root-constant mask width refusal)
    • /root/.local/share/x2w-rev-venv/bin/python -B tests/startup_inline_sampler_check.py binary /usr/lib/llvm-19/bin/llvm-mc: passed (all three fixture programs match llvm-mc)
  • Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP):
    • Debug (--preset dev):
      • cmake --build --preset dev --target offscreen_check -- -j 6 (20.47s)
      • ctest --preset dev -R '^startup_(inline_sampler_(controls|warp)|image_3d_warp)$' --parallel 4 --no-tests=error --output-on-failure: 3/3 passed (0.83s: startup_inline_sampler_controls 0.16s, startup_inline_sampler_warp 0.45s, startup_image_3d_warp 0.77s)
    • Release /O2 (--preset release):
      • cmake --build --preset release --target offscreen_check -- -j 6 (20.83s)
      • ctest --preset release -R '^startup_(inline_sampler_(controls|warp)|image_3d_warp)$' --parallel 4 --no-tests=error --output-on-failure: 3/3 passed (0.83s: startup_inline_sampler_controls 0.16s, startup_inline_sampler_warp 0.45s, startup_image_3d_warp 0.76s)
<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6034809768 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1275#pullrequestreview-6034809768). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T06:44:32Z. **Review:** COMMENTED --- Peer review at commit `c641d1b6ec6aafaa00beb0e0b69c0d46835c3838`: ### Findings - `tests/startup_inline_sampler_check.py`: Clean pure translation, binary reassembly, and D3D12 draw coverage for folded `s_bfm_b32` inline sampler masks (5-bit width/offset masking, zero-width mask, root-constant overwrite rejection via `G.Unsupported`, and clamp vs wrap readback control). - `tests/startup_image_3d.cpp`, `tests/offscreen_check.cpp`, `tests/desktop_gpu.h`: Reuses `--startup-image-3d` with an optional sampler manifest line (defaulting to `"smp 0 0x0 0x0 0x0 0x0"`) and switches `create_root` to `x2w_startup::create_translated_root`, keeping `startup_image_3d_warp` passing. - `CMakeLists.txt`, `.github/workflows/windows.yml`, `AGENTS.md`, `docs/startup-runtime.md`: Wires `startup_inline_sampler_controls`, `startup_inline_sampler_{warp,hardware}` (`SKIP_RETURN_CODE 77`), and Linux CI checks cleanly. ### Verification - **Linux**: - `git diff --check origin/main...HEAD`: clean - `/root/.local/share/x2w-rev-venv/bin/python -B tests/docs_links_check.py`: passed (`Checked 16 Markdown files and 284 links`) - `/root/.local/share/x2w-rev-venv/bin/python -B tests/bidi_controls_check.py`: passed (`Checked 1066 tracked source, script and build/CI files: no bidirectional controls`) - `/root/.local/share/x2w-rev-venv/bin/python -B tests/startup_inline_sampler_check.py`: passed (`clamp`, `wrap`, and root-constant mask width refusal) - `/root/.local/share/x2w-rev-venv/bin/python -B tests/startup_inline_sampler_check.py binary /usr/lib/llvm-19/bin/llvm-mc`: passed (`all three fixture programs match llvm-mc`) - **Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP)**: - Debug (`--preset dev`): - `cmake --build --preset dev --target offscreen_check -- -j 6` (`20.47s`) - `ctest --preset dev -R '^startup_(inline_sampler_(controls|warp)|image_3d_warp)$' --parallel 4 --no-tests=error --output-on-failure`: **3/3 passed** (`0.83s`: `startup_inline_sampler_controls` `0.16s`, `startup_inline_sampler_warp` `0.45s`, `startup_image_3d_warp` `0.77s`) - Release `/O2` (`--preset release`): - `cmake --build --preset release --target offscreen_check -- -j 6` (`20.83s`) - `ctest --preset release -R '^startup_(inline_sampler_(controls|warp)|image_3d_warp)$' --parallel 4 --no-tests=error --output-on-failure`: **3/3 passed** (`0.83s`: `startup_inline_sampler_controls` `0.16s`, `startup_inline_sampler_warp` `0.45s`, `startup_image_3d_warp` `0.76s`)
Jess-Doit commented 2026-11-24 08:01:39 +00:00 (Migrated from github.com)

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


Merged main (dc73c29e) as 0ba01c03. The conflicts were all with #1262, now on main: the CI, AGENTS.md and CMake lists, desktop_gpu.h, and the offscreen_check operation table. Both sides are kept. Against main, this branch's diff is unchanged.

Retest on Windows 10 22H2 19045.6456, GTX 1060 6 GB (driver 32.0.15.6094) and in-box WARP, Debug build, X2W_D3D12_DEBUG=1:

ctest --preset dev --no-tests=error -R '^startup_(inline_sampler_|image_3d_|flat_param_)'

9/9 passed: startup_inline_sampler_*, startup_image_3d_* and startup_flat_param_*.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7125017050 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1275#issuecomment-7125017050). Originally posted by [Jess-Doit](https://github.com/Jess-Doit) on 2026-11-24T07:27:44Z. --- Merged `main` (`dc73c29e`) as `0ba01c03`. The conflicts were all with #1262, now on `main`: the CI, AGENTS.md and CMake lists, `desktop_gpu.h`, and the `offscreen_check` operation table. Both sides are kept. Against `main`, this branch's diff is unchanged. Retest on Windows 10 22H2 `19045.6456`, GTX 1060 6 GB (driver `32.0.15.6094`) and in-box WARP, Debug build, `X2W_D3D12_DEBUG=1`: ``` ctest --preset dev --no-tests=error -R '^startup_(inline_sampler_|image_3d_|flat_param_)' ``` 9/9 passed: `startup_inline_sampler_*`, `startup_image_3d_*` and `startup_flat_param_*`.
Jess-Doit commented 2026-11-24 08:01:40 +00:00 (Migrated from github.com)

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


Merged main (a73e3362). The only conflict was in CMakeLists.txt, where startup_xg_bc_tiling and this PR's startup_inline_sampler_* tests are registered in the same place; both are kept. CMake configures and lists both. No code changed, and against main this branch's diff is unchanged, so the retest above still applies.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7125323910 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1275#issuecomment-7125323910). Originally posted by [Jess-Doit](https://github.com/Jess-Doit) on 2026-11-24T07:44:41Z. --- Merged `main` (`a73e3362`). The only conflict was in `CMakeLists.txt`, where `startup_xg_bc_tiling` and this PR's `startup_inline_sampler_*` tests are registered in the same place; both are kept. CMake configures and lists both. No code changed, and against `main` this branch's diff is unchanged, so the retest above still applies.
upstream-sync closed this pull request 2026-11-24 09:04:22 +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!1268
No description provided.