[PR #1481] rdna2spirv: 16-bit gradients for image_sample_d_g16 and image_sample_… #1511

Open
opened 2026-11-26 20:21:29 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1481
Author: @vsking2000
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: shader-sample-g16


📝 Commits (1)

  • ece08d3 rdna2spirv: 16-bit gradients for image_sample_d_g16 and image_sample_d_cl_g16 (SHADER-SAMPLE-G16)

📊 Changes

3 files changed (+229 additions, -2 deletions)

View changed files

📝 docs/design.md (+2 -1)
➕ tests/semantic/test_sample_g16.py (+190 -0)
📝 tools/rdna2spirv.py (+37 -1)

📄 Description

…d_cl_g16 (SHADER-SAMPLE-G16)

The two g16 forms whose f32-gradient sibling main translates are now the same sample as image_sample_d / image_sample_d_cl, with dP/dx and dP/dy read as f16 halves: two per VGPR, low half first, each axis padded to a whole VGPR (1D (dx, -) (dx, -); 2D/array/cube (x, y) (x, y); 3D (x, y) (z, -) (x, y) (z, -)). Coordinates and clamp follow, packed only under a16; g16 and a16 are independent. Gen.g16_gradients widens each half with UnpackHalf2x16 and drops the pad; the f32-gradient path does the rest. LLVM (SIISelLowering lowerImage, packImage16bitOpsToDwords) and Mesa ACO (aco_select_nir.cpp, emit_pack_v1) agree on every point.

The six compare/offset g16 forms stay refused until their f32 siblings are translated (SHADER-SAMPLE-GRAD-FORMS), and the eight _cd g16 forms stay refused. docs/design.md gets a row. Not run on a GPU.

Claude-Session: https://claude.ai/code/session_01Y7fbZYVY7EtLknWBZUfSLf

Claimed in the coordination issue as:

Depends on:

Fixes:

What and why

Tested

GPUs tested:

AI-assisted:

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • 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.

🔄 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/1481 **Author:** [@vsking2000](https://github.com/vsking2000) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `shader-sample-g16` --- ### 📝 Commits (1) - [`ece08d3`](https://github.com/ubiquitarianism/leonida/commit/ece08d3b1e2c51af15c133ae95480ad27cfb522b) rdna2spirv: 16-bit gradients for image_sample_d_g16 and image_sample_d_cl_g16 (SHADER-SAMPLE-G16) ### 📊 Changes **3 files changed** (+229 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+2 -1) ➕ `tests/semantic/test_sample_g16.py` (+190 -0) 📝 `tools/rdna2spirv.py` (+37 -1) </details> ### 📄 Description …d_cl_g16 (SHADER-SAMPLE-G16) The two g16 forms whose f32-gradient sibling main translates are now the same sample as image_sample_d / image_sample_d_cl, with dP/dx and dP/dy read as f16 halves: two per VGPR, low half first, each axis padded to a whole VGPR (1D (dx, -) (dx, -); 2D/array/cube (x, y) (x, y); 3D (x, y) (z, -) (x, y) (z, -)). Coordinates and clamp follow, packed only under a16; g16 and a16 are independent. Gen.g16_gradients widens each half with UnpackHalf2x16 and drops the pad; the f32-gradient path does the rest. LLVM (SIISelLowering lowerImage, packImage16bitOpsToDwords) and Mesa ACO (aco_select_nir.cpp, emit_pack_v1) agree on every point. The six compare/offset g16 forms stay refused until their f32 siblings are translated (SHADER-SAMPLE-GRAD-FORMS), and the eight _cd g16 forms stay refused. docs/design.md gets a row. Not run on a GPU. Claude-Session: https://claude.ai/code/session_01Y7fbZYVY7EtLknWBZUfSLf Claimed in the coordination issue as: <!-- the item ID from the open "Coordinating who works on what" issue, for example TEST-17, or a link to your claim --> Depends on: <!-- #N for every pull request this one builds on or conflicts with (the coordination issue's Commands section, AGENTS.md); delete the line if it builds on none and conflicts with none --> Fixes: <!-- #N for each issue this closes (GitHub closes it on merge); delete the line if it closes none --> ### What and why <!-- What this changes and the problem it solves. --> ### Tested <!-- What you ran and on which GPU and driver (CONTRIBUTING.md). For the shader translator: how many shaders translate and pass spirv-val, before and after. --> GPUs tested: <!-- vendor, model, driver and OS of each GPU the GPU tests ran on, or n/a --> AI-assisted: <!-- yes or no (AGENTS.md asks a coding agent to say so) --> ### Checklist - [ ] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [ ] One topic; follow-up work goes in a new pull request. - [ ] 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#1511
No description provided.