docs(agc): name what shadPS4, fpPS4 and addrlib do for PS4 layered surfaces and display buffers #13484

Merged
xXPBSXx merged 1 commit from upstream-pr/13484 into main 2026-10-30 20:54:12 +00:00
xXPBSXx commented 2026-10-30 16:41:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-30T16:41:12Z.


What

Two existing debt entries in docs/dev/debt/libSceAgcDriver.md get one sentence each about how other PS4 implementations differ from this code. The entries then read:

  • PS4 (GCN) thick and layered surfaces (libSceAgcDriver, PS4) - 3D and thick modes (GB_TILE_MODE 15 and 19 to 26) throw, and so does a storage image or a depth plane of a layered surface with several mip levels. A sampled layered surface with several mip levels is stored level by level, which is not checked on a console; GcnDetile.cpp runs the GPU detiler over every mode that does not throw. The bank of each layer of a tiled 2D array is rotated by (banks / 2 - 1) times the layer index outside the PRT modes, XORed in as AMD's address library and shadPS4 (tiling.comp, 0614ce324be0) do; fpPS4 (ps4_tiling.pas, 04cefd43e6fd) adds it to the bank instead. Not checked on a console.
  • PS4 render targets and display buffers (libSceAgcDriver, PS4) - a tiled PS4 display buffer is read as Display2DThin with rows padded to 128 elements, as shadPS4's image_info.cpp does. A PS4 render target spans its surface padded to whole macro tiles (1920x1080 at 32 bits is 1920x1088), the display buffer is its top-left corner, and a texture over that corner with the same pitch, tiling and texel size is a GPU copy of it. A PS4 DB_Z_INFO names a GB_TILE_MODE index; the depth image stays on the GPU and HTILE is kept, as for the PS5. shadPS4 (image_info.cpp, 0614ce324be0) rounds the width of a tiled display buffer up to a multiple of 128 itself, whereas DisplayBufferSize requires the pitch to be one already.

The new sentence in the first entry only records the comparison: the rotation of the bank per array layer has been implemented here since #12998, and it records that AMD's address library and shadPS4 XOR the rotation into the bank, where fpPS4 adds it. The second says shadPS4 rounds the width of a tiled display buffer up to 128 itself while DisplayBufferSize requires the pitch to be a multiple of 128 already.

Changed: docs/dev/debt/libSceAgcDriver.md, two existing entries. No code change.

Method: the three were read at the linked commits; only their behaviour is described, no code was taken over. shadPS4 tiling.comp L322-L335 and image_info.cpp L54; fpPS4 ps4_tiling.pas L2887-L2912; AMD addrlib egbaddrlib.cpp L3002-L3049. In fpPS4, xor and + have the same precedence in Pascal, so bank xor bank_swizzle + slice_rotation is evaluated left to right. The statements about this code were read in GcnLayerBankXor and TextureDetiler::layerBankXor (rotation, PRT modes get none) and in DisplayBufferSize (DisplayBuffer.cpp). sceVideoOutRegisterBuffers currently rejects a tiled PS4 buffer, so the display sentence is about that function, not about a title. None of this is measured on a console.

Overlap

