Skip to content

fix(agc): support 4_4_4_4 component orders during PPSA38500 loading - #1832

Open
Thimo188 wants to merge 3 commits into
mainfrom
upstream-pr/27966
Open

Thimo188 wants to merge 3 commits into
mainfrom
upstream-pr/27966

Conversation

@Thimo188

@Thimo188 Thimo188 commented Dec 2, 2026 •

Copy link
Copy Markdown
Owner

Imported from boykopovar/AnyPS5#27966, originally opened by lgqdaxia.

Source commit: e2e97886eee135e83ea9a55e8cdb769768eba6ff. The import branch preserves this fetched upstream PR snapshot. The description and validation below are copied from upstream; no new code changes or test runs were made for this import. Original reviews, discussions, and attachments remain at the linked upstream PR.


What

PPSA38500 stopped presenting during story loading on Windows. Its draw requested a packed 4_4_4_4 UNORM color target with COMP_SWAP=1, which the color decoder rejected.

Use the four-channel mapping already used for RGBA16 to select the source of each nibble in the R16_UINT attachment. Full writes and masked writes now honor STD, ALT, STD_REV and ALT_REV. The packing and rounding logic comes from the existing packed export path. AMD PAL four-component swap definitions

For packed 4_4_4_4, check the blend equation only for channels selected by the guest write mask. Source replacement bypasses blending before component-order translation, including STD_REV and ALT_REV. Equations that blend any written channel retain the existing unsupported checks.

Tested

agc_driver_graphics passed on Ubuntu 26.04.1 LTS, GCC 15.2.0, at e2e97886ee. The test covers alpha-only replacement with RGB writes masked, replacement in both reversed component orders, and rejection when a written channel needs blending. It also checks masked alpha and opaque-destination replacement. Linux validation

The Vulkan comparisons confirmed the component-order fix on Windows with NVIDIA and Linux with AMD.

Vulkan comparisons by GPU and tested revision

Using Windows 11 Pro and NVIDIA driver 621.14, the two Vulkan tests reproduced the format 19, UNORM, swap 1 rejection on main b19e5a8a96 and both passed on 399d893d4b. The color-mapping patch was identical on the initial PR head ab696034d9.

  • agc_driver_packed_unorm4444_color_target read back RGBA nibbles 1, 2, 7 and E as 0xe721, 0xe127, 0x127e and 0x721e for swap modes 0–3. Pixels outside the scissor kept their initial values.
  • agc_driver_packed_unorm4444_partial_write checked red-only writes on a tiled target and preserved the other nibbles. Both Vulkan runs loaded validation layer 1.4.368 and reported zero VUID or synchronization errors. The partial-write test emitted the same ten unused fragment-output warnings on each build.
  • agc_driver_graphics passed on 399d893d4b, including the four red-channel masks and unsupported numeric types.

tablefrogpillow independently ran agc_driver_packed_unorm4444_color_target on a Radeon RX Vega 56 with Linux and RADV. Initial PR head ab696034 passed three runs with zero validation errors. Restoring State.cpp from base 073e0313 reproduced the COMP_SWAP=1 rejection. Independent AMD result

gmankab ran both packed-color fixtures on Fedora Linux 45 Toolbox with a Radeon RX 6800 (RDNA2) and Mesa RADV 26.2.7. The existing decoder on the same startup stack refused COMP_SWAP=1 in both fixtures. Both fixtures and agc_driver_graphics passed with PR revision fc78d6bb, including its alpha-blend case. Khronos validation 1.4.350 loaded on both builds and the logs contained zero VUID entries. Independent RDNA2 result

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
  • Fixes: none
  • Unblocks: PPSA38500 The game which must not be named (PPSA38500) boykopovar/AnyPS5#27523
  • GPUs tested: NVIDIA GeForce RTX 3080 Laptop GPU, NVIDIA 621.14, Windows 11 Pro build 26300. Independent Linux/RADV checks on Radeon RX Vega 56 at ab696034 and Radeon RX 6800 at fc78d6bb.
  • AI-assisted: yes

Summary by CodeRabbit

  • Bug Fixes
    • Improved color-channel handling for 16-bit, four-component color formats across supported component orders.
    • Corrected blending behavior for 4-bit-per-channel color targets, including cases where drawing replaces all affected channels.
    • Preserved unaffected color channels during partial writes, including writes to only the red or RGB channels.

@coderabbitai

coderabbitai Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes: 4_4_4_4 UNORM target handling

Layer / File(s) Summary
Decode component swaps and validate packed writes
core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp, core/libs/prx/libSceAgcDriver/tests/execution/PackedUnorm4444*
Color-format decoding uses a shared component mapping, and format 19 accepts UNORM swap values 0–3. Execution tests check packed values and partial-write masks for the component swaps.
Handle replacement blending and exported channels
core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp, core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
Blend decoding handles replacement equations for exported channels on 4_4_4_4 UNORM targets. Tests cover blend rejection, alpha preservation, opaque destinations, and reversed component orders.

Suggested reviewers: jab-dev, frankea

Change: Bug fix

Merge Risk: Minimal · up to e2e97

This change lets 4_4_4_4 render targets use all four component orders and skips blending when every written channel is replaced. The supplied evidence shows no concrete defect, and tests cover the new behavior, so merge risk is minimal.

Security architecture risk: Minimal · up to e2e97

AGC Graphics accepts more component orders for packed 4_4_4_4 color targets without changing the host attachment format or who controls the target. Writes that actually require blending remain unsupported, and partial writes use the existing merge path.

Security review details

Security Blast Radius

  • inferred — The widened reachability is to more guest-selected component orders on the existing packed render-target path. The changed decode still selects the same host attachment representation and does not grant access to a new class of host resource.

Trust Boundaries and Controls

  • observed — Guest color and blend fields pass through the existing decoder. The unsigned-integer blend check runs before the replacement shortcut, and the packed-target check still rejects blending when a written channel needs a non-replacement equation.

Rollout and rollback

  • inferred — Admission is controlled by the AGC Graphics decoder, not by a new operator setting. Reverting to the compared base would restore live rejection of swaps 0, 1, and 3. The journal still stores the decoded mapping and mask in the existing fields; the source comparison identifies no journal schema migration or new operator action.
Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

Cppcheck (2.22.0)

Cppcheck (2.22.0) exceeded its 180-second time budget. Findings from completed work are retained; remaining checks are incomplete.

core/libs/prx/libSceAgcDriver/tests/Graphics.cpp

Cppcheck interrupted; analysis of this file is incomplete

Usage-based review receipt

  • Mode: Continue automatically
  • Reviewed files: 4
  • Waived: $1.00 (charged $0.00)
  • View usage details

Note

This review exceeded your plan’s limits and used usage-based reviews—free during trial, billed after paid activation unless disabled. Manage usage-based reviews.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9fb8d4da-da02-4255-9194-f7cae625c2c6
Commits

Reviewing files that changed from the base of the PR and between 4131f51 and e2e9788.

Files selected for processing: 4

  • core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
  • core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
  • core/libs/prx/libSceAgcDriver/tests/execution/PackedUnorm4444ColorTarget.cpp
  • core/libs/prx/libSceAgcDriver/tests/execution/PackedUnorm4444PartialWrite.cpp

@github-actions github-actions Bot added the unblocks title Names a title ID on the Unblocks line label Dec 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

unblocks title Names a title ID on the Unblocks line

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants