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

Merged
puridanish284 merged 1 commit from upstream-pr/18721 into main 2026-11-16 06:17:12 +00:00
puridanish284 commented 2026-11-12 04:31:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by puridanish284 on 2026-11-12T04:31:41Z.


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 (c7a3fff544, #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, #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

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5271546691 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18721). Originally posted by [puridanish284](https://github.com/puridanish284) on 2026-11-12T04:31:41Z. --- ### 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 (c7a3fff544, #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 <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> 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_VIEW`s. 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, #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 <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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 under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [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] Fixes: none - [x] Unblocks: none - [x] GPUs tested: lavapipe (llvmpipe, Mesa 25.2.8, Vulkan 1.4.318) on Ubuntu 24.04.5 under WSL2; no hardware GPU - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-11-12 04:43:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-12T04:43:32Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5869248353 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18721#pullrequestreview-5869248353). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-12T04:43:32Z. **Review:** COMMENTED --- # 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. ```sh 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. | <details> <summary>Precheck details</summary> ```text 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. ``` </details> ## 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 - [Slice XOR selection and color-target layout at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/d7899ab4927ae9db355e5dad88e3f0fe5dba79ee/core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp#L2288-L2290) - [CPU color-target XOR validation and address calculation at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/d7899ab4927ae9db355e5dad88e3f0fe5dba79ee/core/libs/prx/libSceAgcDriver/Graphics/src/ColorTargetLayout.cpp#L118-L204) - [Execution-test discovery and CTest registration at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/d7899ab4927ae9db355e5dad88e3f0fe5dba79ee/core/libs/prx/libSceAgcDriver/CMakeLists.txt#L689-L703) - [Current-base texture detile path](https://github.com/boykopovar/AnyPS5/blob/c85dcfd0056e0e341c3a2f5e285c94602353a7b7/core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp#L3332-L3358) - [New array-slice integration test at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/d7899ab4927ae9db355e5dad88e3f0fe5dba79ee/core/libs/prx/libSceAgcDriver/tests/execution/GcnColorArraySlices.cpp) ## 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.
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!18721
No description provided.