Open PRs that change docs/dev/debt/libSceAgcDriver.md (file sets from git diff --name-only against each PR head's merge base, all 1422 open pull requests as of 2026-10-30 12:29 UTC, main 42d009f5f3; the 49 pull requests opened up to 13:25 UTC (1465 open, main da026c7065) change other files, and the pairs below were measured again at that time): 131 touch the file or are ours. Of the pull requests opened since 12:29 UTC, only #13373 (a new "Adaptive staging" entry) touches the file; it merges with and without this commit (checked at main ed1e0ed08f). Measured again on 2026-10-30 at 16:15 UTC against main 9304896d89 (1548 open pull requests): of the 46 pull requests opened since 14:15 UTC, only #13471 touches the file, and it merges with and without this commit; the five pairs below give the same result as before. Measured once more on 2026-10-30 at 16:56 UTC against main 556547da71 (1564 open pull requests, the head of each fetched fresh): 134 touch the file or are ours; the only ones that conflict with this commit but not with main are the five below, and #13373, #13471, #13474 and our other PRs (#12797, #12765, #12742) merge with and without it; #13491 and #13492, opened after the fetch, do not touch the file. Five give a new conflict with this change, all on the same lines: #9674 and #9891 rewrite the thick and layered surfaces entry, #9672 and #9895 the render targets and display buffers entry, and #9892 adds an entry next to them. Whichever of these merges second needs a rebase of the added sentence; the texts do not contradict each other. The others give the same merge result with and without this commit. Our other PRs (#12797, #12765, #12742) have no conflict with it.

Tested

Documentation only. tools/check_conventions.py --base upstream/main passes; both entries stay under 1000 characters; based on main da026c7065, and it merges with main 556547da71 without a conflict (checked 2026-10-30 16:56 UTC). Not built, not 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
  • 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: #9672, #9674, #9891, #9895 (landing order only; same entries) and #9892 (adjacent lines)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

AI-assisted (Claude Code).

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5087801349 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13484). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-30T16:41:12Z. --- ### What Two existing debt entries in `docs/dev/debt/libSceAgcDriver.md` get one sentence each about how other PS4 implementations differ from this code. The entries then read: > - [PS4 (GCN) thick and layered surfaces](../../../core/libs/prx/libSceAgcDriver/Graphics/src/TextureTiling.cpp) (libSceAgcDriver, PS4) - 3D and thick modes (GB_TILE_MODE 15 and 19 to 26) throw, and so does a storage image or a depth plane of a layered surface with several mip levels. A sampled layered surface with several mip levels is stored level by level, which is not checked on a console; [GcnDetile.cpp](../../../core/libs/prx/libSceAgcDriver/tests/execution/GcnDetile.cpp) runs the GPU detiler over every mode that does not throw. The bank of each layer of a tiled 2D array is rotated by (banks / 2 - 1) times the layer index outside the PRT modes, XORed in as AMD's address library and shadPS4 (`tiling.comp`, 0614ce324be0) do; fpPS4 (`ps4_tiling.pas`, 04cefd43e6fd) adds it to the bank instead. Not checked on a console. > - [PS4 render targets and display buffers](../../../core/libs/prx/libSceAgcDriver/Execution/src/DisplayBuffer.cpp) (libSceAgcDriver, PS4) - a tiled PS4 display buffer is read as Display2DThin with rows padded to 128 elements, as shadPS4's `image_info.cpp` does. A PS4 render target spans its surface padded to whole macro tiles (1920x1080 at 32 bits is 1920x1088), the display buffer is its top-left corner, and a texture over that corner with the same pitch, tiling and texel size is a [GPU copy](../../../core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp) of it. A PS4 `DB_Z_INFO` names a GB_TILE_MODE index; the depth image stays on the GPU and HTILE is kept, as for the PS5. shadPS4 (`image_info.cpp`, 0614ce324be0) rounds the width of a tiled display buffer up to a multiple of 128 itself, whereas `DisplayBufferSize` requires the pitch to be one already. The new sentence in the first entry only records the comparison: the rotation of the bank per array layer has been implemented here since #12998, and it records that AMD's address library and shadPS4 XOR the rotation into the bank, where fpPS4 adds it. The second says shadPS4 rounds the width of a tiled display buffer up to 128 itself while `DisplayBufferSize` requires the pitch to be a multiple of 128 already. Changed: `docs/dev/debt/libSceAgcDriver.md`, two existing entries. No code change. Method: the three were read at the linked commits; only their behaviour is described, no code was taken over. shadPS4 [`tiling.comp` L322-L335](https://github.com/shadps4-emu/shadPS4/blob/0614ce324be092791b758d79f93d9f1ca5b10a81/src/video_core/host_shaders/tiling.comp#L322-L335) and [`image_info.cpp` L54](https://github.com/shadps4-emu/shadPS4/blob/0614ce324be092791b758d79f93d9f1ca5b10a81/src/video_core/texture_cache/image_info.cpp#L54); fpPS4 [`ps4_tiling.pas` L2887-L2912](https://github.com/red-prig/fpPS4/blob/04cefd43e6fddd1ab033e7980cd356d14c964905/chip/ps4_tiling.pas#L2887-L2912); AMD addrlib [`egbaddrlib.cpp` L3002-L3049](https://gitlab.freedesktop.org/mesa/mesa/-/blob/393bf0d1467c4a7e208fd0d36b05b99438926079/src/amd/addrlib/src/r800/egbaddrlib.cpp#L3002-L3049). In fpPS4, `xor` and `+` have the same precedence in Pascal, so `bank xor bank_swizzle + slice_rotation` is evaluated left to right. The statements about this code were read in `GcnLayerBankXor` and `TextureDetiler::layerBankXor` (rotation, PRT modes get none) and in `DisplayBufferSize` (`DisplayBuffer.cpp`). `sceVideoOutRegisterBuffers` currently rejects a tiled PS4 buffer, so the display sentence is about that function, not about a title. None of this is measured on a console. ### Overlap Open PRs that change `docs/dev/debt/libSceAgcDriver.md` (file sets from `git diff --name-only` against each PR head's merge base, all 1422 open pull requests as of 2026-10-30 12:29 UTC, main `42d009f5f3`; the 49 pull requests opened up to 13:25 UTC (1465 open, main `da026c7065`) change other files, and the pairs below were measured again at that time): 131 touch the file or are ours. Of the pull requests opened since 12:29 UTC, only #13373 (a new "Adaptive staging" entry) touches the file; it merges with and without this commit (checked at main `ed1e0ed08f`). Measured again on 2026-10-30 at 16:15 UTC against main `9304896d89` (1548 open pull requests): of the 46 pull requests opened since 14:15 UTC, only #13471 touches the file, and it merges with and without this commit; the five pairs below give the same result as before. Measured once more on 2026-10-30 at 16:56 UTC against main `556547da71` (1564 open pull requests, the head of each fetched fresh): 134 touch the file or are ours; the only ones that conflict with this commit but not with main are the five below, and #13373, #13471, #13474 and our other PRs (#12797, #12765, #12742) merge with and without it; #13491 and #13492, opened after the fetch, do not touch the file. Five give a new conflict with this change, all on the same lines: #9674 and #9891 rewrite the thick and layered surfaces entry, #9672 and #9895 the render targets and display buffers entry, and #9892 adds an entry next to them. Whichever of these merges second needs a rebase of the added sentence; the texts do not contradict each other. The others give the same merge result with and without this commit. Our other PRs (#12797, #12765, #12742) have no conflict with it. ### Tested Documentation only. `tools/check_conventions.py --base upstream/main` passes; both entries stay under 1000 characters; based on `main` `da026c7065`, and it merges with `main` `556547da71` without a conflict (checked 2026-10-30 16:56 UTC). Not built, not run. ### Checklist - [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: #9672, #9674, #9891, #9895 (landing order only; same entries) and #9892 (adjacent lines) - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-10-30 16:44:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-30T16:44:57Z.

