feat(libSceAgcDriver): support PS4 2D thick tile mode 20 for volumes #20786

Merged
Gag21 merged 2 commits from upstream-pr/20786 into main 2026-12-04 00:10:27 +00:00
Gag21 commented 2026-11-15 15:24:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Gag21 on 2026-11-15T15:24:08Z.


What

Support PS4 tile mode 20 (Thick_2dThick) in libSceAgcDriver for 3D textures (volumes).

  • Maps PS4 texture tile mode index 20 to TextureTileMode::kGcnThick2D.
  • Implements GCN thick macro-tile equations in GcnTiling:
    • 8x8x4 micro tiles (256 elements per micro tile) organized into macro tiles.
    • Enforces the 1024-byte tile-split cap (Require(!thickMacro || microBytes <= tileSplit)), rejecting element sizes greater than 4 bytes (8 and 16 bytes).
    • Rotates banks across four-slice slabs (GcnLayerBankXor steps by layer / 4), matching AMD addrlib's egbaddrlib.cpp / siaddrlib.cpp (ComputeBankFromCoord and layerBankStep).
  • Handles kGcnThick2D in surface layout descriptions (describeGcnVolume, GetBlockLayout, GetMipTailLayout, ThickBlockExtent):
    • Enforces single-mip volume requirement (mipCount == 1) for thick macro-tiling.
    • Calculates padded macro-tile extents for row elements and blocks per row.
    • Slices are grouped into 4-slice slabs with slab-based guest offsets.
  • Tests:
    • Unit tests in core/libs/prx/libSceAgcDriver/tests/TextureTiling.cpp (gcnThickMacroTilingTests): verifies element address mapping across 1, 2, and 4-byte formats against addrlib formulas, enforces rejection of >4-byte formats and mip chains, and checks padded geometry.
    • GPU compute detiling execution test in core/libs/prx/libSceAgcDriver/tests/execution/GcnDetile.cpp (detileThickVolume): executes GPU detile compute dispatch across an 8-slice volume and verifies 3D sampled view range.
  • Updates technical debt documentation fragment in docs/dev/debt/changes/feat-agc-gcn-thick-2d-tiling.md.

Tested

Windows 11, WinLibs GCC 16.2.0 r1, Release, NVIDIA GeForce RTX 3070 (driver 572.16 / Vulkan 1.4.303), Vulkan SDK 1.4.363.1 validation layer.

Focused AGC test execution with validation layers:

  • ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer ctest --test-dir build-b -R "^(agc_driver_gcn_detile)$" -V passed (1/1 tests passed, 0 VUID- validation errors, loader confirmed inserting VK_LAYER_KHRONOS_validation).
  • ctest --test-dir build-b -R agc_graphics_profile_draw -V passed (100% tests passed, including new gcnThickMacroTilingTests).
  • python tools/check_conventions.py --base origin/main passed cleanly with 0 errors and 0 warnings.
  • python tools/debt_fold.py --root wt-b --check passed cleanly.
  • python tools/pr_overlap.py --names resolveGcnTileMode kGcnThick2D confirmed 0 overlapping PRs on main.

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: NVIDIA GeForce RTX 3070, driver 572.16, Windows 11
  • AI-assisted: yes

