feat(agc): draw into 2_10_10_10 UINT color targets #22609

Merged
milescoviello merged 1 commit from upstream-pr/22609 into main 2026-11-21 11:03:35 +00:00
milescoviello commented 2026-11-17 23:09:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-11-17T23:09:47Z.


What

Crimson Desert (PPSA25286) stops with AGC graphics: unsupported color format 9 number type 4 component swap 0 once it gets past the cube store fixed in #22534. The draw renders into a 2_10_10_10 colour target with NUMBER_TYPE UINT, and DecodeColorFormatRaw only knew the UNORM version of that format.

  • CB_COLOR_INFO FORMAT 9, NUMBER_TYPE 4, COMP_SWAP 0 now decodes to VK_FORMAT_A2B10G10R10_UINT_PACK32. That is the same bit layout as the UNORM case already uses (red in the low 10 bits), and Vulkan requires colour attachment support for it. COMP_SWAP 1 (A2R10G10B10_UINT, optional in Vulkan) still throws.
  • A raw 32-bit export into a narrow UINT channel is masked (32_R) or clamped (32_GR, 32_ABGR, FP16_ABGR) in the shader by the packings from #11513 and #15693, because Vulkan leaves an out-of-range integer attachment write undefined. Those packings apply one limit to all four channels, which can't express 10/10/10/2. Two new packings, UintMask10_10_10_2 and UintClamp10_10_10_2, limit the first three channels to 10 bits and the fourth to 2. NarrowUintPacking picks them for A2B10G10R10_UINT. 32_AR stays unpacked, as it is for every UINT target.
  • The serializer and prepared-specialization bounds take the two new values.

The hardware result for a word wider than a 10- or 2-bit channel is not measured. The debt entry says the new packings follow the Navi21 8- and 16-bit measurement.

Tested

11-20, title run past the stop: main 93f62d93f8 plus #22534, this PR, #22778, #23864, #23880, #22690 and #22703 (all mine) runs Crimson Desert (PPSA25286) for the whole 602 s and reaches the settings menu over the title screen at about 1.7 fps (shot at 600 s, D#16802 post). All 12 rotation runs on main since 11-19 end on the format-71 cube store #22534 fixes, before this PR's draw, 196 to 301 s in. I haven't checked which of the other six PRs that run needed.

Linux (Ubuntu 26.04.1, kernel 7.0), GCC 15.2, Ninja, Release, -DBUILD_TESTING=ON, RTX 4070 Ti on NVIDIA 615.71:

  • agc_driver_graphics:
    • The 2_10_10_10 UINT target decodes to A2B10G10R10_UINT_PACK32 with identity mapping.
    • Its packing per export format is UintMask10_10_10_2 for 32_R, UintClamp10_10_10_2 for 32_GR, 32_ABGR and FP16_ABGR, and Uint for 32_AR, and the blend is dropped.
    • The out-of-range packing check now uses the value past the last packing.
  • agc_driver_uint_color_target draws into A2B10G10R10_UINT (tiled and linear) and reads each 10- and 2-bit field back:
    • in-range words through Uint;
    • wider words through the clamp (32_ABGR, 32_GR) and the mask (32_R);
    • halves through the clamp.
      It also draws through both new packings into R32_UINT and R32G32B32A32_UINT, where the attachment can hold the whole word, so the 10- and 2-bit limits must come from the shader.
  • Both tests pass, 3 runs.
  • Negative control: with main's State.cpp and SpirvModuleEmitter.cpp and the new tests, both fail.

Windows 11 (VM, GeForce GT 1030, WinLibs GCC 16.2, Ninja, Release, ANYPS5_REQUIRE_VULKAN=1): agc_driver_graphics and agc_driver_uint_color_target pass 3 runs on fd2918a80e, the pre-squash commit with this tree.