Review: APPROVED


Reviewed — looks good

The documentation-only changes match the pinned comparison sources and the implementation at the reviewed head.

What I ran

Reviewed head cd67746df82be1d967dd3aed81f349b50b48cb1c against base 556547da71c5e25b742f17b1ed9b27253b6e9d4d; the read-only merge preview onto current main at that base was clean. Environment: Linux x86_64, Python 3.11.2, GCC 12.2.0.

git diff --check 556547da71c5e25b742f17b1ed9b27253b6e9d4d...cd67746df82be1d967dd3aed81f349b50b48cb1c
python3 tools/check_conventions.py --base 556547da71c5e25b742f17b1ed9b27253b6e9d4d --head cd67746df82be1d967dd3aed81f349b50b48cb1c
python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13484

I also inspected the cited external source lines at their pinned commits and the corresponding AnyPS5 implementation at the reviewed head.

Results

Check Result
Diff whitespace check Passed; no output
Conventions and PR template Passed
Current-main/dependency merge previews Clean for #13484 and the four dependencies parsed by the stack helper (#9672, #9674, #9891, #9895); those heads are not included in #13484. #9892 is named in the overlap note and is individually mergeable, but was not part of the parsed chain.
Source comparison Confirmed: AMD addrlib and shadPS4 XOR the layer rotation into the bank; fpPS4 adds it. shadPS4 rounds tiled display width to 128 pixels and DisplayBufferSize requires a pitch divisible by 128.
Aggregate precheck Incomplete: its test-quality helper was unavailable in the isolated checkout; this documentation-only diff has no tests to assess.
Unedited output
All conventions checks passed.

git diff --check produced no output. The precheck output was:

/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13484-cd67746df82b/report.md
/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13484-cd67746df82b/report.json
Conclusion: checks failed

The failed helper emitted:

/usr/bin/python3: can't open file '/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13484-cd67746df82b/head-cd67746df82b-4094f416/tools/pr_test_quality.py': [Errno 2] No such file or directory

Findings

Blocking

None.

Non-blocking

  • The PR description says its latest overlap scan ran at 2026-10-30 17:15 UTC against main 9304896d89. At the live snapshot for this review, it was 16:42 UTC and main was 556547da71c5e25b742f17b1ed9b27253b6e9d4d. Please replace the postdated scan and older Tested base reference with evidence from an actual current-main snapshot.

Sources

