Skip to content

fix(agc): render into 1D color targets as one-row 2D targets - #2095

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
Raghav314:fix/agc-1d-color-targets
Oct 10, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
Raghav314:fix/agc-1d-color-targets

Conversation

@Raghav314

@Raghav314 Raghav314 commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

What

DecodeColorTileMode accepted only 2D (RESOURCE_TYPE 1, depth 0) and 3D (RESOURCE_TYPE 2) color targets. A 1D target (RESOURCE_TYPE 0) threw "unsupported color depth, dimension, resource level or metadata mode".

In addrlib, RESOURCE_TYPE 0 is ADDR_RSRC_TEX_1D. On GFX10 a 1D surface may use the linear and render swizzle modes (Gfx10Rsrc1dSwModeMask), and it gets its swizzle pattern the same way as a 2D surface: GetSwizzlePatternInfo only tells 3D apart. So a 1D color target one row high is laid out exactly like a 2D target one row tall.

  • DecodeColorTileMode accepts RESOURCE_TYPE 0 with depth 0, like 2D. It rejects a 1D target with a standard swizzle mode (SW_4KB_S, SW_64KB_S), which addrlib does not allow for 1D.
  • DecodeColorBuffer decodes a 1D target as that one-row 2D target. One taller than a row (CB_COLOR_ATTRIB2.MIP0_HEIGHT not 0) is rejected as unsupported: addrlib only limits 1D to one row on its linear paths (HwlComputeSurfaceInfoLinear, ComputeSurfaceAddrFromCoordLinear), so a tiled one is not modeled.

PPSA36082

Hades II renders into a 512x1 sRGB 8_8_8_8 target with CB_COLOR_ATTRIB3 = 0x4cc6c000 (RESOURCE_TYPE 0, SW_64KB_R_X, resource level 1) while it loads a level. Plain main stops earlier than that. On main f145139 (where I tested the game; this branch is rebased on current main) with the fixes it needs to get there (#861, #1367, #1249, #1905, #1961, #1959, #1960, #1928 and a fix for the null pixel program miss from #1901), it threw at that draw; with this change it renders it and goes on to the next problem (MSAA, #419).

Tested

Linux (CachyOS), x86-64, GCC, 7800X3D / RTX 4090.

  • agc_driver_graphics (new checks):
    • The game's descriptor decodes as a render target. A linear 1D target decodes. A 1D target with depth, RESOURCE_TYPE 3, or SW_4KB_S / SW_64KB_S is rejected.
    • A 1D target decodes to a one-row extent at its base address. One with a taller CB_COLOR_ATTRIB2 is rejected.
  • Mutations, each failing a check: 1D still rejected; no height check; 1D arrays accepted; standard swizzles accepted.
  • ctest: 494/494.

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

@Raghav314
Raghav314 force-pushed the fix/agc-1d-color-targets branch 2 times, most recently from 2bdce57 to d26b6fa Compare October 9, 2026 08:48
@github-actions github-actions Bot added the agc libSceAgc* label Oct 9, 2026
@Raghav314

Copy link
Copy Markdown
Contributor Author

Heads up: main's CI is currently broken by ShaderFusion.cpp not finding spirv/unified1/spirv.hpp (missing SPIRV-Headers include, fails on main 6cc0503 too), so linux/windows will likely fail here for that reason, not this change. #2093 / #2099 fix it, and I'll rebase once one of them lands.

CB_COLOR_ATTRIB3.RESOURCE_TYPE 0 is a 1D surface (AddrResourceType
ADDR_RSRC_TEX_1D in addrlib). On GFX10, addrlib allows a 1D surface the
linear and render swizzle modes (Gfx10Rsrc1dSwModeMask) and picks its
swizzle pattern the same way as for a 2D surface (GetSwizzlePatternInfo
only tells 3D apart). So a 1D color target one row high is laid out
exactly like a 2D target one row tall, and is decoded as one.

A 1D target with a standard swizzle mode is rejected as invalid; one
with more than one row is not modeled and is rejected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Raghav314
Raghav314 force-pushed the fix/agc-1d-color-targets branch from d26b6fa to 7638ade Compare October 9, 2026 09:14
@Raghav314

Copy link
Copy Markdown
Contributor Author

Rebased on main d9484c7 (with #2099). Ran the linux job from build.yml locally on the new head (SPIRV tools on, test registration check, build, libs): ctest 504/504 pass.

@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

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
#2229 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp L824, L2963

@rmz-24

rmz-24 commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Windows run: Windows 11 Pro 25H2 (10.0.26200.9457), RTX 5060 Ti (NVIDIA 617.42), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON, full build plus libs. 7638ade cherry-picked onto current main d70b899 (applies cleanly).

  • agc_driver_graphics (with the new 1D target checks) passes.
  • Full ctest: 510/510.

AI-assisted: yes

oneandonlydean added a commit to oneandonlydean/AnyPS5 that referenced this pull request Oct 10, 2026
oneandonlydean added a commit to oneandonlydean/AnyPS5 that referenced this pull request Oct 10, 2026
@oneandonlydean
oneandonlydean merged commit d3c5070 into boykopovar:main Oct 10, 2026
8 checks passed
SleglJan pushed a commit to SleglJan/AnyPS5 that referenced this pull request Oct 10, 2026
…rgets

fix(agc): render into 1D color targets as one-row 2D targets
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants