feat(agc): render 4_4_4_4 UNORM color targets through packed R16_UINT exports #8563

Merged
JAB-dev merged 5 commits from upstream-pr/8563 into main 2026-10-23 19:12:20 +00:00
JAB-dev commented 2026-10-20 16:43:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JAB-dev on 2026-10-20T16:43:43Z.


What

Draws can now render into 4-bit-per-channel (4_4_4_4) colour targets on GPUs that cannot attach that format. Arcade Game Zone uses one, and the RTX 4070 SUPER (driver 610.88) exposes none of the four Vulkan 4-bit formats as a colour attachment.

The target (CB_COLOR_INFO format 19, UNORM, COMP_SWAP 2) becomes an R16_UINT attachment, and the pixel shader packs its exports into the guest layout: A in bits 3..0, B in 7..4, G in 11..8 and R in 15..12. The 10_11_11 target already works this way. The layout is the one the PS5 SDK's Agc headers define: in registerstructs.h, CxRenderTarget::Format::k4_4_4_4 (0x4c, format 19 shifted by 2) has four 4-bit channels with X in bits 3..0, Y in 7..4, Z in 11..8 and W in 15..12, and CxRenderTarget::ChannelOrder::kReversed (0x1000, COMP_SWAP 2 shifted by 11) maps A, B, G, R to channels 0 to 3; kRenderTargetChannelOrderReversed in the Gnmp constants.h lists four channels as ABGR. The PS4 SDK 8.008 (kSurfaceFormat4_4_4_4, reversed channel order) and Mesa's ac_translate_colorswap, which programs SWAP_STD_REV for A4B4G4R4_UNORM, agree. These throw:

  • blending
  • DCC
  • truncating rounding
  • CB resolves
  • writes of fewer than four components

Overlap: the open "support packed 16-bit storage images" fix adds the same two Format4_4_4_4UNorm buffer-format cases to SpirvBufferFormat.cpp, at the same anchors. Whichever lands second drops those two lines, and the two PRs do not conflict in behaviour. Each works without the other, so neither depends on the other. No other open PR implements the same functions.

Arcade Game Zone (PPSA19015) on main bf2c63f85 (committed 2026-10-19 20:52 UTC) stops after 13.9 s with AGC graphics: unsupported color format 19 number type 0 component swap 2. With this PR on that commit it stops after 14.5 s with AGC graphics: partial writes of a 4_4_4_4 unorm color target are unsupported. The draw it stops at writes only the top nibble, and the follow-up PR merges such writes. This PR alone does not get the title further.

Tested

Windows 11 x64, GCC 15.2 (WinLibs), NVIDIA GeForce RTX 4070 SUPER, driver 610.88.

  • agc_driver_graphics (unit test) covers decode, export packing, the serializer round trip, shader validation and the refusals.
  • The new execution test agc_driver_packed_unorm4444_color_target_tests draws 32_ABGR and FP16_ABGR exports into a linear target. The exports include NaN, negative, infinite, denormal and rounded values. It compares every pixel with the guest layout, including pixels outside the scissor. The expected words are hard-coded from that layout (golden values such as (1, 0, 0, 0) → 0xF000, (0, 0, 0, 1) → 0x000F and (1, 0.5, 0, 0.25) → 0xF804), not produced by the test's packer. Reversing the nibble order, swapping R and B, or moving A to the top nibble in the driver's packing makes it fail. It needs a Vulkan device and is skipped without one.
  • On main the target is refused at decode, so these tests fail there.
  • The existing 10_11_11, 1_5_5_5 and 5_6_5 target tests pass.
  • Only the linear tile mode is tested.

