[PR #132] [CLOSED] rdna2spirv: image_sample reads integer textures through the typed view in every dimension and stage (SHADER-1404) #183

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

📋 Pull Request Information

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

Base: main ← Head: old-pr/9863


📝 Commits (2)

  • a16ba20 rdna2spirv: image_sample reads integer textures through the typed view in every dimension and stage (SHADER-1404)
  • 0352291 vk_texture_test: integer 2D-array implicit image_sample fixtures (SHADER-1404)

📊 Changes

7 files changed (+163 additions, -30 deletions)

View changed files

📝 docs/design.md (+1 -1)
➕ runtime/test/shaders/ps_sample_array_sint.asm (+26 -0)
➕ runtime/test/shaders/ps_sample_array_uint.asm (+25 -0)
📝 runtime/test/vk_texture_test.cpp (+44 -8)
📝 scripts/run_gpu_tests.py (+5 -2)
📝 tests/semantic/test_sample_typed_dims.py (+45 -12)
📝 tools/rdna2spirv.py (+17 -7)

📄 Description

Carried over from old PR 9863 by raulmesa96 in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9863, 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.
raulmesa96: 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):

SHADER-1404 (up for grabs in #9677; I could not claim it there because comments are limited to collaborators).

image_sample (implicit LOD) took the typed UINT/SINT read only in a 2D pixel shader. A UINT/SINT 2D-array, 3D, cube or 1D texture, or any integer texture sampled outside a pixel shader, went through the float view, so the VGPRs held a converted float instead of the integer texel. image_sample_l / image_sample_lz already used image_read_typed in every dimension.

Now image_sample uses image_read_typed in every dimension and stage:

  • In a pixel shader the implicit LOD becomes OpImageSampleExplicitLod ... Grad with OpDPdx/OpDPdy taken before the per-format branch, over the coordinates that have a derivative (grad_width): s for 1D; s, t for 2D, 2D-array and cube (its 6-layer 2D-array view, as the float path samples it); s, t, r for 3D. The array layer has no derivative.
  • Outside a pixel shader there are no derivatives, so the LOD is 0, as on the float path.

docs/design.md: the "in every dimension" contract row now covers image_sample and says how the implicit LOD is lowered.

Tested:

  • tests/semantic/test_sample_typed_dims.py: extended to image_sample (alias and sampled-image type per dimension, gradient width and the OpVectorShuffle for array/cube, LOD 0 in a vertex shader). The new cases fail on main (13 failures) and pass with this change.
  • Full translator suite, python -I scripts/run_semantic_tests.py tests/semantic: 459 files, 6048 tests. Four files fail identically with and without this change (test_exec_computed, test_image_atomics_guard, test_sopc_validation, test_unary_f16_validation); two of them need spirv-as/spirv-val, which are not installed here.
  • tests/test_docs_links.py, python -m compileall.
  • Not run: spirv-val on the new modules (the test has a spirv-val case, skipped here) and a GPU readback on a non-2D integer texture. GPU available for a fixture: NVIDIA RTX 3060 (Windows).

No game files. AI-assisted (Claude Code).

🤖 Generated with Claude Code


🔄 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/132 **Author:** [@Andretuta](https://github.com/Andretuta) **Created:** 11/24/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `old-pr/9863` --- ### 📝 Commits (2) - [`a16ba20`](https://github.com/ubiquitarianism/leonida/commit/a16ba20a47bd61a013f569a6fb885be87e8161d7) rdna2spirv: image_sample reads integer textures through the typed view in every dimension and stage (SHADER-1404) - [`0352291`](https://github.com/ubiquitarianism/leonida/commit/0352291674721e98ddc5e6a1646fb2ea33c31fd5) vk_texture_test: integer 2D-array implicit image_sample fixtures (SHADER-1404) ### 📊 Changes **7 files changed** (+163 additions, -30 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+1 -1) ➕ `runtime/test/shaders/ps_sample_array_sint.asm` (+26 -0) ➕ `runtime/test/shaders/ps_sample_array_uint.asm` (+25 -0) 📝 `runtime/test/vk_texture_test.cpp` (+44 -8) 📝 `scripts/run_gpu_tests.py` (+5 -2) 📝 `tests/semantic/test_sample_typed_dims.py` (+45 -12) 📝 `tools/rdna2spirv.py` (+17 -7) </details> ### 📄 Description > Carried over from **old PR 9863** by `raulmesa96` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/9863`, 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. > `raulmesa96`: 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): SHADER-1404 (up for grabs in `#9677`; I could not claim it there because comments are limited to collaborators). `image_sample` (implicit LOD) took the typed UINT/SINT read only in a 2D pixel shader. A UINT/SINT 2D-array, 3D, cube or 1D texture, or any integer texture sampled outside a pixel shader, went through the float view, so the VGPRs held a converted float instead of the integer texel. `image_sample_l` / `image_sample_lz` already used `image_read_typed` in every dimension. Now `image_sample` uses `image_read_typed` in every dimension and stage: - In a pixel shader the implicit LOD becomes `OpImageSampleExplicitLod ... Grad` with `OpDPdx`/`OpDPdy` taken before the per-format branch, over the coordinates that have a derivative (`grad_width`): s for 1D; s, t for 2D, 2D-array and cube (its 6-layer 2D-array view, as the float path samples it); s, t, r for 3D. The array layer has no derivative. - Outside a pixel shader there are no derivatives, so the LOD is 0, as on the float path. `docs/design.md`: the "in every dimension" contract row now covers `image_sample` and says how the implicit LOD is lowered. Tested: - `tests/semantic/test_sample_typed_dims.py`: extended to `image_sample` (alias and sampled-image type per dimension, gradient width and the `OpVectorShuffle` for array/cube, LOD 0 in a vertex shader). The new cases fail on main (13 failures) and pass with this change. - Full translator suite, `python -I scripts/run_semantic_tests.py tests/semantic`: 459 files, 6048 tests. Four files fail identically with and without this change (`test_exec_computed`, `test_image_atomics_guard`, `test_sopc_validation`, `test_unary_f16_validation`); two of them need `spirv-as`/`spirv-val`, which are not installed here. - `tests/test_docs_links.py`, `python -m compileall`. - Not run: `spirv-val` on the new modules (the test has a `spirv-val` case, skipped here) and a GPU readback on a non-2D integer texture. GPU available for a fixture: NVIDIA RTX 3060 (Windows). No game files. AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <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:04 +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#183
No description provided.