feat(agc): accept UINT16_ABGR color exports into unsigned integer targets #1073

Merged
alfalfa-star merged 1 commit from upstream-pr/1073 into main 2026-10-09 22:13:24 +00:00
alfalfa-star commented 2026-10-07 08:38:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by alfalfa-star on 2026-10-07T08:38:36Z.


What

SPI_SHADER_COL_FORMAT 7 (UINT16_ABGR) is accepted when the target's CB_COLOR_INFO number type is UINT. DecodeState rejected it although the recompiler already handles it: an MRT output under mode 7 is a uvec4 (SpirvEmitterHelpers), and a compressed export's 16-bit halves are taken with OpBitFieldUExtract (ExportVector).

  • The target records the export (ColorTarget::uintExport). Shader validation then requires a u32x4 output at its location instead of f32x4.
  • Blending into such a target is refused, since Vulkan has no blending of integer attachments.
  • Format 7 into a target that is not UINT still throws, as does SINT16_ABGR (8), whose halves would need sign extension.
  • A TechnicalDebt line records that a 16-bit value beyond a narrower target's range (R8_UINT) is undefined in Vulkan and the console's behaviour is not confirmed.

Tested

Linux 7.2.9 (Arch), Mesa 26.2.4 RADV, RX 9070 XT.

  • PPSA14632 (LEGO Horizon Adventures) draws into a 2848x1600 R8_UINT target with export format 7. About 290 draws per 3 minutes were dropped; they now record.
  • New execution test agc_driver_pixel_uint16_export draws compressed MRT0 exports under mode 7 into a linear 16_16_16_16 UINT target, one row per pair of packed words (0x0000ffff/0xffff0000, 0x00010002/0xffffffff, the two swapped, and four distinct halves), and reads every 16-bit component back under the identity, STD_REV (0x1b) and ALT_REV (0x93) export mappings. A sixth row stays untouched. It fails if the halves are swapped or the mapping is ignored. agc_driver_graphics covers the decode, the uintExport flag and the blend refusal.
  • ctest: 464 of 464 pass on current main.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4770119041 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1073). Originally posted by [alfalfa-star](https://github.com/alfalfa-star) on 2026-10-07T08:38:36Z. --- ### What `SPI_SHADER_COL_FORMAT` 7 (`UINT16_ABGR`) is accepted when the target's `CB_COLOR_INFO` number type is UINT. `DecodeState` rejected it although the recompiler already handles it: an MRT output under mode 7 is a `uvec4` (`SpirvEmitterHelpers`), and a compressed export's 16-bit halves are taken with `OpBitFieldUExtract` (`ExportVector`). - The target records the export (`ColorTarget::uintExport`). Shader validation then requires a `u32x4` output at its location instead of `f32x4`. - Blending into such a target is refused, since Vulkan has no blending of integer attachments. - Format 7 into a target that is not UINT still throws, as does `SINT16_ABGR` (8), whose halves would need sign extension. - A TechnicalDebt line records that a 16-bit value beyond a narrower target's range (`R8_UINT`) is undefined in Vulkan and the console's behaviour is not confirmed. ### Tested Linux 7.2.9 (Arch), Mesa 26.2.4 RADV, RX 9070 XT. - PPSA14632 (LEGO Horizon Adventures) draws into a 2848x1600 `R8_UINT` target with export format 7. About 290 draws per 3 minutes were dropped; they now record. - New execution test `agc_driver_pixel_uint16_export` draws compressed MRT0 exports under mode 7 into a linear 16_16_16_16 UINT target, one row per pair of packed words (`0x0000ffff`/`0xffff0000`, `0x00010002`/`0xffffffff`, the two swapped, and four distinct halves), and reads every 16-bit component back under the identity, STD_REV (`0x1b`) and ALT_REV (`0x93`) export mappings. A sixth row stays untouched. It fails if the halves are swapped or the mapping is ignored. `agc_driver_graphics` covers the decode, the `uintExport` flag and the blend refusal. - `ctest`: 464 of 464 pass on current `main`. ### 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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-07 08:54:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-07T08:54:55Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#1485 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp L556
#1492 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp L556
#1735 core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp L56
#2169 core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp L56
core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp L595-596
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp L1092, L2846
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6034487289 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1073#issuecomment-6034487289). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-07T08:54:55Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #1485 | `core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp` [L556](https://github.com/boykopovar/AnyPS5/blob/c2ac5dd93f0b6275634fe57415681f27af95ae7d/core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp#L556) | | | | #1492 | `core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp` [L556](https://github.com/boykopovar/AnyPS5/blob/c2ac5dd93f0b6275634fe57415681f27af95ae7d/core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp#L556) | | | | #1735 | `core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp` [L56](https://github.com/boykopovar/AnyPS5/blob/c2ac5dd93f0b6275634fe57415681f27af95ae7d/core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp#L56) | | | | #2169 | `core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp` [L56](https://github.com/boykopovar/AnyPS5/blob/c2ac5dd93f0b6275634fe57415681f27af95ae7d/core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp#L56)<br>`core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp` [L595-596](https://github.com/boykopovar/AnyPS5/blob/c2ac5dd93f0b6275634fe57415681f27af95ae7d/core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp#L595-L596)<br>`core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` [L1092](https://github.com/boykopovar/AnyPS5/blob/c2ac5dd93f0b6275634fe57415681f27af95ae7d/core/libs/prx/libSceAgcDriver/tests/Graphics.cpp#L1092), [L2846](https://github.com/boykopovar/AnyPS5/blob/c2ac5dd93f0b6275634fe57415681f27af95ae7d/core/libs/prx/libSceAgcDriver/tests/Graphics.cpp#L2846) | | |
Celegans12 commented 2026-10-07 13:02:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-07T13:02:04Z.


I've had this PR in our Ghost of Yotei (PPSA26344 v1.008) integration tree for two long runs, and it removes the only UINT16_ABGR skips the game hit. Without it, DRAW_INDEX_AUTO draws with export format 7 were skipped about 0.2 times per present from the menus on, 75 times in a 1,500 s run. Most of them went into four colour targets (0x201b871200 and three neighbours, about 15 each), plus 14 others once each.

With this PR at 74870921d on main 0d3c1eec8, a 2,700 s run has no color export format 7 is unsupported lines at all, and those targets don't show up in any other error either. A second 2,700 s run that got past the New Game settings had none too. Neither run had a FATAL or a device lost, on Windows 11 with an RTX 3080 Laptop GPU. The branch still merges cleanly onto current main (68010dfbf).

One thing this doesn't tell you: our log names a target only when a draw is skipped, so I can't see which integer format those targets have or what values reached them. The clamp-or-truncate question in your TechnicalDebt line stays open as far as Yotei goes.

Details

Builds:

  • with this PR: yotei/integration 5c55633a3 = main 0d3c1eec8 (#934 merge, 2026-10-07) + our open PRs + #375 at cc1ed88c9 + #1073 at 74870921d + env-gated local probes;
  • without it: yotei/integration c26df5aac (older main, without #1073).

The skip, from stderr of the run without the PR:

[gpu] skipped draw: AGC graphics: color export format 7 is unsupported [DRAW_INDEX_AUTO, color target 0x201d25e100]
phase (run without the PR) skips per present
boot, 0-680 s 18 0.02
menus, 680-1,092 s 28 0.22
gamma screen, 1,092-1,396 s 20 0.26
world, 1,396-1,600 s 8 0.20

The log has 75 such lines, all DRAW_INDEX_AUTO with format 7 (the per-phase counts cover the presents' windows, 74). By target: 0x201c296300 16, 0x201b871200 15, 0x201bbd2d00 15, 0x201ccbb400 15, and 0x201b750900, 0x201bab2400, 0x201be13f00, 0x201bf34800, 0x201c175a00, 0x201c4d7500, 0x201c5f7e00, 0x201c839000, 0x201c959900, 0x201cb9ab00, 0x201cefc600, 0x201d01cf00, 0x201d25e100 and 0x201d37ea00 once each.

With the PR: 0 lines in the cold 2,700 s run (1,115 presents) and 0 in the warm one, and none of the four main targets appears anywhere in the cold run's 526 MB stdout or its stderr.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6038473828 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1073#issuecomment-6038473828). Originally posted by [Celegans12](https://github.com/Celegans12) on 2026-10-07T13:02:04Z. --- I've had this PR in our Ghost of Yotei (PPSA26344 v1.008) integration tree for two long runs, and it removes the only UINT16_ABGR skips the game hit. Without it, `DRAW_INDEX_AUTO` draws with export format 7 were skipped about 0.2 times per present from the menus on, 75 times in a 1,500 s run. Most of them went into four colour targets (0x201b871200 and three neighbours, about 15 each), plus 14 others once each. With this PR at 74870921d on main 0d3c1eec8, a 2,700 s run has no `color export format 7 is unsupported` lines at all, and those targets don't show up in any other error either. A second 2,700 s run that got past the New Game settings had none too. Neither run had a FATAL or a device lost, on Windows 11 with an RTX 3080 Laptop GPU. The branch still merges cleanly onto current main (68010dfbf). One thing this doesn't tell you: our log names a target only when a draw is skipped, so I can't see which integer format those targets have or what values reached them. The clamp-or-truncate question in your TechnicalDebt line stays open as far as Yotei goes. <details><summary>Details</summary> Builds: - with this PR: `yotei/integration` 5c55633a3 = main 0d3c1eec8 (#934 merge, 2026-10-07) + our open PRs + #375 at cc1ed88c9 + #1073 at 74870921d + env-gated local probes; - without it: `yotei/integration` c26df5aac (older main, without #1073). The skip, from `stderr` of the run without the PR: ``` [gpu] skipped draw: AGC graphics: color export format 7 is unsupported [DRAW_INDEX_AUTO, color target 0x201d25e100] ``` | phase (run without the PR) | skips | per present | |---|---|---| | boot, 0-680 s | 18 | 0.02 | | menus, 680-1,092 s | 28 | 0.22 | | gamma screen, 1,092-1,396 s | 20 | 0.26 | | world, 1,396-1,600 s | 8 | 0.20 | The log has 75 such lines, all `DRAW_INDEX_AUTO` with format 7 (the per-phase counts cover the presents' windows, 74). By target: 0x201c296300 16, 0x201b871200 15, 0x201bbd2d00 15, 0x201ccbb400 15, and 0x201b750900, 0x201bab2400, 0x201be13f00, 0x201bf34800, 0x201c175a00, 0x201c4d7500, 0x201c5f7e00, 0x201c839000, 0x201c959900, 0x201cb9ab00, 0x201cefc600, 0x201d01cf00, 0x201d25e100 and 0x201d37ea00 once each. With the PR: 0 lines in the cold 2,700 s run (1,115 presents) and 0 in the warm one, and none of the four main targets appears anywhere in the cold run's 526 MB `stdout` or its `stderr`. </details>
adriadam10 commented 2026-10-08 05:59:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T05:59:20Z.

Review: CHANGES_REQUESTED


Thanks, the decode/validation side looks right: the NUMBER_TYPE check matches the recompiler's existing mode 7 handling, blending is refused, and the TechnicalDebt line is in the right section. ctest passes locally (416/416) and CI is green.

One thing to fix:

  • tests/PixelUint16Export.cpp:15-26: the test counts SPIR-V opcodes (OpBitFieldUExtract, half unpacks), so it pins the IR shape, not the result. A different but correct lowering would fail it, and a wrong extraction (swapped halves, wrong shift) with four extracts would pass. Please run the shader and compare values, as the other execution tests do: export packed words with edge rows (0x0000ffff, 0xffff0000, 0x00010002, 0xffffffff) and check each 16-bit half arrives as the expected uvec4 component, including the targetExportMapping swizzle. Keep the mode 4 case for contrast if you like.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5452204946 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1073#pullrequestreview-5452204946). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-08T05:59:20Z. **Review:** CHANGES_REQUESTED --- Thanks, the decode/validation side looks right: the NUMBER_TYPE check matches the recompiler's existing mode 7 handling, blending is refused, and the TechnicalDebt line is in the right section. ctest passes locally (416/416) and CI is green. One thing to fix: - `tests/PixelUint16Export.cpp:15-26`: the test counts SPIR-V opcodes (`OpBitFieldUExtract`, half unpacks), so it pins the IR shape, not the result. A different but correct lowering would fail it, and a wrong extraction (swapped halves, wrong shift) with four extracts would pass. Please run the shader and compare values, as the other execution tests do: export packed words with edge rows (`0x0000ffff`, `0xffff0000`, `0x00010002`, `0xffffffff`) and check each 16-bit half arrives as the expected `uvec4` component, including the `targetExportMapping` swizzle. Keep the mode 4 case for contrast if you like.
alfalfa-star commented 2026-10-08 16:53:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by alfalfa-star on 2026-10-08T16:53:57Z.


@adriadam10 Done in 45541350, rebased onto current main. The opcode-count test is gone. agc_driver_pixel_uint16_export is an execution test now: it draws compressed mode 7 exports into a linear 16_16_16_16 UINT target and reads every 16-bit component back. Each scissored row exports one pair of packed words: the edge rows you listed (0x0000ffff/0xffff0000, 0x00010002/0xffffffff, and the same pairs swapped), plus one row with four distinct halves, so any component swap shows. It runs under the identity, STD_REV (0x1b) and ALT_REV (0x93) targetExportMappings. I checked that it catches both failure modes: with the halves swapped in ExportVector it fails on row 0, and with the mapping shuffle skipped it fails under STD_REV. I left out the mode 4 case. ctest: 464/464 on RADV (RX 9070 XT).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6064833342 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1073#issuecomment-6064833342). Originally posted by [alfalfa-star](https://github.com/alfalfa-star) on 2026-10-08T16:53:57Z. --- @adriadam10 Done in 45541350, rebased onto current `main`. The opcode-count test is gone. `agc_driver_pixel_uint16_export` is an execution test now: it draws compressed mode 7 exports into a linear 16_16_16_16 UINT target and reads every 16-bit component back. Each scissored row exports one pair of packed words: the edge rows you listed (`0x0000ffff`/`0xffff0000`, `0x00010002`/`0xffffffff`, and the same pairs swapped), plus one row with four distinct halves, so any component swap shows. It runs under the identity, STD_REV (`0x1b`) and ALT_REV (`0x93`) `targetExportMapping`s. I checked that it catches both failure modes: with the halves swapped in `ExportVector` it fails on row 0, and with the mapping shuffle skipped it fails under STD_REV. I left out the mode 4 case. `ctest`: 464/464 on RADV (RX 9070 XT).
XairRrR commented 2026-10-09 11:55:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-09T11:55:20Z.


Uncharted: Legacy of Thieves Collection (PPSA05684) stops at this on main:

AGC graphics: color export format 7 is unsupported

I made the same change independently (format 7 into UINT targets only, uvec4 outputs, no blending) while bringing the title up to its main menu, so I'm not opening a competing PR. I have not run this branch itself with the title.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6080348459 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1073#issuecomment-6080348459). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-10-09T11:55:20Z. --- Uncharted: Legacy of Thieves Collection (PPSA05684) stops at this on `main`: ``` AGC graphics: color export format 7 is unsupported ``` I made the same change independently (format 7 into UINT targets only, `uvec4` outputs, no blending) while bringing the title up to its main menu, so I'm not opening a competing PR. I have not run this branch itself with the title.
alfalfa-star commented 2026-10-09 19:58:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by alfalfa-star on 2026-10-09T19:58:27Z.


@adriadam10 Could you take another look? The opcode-count test is replaced by the execution test you asked for (45541350, details above). CI is green and it still merges cleanly onto main.

@XairRrR Thanks for the Uncharted report.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6088267758 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1073#issuecomment-6088267758). Originally posted by [alfalfa-star](https://github.com/alfalfa-star) on 2026-10-09T19:58:27Z. --- @adriadam10 Could you take another look? The opcode-count test is replaced by the execution test you asked for (45541350, details above). CI is green and it still merges cleanly onto `main`. @XairRrR Thanks for the Uncharted report.
adriadam10 commented 2026-10-09 22:13:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T22:13:20Z.

Review: APPROVED


Checked the decode/validation change against the recompiler's mode 7 handling, ran the new agc_driver_pixel_uint16_export execution test (all three export mappings) plus agc_driver_graphics, full ctest green on top of current main; the test does not build without the change. Merging.

Nit for later: the new TechnicalDebt line lacks a final period.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5475835062 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1073#pullrequestreview-5475835062). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-09T22:13:20Z. **Review:** APPROVED --- Checked the decode/validation change against the recompiler's mode 7 handling, ran the new `agc_driver_pixel_uint16_export` execution test (all three export mappings) plus `agc_driver_graphics`, full ctest green on top of current `main`; the test does not build without the change. Merging. Nit for later: the new TechnicalDebt line lacks a final period.
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!1073
No description provided.