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

Closed
github-bot wants to merge 1 commit from gh-pr/110/head into gh-pr/110/base
Owner

@⁠Andretuta on GitHub · 2026-11-24 02:20 UTC · original
ubiquitarianism:old-pr/9843 → main · +96 −15 · 3 files · 1 commits · closed without merging

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

**@⁠Andretuta** on GitHub · 2026-11-24 02:20 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/110) `ubiquitarianism:old-pr/9843` → `main` · +96 −15 · 3 files · 1 commits · closed without merging > 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)
image_sample took the typed read only in the pixel shader's 2D form, so a UINT or SINT 2D-array, 3D, cube or 1D
image, and any integer image sampled outside the PS, was read through the float view: the VGPRs held a converted
float instead of the integer texel. image_sample_l / image_sample_lz already read the integer alias in every
dimension (EGEN-SAMPLE-TYPED-DIMS).

In the PS the sample now takes the gradients of the coordinates an implicit LOD derives from (1D: one; 2D, 2D array
and cube: two, not the layer; 3D: three) before the format branch, as the 2D form did. Elsewhere it samples at
LOD 0, as its float form does. tests/semantic/test_sample_typed_dims.py covers the aliases, the gradients, the LOD
and spirv-val for both stages; the design row says so.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:44:48 +00:00
github-bot closed this pull request 2026-11-26 08:44:48 +00:00
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-24 19:49 UTC · original

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

**@⁠aslan2142** on GitHub · 2026-11-24 19:49 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/110#issuecomment-7142644343) 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

This discussion has been locked. Commenting is limited to contributors.
No description provided.