Skip to content

feat(agc): draw into later slices of 2D-tiled PS4 color target arrays - #18721

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
puridanish284:claude/ps4-color-array-slices
Nov 16, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
puridanish284:claude/ps4-color-array-slices

Conversation

@puridanish284

Copy link
Copy Markdown
Contributor

What

A CB_COLOR_VIEW of slice 1 or later of a PS4 (GCN) color target in a 2D-tiled mode (GcnDisplay2D, GcnThin2D) throws GCN color views of a later slice of a 2D-tiled array, whose banks rotate per slice, are not implemented. #9675 made one-slice views render (Gang Beasts, CUSA04865, renders into single slices of a layered target) and left this case refused, because the texture path rotates the bank of each layer of a 2D-tiled array (c7a3fff, #12998) and a color target was not placed that way (debt entry "PS4 color array slices"). A title that renders cube faces or texture-array slices one at a time into a 2D-tiled surface stops there.

Such a slice now carries its layer's rotation as its bank XOR, the way a sliced PS5 color target folds its slice into pipeBankXor:

  • DecodeGcnColorBuffer sets pipeBankXor to GcnLayerBankXor(GcnTiling(mode, element size), slice), the XOR the texture path applies to that array layer: (banks / 2 - 1) times the slice on the bank bits, as addrlib's ComputeBankFromCoord does for ADDR_TM_2D_TILED_THIN1. The slice address stays the base plus the slice times the slice size.
  • The GPU detile and retile dispatches already XOR a surface's pipeBankXor into the offset inside each macro tile (TextureDetile.comp, equation family), and each of their calls in Texture.cpp passes descriptor.pipeBankXor, so the target's storage image is imported and written back at the rotated offsets with no other change.
  • ColorTargetLayout, the CPU layout of ReadColorTarget and WriteColorTarget, now applies the XOR in the 2D-tiled GCN modes too, and refuses one outside their bank bits; the 1D-tiled and linear GCN modes take none.
  • A later slice of a multisampled 2D-tiled target still throws, with its own message: the multisampled path keeps its samples on the host and is not changed here.

Unchanged: a view of several slices still throws. Slice 0 has no XOR, so every target main accepts decodes as before. A later slice's CMASK base is not offset by the slice: single-sample GCN targets take no CMASK on main, and multisampled later slices of the 2D-tiled modes throw.

Debt: the "PS4 color array slices" entry now says how a later slice of the 2D-tiled modes is placed, and that a multisampled one throws.

Overlap: tools/pr_overlap.py --branch claude/ps4-color-array-slices against main and the 1931 open pull requests reports no conflict among those it could merge, and fails closed on 48 that conflict with main and share State.cpp or the debt file. None of the 48 changes DecodeGcnColorBuffer or the "PS4 color array slices" entry; #9748's hunk next to the function adds ArraySurfaceForTarget after it, which main already has. The branch merges cleanly with #18176, #18177 and #18207.

Tested

Windows 11 with WSL2 Ubuntu 24.04.5 LTS (kernel 6.18.54.1-microsoft-standard-WSL2), gcc 13.3.0, -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON, test targets only, on main 177495a68f. No title or console.

  • agc_driver_graphics: a new case checks, for both 2D-tiled color modes at 1 to 16 bytes per element and array slices 0 to 5, that ColorTargetLayout with the slice's GcnLayerBankXor places every element of a surface two macro tiles wide where the test's addrlib reference referenceGcnAddress places it for that slice, and that a XOR outside the bank bits, on a 1D-tiled mode or on a linear mode is refused.
  • agc_gcn_color_target: slice 3 of a 32-bit Thin2D array decodes at the base plus three slices with XOR 0x2800 (5 << 11), slice 1 of Display2D with 0x3800 (7 << 11), slice 0 with none, slice 2 of Thin1D at the base plus two slices with none; slice 1 of a 4x Thin2D array is refused.
  • New agc_driver_gcn_color_array_slices (lavapipe): six-slice 128x64 RGBA8 Thin2D and Display2D arrays are filled with a position-coded background placed by the texture path's model (DescribeSurface of the 2D array, GcnTiling and GcnLayerBankXor). A triangle whose color encodes each pixel's position and slice is drawn into slices 0, 1, 2 and 5 through decoded CB_COLOR_VIEWs. After the flush, every texel at the texture path's offset holds its drawn color or its own background (3306 drawn texels per drawn slice), and slices 3 and 4 keep their background.
  • Mutation checks: without the XOR in DecodeGcnColorBuffer, agc_gcn_color_target and agc_driver_gcn_color_array_slices fail. With the XOR kept on the target but dropped from the surface the GPU tiles (SurfaceForTarget), the latter fails at Thin2D slice 1: the texel the texture path places at (40, 0) holds 50 30 20 ff, neither its background nor the color drawn for it (the color drawn for (80, 48)). Without the XOR in ColorTargetLayout's GCN offset, agc_driver_graphics fails at PS4 color tile mode 258 at 1 bytes places element 0,0 of array slice 1 at 0, addrlib places it at 14336.
  • Validation layer: the same focused tests, ctest -R '^(agc_driver_graphics|agc_gcn_color_target|agc_driver_gcn_.*)$' -V, on main 177495a68f (8 tests) and on this branch (9 tests), with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (Ubuntu's 1.3.275 layer through VK_LAYER_PATH). All pass on both, neither log contains was not found but was requested by env var VK_INSTANCE_LAYERS, and each GPU test logs only VUID-VkDeviceCreateInfo-pNext-pNext once at device creation on both sides (the old layer does not know the repository's newer structs, tests: with a Vulkan validation layer older than the repo's headers, agc_driver_image_table* fail on main from VUID-VkDeviceCreateInfo-pNext-pNext (unknown VK_KHR_shader_fma / VK_KHR_maintenance8 structs) #17693). The branch adds no VUID-.
  • python3 tools/check_conventions.py --base upstream/main: all conventions checks passed. tools/check_test_registration.py: no new test left unregistered.
  • Not built for Windows or macOS here (no MinGW toolchain on this machine), not run on a hardware GPU, and not run on a title.

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 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: lavapipe (llvmpipe, Mesa 25.2.8, Vulkan 1.4.318) on Ubuntu 24.04.5 under WSL2; no hardware GPU
  • AI-assisted: yes

🤖 Generated with Claude Code

A CB_COLOR_VIEW of slice 1 or later of a GCN color target in GcnDisplay2D
or GcnThin2D threw, because the texture path rotates the bank of each
layer of a 2D-tiled array (GcnLayerBankXor) and a color target was not
placed that way. Such a slice now carries that layer's rotation as its
bank XOR, the way a sliced PS5 color target folds its slice into
pipeBankXor. The GPU detile and retile dispatches already XOR it into
the offset inside each macro tile; ColorTargetLayout now does the same
for the 2D-tiled GCN modes and refuses a XOR outside their bank bits. A
later slice of a multisampled 2D-tiled target still throws.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — current-base test evidence incomplete

I reviewed all six changed files at head d7899ab4927ae9db355e5dad88e3f0fe5dba79ee against base c85dcfd0056e0e341c3a2f5e285c94602353a7b7; I found no substantiated code blocker, but the reported paired Vulkan run used an older baseline and required hosted checks are still queued.

What I ran

Environment: Debian 12 Linux, Python 3.11.2, GCC 12.2.0. No build or C++ test was run locally.

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 18721 --output-dir /tmp/pr18721-precheck

The precheck pinned the exact head and base above and confirmed both remained unchanged through its run. I also read all six changed files, their relevant call paths, and the test registration in the changed head.

Results

Check Result Note
Diff and conventions passed Applicable no-build checks passed.
Dependency and mergeability passed The isolated merge preview is clean against the recorded base.
Test registration and assertions passed The new execution test is picked up by the existing CMake glob and CTest registration.
Focused Vulkan tests not run I did not build locally; the author reports a paired run on an older main baseline.
Hosted CI not run All six checks were queued when last read.
Precheck details
Head unchanged at completion: True
Base branch tip at completion: c85dcfd0056e0e341c3a2f5e285c94602353a7b7

diff_check: passed
conventions_and_pr_template: passed
changed_export_abi_audit: not applicable (no recognized export declarations changed)
live_dependency_and_mergeability_check: passed
test_quality_heuristics: passed; emitted three possible-unregistered-test warnings
build_and_compile: not run (no-build precheck)
build_dependent_cpp_tests: not run (no-build precheck)

The three registration warnings are false positives: CMake discovers tests/execution/*.cpp with GLOB_RECURSE-style file globbing and registers the discovered targets with CTest.

Negative control

The author reports mutation checks that remove the XOR at decode, GPU surface mapping, and CPU target offset, with the corresponding tests failing. I did not run these controls myself, so they are author-reported evidence only.

Findings

Blocking

None found in the six changed files reviewed.

Non-blocking

The PR description reports paired focused runs using 177495a68f4b4f16d0baba3ba73c55654e42a386 as main. The current review base is c85dcfd0056e0e341c3a2f5e285c94602353a7b7, which contains a later change to Texture.cpp, a path used by the tiled upload/detile flow. The old-baseline run therefore does not verify this PR combined with the current base. Please rerun the same focused main/PR comparison on the current base and report the exact SHAs and validation-layer comparison. This evidence gap is not, by itself, a code defect, so I am not requesting changes.

Sources

Not verified

  • No local build or focused C++/Vulkan test was run.
  • No hardware GPU or PS4/PS5 console was tested; the author reports lavapipe only.
  • The author’s paired main/PR runs do not include the current base’s later Texture.cpp changes.
  • Hosted checks were queued when last read; their completion is not verified here.

To get this to a good state

Rerun the same focused Vulkan test on the current main and PR head, on the same machine, and include both exact SHAs plus the validation-layer comparison. I will re-check the evidence and the required hosted checks on the resulting head before considering approval.

@MarcZX10

Copy link
Copy Markdown
Contributor

Correction — CMake test discovery

In my review of head d7899ab4927ae9db355e5dad88e3f0fe5dba79ee, I incorrectly called the execution-test glob recursive; it is file(GLOB ...), and the conclusion that the new test is discovered and registered remains unchanged.

Sources

@github-actions github-actions Bot added docs agc libSceAgc* labels Nov 12, 2026
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 1395 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
PR 4448 docs/dev/debt/libSceAgcDriver.md
PR 5372 docs/dev/debt/libSceAgcDriver.md
PR 5925 docs/dev/debt/libSceAgcDriver.md
PR 6186 docs/dev/debt/libSceAgcDriver.md
PR 6188 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
PR 6235 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
PR 6280 docs/dev/debt/libSceAgcDriver.md
PR 6412 docs/dev/debt/libSceAgcDriver.md
PR 6481 docs/dev/debt/libSceAgcDriver.md
PR 6804 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6808 docs/dev/debt/libSceAgcDriver.md
PR 7002 docs/dev/debt/libSceAgcDriver.md
PR 7256 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7449 docs/dev/debt/libSceAgcDriver.md
PR 7642 docs/dev/debt/libSceAgcDriver.md
PR 8592 docs/dev/debt/libSceAgcDriver.md
PR 9335 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9356 docs/dev/debt/libSceAgcDriver.md
PR 9387 docs/dev/debt/libSceAgcDriver.md
PR 9895 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9950 docs/dev/debt/libSceAgcDriver.md
PR 10049 docs/dev/debt/libSceAgcDriver.md
PR 10193 docs/dev/debt/libSceAgcDriver.md
PR 10249 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
PR 10359 docs/dev/debt/libSceAgcDriver.md
PR 10743 docs/dev/debt/libSceAgcDriver.md
PR 11551 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
docs/dev/debt/libSceAgcDriver.md
PR 11825 core/libs/prx/libSceAgcDriver/Graphics/src/ColorTargetLayout.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
docs/dev/debt/libSceAgcDriver.md
PR 12904 docs/dev/debt/libSceAgcDriver.md
PR 13809 docs/dev/debt/libSceAgcDriver.md
PR 13863 docs/dev/debt/libSceAgcDriver.md
PR 13920 docs/dev/debt/libSceAgcDriver.md
PR 13928 docs/dev/debt/libSceAgcDriver.md
PR 13929 docs/dev/debt/libSceAgcDriver.md
PR 13963 docs/dev/debt/libSceAgcDriver.md
PR 14944 docs/dev/debt/libSceAgcDriver.md
PR 15456 docs/dev/debt/libSceAgcDriver.md
PR 15529 docs/dev/debt/libSceAgcDriver.md
PR 15548 docs/dev/debt/libSceAgcDriver.md
PR 15621 docs/dev/debt/libSceAgcDriver.md
PR 16260 docs/dev/debt/libSceAgcDriver.md
PR 16483 docs/dev/debt/libSceAgcDriver.md
PR 16753 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
PR 17611 docs/dev/debt/libSceAgcDriver.md
PR 17915 docs/dev/debt/libSceAgcDriver.md
PR 17956 docs/dev/debt/libSceAgcDriver.md
PR 18139 docs/dev/debt/libSceAgcDriver.md
PR 18515 docs/dev/debt/libSceAgcDriver.md
PR 20084 docs/dev/debt/libSceAgcDriver.md
PR 20187 docs/dev/debt/libSceAgcDriver.md

@JJenkx

JJenkx commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Windows check of head d7899ab492. Setup: Windows 11 Enterprise 22621, AMD RX 6700 XT, AMD driver 26.10.1, MinGW-w64 GCC 15.2 UCRT, Release.

This PR's tests:

  • agc_driver_gcn_color_array_slices (new);
  • agc_gcn_color_target;
  • agc_driver_graphics, which builds tests/TextureTiling.cpp.

These ran together with the other libSceAgcDriver tests that cover the changed files, 48 tests in all:

  • GPU, through the shared Windows GPU FIFO with ANYPS5_REQUIRE_VULKAN=1, merged onto main 145e689ada (merge b287f002a1): all 48 passed in 3 of 3 runs, 144 of 144 outcomes. The binaries matched the hashes recorded at preparation, and the receipt shows exit 0 and app_count=0.
  • CPU, Vulkan hidden, merge 7245c26a61: 47 passed and agc_driver_gcn_color_array_slices skipped (it needs a device), 0 failed, in 3 of 3 runs.

AI-assisted: yes.

@puridanish284

Copy link
Copy Markdown
Contributor Author

@MarcZX10 thanks. Here is the paired run on the review base, same machine and options as in the description:

  • main c85dcfd005 and this head d7899ab492 merged onto c85dcfd005 (temporary merge 3b65fb4cdf, not pushed), each built from that tree in the same build directory: WSL2 Ubuntu 24.04.5, gcc 13.3.0, Release, lavapipe (Mesa 25.2.8, Vulkan 1.4.318).
  • ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (Ubuntu's 1.3.275 layer through VK_LAYER_PATH), ctest -R '^(agc_driver_graphics|agc_gcn_color_target|agc_driver_gcn_.*)$' -j 8 --timeout 600 -V.
  • main: 8 of 8 pass. Merge: 9 of 9 pass, the 8 plus agc_driver_gcn_color_array_slices.
  • Neither log contains was not found but was requested by env var VK_INSTANCE_LAYERS. The only VUID- in either is VUID-VkDeviceCreateInfo-pNext-pNext, once per GPU test at device creation (the old layer, tests: with a Vulkan validation layer older than the repo's headers, agc_driver_image_table* fail on main from VUID-VkDeviceCreateInfo-pNext-pNext (unknown VK_KHR_shader_fma / VK_KHR_maintenance8 structs) #17693): 6 on main, the same 6 on the merge plus 1 for the new test. No new VUID-.

The merge also passes with #18176 and #18177's current heads merged in (agc_gcn_color_target, agc_driver_graphics, agc_driver_gcn_color_array_slices, agc_driver_gcn_fast_clear_color_target, agc_driver_gcn_eqaa_color_target).


Generated by Claude Code

@Doorriiaann

Copy link
Copy Markdown
Contributor

An NVIDIA run, next to the lavapipe and RX 6700 XT runs: RTX 3070 (8 GB), NVIDIA 610.57.04, Debian 13, kernel 6.12.115, GCC 13.3.0 Release, validation layer 1.4.335, ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ctest -R 'gcn_color|color_array_slices' -V, 2 runs each.

merge-base 177495a this PR d7899ab
agc_gcn_color_target passed 2/2 passed 2/2, with this PR's cases
agc_driver_gcn_color_array_slices — passed 2/2
VUID- lines / layer not found 0 / 0 0 / 0

Negative control: this PR's GcnColorArraySlices.cpp, GcnColorTarget.cpp and TextureTiling.cpp on the merge-base, 2 runs: both tests fail 2/2 with AGC graphics: GCN color views of a later slice of a 2D-tiled array, whose banks rotate per slice, are not implemented.

AI-assisted: yes

@hamdanpor-ctrl

Copy link
Copy Markdown
Contributor

Test report, NVIDIA on Windows: clean.

  • GPU: NVIDIA GeForce RTX 3050 Laptop GPU, driver 617.42, Windows 11 Pro (10.0.26300)
  • Build: WinLibs GCC 15.2.0 r7 UCRT, Release, all AGC execution tests built
  • Compared: main at 63f37bf, and the same commit with d7899ab merged (git merge --no-ff, clean)
  • Environment: ANYPS5_GPU=NVIDIA, ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (Vulkan SDK 1.4.363.0)
  • Command: ctest --test-dir build -V --parallel 4 -R "^agc_|^request_serializer|shader"
main main + this PR
Passed 1623 1624
Failed 0 0
VUID- lines 0 0
Validation messages 61 61, same IDs
  • New agc_driver_gcn_color_array_slices passes.
  • Every other test has the same result on both commits; the layer loads in both logs and neither reports it missing.

Single run each. AI-assisted (Claude Code).

@tablefrogpillow

Copy link
Copy Markdown
Contributor

Verified on three AMD generations on Linux (RADV, Mesa 26.2.6), validation layer 1.4.363 (no VUID-), at d7899ab492. Vega here is GCN5 (gfx900) — the only GCN-architecture GPU in the runs so far (the checks above are RDNA2, NVIDIA and lavapipe), so it exercises the per-slice bank rotation on actual GCN silicon.

agc_driver_gcn_color_array_slices, PR head vs a negative control that keeps this PR's test but reverts ColorTargetLayout.cpp and State.cpp to the PR's merge-base:

GPU PR head control (fix reverted)
Vega (VEGA10, gfx900, GCN5) 3/3 pass 0/3 pass
RDNA2 (RAPHAEL, gfx1036) 3/3 pass 0/3 pass
RDNA3 (NAVI31, gfx1100) 3/3 pass 0/3 pass

The control fails deterministically on all three: AGC graphics: GCN color views of a later slice of a 2D-tiled array, whose banks rotate per slice, are not implemented. With the fix, slice-1-and-later views of the 2D-tiled GCN color array render on every AMD generation here, including real GCN silicon; 0 VUID- in every run.

AI-assisted: yes.

@Gag21

Gag21 commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Independent qualification and hardware test run on Windows 11 with latest main baseline (d31916ed37):

Environment

  • Host: Windows 11 Pro 64-bit, Intel Core i5-6600K @ 3.50GHz, 48 GiB RAM
  • Compiler: WinLibs GCC 16.2.0, CMake 3.31.6, Ninja
  • GPU: NVIDIA GeForce RTX 3070 (Driver 591.86, Vulkan 1.4.318)
  • Validation Layers: VK_LAYER_KHRONOS_validation enabled with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_LOADER_DEBUG=layer

Test Results

  • agc_driver_gcn_color_array_slices: Passed (1.20s). 13,224 Thin2D texels and 13,224 Display2D drawn texels match the reference texture model across all array slices.
  • agc_gcn_color_target: Passed (0.05s).
  • agc_driver_graphics: Passed (80.40s).
  • Vulkan Validation: Log confirmed layer insertion (Insert instance layer "VK_LAYER_KHRONOS_validation"), zero missing layer warnings, and 0 VUID- validation errors.

Negative Control

  • Reverted the pipe bank XOR assignment in State.cpp (color.pipeBankXor = GcnLayerBankXor(...)).
  • Re-running agc_driver_gcn_color_array_slices failed deterministically:
    AGC graphics: Thin2D: the color target of slice 1 does not carry the bank rotation of its array layer
  • Restored cleanly and re-verified.

Conventions & Quality

  • python tools/check_conventions.py --base origin/main passed cleanly with 0 findings.
  • Zero comments added in code. Technical debt entry properly formatted.

The implementation is verified and ready for merge.

@oneandonlydean
oneandonlydean merged commit c645264 into boykopovar:main Nov 16, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants