feat(shader): load R10_G10_B10_A2 float images through a 32-bit view #17701

Merged
SHOnnay merged 8 commits from upstream-pr/17701 into main 2026-11-21 09:18:42 +00:00
SHOnnay commented 2026-11-09 10:53:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by SHOnnay on 2026-11-09T10:53:38Z.


What

Guest image format 131 (Format10_10_10_2Float) packs R, G and B as unsigned floats with a 4-bit exponent (bias 7) and a 6-bit mantissa, and A as a 2-bit UNORM. Vulkan has no format for it, so a T# using it made the draw or dispatch fail with the NumericClass reason, and the driver threw unsupported guest texture format 131.

The format is now held in an R32_UINT image like the other packed formats without a host equivalent, and an image_load that uses no sampler decodes it in the shader. R, G and B follow the layout in the shader debt entry (bits 0-9, 10-19 and 20-29, denormal at exponent 0, finite at exponent 15, 0x3ff reads 508); A is bits 30-31 as UNORM. The layout was measured with image_load on RDNA2 (gfx1036) through the hardware oracle, not on the PS5's gfx1013.

Refused with an error, as before or newly: a write, a packed MIMG access, an atomic, a sample, a gather, a LOD query, and DCC fast-clear codes 0001, 1110 and 1111 (a raw R32_UINT fill would not read as white in this layout). A runtime image mode for the format is generated only for images that are not written.

