feat(agc): draw PS4 color targets in the PRT tile modes #22514

Open
puridanish284 wants to merge 1 commit from upstream-pr/22514 into main
puridanish284 commented 2026-11-17 18:25:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by puridanish284 on 2026-11-17T18:25:32Z.


What

A PS4 (GCN) color target in GB_TILE_MODE 11, 12, 16 or 17 (the display and thin PRT modes, 1D and 2D) threw PS4 color target tile mode index N is not implemented, although textures in the same modes already decode. DecodeGcnColorBuffer now accepts them as four new ColorTileMode values that map to the existing kGcnDisplayPrt, kGcnDisplay2DPrt, kGcnThinPrt and kGcnThin2DPrt texture modes, so ColorTargetLayout and the resident image use GcnTiling's PRT geometry. Slices are one whole surface apart and, as for PRT texture layers (layerBankStep 0), take no per-slice bank rotation. macroTiled now comes from IsGcnMacroTiled, so the existing refusal of multisampled later slices covers the PRT modes too. GB_TILE_MODE 15 and 18 to 30 still throw. A debt fragment adds a PS4 (GCN) PRT color targets entry (not checked on a console; partly resident PRT surfaces are not modeled).

Tests:

  • New execution test GcnPrtColorTarget (agc_driver_gcn_prt_color_target): fills three-slice 128x128 RGBA8 arrays in each of the four modes through the texture path's placement, draws a triangle into slices 0 and 2 and checks every texel is either its background or the drawn color at the place the texture path gives it. Mutation check: mapping GcnThinPrt to kGcnThin2DPrt fails it (ThinPrt slice 0: the texel the texture path places at (16, 27) holds 08 1b 10 ff, neither its background nor the color drawn for it).
  • GcnColorTarget.cpp PrtTargetsDecode: each mode decodes as its PRT tile mode over one 128x128 macro tile, slice 1 lands one macro tile further on without a bank XOR, a target half a macro tile tall is refused, and mode 15 still throws.

Tested

WSL2 Ubuntu on Windows 11, Release build with GCC, lavapipe (Mesa 25.2.8). Same 20 focused tests (ctest -R '^(agc_driver_gcn_|agc_gcn_|agc_driver_graphics$|agc_driver_[a-z0-9_]*color_target$)', agc_gcn_vop3_compare_true not built) with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, VK_LOADER_DEBUG=layer:

  • main 5adb7d22ab: 20/20 passed, 17 Insert instance layer "VK_LAYER_KHRONOS_validation" lines, no was not found line, 51 VUID-VkDeviceCreateInfo-pNext-pNext.
  • This PR: 21/21 passed (the 20 plus agc_driver_gcn_prt_color_target), 18 insert lines, no was not found line, 54 VUID-VkDeviceCreateInfo-pNext-pNext.

The only validation ID on both is the device-creation one from Ubuntu's older 1.3.275 layer (#17693), three per test; the change adds no new VUID-. No title was run.

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: lavapipe (Mesa 25.2.8 llvmpipe, Vulkan 1.4.318), WSL2 Ubuntu on Windows 11
  • AI-assisted: yes

