feat(agc): sample and store 1_5_5_5 UNorm images #14628

Merged
AlexWhitehouse merged 2 commits from upstream-pr/14628 into main 2026-11-14 11:38:57 +00:00
AlexWhitehouse commented 2026-11-01 16:36:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by AlexWhitehouse on 2026-11-01T16:36:15Z.


What

Supports guest image format code 135 (IrBufferFormat::Format1_5_5_5UNorm) for sampling and for image loads and stores. Before this PR the descriptor table marked it unsupported and it had no Vulkan mapping.

Layout. X is one bit at bit 0, and Y, Z and W are five bits each at bits 1, 6 and 11, all UNORM.

  • Mesa's gfx10 tables (418c4cfa6708a0e0b1175e72fb8fd27d3ca1615a, src/amd/registers/gfx10-rsrc.json) name code 135 GFX10_FORMAT_5_5_5_1_UNORM, and src/amd/common/gfx10_format_table.py reverses that name into little-endian component order.
  • AMD's RDNA 2 ISA guide, §8.2.8, Table 47 (printed pp. 78-79), classifies 135 as an image-only format.
  • Code 134 is the one Mesa calls 1_5_5_5, and the debt entry spells that out.

Mapping.

  • Sampling and loads go through VK_FORMAT_R5G5B5A1_UNORM_PACK16, with guest X, Y, Z and W read from host A, B, G and R.
  • Storage views use R16_UINT with the existing packed-16 bitfield conversion that 133, 134 and 136 already use.
  • A new image-only GetImageFormatInfo supplies 135's layout, so typed buffers still reject it, as Table 47 requires.

Debt. The docs/dev/debt/libSceAgcDriver.md and shader.md entries state what is unverified on the PS5: normalization, store rounding ties and NaN handling. They also note that loads and filtering follow the host's UNORM precision: lavapipe point samples and NVIDIA loads quantize 5-bit channels to 8 bits.

The progress scan's format coverage moves from sampled 81 to 82 and host 68 to 69, with typed buffer unchanged at 80.

Tested

  • agc_driver_image_packed16_load (tests/execution/ImagePacked16Load.cpp) now also walks every bit of the 16-bit word through 133, 134, 135 and 136. It checks endpoints, XYZW, ZYXW and another swizzle, point and bilinear samples, and that 135 is rejected as a buffer format.
    • Values of 0 and 1 must be exact.
    • Fractions allow 1/255 + 1e-5. NVIDIA RTX 3060 loads return 5-bit channels at 8-bit UNORM precision, for example 8/255 for 1/31.
  • agc_driver_image_packed16_storage_135 (tests/execution/ImageConvertedUnorm.cpp) stores through the packed-16 path and compares the guest bytes, with guard bytes around the target.
  • Mutation checks:
    • swapping the bit offsets 1 and 6 of 135 fails storage_135 at ImageConvertedUnorm.cpp:512;
    • reversing 135's A/B/G/R swizzle fails agc_driver_image_packed16_load.
  • Required focused comparison: ctest -R "^agc_driver_image_packed16_(load|storage_13[3-6])$" -V on main (f2d874c1fd) and this PR (61fb2c4955), with the same test sources and ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation:
    • NVIDIA RTX 3060, Windows 11: main passes 3/5, with load and storage_135 failing on sampled image descriptor uses an unsupported format. This PR passes 5/5. The validation layer was loaded and inserted for every test (checked with VK_LOADER_DEBUG=layer), there was no missing-layer warning, no skips, and no VUID- errors in either log.
    • lavapipe, Ubuntu 26.04: main passes 3/5 and this PR passes 5/5, with no missing-layer warning, no skips and no VUID- errors in either log.
  • Wider runs on lavapipe, with the same variables: ctest -R "agc_driver_image|agc_driver_format|buffer_format|texture" passes 78/78, and public_headers passes 65/65.
  • python3 tools/check_conventions.py --base origin/main: all conventions checks passed.
  • python3 tools/pr_overlap.py: no confirmed overlap. The tool could not compare 77 open PRs that conflict with main. None of their diffs adds Format1_5_5_5UNorm, a 135 table entry, R5G5B5A1_UNORM_PACK16 or GetImageFormatInfo.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 3060, driver 610.88, Windows 11 Pro 10.0.26300; lavapipe (llvmpipe, Mesa 26.0.8, LLVM 21.1.8), Ubuntu 26.04 x86-64
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5109343329 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14628). Originally posted by [AlexWhitehouse](https://github.com/AlexWhitehouse) on 2026-11-01T16:36:15Z. --- ### What Supports guest image format code 135 (`IrBufferFormat::Format1_5_5_5UNorm`) for sampling and for image loads and stores. Before this PR the descriptor table marked it unsupported and it had no Vulkan mapping. **Layout.** X is one bit at bit 0, and Y, Z and W are five bits each at bits 1, 6 and 11, all UNORM. - Mesa's gfx10 tables (418c4cfa6708a0e0b1175e72fb8fd27d3ca1615a, `src/amd/registers/gfx10-rsrc.json`) name code 135 `GFX10_FORMAT_5_5_5_1_UNORM`, and `src/amd/common/gfx10_format_table.py` reverses that name into little-endian component order. - AMD's RDNA 2 ISA guide, §8.2.8, Table 47 (printed pp. 78-79), classifies 135 as an image-only format. - Code 134 is the one Mesa calls `1_5_5_5`, and the debt entry spells that out. **Mapping.** - Sampling and loads go through `VK_FORMAT_R5G5B5A1_UNORM_PACK16`, with guest X, Y, Z and W read from host A, B, G and R. - Storage views use `R16_UINT` with the existing packed-16 bitfield conversion that 133, 134 and 136 already use. - A new image-only `GetImageFormatInfo` supplies 135's layout, so typed buffers still reject it, as Table 47 requires. **Debt.** The `docs/dev/debt/libSceAgcDriver.md` and `shader.md` entries state what is unverified on the PS5: normalization, store rounding ties and NaN handling. They also note that loads and filtering follow the host's UNORM precision: lavapipe point samples and NVIDIA loads quantize 5-bit channels to 8 bits. The progress scan's format coverage moves from sampled 81 to 82 and host 68 to 69, with typed buffer unchanged at 80. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> - **`agc_driver_image_packed16_load`** (`tests/execution/ImagePacked16Load.cpp`) now also walks every bit of the 16-bit word through 133, 134, 135 and 136. It checks endpoints, `XYZW`, `ZYXW` and another swizzle, point and bilinear samples, and that 135 is rejected as a buffer format. - Values of 0 and 1 must be exact. - Fractions allow 1/255 + 1e-5. NVIDIA RTX 3060 loads return 5-bit channels at 8-bit UNORM precision, for example 8/255 for 1/31. - **`agc_driver_image_packed16_storage_135`** (`tests/execution/ImageConvertedUnorm.cpp`) stores through the packed-16 path and compares the guest bytes, with guard bytes around the target. - **Mutation checks:** - swapping the bit offsets 1 and 6 of 135 fails `storage_135` at `ImageConvertedUnorm.cpp:512`; - reversing 135's A/B/G/R swizzle fails `agc_driver_image_packed16_load`. - **Required focused comparison:** `ctest -R "^agc_driver_image_packed16_(load|storage_13[3-6])$" -V` on `main` (f2d874c1fd) and this PR (61fb2c4955), with the same test sources and `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1` and `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`: - **NVIDIA RTX 3060, Windows 11:** main passes 3/5, with load and storage_135 failing on `sampled image descriptor uses an unsupported format`. This PR passes 5/5. The validation layer was loaded and inserted for every test (checked with `VK_LOADER_DEBUG=layer`), there was no missing-layer warning, no skips, and no `VUID-` errors in either log. - **lavapipe, Ubuntu 26.04:** main passes 3/5 and this PR passes 5/5, with no missing-layer warning, no skips and no `VUID-` errors in either log. - **Wider runs on lavapipe**, with the same variables: `ctest -R "agc_driver_image|agc_driver_format|buffer_format|texture"` passes 78/78, and `public_headers` passes 65/65. - `python3 tools/check_conventions.py --base origin/main`: all conventions checks passed. - `python3 tools/pr_overlap.py`: no confirmed overlap. The tool could not compare 77 open PRs that conflict with `main`. None of their diffs adds `Format1_5_5_5UNorm`, a 135 table entry, `R5G5B5A1_UNORM_PACK16` or `GetImageFormatInfo`. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: NVIDIA GeForce RTX 3060, driver 610.88, Windows 11 Pro 10.0.26300; lavapipe (llvmpipe, Mesa 26.0.8, LLVM 21.1.8), Ubuntu 26.04 x86-64 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-11-02 07:20:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-02T07:20:59Z.

Review: COMMENTED


Reviewed — no blocking findings in the code read; the 1_5_5_5 image tests have no hosted pass

This PR adds sampling and storing of 1_5_5_5 UNorm images: a format-135 entry in the texture format table, a helper that gives the image path its own format description, and the SPIR-V image emitter using it. I read the production change in full. The layout comes from a Mesa commit that the debt entry cites, and I did not check that commit. The Windows run selected 39 cases, and none of them is the image tests this PR changes.

What I ran

  • Head 61b7d9bcaaf56a4477df7d254884fe6fc94152c8; base f2d874c1fdccf781c0fa5d86619bb5dd8894b958. 13 files, +81/-16: Graphics/src/Texture.cpp, Graphics/src/TextureFormat.cpp (new format and GetImageFormatInfo), Optimization/src/ResourceMaterializer.cpp, RdnaDecoder/src/RdnaDescriptorFormat.cpp, SpirvBackend/include/SpirvBackend/SpirvBufferFormat.hpp, SpirvBackend/src/SpirvBufferFormat.cpp, SpirvBackend/src/SpirvImageEmitter.cpp, the image-test CMake fragment, four test sources, and two debt lines.
  • Read the production change in full (the Graphics, Execution, shader and docs parts of the diff). The test diffs were not read: ImageConvertedUnorm.cpp (+14/-), ImagePacked16Load.cpp (+49), TextureFormat.cpp (+3/-1).
  • Hosted, Windows CTest: 39 of 39 passed. None of the cases in the run is named for the image tests (ImageConvertedUnorm, ImagePacked16Load).
  • Read-only checks from the trusted main checkout: diff check, conventions and PR template, and the stack check all passed (no declared dependencies, no errors). ABI audit not applicable.
  • The test-quality helper flagged three of the changed test sources as possibly unregistered. Not investigated further.
  • No MarcZX10 review at this head.

Results

Check Result Note
Diff check passed
Conventions and PR template passed conventions check from the main checkout
Mergeability and dependencies passed stack check: no declared dependencies, no errors
ABI audit not applicable no export changed
Image tests (hosted, Windows) not verified no case for ImageConvertedUnorm or ImagePacked16Load appears in the 39-case run
Production change (read) passed by reading no blocking defect found in the read
Bit layout (X/Y/Z/W at bits 0/1/6/11, widths 1/5/5/5) not verified taken from the cited Mesa commit, which was not checked; the debt entry says there is no PS5 measurement
Relinkers and relinker-asan (hosted) passed all succeeded
library-portability (hosted) passed
Negative controls not run no local build
Read-only check output

Precheck was not run: no PR-head code is run here. Diff check: passed. Conventions: passed. Stack check: passed, no declared dependencies, no errors. ABI audit: not applicable. Hosted: gh api repos/boykopovar/AnyPS5/commits/61b7d9bcaaf56a4477df7d254884fe6fc94152c8/check-runs, and the Windows job log (39 of 39).

Negative control

Not run here. A negative control needs a local build and run of the image tests, and code from this head is not run here.

Findings

Blocking

None from the code read.

Non-blocking

  • No hosted case exercises the new format. The 1_5_5_5 path is therefore covered only by the tests that the run did not select.
  • The bit layout rests on an external source that the debt entry cites, and the debt entry says it has no PS5 measurement. That is the PR's own disclosure, and I did not check the cited commit.

Sources

Not verified

  • The image test sources (ImageConvertedUnorm.cpp, ImagePacked16Load.cpp) and the TextureFormat.cpp test change.
  • The bit layout of format 135, against the cited Mesa commit or against hardware.
  • Any hosted pass for the new format.

To get this to a good state

  • Run ImageConvertedUnorm and ImagePacked16Load in hosted CI at this head. Nothing else blocking.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5733187276 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14628#pullrequestreview-5733187276). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-02T07:20:59Z. **Review:** COMMENTED --- # Reviewed — no blocking findings in the code read; the 1_5_5_5 image tests have no hosted pass This PR adds sampling and storing of `1_5_5_5 UNorm` images: a format-135 entry in the texture format table, a helper that gives the image path its own format description, and the SPIR-V image emitter using it. I read the production change in full. The layout comes from a Mesa commit that the debt entry cites, and I did not check that commit. The Windows run selected 39 cases, and none of them is the image tests this PR changes. ## What I ran - Head `61b7d9bcaaf56a4477df7d254884fe6fc94152c8`; base `f2d874c1fdccf781c0fa5d86619bb5dd8894b958`. 13 files, +81/-16: `Graphics/src/Texture.cpp`, `Graphics/src/TextureFormat.cpp` (new format and `GetImageFormatInfo`), `Optimization/src/ResourceMaterializer.cpp`, `RdnaDecoder/src/RdnaDescriptorFormat.cpp`, `SpirvBackend/include/SpirvBackend/SpirvBufferFormat.hpp`, `SpirvBackend/src/SpirvBufferFormat.cpp`, `SpirvBackend/src/SpirvImageEmitter.cpp`, the image-test CMake fragment, four test sources, and two debt lines. - Read the production change in full (the Graphics, Execution, shader and docs parts of the diff). The test diffs were not read: `ImageConvertedUnorm.cpp` (+14/-), `ImagePacked16Load.cpp` (+49), `TextureFormat.cpp` (+3/-1). - Hosted, Windows CTest: 39 of 39 passed. None of the cases in the run is named for the image tests (`ImageConvertedUnorm`, `ImagePacked16Load`). - Read-only checks from the trusted main checkout: diff check, conventions and PR template, and the stack check all passed (no declared dependencies, no errors). ABI audit not applicable. - The test-quality helper flagged three of the changed test sources as possibly unregistered. Not investigated further. - No MarcZX10 review at this head. ## Results | Check | Result | Note | | --- | --- | --- | | Diff check | passed | | | Conventions and PR template | passed | conventions check from the main checkout | | Mergeability and dependencies | passed | stack check: no declared dependencies, no errors | | ABI audit | not applicable | no export changed | | Image tests (hosted, Windows) | not verified | no case for `ImageConvertedUnorm` or `ImagePacked16Load` appears in the 39-case run | | Production change (read) | passed by reading | no blocking defect found in the read | | Bit layout (X/Y/Z/W at bits 0/1/6/11, widths 1/5/5/5) | not verified | taken from the cited Mesa commit, which was not checked; the debt entry says there is no PS5 measurement | | Relinkers and relinker-asan (hosted) | passed | all succeeded | | `library-portability` (hosted) | passed | | | Negative controls | not run | no local build | <details><summary>Read-only check output</summary> Precheck was not run: no PR-head code is run here. Diff check: passed. Conventions: passed. Stack check: passed, no declared dependencies, no errors. ABI audit: not applicable. Hosted: `gh api repos/boykopovar/AnyPS5/commits/61b7d9bcaaf56a4477df7d254884fe6fc94152c8/check-runs`, and the Windows job log (39 of 39). </details> ## Negative control Not run here. A negative control needs a local build and run of the image tests, and code from this head is not run here. ## Findings **Blocking** None from the code read. **Non-blocking** - No hosted case exercises the new format. The 1_5_5_5 path is therefore covered only by the tests that the run did not select. - The bit layout rests on an external source that the debt entry cites, and the debt entry says it has no PS5 measurement. That is the PR's own disclosure, and I did not check the cited commit. ## Sources - Format and helper: https://github.com/boykopovar/AnyPS5/blob/61b7d9bcaaf56a4477df7d254884fe6fc94152c8/core/libs/prx/libSceAgcDriver/Graphics/src/TextureFormat.cpp - Image emitter: https://github.com/boykopovar/AnyPS5/blob/61b7d9bcaaf56a4477df7d254884fe6fc94152c8/core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp - Debt entry: https://github.com/boykopovar/AnyPS5/blob/61b7d9bcaaf56a4477df7d254884fe6fc94152c8/docs/dev/debt/libSceAgcDriver.md - Windows job log: check-run `windows` on 61b7d9bcaaf56a4477df7d254884fe6fc94152c8 ## Not verified - The image test sources (`ImageConvertedUnorm.cpp`, `ImagePacked16Load.cpp`) and the `TextureFormat.cpp` test change. - The bit layout of format 135, against the cited Mesa commit or against hardware. - Any hosted pass for the new format. ## To get this to a good state - Run `ImageConvertedUnorm` and `ImagePacked16Load` in hosted CI at this head. Nothing else blocking.
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
boykopovar/AnyPS5!14628
No description provided.