Not verified

  • No build or tests were run; the PR changes documentation only.
  • Hosted conventions, intake, labels and eligibility checks were queued at the final check snapshot.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5715583924 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13484#pullrequestreview-5715583924). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-30T16:44:57Z. **Review:** APPROVED --- # Reviewed — looks good The documentation-only changes match the pinned comparison sources and the implementation at the reviewed head. ## What I ran Reviewed head `cd67746df82be1d967dd3aed81f349b50b48cb1c` against base `556547da71c5e25b742f17b1ed9b27253b6e9d4d`; the read-only merge preview onto current `main` at that base was clean. Environment: Linux x86_64, Python 3.11.2, GCC 12.2.0. ```sh git diff --check 556547da71c5e25b742f17b1ed9b27253b6e9d4d...cd67746df82be1d967dd3aed81f349b50b48cb1c python3 tools/check_conventions.py --base 556547da71c5e25b742f17b1ed9b27253b6e9d4d --head cd67746df82be1d967dd3aed81f349b50b48cb1c python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13484 ``` I also inspected the cited external source lines at their pinned commits and the corresponding AnyPS5 implementation at the reviewed head. ## Results | Check | Result | | --- | --- | | Diff whitespace check | Passed; no output | | Conventions and PR template | Passed | | Current-main/dependency merge previews | Clean for #13484 and the four dependencies parsed by the stack helper (#9672, #9674, #9891, #9895); those heads are not included in #13484. #9892 is named in the overlap note and is individually mergeable, but was not part of the parsed chain. | | Source comparison | Confirmed: AMD addrlib and shadPS4 XOR the layer rotation into the bank; fpPS4 adds it. shadPS4 rounds tiled display width to 128 pixels and `DisplayBufferSize` requires a pitch divisible by 128. | | Aggregate precheck | Incomplete: its test-quality helper was unavailable in the isolated checkout; this documentation-only diff has no tests to assess. | <details> <summary>Unedited output</summary> ```text All conventions checks passed. ``` `git diff --check` produced no output. The precheck output was: ```text /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13484-cd67746df82b/report.md /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13484-cd67746df82b/report.json Conclusion: checks failed ``` The failed helper emitted: ```text /usr/bin/python3: can't open file '/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13484-cd67746df82b/head-cd67746df82b-4094f416/tools/pr_test_quality.py': [Errno 2] No such file or directory ``` </details> ## Findings ### Blocking None. ### Non-blocking - The PR description says its latest overlap scan ran at `2026-10-30 17:15 UTC` against main `9304896d89`. At the live snapshot for this review, it was 16:42 UTC and main was `556547da71c5e25b742f17b1ed9b27253b6e9d4d`. Please replace the postdated scan and older `Tested` base reference with evidence from an actual current-main snapshot. ## Sources - AnyPS5 layer rotation implementation at this head: [TextureTiling.cpp](https://github.com/boykopovar/AnyPS5/blob/cd67746df82be1d967dd3aed81f349b50b48cb1c/core/libs/prx/libSceAgcDriver/Graphics/src/TextureTiling.cpp#L560-L562), [TextureTiling.hpp](https://github.com/boykopovar/AnyPS5/blob/cd67746df82be1d967dd3aed81f349b50b48cb1c/core/libs/prx/libSceAgcDriver/Graphics/include/TextureTiling.hpp#L96). - AnyPS5 display pitch validation at this head: [DisplayBuffer.cpp](https://github.com/boykopovar/AnyPS5/blob/cd67746df82be1d967dd3aed81f349b50b48cb1c/core/libs/prx/libSceAgcDriver/Execution/src/DisplayBuffer.cpp#L150-L153). - [shadPS4 `tiling.comp`](https://github.com/shadps4-emu/shadPS4/blob/0614ce324be092791b758d79f93d9f1ca5b10a81/src/video_core/host_shaders/tiling.comp#L320-L335) and [shadPS4 `image_info.cpp`](https://github.com/shadps4-emu/shadPS4/blob/0614ce324be092791b758d79f93d9f1ca5b10a81/src/video_core/texture_cache/image_info.cpp#L45-L55). - [fpPS4 `ps4_tiling.pas`](https://github.com/red-prig/fpPS4/blob/04cefd43e6fddd1ab033e7980cd356d14c964905/chip/ps4_tiling.pas#L2885-L2912) and [AMD addrlib `egbaddrlib.cpp`](https://gitlab.freedesktop.org/mesa/mesa/-/blob/393bf0d1467c4a7e208fd0d36b05b99438926079/src/amd/addrlib/src/r800/egbaddrlib.cpp#L3000-L3049). ## Not verified - No build or tests were run; the PR changes documentation only. - Hosted conventions, intake, labels and eligibility checks were queued at the final check snapshot.
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!13484
No description provided.