tools/pr_overlap.py failed closed. #18177 and #22140 conflict only where GcnColorTarget.cpp's main() lists its test calls. #22140 materializes partial CMASK fast clears of GcnThin2D and GcnDisplay2D targets only, so a fast-cleared 2D PRT target keeps its current path whichever merges first. The other PRs it could not compare (#1395, #6188, #6235, #6804, #7256, #9895, #10249, #11825, #20845) do not touch the GCN color tile-mode switch or ColorTextureTileMode.

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5362623378 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22514). Originally posted by [puridanish284](https://github.com/puridanish284) on 2026-11-17T18:25:32Z. --- ### What A PS4 (GCN) color target in GB_TILE_MODE 11, 12, 16 or 17 (the display and thin PRT modes, 1D and 2D) threw `PS4 color target tile mode index N is not implemented`, although textures in the same modes already decode. `DecodeGcnColorBuffer` now accepts them as four new `ColorTileMode` values that map to the existing `kGcnDisplayPrt`, `kGcnDisplay2DPrt`, `kGcnThinPrt` and `kGcnThin2DPrt` texture modes, so `ColorTargetLayout` and the resident image use `GcnTiling`'s PRT geometry. Slices are one whole surface apart and, as for PRT texture layers (`layerBankStep` 0), take no per-slice bank rotation. `macroTiled` now comes from `IsGcnMacroTiled`, so the existing refusal of multisampled later slices covers the PRT modes too. GB_TILE_MODE 15 and 18 to 30 still throw. A debt fragment adds a `PS4 (GCN) PRT color targets` entry (not checked on a console; partly resident PRT surfaces are not modeled). Tests: - New execution test `GcnPrtColorTarget` (`agc_driver_gcn_prt_color_target`): fills three-slice 128x128 RGBA8 arrays in each of the four modes through the texture path's placement, draws a triangle into slices 0 and 2 and checks every texel is either its background or the drawn color at the place the texture path gives it. Mutation check: mapping `GcnThinPrt` to `kGcnThin2DPrt` fails it (`ThinPrt slice 0: the texel the texture path places at (16, 27) holds 08 1b 10 ff, neither its background nor the color drawn for it`). - `GcnColorTarget.cpp` `PrtTargetsDecode`: each mode decodes as its PRT tile mode over one 128x128 macro tile, slice 1 lands one macro tile further on without a bank XOR, a target half a macro tile tall is refused, and mode 15 still throws. ### Tested WSL2 Ubuntu on Windows 11, Release build with GCC, lavapipe (Mesa 25.2.8). Same 20 focused tests (`ctest -R '^(agc_driver_gcn_|agc_gcn_|agc_driver_graphics$|agc_driver_[a-z0-9_]*color_target$)'`, `agc_gcn_vop3_compare_true` not built) with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, `VK_LOADER_DEBUG=layer`: - `main` 5adb7d22ab: 20/20 passed, 17 `Insert instance layer "VK_LAYER_KHRONOS_validation"` lines, no `was not found` line, 51 `VUID-VkDeviceCreateInfo-pNext-pNext`. - This PR: 21/21 passed (the 20 plus `agc_driver_gcn_prt_color_target`), 18 insert lines, no `was not found` line, 54 `VUID-VkDeviceCreateInfo-pNext-pNext`. The only validation ID on both is the device-creation one from Ubuntu's older 1.3.275 layer (#17693), three per test; the change adds no new `VUID-`. No title was run. ### 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) and the licence notice of code adapted from upstream (see AGENTS.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 (Mesa 25.2.8 llvmpipe, Vulkan 1.4.318), WSL2 Ubuntu on Windows 11 - [x] AI-assisted: yes `tools/pr_overlap.py` failed closed. #18177 and #22140 conflict only where `GcnColorTarget.cpp`'s `main()` lists its test calls. #22140 materializes partial CMASK fast clears of `GcnThin2D` and `GcnDisplay2D` targets only, so a fast-cleared 2D PRT target keeps its current path whichever merges first. The other PRs it could not compare (#1395, #6188, #6235, #6804, #7256, #9895, #10249, #11825, #20845) do not touch the GCN color tile-mode switch or `ColorTextureTileMode`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-11-21 08:38:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T08:38:04Z.

Review: COMMENTED


Reviewed — no blocking findings

The changed code and all added lines support the stated PRT color target behavior; I could not run the reported checks in this review environment.

What I ran

Reviewed head 0122daa352b8cc2975f03a0490aec9967e99d752. I inspected the prepared diff and traced the changed layout and decode logic with the pinned repo_read.py reader. No test or build commands were run.

Results

Check Result Note
Diff and changed lines passed All six changed files inspected
Build and tests not run Author reports 21 focused tests passed
Console behavior not run Author states this was not checked

Findings

Blocking

None.

Non-blocking

None.

Not verified

I did not run the build or tests, so the reported test results are author-provided. Physical console behavior and partly resident PRT surfaces were not verified. The six changed files listed in review/manifest.json were read, including all added lines; files.json lists no excluded changed files.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6004187377 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22514#pullrequestreview-6004187377). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-21T08:38:04Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The changed code and all added lines support the stated PRT color target behavior; I could not run the reported checks in this review environment. ## What I ran Reviewed head `0122daa352b8cc2975f03a0490aec9967e99d752`. I inspected the prepared diff and traced the changed layout and decode logic with the pinned `repo_read.py` reader. No test or build commands were run. ## Results | Check | Result | Note | |---|---|---| | Diff and changed lines | passed | All six changed files inspected | | Build and tests | not run | Author reports 21 focused tests passed | | Console behavior | not run | Author states this was not checked | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified I did not run the build or tests, so the reported test results are author-provided. Physical console behavior and partly resident PRT surfaces were not verified. The six changed files listed in `review/manifest.json` were read, including all added lines; `files.json` lists no excluded changed files. ## To get this to a good state Nothing is required.
ligmaSec commented 2026-12-03 22:09:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T22:09:47Z.

Review: COMMENTED


Trial merging onto main a1b75b0947 conflicts in GcnColorTarget.cpp. The new modes reuse the texture path's PRT geometry, so the nonzero slice case matters as much as the register decode. Please preserve the tests for whole-surface slice spacing and no per-slice bank rotation while retaining the refusal of multisampled later macro-tiled slices. The paired Vulkan run is pending the merge resolution.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6179477954 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22514#pullrequestreview-6179477954). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T22:09:47Z. **Review:** COMMENTED --- Trial merging onto `main` `a1b75b0947` conflicts in `GcnColorTarget.cpp`. The new modes reuse the texture path's PRT geometry, so the nonzero slice case matters as much as the register decode. Please preserve the tests for whole-surface slice spacing and no per-slice bank rotation while retaining the refusal of multisampled later macro-tiled slices. The paired Vulkan run is pending the merge resolution. AI-assisted: yes.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/22514:upstream-pr/22514'
git switch 'upstream-pr/22514'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/22514'
git switch 'upstream-pr/22514'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/22514'
git switch 'upstream-pr/22514'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/22514'
git switch 'main'
git merge --squash 'upstream-pr/22514'
git switch 'main'
git merge --ff-only 'upstream-pr/22514'
git switch 'main'
git merge 'upstream-pr/22514'
git push origin 'main'
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!22514
No description provided.