[PR #110] [CLOSED] rdna2spirv: a plain image_sample reads a UINT/SINT image in every dimension and stage (SHADER-1404) #162

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

📋 Pull Request Information

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

Base: main ← Head: old-pr/9843


📝 Commits (1)

  • 1c08f38 rdna2spirv: a plain image_sample reads a UINT/SINT image in every dimension and stage (SHADER-1404)

📊 Changes

3 files changed (+96 additions, -15 deletions)

View changed files

📝 docs/design.md (+1 -1)
📝 tests/semantic/test_sample_typed_dims.py (+81 -9)
📝 tools/rdna2spirv.py (+14 -5)

📄 Description

Carried over from old PR 9843 by tiagonogueiraa-bit in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9843, 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.
tiagonogueiraa-bit: 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, claimed in #9677: https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7116572064

What

image_sample (no LOD dword) took the UINT/SINT typed read only in the pixel shader's 2D form. Two cases still read an integer image through the float view, so the VGPRs held a converted float instead of the integer texel:

  • a UINT/SINT 2D-array, 3D, cube or 1D image in the PS;
  • any integer image sampled outside the PS, including 2D.

The hardware picks the view from T# FORMAT in every dimension and stage. EGEN-SAMPLE-TYPED-DIMS (4dcb96e44) already fixed image_sample_l / image_sample_lz; this PR covers the plain form.

How

image_sample now goes through the same image_read_typed dispatch as the explicit-LOD forms:

  • Pixel shader: it samples with gradients of the coordinates an implicit LOD derives from, taken before the format branch, as the 2D form already did. That's one coordinate for 1D, two for 2D, 2D array and cube (not the layer, matching the float form's implicit LOD on the cube's 2D-array view), and three for 3D. The float, uint and sint views all take the same gradients.
  • Other stages: it samples at LOD 0, as its float form does.

The _b, _c*, _d, _cl and _o forms are unchanged.

Tests

tests/semantic/test_sample_typed_dims.py gets a new class, ImplicitSampleTypedDims, that checks every dimension in a PS and in a CS:

  • both integer aliases on the dimension's sampled binding, and the float view kept;
  • the gradient type, with all three views taking the same gradients, and no layer gradient for 2D array and cube;
  • Lod %f0 and no derivatives in the CS;
  • spirv-val --target-env vulkan1.2 passes on every module.

Without the translator change, 18 of the new subtests fail. The PS 2D case passes both ways, since that form was already typed.

What I ran, on macOS 26 with an Apple M4 (CPU only) and Python 3.12.13:

  • Translator suite: python -I scripts/run_semantic_tests.py -j 4 tests/semantic gives 459 files and 6,050 tests. Two files fail, test_exec_computed and test_image_atomics_guard, and both fail the same way on main 2d53a8055.
  • Docs and contract tests: tests/test_design_contract_rows.py, test_docs_table_rows.py and test_semantic_translator_use.py pass. test_docs_repeated_lines.py and test_docs_repo_paths.py fail the same way on main, on files this PR doesn't touch (tests/semantic/README.md, docs/retail_boot_intel_host.md).
  • No game data: scripts/check_no_game_data.py passes on the changed files.

Not GPU-verified. A pixel readback on a non-2D integer texture is still missing; the design row says so. The existing 2D fixtures, ps_sample_implicit_uint and ps_sample_implicit_sint, take the same path. No game files were used.

AI-assisted (Claude Code, Claude Opus 5.5).

🤖 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/110 **Author:** [@Andretuta](https://github.com/Andretuta) **Created:** 11/24/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `old-pr/9843` --- ### 📝 Commits (1) - [`1c08f38`](https://github.com/ubiquitarianism/leonida/commit/1c08f3856de0d503086e570ed8299a78807ca77c) rdna2spirv: a plain image_sample reads a UINT/SINT image in every dimension and stage (SHADER-1404) ### 📊 Changes **3 files changed** (+96 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+1 -1) 📝 `tests/semantic/test_sample_typed_dims.py` (+81 -9) 📝 `tools/rdna2spirv.py` (+14 -5) </details> ### 📄 Description > Carried over from **old PR 9843** by `tiagonogueiraa-bit` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/9843`, 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. > `tiagonogueiraa-bit`: 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, claimed in `#9677`: https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7116572064 ## What `image_sample` (no LOD dword) took the UINT/SINT typed read only in the pixel shader's 2D form. Two cases still read an integer image through the float view, so the VGPRs held a converted float instead of the integer texel: - a UINT/SINT 2D-array, 3D, cube or 1D image in the PS; - any integer image sampled outside the PS, including 2D. The hardware picks the view from T# FORMAT in every dimension and stage. EGEN-SAMPLE-TYPED-DIMS (`4dcb96e44`) already fixed `image_sample_l` / `image_sample_lz`; this PR covers the plain form. ## How `image_sample` now goes through the same `image_read_typed` dispatch as the explicit-LOD forms: - **Pixel shader:** it samples with gradients of the coordinates an implicit LOD derives from, taken before the format branch, as the 2D form already did. That's one coordinate for 1D, two for 2D, 2D array and cube (not the layer, matching the float form's implicit LOD on the cube's 2D-array view), and three for 3D. The float, uint and sint views all take the same gradients. - **Other stages:** it samples at LOD 0, as its float form does. The `_b`, `_c*`, `_d`, `_cl` and `_o` forms are unchanged. ## Tests `tests/semantic/test_sample_typed_dims.py` gets a new class, `ImplicitSampleTypedDims`, that checks every dimension in a PS and in a CS: - both integer aliases on the dimension's sampled binding, and the float view kept; - the gradient type, with all three views taking the same gradients, and no layer gradient for 2D array and cube; - `Lod %f0` and no derivatives in the CS; - `spirv-val --target-env vulkan1.2` passes on every module. Without the translator change, 18 of the new subtests fail. The PS 2D case passes both ways, since that form was already typed. What I ran, on macOS 26 with an Apple M4 (CPU only) and Python 3.12.13: - **Translator suite:** `python -I scripts/run_semantic_tests.py -j 4 tests/semantic` gives 459 files and 6,050 tests. Two files fail, `test_exec_computed` and `test_image_atomics_guard`, and both fail the same way on `main` `2d53a8055`. - **Docs and contract tests:** `tests/test_design_contract_rows.py`, `test_docs_table_rows.py` and `test_semantic_translator_use.py` pass. `test_docs_repeated_lines.py` and `test_docs_repo_paths.py` fail the same way on `main`, on files this PR doesn't touch (`tests/semantic/README.md`, `docs/retail_boot_intel_host.md`). - **No game data:** `scripts/check_no_game_data.py` passes on the changed files. **Not GPU-verified.** A pixel readback on a non-2D integer texture is still missing; the design row says so. The existing 2D fixtures, `ps_sample_implicit_uint` and `ps_sample_implicit_sint`, take the same path. No game files were used. AI-assisted (Claude Code, Claude Opus 5.5). 🤖 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:16:59 +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#162
No description provided.