Summary by CodeRabbit

  • New Features
    • Added support for PS4 2D thick-tiled textures, including detiling of layered 3D textures.
    • Thick-tiled surfaces support elements up to 4 bytes and must have a single mip level.
  • Bug Fixes
    • Corrected layer banking and layout calculations for thick-tiled textures, including the first layer.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5324181439 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20786). Originally posted by [Gag21](https://github.com/Gag21) on 2026-11-15T15:24:08Z. --- ### What Support PS4 tile mode 20 (`Thick_2dThick`) in libSceAgcDriver for 3D textures (volumes). - Maps PS4 texture tile mode index 20 to `TextureTileMode::kGcnThick2D`. - Implements GCN thick macro-tile equations in `GcnTiling`: - 8x8x4 micro tiles (256 elements per micro tile) organized into macro tiles. - Enforces the 1024-byte tile-split cap (`Require(!thickMacro || microBytes <= tileSplit)`), rejecting element sizes greater than 4 bytes (8 and 16 bytes). - Rotates banks across four-slice slabs (`GcnLayerBankXor` steps by `layer / 4`), matching AMD addrlib's `egbaddrlib.cpp` / `siaddrlib.cpp` (`ComputeBankFromCoord` and `layerBankStep`). - Handles `kGcnThick2D` in surface layout descriptions (`describeGcnVolume`, `GetBlockLayout`, `GetMipTailLayout`, `ThickBlockExtent`): - Enforces single-mip volume requirement (`mipCount == 1`) for thick macro-tiling. - Calculates padded macro-tile extents for row elements and blocks per row. - Slices are grouped into 4-slice slabs with slab-based guest offsets. - Tests: - Unit tests in `core/libs/prx/libSceAgcDriver/tests/TextureTiling.cpp` (`gcnThickMacroTilingTests`): verifies element address mapping across 1, 2, and 4-byte formats against addrlib formulas, enforces rejection of >4-byte formats and mip chains, and checks padded geometry. - GPU compute detiling execution test in `core/libs/prx/libSceAgcDriver/tests/execution/GcnDetile.cpp` (`detileThickVolume`): executes GPU detile compute dispatch across an 8-slice volume and verifies 3D sampled view range. - Updates technical debt documentation fragment in `docs/dev/debt/changes/feat-agc-gcn-thick-2d-tiling.md`. ### Tested Windows 11, WinLibs GCC 16.2.0 r1, Release, NVIDIA GeForce RTX 3070 (driver 572.16 / Vulkan 1.4.303), Vulkan SDK 1.4.363.1 validation layer. Focused AGC test execution with validation layers: - `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer ctest --test-dir build-b -R "^(agc_driver_gcn_detile)$" -V` passed (1/1 tests passed, 0 `VUID-` validation errors, loader confirmed inserting `VK_LAYER_KHRONOS_validation`). - `ctest --test-dir build-b -R agc_graphics_profile_draw -V` passed (100% tests passed, including new `gcnThickMacroTilingTests`). - `python tools/check_conventions.py --base origin/main` passed cleanly with 0 errors and 0 warnings. - `python tools/debt_fold.py --root wt-b --check` passed cleanly. - `python tools/pr_overlap.py --names resolveGcnTileMode kGcnThick2D` confirmed 0 overlapping PRs on main. ### 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: NVIDIA GeForce RTX 3070, driver 572.16, Windows 11 - [x] AI-assisted: yes <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Added support for PS4 2D thick-tiled textures, including detiling of layered 3D textures. * Thick-tiled surfaces support elements up to 4 bytes and must have a single mip level. * **Bug Fixes** * Corrected layer banking and layout calculations for thick-tiled textures, including the first layer. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
MarcZX10 commented 2026-11-21 08:44:16 +00:00 (Migrated from github.com)

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

Review: DISMISSED


Reviewed — changes requested

Changes are required before merge: limit the new single-mip restriction to the thick 2D mode so existing macro-tiled volume mip chains remain supported.

What I ran

Reviewed head ab4504e92affa4fe098040eef886a753a88ed16c using repo_read.py artifacts and repository reads. No tests were run; the Windows and Vulkan checks in the PR description are author-reported.

Results

Check Result Note
Code review failed Existing macro-tiled volume mip chains are rejected
Tests not run PR-reported checks were not rerun

Negative control

Not run; no test execution was performed.

Findings

Blocking

  • core/libs/prx/libSceAgcDriver/Graphics/src/TextureTiling.cpp:150 applies the single-mip requirement to every mode classified by IsGcnMacroTiled, including existing GCN modes such as kGcnDisplay2D and kGcnThin2D. Since describeGcnVolume handles these modes too, a previously accepted multi-mip 3D descriptor now throws. Restrict this guard to kGcnThick2D (or otherwise to the newly unsupported thick mode) and preserve the existing behavior for other modes.

Non-blocking

None.

Sources

Not verified

No tests or builds were run. The PR description reports Windows 11, GCC, and Vulkan checks, which were not independently confirmed. Read all eight changed files listed as reviewed in manifest.json; files.json was not available in the prepared artifacts.

To get this to a good state

Restrict the mip-chain rejection to mode 20 and retain support for macro-tiled volume mip chains in other modes. Rerun the focused AGC tests and convention check on the updated head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6004211071 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20786#pullrequestreview-6004211071). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-21T08:44:16Z. **Review:** DISMISSED --- # Reviewed — changes requested Changes are required before merge: limit the new single-mip restriction to the thick 2D mode so existing macro-tiled volume mip chains remain supported. ## What I ran Reviewed head `ab4504e92affa4fe098040eef886a753a88ed16c` using `repo_read.py` artifacts and repository reads. No tests were run; the Windows and Vulkan checks in the PR description are author-reported. ## Results | Check | Result | Note | |---|---|---| | Code review | failed | Existing macro-tiled volume mip chains are rejected | | Tests | not run | PR-reported checks were not rerun | ## Negative control Not run; no test execution was performed. ## Findings ### Blocking - `core/libs/prx/libSceAgcDriver/Graphics/src/TextureTiling.cpp:150` applies the single-mip requirement to every mode classified by `IsGcnMacroTiled`, including existing GCN modes such as `kGcnDisplay2D` and `kGcnThin2D`. Since `describeGcnVolume` handles these modes too, a previously accepted multi-mip 3D descriptor now throws. Restrict this guard to `kGcnThick2D` (or otherwise to the newly unsupported thick mode) and preserve the existing behavior for other modes. ### Non-blocking None. ## Sources - [Changed volume layout guard](https://github.com/boykopovar/AnyPS5/blob/ab4504e92affa4fe098040eef886a753a88ed16c/core/libs/prx/libSceAgcDriver/Graphics/src/TextureTiling.cpp#L634-L636) - [Macro-tiled mode classification](https://github.com/boykopovar/AnyPS5/blob/ab4504e92affa4fe098040eef886a753a88ed16c/core/libs/prx/libSceAgcDriver/Graphics/include/GuestTextureResource.hpp#L131-L136) ## Not verified No tests or builds were run. The PR description reports Windows 11, GCC, and Vulkan checks, which were not independently confirmed. Read all eight changed files listed as reviewed in `manifest.json`; `files.json` was not available in the prepared artifacts. ## To get this to a good state Restrict the mip-chain rejection to mode 20 and retain support for macro-tiled volume mip chains in other modes. Rerun the focused AGC tests and convention check on the updated head.
MarcZX10 commented 2026-11-28 12:21:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-28T12:21:23Z.

Review: COMMENTED


Reviewed — no blocking findings

The inspected changes add PS4 tile mode 20 support; no blocking defect was verified, and the reported checks were not run in this review.

What I ran

  • Read the prepared description, commit list, manifest, and full diff for head 4c503cd0e37dc82fa0a9574f7fe0419b7e4117f2.
  • Used repo_read.py to inspect changed code and its relevant callers; no tests or build commands were run.

Results

Check Result Note
Prepared diff review passed Changed hunks inspected
Automated checks not run Results in the description are author-reported
Negative control not run No test mutation was performed

Findings

Blocking

None verified.

Non-blocking

None.

Not verified

  • Did not run the author-reported unit, GPU execution, convention, debt, or overlap checks.
  • Did not inspect the complete contents of each changed source and test file; the diff and targeted changed regions were inspected. Physical console behavior was not verified.
  • Read the changed regions of all eight files listed in the manifest. No changed files were excluded by the manifest.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6097747444 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20786#pullrequestreview-6097747444). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-28T12:21:23Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The inspected changes add PS4 tile mode 20 support; no blocking defect was verified, and the reported checks were not run in this review. ## What I ran - Read the prepared description, commit list, manifest, and full diff for head `4c503cd0e37dc82fa0a9574f7fe0419b7e4117f2`. - Used `repo_read.py` to inspect changed code and its relevant callers; no tests or build commands were run. ## Results | Check | Result | Note | |---|---|---| | Prepared diff review | passed | Changed hunks inspected | | Automated checks | not run | Results in the description are author-reported | | Negative control | not run | No test mutation was performed | ## Findings ### Blocking None verified. ### Non-blocking None. ## Not verified - Did not run the author-reported unit, GPU execution, convention, debt, or overlap checks. - Did not inspect the complete contents of each changed source and test file; the diff and targeted changed regions were inspected. Physical console behavior was not verified. - Read the changed regions of all eight files listed in the manifest. No changed files were excluded by the manifest. ## To get this to a good state Nothing is required.
ligmaSec commented 2026-12-03 22:21:25 +00:00 (Migrated from github.com)

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

Review: COMMENTED


The trial merge onto a1b75b0947 was clean. I checked the four-slice slab geometry, the bank rotation and the transfer path’s slice index. The exhaustive host fixture checks that the equation covers each location once, while GcnDetile compares actual GPU output across several slabs. Please retain both and keep the refusal coverage for mode-20 mip chains and unsupported element widths. Paired lavapipe validation is pending.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6179629245 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20786#pullrequestreview-6179629245). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T22:21:25Z. **Review:** COMMENTED --- The trial merge onto `a1b75b0947` was clean. I checked the four-slice slab geometry, the bank rotation and the transfer path’s slice index. The exhaustive host fixture checks that the equation covers each location once, while `GcnDetile` compares actual GPU output across several slabs. Please retain both and keep the refusal coverage for mode-20 mip chains and unsupported element widths. Paired lavapipe validation is pending. AI-assisted: yes.
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!20786
No description provided.