rdna2spirv: image_sample* outside 2D selects the UINT/SINT sampled view (OLD-9959 / SHADER-1404) #1247

Open
github-bot wants to merge 2 commits from github-bot/gh-1247 into main AGit
Owner

@⁠ambroseautomation on GitHub · 2026-11-24 20:48 UTC · original
ambroseautomation:carry/old-9959-sample-typed-dims → main · +560 −38 · 12 files · 2 commits · open

Claimed in the coordination issue as: OLD-9959 (#14)

What and why

Carries forward old-pr/9959 (draft #225, original commit author slipperysquid preserved; indexed in #17; SHADER-1404), rebased cleanly onto current main, plus a small follow-up commit (68762f09c) updating tests/test_shader_checks.py for the new SAMPLE_DIMS_TESTS / sample_dims_test hook in check.py.

Extends typed UINT/SINT view selection in tools/rdna2spirv.py to implicit image_sample across every texture dimension and stage (matching image_sample_l / image_sample_lz):

  • Selects the T# FORMAT's float, UINT, or SINT sampled view for image_sample across 1D, 2D, 2D-array, cube, and 3D dimensions and in both pixel and non-pixel stages.
  • Computes quad gradients (OpDPdx / OpDPdy) before the per-format branch at the non-layer coordinate width in pixel shaders, and samples at explicit LOD 0 outside the pixel stage.
  • Adds tests/semantic/test_sample_implicit_dims.py, updates tests/semantic/test_sample_typed_dims.py, adds GPU fixtures ps_sample_array_uint/sint and ps_sample_volume_uint/sint with new vk_texture_test modes wired into check.py and scripts/run_gpu_tests.py, updates tests/test_shader_checks.py, and updates the contract row in docs/design.md.

Tested

  • python -m unittest discover -s tests/semantic -p test_sample_implicit_dims.py -v: 6 tests, OK (1 skipped: spirv-val not on PATH).
  • python -m unittest discover -s tests/semantic -p test_sample_typed_dims.py -v: 4 tests, OK (1 skipped: spirv-val not on PATH).
  • python -I tests/test_shader_checks.py: 87 tests, OK.
  • python -I tests/test_docs_links.py: 16 tests, OK.
  • python -I scripts/run_semantic_tests.py tests/semantic: 471 files, 6,174 tests, 0 files failed.
  • python -I scripts/check_no_game_data.py on all 12 touched files: exit 0 (no game data).

GPUs tested: n/a (CPU SPIR-V interpreter semantic suite on Windows 11 Pro 64-bit, Python 3.12.10; original author verified the GPU fixtures on RX 6800 XT / RTX 3070 / llvmpipe)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed.
**@⁠ambroseautomation** on GitHub · 2026-11-24 20:48 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1247) `ambroseautomation:carry/old-9959-sample-typed-dims` → `main` · +560 −38 · 12 files · 2 commits · open Claimed in the coordination issue as: OLD-9959 (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ### What and why Carries forward `old-pr/9959` (draft #225, original commit author `slipperysquid` preserved; indexed in #17; SHADER-1404), rebased cleanly onto current `main`, plus a small follow-up commit (`68762f09c`) updating `tests/test_shader_checks.py` for the new `SAMPLE_DIMS_TESTS` / `sample_dims_test` hook in `check.py`. Extends typed UINT/SINT view selection in `tools/rdna2spirv.py` to implicit `image_sample` across every texture dimension and stage (matching `image_sample_l` / `image_sample_lz`): - Selects the T# FORMAT's float, UINT, or SINT sampled view for `image_sample` across 1D, 2D, 2D-array, cube, and 3D dimensions and in both pixel and non-pixel stages. - Computes quad gradients (`OpDPdx` / `OpDPdy`) before the per-format branch at the non-layer coordinate width in pixel shaders, and samples at explicit LOD 0 outside the pixel stage. - Adds `tests/semantic/test_sample_implicit_dims.py`, updates `tests/semantic/test_sample_typed_dims.py`, adds GPU fixtures `ps_sample_array_uint`/`sint` and `ps_sample_volume_uint`/`sint` with new `vk_texture_test` modes wired into `check.py` and `scripts/run_gpu_tests.py`, updates `tests/test_shader_checks.py`, and updates the contract row in `docs/design.md`. ### Tested - `python -m unittest discover -s tests/semantic -p test_sample_implicit_dims.py -v`: 6 tests, OK (1 skipped: `spirv-val` not on PATH). - `python -m unittest discover -s tests/semantic -p test_sample_typed_dims.py -v`: 4 tests, OK (1 skipped: `spirv-val` not on PATH). - `python -I tests/test_shader_checks.py`: 87 tests, OK. - `python -I tests/test_docs_links.py`: 16 tests, OK. - `python -I scripts/run_semantic_tests.py tests/semantic`: 471 files, 6,174 tests, 0 files failed. - `python -I scripts/check_no_game_data.py` on all 12 touched files: exit 0 (no game data). GPUs tested: n/a (CPU SPIR-V interpreter semantic suite on Windows 11 Pro 64-bit, Python 3.12.10; original author verified the GPU fixtures on RX 6800 XT / RTX 3070 / llvmpipe) AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed.
image_sample took the typed read (the float, UINT or SINT view the T# FORMAT
selects) only in a 2D pixel shader. A 2D-array, cube, 3D or 1D implicit
sample, and any implicit sample outside the pixel stage, read an integer
texture through the float view; a d16 sample then narrowed the integer bits as
a float. image_sample_l / _lz already take the typed read in every dimension
(#9517); image_sample now does too. In the pixel stage the quad gradients are
taken before the format branch at the width Grad takes ((s, t) for 2D, 2D
array and cube, all three for 3D, one for 1D); elsewhere the sample is Lod 0.

Tests: tests/semantic/test_sample_implicit_dims.py (11 of its checks fail on
the translator before this change), and GPU fixtures ps_sample_array_uint/sint
and ps_sample_volume_uint/sint run by new vk_texture_test modes array-uint,
array-sint, volume-uint and volume-sint (an integer 12-layer 2D array at
binding 3 and a 128x128x4 volume at binding 6, each with a mip 1), wired into
check.py and scripts/run_gpu_tests.py. 4096/4096 pixels exact on RX 6800 XT
(RADV Mesa 26.2.7), RTX 3070 (NVIDIA 595.99.02) and llvmpipe; every pixel
fails with the translator before this change. Contract row in docs/design.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:44:22 +00:00
Author
Owner

@⁠GeorgiyDemo on GitHub · 2026-11-24 21:05 UTC · original

Tested 68762f09c on Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), against main 66d4f5aa3, with the PR's own runtime/test/vk_texture_test.cpp rebuilt from its head (the main binary rejects the new fixtures' arguments with a usage line):

  • GPU, PR build: --filter ps_sample_ 10/10 on MoltenVK 1.4.2 and 10/10 on KosmicKrisp (Mesa 26.3.1). The four new fixtures each pass with "4096 exact pixels (image_sample, _l and _lz of the integer texture)".
  • New fixtures with main's translator (same build, tools/rdna2spirv.py swapped back): 6/10 — ps_sample_array_sint, ps_sample_array_uint, ps_sample_volume_sint and ps_sample_volume_uint all FAIL, so the fixtures do catch the view-selection bug rather than only passing at the head.
  • Semantic: test_sample_implicit_dims.py passes at this head and fails 11 times against main; test_sample_typed_dims.py passes both here and on main, so that one does not discriminate.

AI-assisted; synthetic fixtures only, no game data.

**@⁠GeorgiyDemo** on GitHub · 2026-11-24 21:05 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1247#issuecomment-7144465175) Tested `68762f09c` on Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), against `main` `66d4f5aa3`, with the PR's own `runtime/test/vk_texture_test.cpp` rebuilt from its head (the `main` binary rejects the new fixtures' arguments with a usage line): - **GPU, PR build:** `--filter ps_sample_` 10/10 on **MoltenVK 1.4.2** and 10/10 on **KosmicKrisp** (Mesa 26.3.1). The four new fixtures each pass with "4096 exact pixels (image_sample, _l and _lz of the integer texture)". - **New fixtures with `main`'s translator** (same build, `tools/rdna2spirv.py` swapped back): 6/10 — `ps_sample_array_sint`, `ps_sample_array_uint`, `ps_sample_volume_sint` and `ps_sample_volume_uint` all FAIL, so the fixtures do catch the view-selection bug rather than only passing at the head. - **Semantic:** `test_sample_implicit_dims.py` passes at this head and fails 11 times against `main`; `test_sample_typed_dims.py` passes both here and on `main`, so that one does not discriminate. AI-assisted; synthetic fixtures only, no game data.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1247/head:github-bot/gh-1247'
git switch 'github-bot/gh-1247'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1247'
git switch 'github-bot/gh-1247'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1247'
git switch 'github-bot/gh-1247'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1247'
git switch 'main'
git merge --squash 'github-bot/gh-1247'
git switch 'main'
git merge --ff-only 'github-bot/gh-1247'
git switch 'main'
git merge 'github-bot/gh-1247'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.