Skip to content

fix(agc): raise a color-only single-sample scan with MSAA_ENABLE to the target's samples - #1609

Open
Thimo188 wants to merge 2 commits into
mainfrom
upstream-pr/27672
Open

Thimo188 wants to merge 2 commits into
mainfrom
upstream-pr/27672

Conversation

@Thimo188

@Thimo188 Thimo188 commented Dec 2, 2026 •

Copy link
Copy Markdown
Owner

Imported from boykopovar/AnyPS5#27672, originally opened by DerKarussellbremser.

Source commit: c2c4e8b1956b379306f4f7b538433f2a940d0674. 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

A draw with one multisampled color target, no depth target and a one-sample rasterizer (PA_SC_AA_CONFIG) is raised to the target's sample count with every sample at the pixel centre (boykopovar#4414). That was limited to draws with MSAA_ENABLE clear in PA_SC_MODE_CNTL_0. With the bit set the draw kept one sample and DecodeState threw a color target's sample count differs from the rasterizer's.

The depth-only case already handles the same state: a one-sample rasterizer with MSAA_ENABLE set scans into a multisampled depth target under the conditions of singleSampleDepthScanRejection (triangles and rectangles only, no Z interpolation or overrasterization in DB_EQAA, no pixel program reading the sample index, no sample-mask export). The color-only case now does the same under the same conditions. The check takes the target's name and is shared by both; the depth messages are unchanged.

Both raises also repeat sampleCoverageSupported with the raised sample count (review, c2c4e8b). It ran only before the raise, at one sample, where it accepts every state, so a running pixel program reading SAMPLE_COVERAGE together with a sample-rate input passed through both raises. The depth raise had that order on main.

Assassin's Creed Black Flag Resynced (PPSA28183, 01.006.038) issues such a draw after its opening scene, before the Animus sequence: one color target with 4 samples at 640x360, no depth target, PA_SC_AA_CONFIG with one sample, PA_SC_MODE_CNTL_0 = 0x3. The title stopped there.

Tested

Windows 11 Home 10.0.26200, i7-10750H, 16 GB, NVIDIA GeForce RTX 2060 6 GB, driver 610.91, WinLibs GCC 15.2.0 r7 UCRT, Release, on main 00b15fcbb0.

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: none
  • GPUs tested: NVIDIA GeForce RTX 2060, driver 610.91, Windows 11 Home 10.0.26200
  • AI-assisted: yes

🤖 Generated with Claude Code

https://claude.ai/code/session_011TXsSW8zeAgKgHLCFsYwM3

Summary by CodeRabbit

  • Bug Fixes
    • Improved validation for single-sample rendering to multisampled color and depth targets, including when MSAA is enabled.
    • Sample-coverage settings are now checked consistently when rasterizer sample counts change.
    • Draws with unsupported sample locations, primitive types, shader sample-index reads, sample-mask exports, or alpha-to-coverage are rejected.
    • Clarified when sample coverage is accepted based on whether sample-rate inputs are used.

DerKarussellbremser and others added 2 commits November 26, 2026 22:43
…he target's samples

A draw with one color target of several samples, no depth target and a
one-sample rasterizer (PA_SC_AA_CONFIG) is raised to the target's sample
count with every sample at the pixel centre. That was limited to draws
with MSAA_ENABLE clear in PA_SC_MODE_CNTL_0; with the bit set the draw
kept one sample and failed with "a color target's sample count differs
from the rasterizer's".

The depth-only case already scans a one-sample rasterizer into a
multisampled target with MSAA_ENABLE set, under the conditions of
singleSampleDepthScanRejection. The color-only case now does the same
under the same conditions, so the check takes the target's name and is
shared by both.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011TXsSW8zeAgKgHLCFsYwM3
sampleCoverageSupported ran while the rasterizer still had one sample,
where it accepts every state. The depth raise and the color raise then
set the target's sample count without asking again, so a running pixel
program that reads SAMPLE_COVERAGE together with a sample-rate input
ran at the raised count, a state the same check refuses for a
multisampled rasterizer.

Both raises now repeat the check with the raised count.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011TXsSW8zeAgKgHLCFsYwM3
@coderabbitai

coderabbitai Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes: Scan validation

Layer / File(s) Summary
Generalize scan and coverage checks
core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
The scan rejection helper accepts a depth or color target name. A shared helper validates sample coverage.
Apply checks to target sample counts
core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp, core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
Depth and color target paths apply scan rejection and sample-coverage checks. Tests cover accepted and rejected color-only multisample states.

Suggested reviewers: birdmarty

Change: Bug fix

Merge Risk: Minimal · up to c2c4e

The change lets a color-only draw with a multisampled target and one-sample rasterizer proceed when MSAA_ENABLE is set, while keeping the existing rejection conditions and re-checking sample coverage. No concrete merge-blocking risk was found. Hardware coverage beyond the author's tested setup remains unverified.

Security architecture risk: Minimal · up to c2c4e

AgcDriver now accepts eligible multisampled color draws through its existing validation path. It applies the same scan restrictions used for depth draws and checks shader coverage again after raising the sample count. The review found no material weakening of security or failure containment.

Security review details

Security Blast Radius

  • observed — The expanded acceptance applies to guest-supplied draw state on the existing AgcDriver decode path. The color promotion requires a multisampled color target, a one-sample rasterizer, no previously decoded color target, no depth target, and alpha-to-coverage disabled. Subsequent target compatibility checks remain in place.

Trust Boundaries and Controls

  • observed — For the newly accepted MSAA-enabled color case, DecodeState applies the shared primitive and DB_EQAA restrictions and, when the pixel program runs, checks sample-index input and sample-mask export before promotion. It then checks shader coverage using the promoted sample count before returning decoded state.
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: 2
  • Waived: $0.50 (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: 549e55c6-0295-42a6-85c4-5f76b2c50f01
Commits

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

Files selected for processing: 2

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

Limit details: You’ve used all 10 included reviews currently available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants