[PR #154] [CLOSED] rdna2spirv: implicit samples read the T# FORMAT view in every dimension (SHADER-1404) #207

Closed
opened 2026-11-26 20:17:08 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/154
Author: @Andretuta
Created: 11/24/2026
Status: ❌ Closed

Base: main ← Head: old-pr/9886


📝 Commits (2)

  • fd8ab16 rdna2spirv: implicit samples read the T# FORMAT view in every dimension (SHADER-1404)
  • fde408d gpu: a 2D-array UINT fixture for implicit typed samples (SHADER-1404)

📊 Changes

7 files changed (+188 additions, -16 deletions)

View changed files

📝 docs/design.md (+1 -1)
📝 runtime/test/shaders/check.py (+5 -1)
➕ runtime/test/shaders/ps_sample_implicit_uint_array.asm (+29 -0)
📝 runtime/test/vk_texture_test.cpp (+16 -6)
📝 scripts/run_gpu_tests.py (+2 -2)
➕ tests/semantic/test_sample_implicit_dims.py (+117 -0)
📝 tools/rdna2spirv.py (+18 -6)

📄 Description

Carried over from old PR 9886 by ruipedro-pinheiro in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9886, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
ruipedro-pinheiro: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

Claimed in the coordination issue as: SHADER-1404 — https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7116603786

Depends on: none

What and why

image_sample chose the UINT/SINT sampled view the T# FORMAT selects only when the stage was ps and the dimension 2D (tools/rdna2spirv.py). An integer 2D-array, cube, 3D or 1D texture, and any implicit sample outside the pixel stage, was sampled through the float view: the result VGPRs held a converted float instead of the integer texel the measured T# FORMAT rule in docs/design.md returns.

Every image_sample form now takes the typed read that image_load, image_sample_l and image_sample_lz already take. The pixel stage keeps the implicit LOD as the quad derivatives, as Grad, at the width the dimension samples — two components for 2D, 2D-array and cube (the array layer is not differentiated), three for 3D, scalar for 1D — which is the vector OpDPdx differentiates. Outside the pixel stage there are no derivatives, so the sample is Lod 0. image_sample_c* stays on the float view (a depth compare takes a Dref view); the bias (_b) and offset (_o) forms are out of this change.

docs/design.md: the row "Implicit 2D pixel-shader integer samples" becomes "Implicit integer samples", with the dimension/stage rule and what is checked where.

Note: #9667 proposed the same fix on a base from before #9517 merged and was closed unmerged; main still had the 2D/ps-only condition.

Tested

Linux (CachyOS), Intel UHD Graphics 620 (CML GT2) through Mesa 26.2.5 (ANV), no game files. Python 3.14.8, SPIRV-Tools v2026.4 (spirv-as/spirv-val), LLVM 23.1.4 (llvm-mc).

  • python -I tests/semantic/test_sample_implicit_dims.py -v: 3 tests OK — every dimension in the pixel stage (the alias each dimension loads, the three sample types, the OpDPdx/OpDPdy width), the float view still sampled for a float format, and the compute stage as Lod %f0; spirv-as and spirv-val --target-env vulkan1.2 on every module.
  • python -I scripts/run_semantic_tests.py tests/semantic: 460 files, 6,049 tests, 2 files failed (test_exec_computed, test_image_atomics_guard). Both fail with the same counts on main at 2d53a80 without this change.
  • python -I -m unittest discover -s tests/semantic -p 'test_sample*.py' and -p 'test_image_gather4_variants.py': 31 and 13 tests OK.
  • No corpus run: no game files here, so no translate / spirv-val counts over the 26,503 shaders.
  • GPU (Mesa ANV, Intel UHD 620): python -I scripts/run_gpu_tests.py --build runtime/build --work /tmp/opencode/gputest --filter ps_sample_implicit — 3/3 pass. ps_sample_implicit_sint and ps_sample_implicit_uint keep the 2D path; the new ps_sample_implicit_uint_array samples the unsigned two-mip image through a one-layer 2D_ARRAY view (non-2D implicit sample), 4096/4096 pixels exact in each pass. With the translator at 2d53a80 the array fixture fails ((0,0): RGBA32F bits (0, 0, 0, 0) != (1065353216, 0, 0, 1065353216)), so the fixture catches the regression.

AI-assisted: yes (opencode, deepseek-v4.1-flash-free).

Checklist

  • 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.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/154 **Author:** [@Andretuta](https://github.com/Andretuta) **Created:** 11/24/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `old-pr/9886` --- ### 📝 Commits (2) - [`fd8ab16`](https://github.com/ubiquitarianism/leonida/commit/fd8ab162ca6f46c44438525c42294e2fb2ebe3c2) rdna2spirv: implicit samples read the T# FORMAT view in every dimension (SHADER-1404) - [`fde408d`](https://github.com/ubiquitarianism/leonida/commit/fde408da00b6fafbb15d90fa8d53976f5cc9ab41) gpu: a 2D-array UINT fixture for implicit typed samples (SHADER-1404) ### 📊 Changes **7 files changed** (+188 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+1 -1) 📝 `runtime/test/shaders/check.py` (+5 -1) ➕ `runtime/test/shaders/ps_sample_implicit_uint_array.asm` (+29 -0) 📝 `runtime/test/vk_texture_test.cpp` (+16 -6) 📝 `scripts/run_gpu_tests.py` (+2 -2) ➕ `tests/semantic/test_sample_implicit_dims.py` (+117 -0) 📝 `tools/rdna2spirv.py` (+18 -6) </details> ### 📄 Description > Carried over from **old PR 9886** by `ruipedro-pinheiro` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/9886`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > `ruipedro-pinheiro`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): Claimed in the coordination issue as: SHADER-1404 — https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7116603786 Depends on: none ### What and why `image_sample` chose the UINT/SINT sampled view the T# FORMAT selects only when the stage was `ps` and the dimension 2D (`tools/rdna2spirv.py`). An integer 2D-array, cube, 3D or 1D texture, and any implicit sample outside the pixel stage, was sampled through the float view: the result VGPRs held a converted float instead of the integer texel the measured T# FORMAT rule in `docs/design.md` returns. Every `image_sample` form now takes the typed read that `image_load`, `image_sample_l` and `image_sample_lz` already take. The pixel stage keeps the implicit LOD as the quad derivatives, as `Grad`, at the width the dimension samples — two components for 2D, 2D-array and cube (the array layer is not differentiated), three for 3D, scalar for 1D — which is the vector `OpDPdx` differentiates. Outside the pixel stage there are no derivatives, so the sample is `Lod 0`. `image_sample_c*` stays on the float view (a depth compare takes a `Dref` view); the bias (`_b`) and offset (`_o`) forms are out of this change. `docs/design.md`: the row "Implicit 2D pixel-shader integer samples" becomes "Implicit integer samples", with the dimension/stage rule and what is checked where. Note: `#9667` proposed the same fix on a base from before `#9517` merged and was closed unmerged; `main` still had the 2D/`ps`-only condition. ### Tested Linux (CachyOS), Intel UHD Graphics 620 (CML GT2) through Mesa 26.2.5 (ANV), no game files. Python 3.14.8, SPIRV-Tools v2026.4 (`spirv-as`/`spirv-val`), LLVM 23.1.4 (`llvm-mc`). - `python -I tests/semantic/test_sample_implicit_dims.py -v`: 3 tests OK — every dimension in the pixel stage (the alias each dimension loads, the three sample types, the `OpDPdx`/`OpDPdy` width), the float view still sampled for a float format, and the compute stage as `Lod %f0`; `spirv-as` and `spirv-val --target-env vulkan1.2` on every module. - `python -I scripts/run_semantic_tests.py tests/semantic`: 460 files, 6,049 tests, 2 files failed (`test_exec_computed`, `test_image_atomics_guard`). Both fail with the same counts on `main` at `2d53a80` without this change. - `python -I -m unittest discover -s tests/semantic -p 'test_sample*.py'` and `-p 'test_image_gather4_variants.py'`: 31 and 13 tests OK. - No corpus run: no game files here, so no translate / `spirv-val` counts over the 26,503 shaders. - GPU (Mesa ANV, Intel UHD 620): `python -I scripts/run_gpu_tests.py --build runtime/build --work /tmp/opencode/gputest --filter ps_sample_implicit` — 3/3 pass. `ps_sample_implicit_sint` and `ps_sample_implicit_uint` keep the 2D path; the new `ps_sample_implicit_uint_array` samples the unsigned two-mip image through a one-layer 2D_ARRAY view (non-2D implicit sample), 4096/4096 pixels exact in each pass. With the translator at `2d53a80` the array fixture fails (`(0,0): RGBA32F bits (0, 0, 0, 0) != (1065353216, 0, 0, 1065353216)`), so the fixture catches the regression. AI-assisted: yes (opencode, deepseek-v4.1-flash-free). ### Checklist - [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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:17:08 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#207
No description provided.