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

Closed
Andretuta wants to merge 2 commits from upstream-pr/132 into main
Andretuta commented 2026-11-24 02:24:34 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Andretuta on 2026-11-24T02:24:34Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5464897374 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/132). Originally posted by [Andretuta](https://github.com/Andretuta) on 2026-11-24T02:24:34Z. --- > 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)
aslan2142 commented 2026-11-24 19:49:43 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-24T19:49:43Z.


Thanks for this work on SHADER-1404. Closing this carried-over draft in favour of #225, which makes the same
translator change.

  • The image_sample lowering here is the same as #225's (typed read in every dimension, Grad in the PS,
    Lod 0 elsewhere).
  • #225 also adds UINT and SINT GPU fixtures on a 2D array and a 3D volume, and they fail on every pixel without
    the fix.
  • If you think something here is missing from #225, please say so on #225.

The old-pr/* branch stays; see #17 for the list of carried-over PRs.

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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7142646097 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/132#issuecomment-7142646097). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-11-24T19:49:43Z. --- Thanks for this work on SHADER-1404. Closing this carried-over draft in favour of #225, which makes the same translator change. - The `image_sample` lowering here is the same as #225's (typed read in every dimension, `Grad` in the PS, `Lod 0` elsewhere). - #225 also adds UINT and SINT GPU fixtures on a 2D array and a 3D volume, and they fail on every pixel without the fix. - If you think something here is missing from #225, please say so on #225. The `old-pr/*` branch stays; see #17 for the list of carried-over PRs. AI-assisted (Claude Code, Claude Opus 5.5).

Pull request closed

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
ProjectLeonida/mandy!132
No description provided.