rdna2spirv: implicit samples read the T# FORMAT view in every dimension (SHADER-1404) #154

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

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


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

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


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:7142649152 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/154#issuecomment-7142649152). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-11-24T19:49:50Z. --- 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!154
No description provided.