The shader debt entry for format 131 now lists only what is still open: the value of a denormal (decoded as the mantissa times 2^-12, which is the format's defined math, not a measured hardware result), the rounding of the 2-bit alpha (within 1 ULP of alpha/3), and the alpha of a D16 load.

Tests: agc_driver_image_format_131 loads 2048 texels that cover every 10-bit value in each of R, G and B, with swizzles X Y Z W, W Z Y X and X 0 1 W, and compares R, G and B bit-exactly with values computed from the documented layout in the test (not by calling the decoder); alpha is compared within 1 ULP for 1/3 and 2/3 and exactly for 0 and 1. It also loads with D16 on X Y Z 1, and checks that image_store, image_sample_lz, image_gather4, image_get_lod, image_load_pck and image_atomic_add of the format are refused. The atomic refusal predates this change (the existing 32-bit-only atomic format check) and is pinned, not new. agc_driver_graphics gains assertions for the driver remap, the numeric class and the DCC clear refusals. Both fail on main (unsupported guest texture format 131; sampled image descriptor uses an unsupported format) and pass here.

Evidence level: unit test bit-exact (decode, executed on a GPU through the recompiler); SPIR-V from Recompile is validated by SPIRV-Tools in a build with ANYPS5_ENABLE_SPIRV_TOOLS=ON. No title was run.

Tested

Windows 11, MinGW-w64 GCC 15.2 (UCRT, SEH), Release, BUILD_TESTING=ON, ANYPS5_ENABLE_SPIRV_TOOLS=ON, NVIDIA GeForce RTX 4070, driver 621.01, Vulkan 1.4.357. The GCC 15.2 runtime directory was first on PATH for the test session.

  • Full ctest --timeout 120 on main at c3112f0c0f (this change's files reverted to main): 4803 tests, 4801 passed, 2 failed: windows_integer_overflow_report (Timeout) and guest_timed_join_import_libkernel_web (libkernel_web.prx could not be loaded, GetLastError 126).
  • Full ctest --timeout 120 on this branch (same base): 4804 tests, 4802 passed, the same 2 failed. The 1 extra test is agc_driver_image_format_131.
  • Focused runs with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (agc_driver_graphics, agc_driver_image_packed16_storage_*, agc_driver_image_depth24*, plus agc_driver_image_format_131 here): neither log contains was not found but was requested by env var VK_INSTANCE_LAYERS, and neither contains VUID-. These were run on an earlier base, before the final rebase.
  • After the final rebase onto upstream/main c0d23c29c1: rebuilt, and the 1181 ctest tests matching agc_driver|shader|recompiler|spirv|rdna ran with the validation layer: 0 failed, 0 VUID-, 0 was not found but was requested; 10 skipped by the tests themselves (missing Vulkan features). Full suite not re-run on this base.
  • Only agc_driver_image_format_131 and agc_driver_graphics fail on main; the gather/LOD/pck/atomic refusal tests are regression guards for unsupported paths.
  • python tools/check_conventions.py --base upstream/main: all checks passed.
  • tools/pr_overlap.py failed closed (could not confirm overlap with a list of open PRs that share files); compared by hand, no open PR decodes format 131.

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 (conflicts with #14709, which renames enumerator 131 to Format6E4Float; I will rebase whichever merges second)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 4070, driver 621.01, Windows 11
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5222708405 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17701). Originally posted by [SHOnnay](https://github.com/SHOnnay) on 2026-11-09T10:53:38Z. --- ### What Guest image format 131 (`Format10_10_10_2Float`) packs R, G and B as unsigned floats with a 4-bit exponent (bias 7) and a 6-bit mantissa, and A as a 2-bit UNORM. Vulkan has no format for it, so a T# using it made the draw or dispatch fail with the `NumericClass` reason, and the driver threw `unsupported guest texture format 131`. The format is now held in an `R32_UINT` image like the other packed formats without a host equivalent, and an `image_load` that uses no sampler decodes it in the shader. R, G and B follow the layout in the shader debt entry (bits 0-9, 10-19 and 20-29, denormal at exponent 0, finite at exponent 15, 0x3ff reads 508); A is bits 30-31 as UNORM. The layout was measured with `image_load` on RDNA2 (gfx1036) through the hardware oracle, not on the PS5's gfx1013. Refused with an error, as before or newly: a write, a packed MIMG access, an atomic, a sample, a gather, a LOD query, and DCC fast-clear codes 0001, 1110 and 1111 (a raw R32_UINT fill would not read as white in this layout). A runtime image mode for the format is generated only for images that are not written. The shader debt entry for format 131 now lists only what is still open: the value of a denormal (decoded as the mantissa times 2^-12, which is the format's defined math, not a measured hardware result), the rounding of the 2-bit alpha (within 1 ULP of alpha/3), and the alpha of a D16 load. Tests: `agc_driver_image_format_131` loads 2048 texels that cover every 10-bit value in each of R, G and B, with swizzles X Y Z W, W Z Y X and X 0 1 W, and compares R, G and B bit-exactly with values computed from the documented layout in the test (not by calling the decoder); alpha is compared within 1 ULP for 1/3 and 2/3 and exactly for 0 and 1. It also loads with D16 on X Y Z 1, and checks that `image_store`, `image_sample_lz`, `image_gather4`, `image_get_lod`, `image_load_pck` and `image_atomic_add` of the format are refused. The atomic refusal predates this change (the existing 32-bit-only atomic format check) and is pinned, not new. `agc_driver_graphics` gains assertions for the driver remap, the numeric class and the DCC clear refusals. Both fail on `main` (`unsupported guest texture format 131`; `sampled image descriptor uses an unsupported format`) and pass here. Evidence level: unit test bit-exact (decode, executed on a GPU through the recompiler); SPIR-V from `Recompile` is validated by SPIRV-Tools in a build with `ANYPS5_ENABLE_SPIRV_TOOLS=ON`. No title was run. ### Tested Windows 11, MinGW-w64 GCC 15.2 (UCRT, SEH), Release, `BUILD_TESTING=ON`, `ANYPS5_ENABLE_SPIRV_TOOLS=ON`, NVIDIA GeForce RTX 4070, driver 621.01, Vulkan 1.4.357. The GCC 15.2 runtime directory was first on `PATH` for the test session. - Full `ctest --timeout 120` on `main` at c3112f0c0f (this change's files reverted to `main`): 4803 tests, 4801 passed, 2 failed: `windows_integer_overflow_report` (Timeout) and `guest_timed_join_import_libkernel_web` (`libkernel_web.prx` could not be loaded, GetLastError 126). - Full `ctest --timeout 120` on this branch (same base): 4804 tests, 4802 passed, the same 2 failed. The 1 extra test is `agc_driver_image_format_131`. - Focused runs with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1` and `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` (`agc_driver_graphics`, `agc_driver_image_packed16_storage_*`, `agc_driver_image_depth24*`, plus `agc_driver_image_format_131` here): neither log contains `was not found but was requested by env var VK_INSTANCE_LAYERS`, and neither contains `VUID-`. These were run on an earlier base, before the final rebase. - After the final rebase onto upstream/main c0d23c29c1: rebuilt, and the 1181 ctest tests matching `agc_driver|shader|recompiler|spirv|rdna` ran with the validation layer: 0 failed, 0 `VUID-`, 0 `was not found but was requested`; 10 skipped by the tests themselves (missing Vulkan features). Full suite not re-run on this base. - Only agc_driver_image_format_131 and agc_driver_graphics fail on main; the gather/LOD/pck/atomic refusal tests are regression guards for unsupported paths. - `python tools/check_conventions.py --base upstream/main`: all checks passed. - `tools/pr_overlap.py` failed closed (could not confirm overlap with a list of open PRs that share files); compared by hand, no open PR decodes format 131. ### 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 (conflicts with #14709, which renames enumerator 131 to `Format6E4Float`; I will rebase whichever merges second) - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: NVIDIA GeForce RTX 4070, driver 621.01, Windows 11 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-11-20 15:57:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T15:57:41Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the targeted implementation and regression coverage support the stated load-only behavior, though I did not run checks myself.

What I ran

Reviewed head f3ef4514e80aa6cc4c68f8f90a068e500b0b3fea using the prepared diff and repo_read.py source reads. No commands or tests were run; the test results in the description are author-reported.

Results

Check Result Note
Diff and implementation review passed All changed files read
Automated checks not run Results in description are author-reported
PS5 hardware behavior not run No title was run

Findings

Blocking

None.

Non-blocking

None.

Not verified

No automated checks were run during this review. The PR description reports focused test success on the final rebase and full-suite results on an earlier base; these were not independently verified. No title or PS5 gfx1013 behavior was tested. Read all 11 changed files listed in manifest.json, including every added line. No changed files were excluded.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5995529429 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17701#pullrequestreview-5995529429). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T15:57:41Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the targeted implementation and regression coverage support the stated load-only behavior, though I did not run checks myself. ## What I ran Reviewed head `f3ef4514e80aa6cc4c68f8f90a068e500b0b3fea` using the prepared diff and `repo_read.py` source reads. No commands or tests were run; the test results in the description are author-reported. ## Results | Check | Result | Note | |---|---|---| | Diff and implementation review | passed | All changed files read | | Automated checks | not run | Results in description are author-reported | | PS5 hardware behavior | not run | No title was run | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified No automated checks were run during this review. The PR description reports focused test success on the final rebase and full-suite results on an earlier base; these were not independently verified. No title or PS5 gfx1013 behavior was tested. Read all 11 changed files listed in `manifest.json`, including every added line. No changed files were excluded. ## To get this to a good state Nothing is required.
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!17701
No description provided.