Crimson Desert (PPSA25286), Linux, RTX 4070 Ti: offline (APS5_NET_DISCONNECTED=1), 22G cap. The title only reaches this draw with #22534, so both builds include it.

  • Base: 5e54d3fb1e (main b179497cf5 plus #22534), warm cache, 300 s. Run 1 never reached the draw in 307 s. Run 2 failed presenting at 172 s, after its second present: [gpu] driver failure: AGC graphics: unsupported color format 9 number type 4 component swap 0, then EXIT-134.

  • This PR: 644f249933 (main 9f75bf0be3 plus #22534 plus this change), 420 s. The cold-cache run never presented. The warm run had no colour-format error, presented twice and ran on to 413 s. Its log shows work neither base run reached: seven 2D read of the 2D array ... built from slice 0 alone lines, a has 2 dynamic-resolution variants in one image table line, two more sampled-texture budget updates, and two more shaders prepared at use. It then stopped on something else: guest allocation 0x20037d0000+0x10000 is still pinned by GPU work or an import (waited 60000 ms for the lease).

  • The screen is black after the first present in every run, so I'm not claiming visible progress.

  • git merge-tree against main is clean. tools/check_conventions.py passes on the branch and this body, and tools/debt_fold.py --check reports nothing new for this fragment.

  • rafaconvaitis's Windows + AMD run of 4be6c4a707 merged onto main 9a50e1014e (Radeon 760M, AMD Software 26.11.2, WinLibs GCC 15.2.0, Khronos validation layer 1.4.363): agc_driver_uint_color_target passes 3/3 on both sides with no VUID- lines.

  • Colewiz7's RADV run of 4be6c4a707 merged onto main 26604382a5 as e2caaa4abd (Linux 7.3.4, GCC 16.2.1, Mesa 26.2.6, RX 7900 XT and the Ryzen 7 7800X3D iGPU, Khronos validation layer 1.4.363.1): no new failures against main and no VUID- or SYNC-HAZARD lines.

  • domx4q's Linux + NVIDIA run with the validation layer of 4be6c4a707 merged onto main fbaae8a79d (Arch Linux, GCC 16.2.1, RTX 4090, NVIDIA 620.70.06, Khronos validation layer 1.4.363.1): agc_driver_graphics and agc_driver_uint_color_target pass on both sides with no VUID- lines. With main's State.cpp and SpirvModuleEmitter.cpp and this PR's tests, agc_driver_uint_color_target fails with unsupported color format 9 number type 4 component swap 0.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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 (Crimson Desert reaches this draw only with #22534)
  • Fixes: none
  • Unblocks: PPSA25286 #16802 (after #22534's stop; see Tested)
  • GPUs tested: NVIDIA RTX 4070 Ti (Linux), NVIDIA GeForce GT 1030 (Windows), AMD Radeon 760M (Windows, rafaconvaitis), AMD RX 7900 XT and the Ryzen 7 7800X3D iGPU (gfx1036) (Linux, RADV, Colewiz7), NVIDIA RTX 4090 (Linux, domx4q)
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5366643840 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22609). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-11-17T23:09:47Z. --- ### What Crimson Desert (PPSA25286) stops with `AGC graphics: unsupported color format 9 number type 4 component swap 0` once it gets past the cube store fixed in #22534. The draw renders into a `2_10_10_10` colour target with `NUMBER_TYPE` UINT, and `DecodeColorFormatRaw` only knew the UNORM version of that format. - `CB_COLOR_INFO` `FORMAT` 9, `NUMBER_TYPE` 4, `COMP_SWAP` 0 now decodes to `VK_FORMAT_A2B10G10R10_UINT_PACK32`. That is the same bit layout as the UNORM case already uses (red in the low 10 bits), and Vulkan requires colour attachment support for it. `COMP_SWAP` 1 (`A2R10G10B10_UINT`, optional in Vulkan) still throws. - A raw 32-bit export into a narrow UINT channel is masked (`32_R`) or clamped (`32_GR`, `32_ABGR`, `FP16_ABGR`) in the shader by the packings from #11513 and #15693, because Vulkan leaves an out-of-range integer attachment write undefined. Those packings apply one limit to all four channels, which can't express 10/10/10/2. Two new packings, `UintMask10_10_10_2` and `UintClamp10_10_10_2`, limit the first three channels to 10 bits and the fourth to 2. `NarrowUintPacking` picks them for `A2B10G10R10_UINT`. `32_AR` stays unpacked, as it is for every UINT target. - The serializer and prepared-specialization bounds take the two new values. The hardware result for a word wider than a 10- or 2-bit channel is not measured. The debt entry says the new packings follow the Navi21 8- and 16-bit measurement. ### Tested **11-20, title run past the stop:** `main` `93f62d93f8` plus #22534, this PR, #22778, #23864, #23880, #22690 and #22703 (all mine) runs Crimson Desert (PPSA25286) for the whole 602 s and reaches the settings menu over the title screen at about 1.7 fps ([shot at 600 s](https://github.com/milescoviello/AnyPS5/releases/download/cd-stack3-1120/cd-stack3-600s.png), [D#16802 post](https://github.com/boykopovar/AnyPS5/discussions/16802#discussioncomment-19788998)). All 12 rotation runs on `main` since 11-19 end on the format-71 cube store #22534 fixes, before this PR's draw, 196 to 301 s in. I haven't checked which of the other six PRs that run needed. Linux (Ubuntu 26.04.1, kernel 7.0), GCC 15.2, Ninja, Release, `-DBUILD_TESTING=ON`, RTX 4070 Ti on NVIDIA 615.71: - `agc_driver_graphics`: - The 2_10_10_10 UINT target decodes to `A2B10G10R10_UINT_PACK32` with identity mapping. - Its packing per export format is `UintMask10_10_10_2` for `32_R`, `UintClamp10_10_10_2` for `32_GR`, `32_ABGR` and `FP16_ABGR`, and `Uint` for `32_AR`, and the blend is dropped. - The out-of-range packing check now uses the value past the last packing. - `agc_driver_uint_color_target` draws into `A2B10G10R10_UINT` (tiled and linear) and reads each 10- and 2-bit field back: - in-range words through `Uint`; - wider words through the clamp (`32_ABGR`, `32_GR`) and the mask (`32_R`); - halves through the clamp. It also draws through both new packings into `R32_UINT` and `R32G32B32A32_UINT`, where the attachment can hold the whole word, so the 10- and 2-bit limits must come from the shader. - Both tests pass, 3 runs. - Negative control: with `main`'s `State.cpp` and `SpirvModuleEmitter.cpp` and the new tests, both fail. Windows 11 (VM, GeForce GT 1030, WinLibs GCC 16.2, Ninja, Release, `ANYPS5_REQUIRE_VULKAN=1`): `agc_driver_graphics` and `agc_driver_uint_color_target` pass 3 runs on fd2918a80e, the pre-squash commit with this tree. **Crimson Desert (PPSA25286), Linux, RTX 4070 Ti:** offline (`APS5_NET_DISCONNECTED=1`), 22G cap. The title only reaches this draw with #22534, so both builds include it. - **Base:** `5e54d3fb1e` (`main` b179497cf5 plus #22534), warm cache, 300 s. Run 1 never reached the draw in 307 s. Run 2 failed presenting at 172 s, after its second present: `[gpu] driver failure: AGC graphics: unsupported color format 9 number type 4 component swap 0`, then `EXIT-134`. - **This PR:** `644f249933` (`main` 9f75bf0be3 plus #22534 plus this change), 420 s. The cold-cache run never presented. The warm run had no colour-format error, presented twice and ran on to 413 s. Its log shows work neither base run reached: seven `2D read of the 2D array ... built from slice 0 alone` lines, a `has 2 dynamic-resolution variants in one image table` line, two more sampled-texture budget updates, and two more shaders prepared at use. It then stopped on something else: `guest allocation 0x20037d0000+0x10000 is still pinned by GPU work or an import (waited 60000 ms for the lease)`. - The screen is black after the first present in every run, so I'm not claiming visible progress. - `git merge-tree` against `main` is clean. `tools/check_conventions.py` passes on the branch and this body, and `tools/debt_fold.py --check` reports nothing new for this fragment. - rafaconvaitis's [Windows + AMD run](https://github.com/boykopovar/AnyPS5/pull/22609#issuecomment-6995935681) of `4be6c4a707` merged onto `main` `9a50e1014e` (Radeon 760M, AMD Software 26.11.2, WinLibs GCC 15.2.0, Khronos validation layer 1.4.363): `agc_driver_uint_color_target` passes 3/3 on both sides with no `VUID-` lines. - Colewiz7's [RADV run](https://github.com/boykopovar/AnyPS5/pull/22609#issuecomment-7001756574) of `4be6c4a707` merged onto `main` `26604382a5` as `e2caaa4abd` (Linux 7.3.4, GCC 16.2.1, Mesa 26.2.6, RX 7900 XT and the Ryzen 7 7800X3D iGPU, Khronos validation layer 1.4.363.1): no new failures against `main` and no `VUID-` or `SYNC-HAZARD` lines. - domx4q's [Linux + NVIDIA run with the validation layer](https://github.com/boykopovar/AnyPS5/pull/22609#issuecomment-7010845878) of `4be6c4a707` merged onto `main` `fbaae8a79d` (Arch Linux, GCC 16.2.1, RTX 4090, NVIDIA 620.70.06, Khronos validation layer 1.4.363.1): `agc_driver_graphics` and `agc_driver_uint_color_target` pass on both sides with no `VUID-` lines. With `main`'s `State.cpp` and `SpirvModuleEmitter.cpp` and this PR's tests, `agc_driver_uint_color_target` fails with `unsupported color format 9 number type 4 component swap 0`. ### 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) and the licence notice of code adapted from upstream (see AGENTS.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 (Crimson Desert reaches this draw only with #22534) - [x] Fixes: none - [x] Unblocks: PPSA25286 #16802 (after #22534's stop; see Tested) - [x] GPUs tested: NVIDIA RTX 4070 Ti (Linux), NVIDIA GeForce GT 1030 (Windows), AMD Radeon 760M (Windows, rafaconvaitis), AMD RX 7900 XT and the Ryzen 7 7800X3D iGPU (gfx1036) (Linux, RADV, Colewiz7), NVIDIA RTX 4090 (Linux, domx4q) - [x] AI-assisted: yes
MarcZX10 commented 2026-11-19 00:47:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T00:47:00Z.

Review: COMMENTED


Reviewed — no blocking findings

Nothing in the inspected changes blocks merge; the new UINT format decoding and per-channel shader packing are consistently represented in state decoding, specialization, serialization, and execution tests.

What I ran

Reviewed head 4be6c4a7070423af688cedeff654da50129a160a. No commands or tests were run; the author reports GPU and title runs in the PR description, which were not independently reproduced.

Results

Check Result Note
Source review passed Core implementation and execution test inspected
Automated checks not run No local command execution available
Merge preview not run Author reports a clean merge-tree

Findings

Blocking

None.

Non-blocking

None.

Not verified

core/libs/prx/libSceAgcDriver/tests/Graphics.cpp was excluded from the review folder because it exceeded the size limit. Its changed lines were visible in the diff, but its full text was not read. The reported build, GPU runs, negative control, and Crimson Desert behavior were not independently verified. Files read: description.md, commits.md, manifest.json, diff.patch, State.cpp, UintColorTarget.cpp, RequestSerializer.cpp, FragmentOutputSpecialization.hpp, Recompiler.hpp, and SpirvModuleEmitter.cpp. Excluded changed file: Graphics.cpp.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5967582504 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22609#pullrequestreview-5967582504). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-19T00:47:00Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Nothing in the inspected changes blocks merge; the new UINT format decoding and per-channel shader packing are consistently represented in state decoding, specialization, serialization, and execution tests. ## What I ran Reviewed head `4be6c4a7070423af688cedeff654da50129a160a`. No commands or tests were run; the author reports GPU and title runs in the PR description, which were not independently reproduced. ## Results | Check | Result | Note | |---|---|---| | Source review | passed | Core implementation and execution test inspected | | Automated checks | not run | No local command execution available | | Merge preview | not run | Author reports a clean merge-tree | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` was excluded from the review folder because it exceeded the size limit. Its changed lines were visible in the diff, but its full text was not read. The reported build, GPU runs, negative control, and Crimson Desert behavior were not independently verified. Files read: `description.md`, `commits.md`, `manifest.json`, `diff.patch`, `State.cpp`, `UintColorTarget.cpp`, `RequestSerializer.cpp`, `FragmentOutputSpecialization.hpp`, `Recompiler.hpp`, and `SpirvModuleEmitter.cpp`. Excluded changed file: `Graphics.cpp`. ## 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!22609
No description provided.