Vulkan validation: I ran the same focused tests on main and on this branch, on the same machine and GPU, through ctest -V with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ANYPS5_NO_SHADER_CACHE=1 and ANYPS5_REQUIRE_VULKAN=1. Neither log contains "was not found but was requested by env var". The 23 existing tests report the same VUID ids with the same counts on both:

  • agc_driver_graphics, agc_shader_memory, request_serializer and agc_multisample_guest_access
  • the 5_6_5, 10_11_11, 11_11_10, mip-tail and sRGB8 colour target tests, and the two uint8x4 colour target tests
  • the six multisample readback tests
  • the multisample fill, retirement, pass-order, sample-mask, sample-target and native depth tests

The new execution test reports only VUID-VkPhysicalDeviceProperties2-pNext-pNext and VUID-VkDeviceCreateInfo-pNext-pNext. Every Vulkan test among them reports these on main too: the layer is the Vulkan SDK 1.3.236 build, older than the 1.4 driver, and does not know the newer structures in those chains.

Linux not tested.

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: PPSA19015 #8562
  • GPUs tested: NVIDIA GeForce RTX 4070 SUPER, driver 610.88, Windows 11
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4939151816 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8563). Originally posted by [JAB-dev](https://github.com/JAB-dev) on 2026-10-20T16:43:43Z. --- ### What Draws can now render into 4-bit-per-channel (4_4_4_4) colour targets on GPUs that cannot attach that format. Arcade Game Zone uses one, and the RTX 4070 SUPER (driver 610.88) exposes none of the four Vulkan 4-bit formats as a colour attachment. The target (CB_COLOR_INFO format 19, UNORM, COMP_SWAP 2) becomes an R16_UINT attachment, and the pixel shader packs its exports into the guest layout: A in bits 3..0, B in 7..4, G in 11..8 and R in 15..12. The 10_11_11 target already works this way. The layout is the one the PS5 SDK's Agc headers define: in `registerstructs.h`, `CxRenderTarget::Format::k4_4_4_4` (0x4c, format 19 shifted by 2) has four 4-bit channels with X in bits 3..0, Y in 7..4, Z in 11..8 and W in 15..12, and `CxRenderTarget::ChannelOrder::kReversed` (0x1000, `COMP_SWAP` 2 shifted by 11) maps A, B, G, R to channels 0 to 3; `kRenderTargetChannelOrderReversed` in the Gnmp `constants.h` lists four channels as ABGR. The PS4 SDK 8.008 (`kSurfaceFormat4_4_4_4`, reversed channel order) and Mesa's `ac_translate_colorswap`, which programs `SWAP_STD_REV` for `A4B4G4R4_UNORM`, agree. These throw: - blending - DCC - truncating rounding - CB resolves - writes of fewer than four components Overlap: the open "support packed 16-bit storage images" fix adds the same two `Format4_4_4_4UNorm` buffer-format cases to `SpirvBufferFormat.cpp`, at the same anchors. Whichever lands second drops those two lines, and the two PRs do not conflict in behaviour. Each works without the other, so neither depends on the other. No other open PR implements the same functions. Arcade Game Zone (PPSA19015) on `main` bf2c63f85 (committed 2026-10-19 20:52 UTC) stops after 13.9 s with `AGC graphics: unsupported color format 19 number type 0 component swap 2`. With this PR on that commit it stops after 14.5 s with `AGC graphics: partial writes of a 4_4_4_4 unorm color target are unsupported`. The draw it stops at writes only the top nibble, and the follow-up PR merges such writes. This PR alone does not get the title further. ### Tested Windows 11 x64, GCC 15.2 (WinLibs), NVIDIA GeForce RTX 4070 SUPER, driver 610.88. - `agc_driver_graphics` (unit test) covers decode, export packing, the serializer round trip, shader validation and the refusals. - The new execution test `agc_driver_packed_unorm4444_color_target_tests` draws 32_ABGR and FP16_ABGR exports into a linear target. The exports include NaN, negative, infinite, denormal and rounded values. It compares every pixel with the guest layout, including pixels outside the scissor. The expected words are hard-coded from that layout (golden values such as (1, 0, 0, 0) → 0xF000, (0, 0, 0, 1) → 0x000F and (1, 0.5, 0, 0.25) → 0xF804), not produced by the test's packer. Reversing the nibble order, swapping R and B, or moving A to the top nibble in the driver's packing makes it fail. It needs a Vulkan device and is skipped without one. - On `main` the target is refused at decode, so these tests fail there. - The existing 10_11_11, 1_5_5_5 and 5_6_5 target tests pass. - Only the linear tile mode is tested. Vulkan validation: I ran the same focused tests on `main` and on this branch, on the same machine and GPU, through `ctest -V` with `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, `ANYPS5_NO_SHADER_CACHE=1` and `ANYPS5_REQUIRE_VULKAN=1`. Neither log contains "was not found but was requested by env var". The 23 existing tests report the same VUID ids with the same counts on both: - `agc_driver_graphics`, `agc_shader_memory`, `request_serializer` and `agc_multisample_guest_access` - the 5_6_5, 10_11_11, 11_11_10, mip-tail and sRGB8 colour target tests, and the two uint8x4 colour target tests - the six multisample readback tests - the multisample fill, retirement, pass-order, sample-mask, sample-target and native depth tests The new execution test reports only `VUID-VkPhysicalDeviceProperties2-pNext-pNext` and `VUID-VkDeviceCreateInfo-pNext-pNext`. Every Vulkan test among them reports these on `main` too: the layer is the Vulkan SDK 1.3.236 build, older than the 1.4 driver, and does not know the newer structures in those chains. Linux not tested. ### Checklist - [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: PPSA19015 #8562 - [x] GPUs tested: NVIDIA GeForce RTX 4070 SUPER, driver 610.88, Windows 11 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
janzezno commented 2026-10-21 14:56:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by janzezno on 2026-10-21T14:56:05Z.


Run on AMD hardware.

Host: Arch Linux, kernel 7.2.11, AMD Radeon RX 7900 GRE (RADV NAVI31), Mesa 26.2.5, GCC 16.2.1, Release, BUILD_TESTING=ON.
main cecb540a6; PR head acdbc02c8 merged on top (clean merge).

ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build -j6 -V -R '^agc_driver_graphics$|color_target|buffer_format|tbuffer_format'
  • main: 9 of 9 pass. PR: 10 of 10 pass, including the new agc_driver_packed_unorm4444_color_target (4_4_4_4 unorm color target tests passed) and agc_driver_graphics.
  • The packed R16_UINT path doesn't depend on attachment support, so this exercises the same code as the RTX 4070 SUPER run, on a second vendor.
  • Both runs log the same six VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605, all from agc_driver_tbuffer_format_d16, which #6782 covers. The PR adds none. The validation layer loaded in both runs.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6319088146 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8563#issuecomment-6319088146). Originally posted by [janzezno](https://github.com/janzezno) on 2026-10-21T14:56:05Z. --- Run on AMD hardware. Host: Arch Linux, kernel 7.2.11, AMD Radeon RX 7900 GRE (RADV NAVI31), Mesa 26.2.5, GCC 16.2.1, Release, `BUILD_TESTING=ON`. `main` `cecb540a6`; PR head `acdbc02c8` merged on top (clean merge). ``` ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build -j6 -V -R '^agc_driver_graphics$|color_target|buffer_format|tbuffer_format' ``` - `main`: 9 of 9 pass. PR: 10 of 10 pass, including the new `agc_driver_packed_unorm4444_color_target` (`4_4_4_4 unorm color target tests passed`) and `agc_driver_graphics`. - The packed `R16_UINT` path doesn't depend on attachment support, so this exercises the same code as the RTX 4070 SUPER run, on a second vendor. - Both runs log the same six `VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605`, all from `agc_driver_tbuffer_format_d16`, which #6782 covers. The PR adds none. The validation layer loaded in both runs.
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!8563
No description provided.