fix(libSceAgcDriver): pad level 0 rows of a POW2_PAD PS4 mip chain #9842

Merged
ntamas94 merged 6 commits from upstream-pr/9842 into main 2026-11-02 07:58:48 +00:00
ntamas94 commented 2026-10-22 17:27:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ntamas94 on 2026-10-22T17:27:15Z.


What

A GCN T# with POW2_PAD set and more than one level has every level padded to power-of-two dimensions, level 0 included. Level 0's pitch already is a power of two; its rows are padded too. ComputeGcnMipLayout padded only levels 1 and up, so level 1 started after the micro-tile-aligned height of level 0 instead of its padded height.

Knowledge is Power: Decades (CUSA12435, Unity) hits it with the 68x68, seven-level, Thin_1dThin icon of its PlayLink notifications ("a player joined / left") and of the AWAY badge. The title's CPU tiler writes the chain the way its DMA copies place it: level 0 is 128x128 texels (0x10000 bytes), level 1 starts at +0x10000, level 2 at +0x14000. The driver read level 1 at +0x9000 (128 * 72 texels), which is in level 0's padding rows. The notification shows the icon downscaled, so it sampled level 1 and showed the stale texture data left there as coloured noise. shadPS4 pads every level, level 0 included, and shows the icon clean.

Level 0's rows are now padded too when the chain has more than one level. Level 0's width stays the T# pitch. A single POW2_PAD level keeps its micro-tile-aligned rows.

#9674 (tile mode 19, Thick_1dThick) adds a volume layout that pads its levels the same way; once both are in, its level 0 rows and depth need the same change, which I will make there.

Tested

Windows 11 Pro (10.0.26200), WinLibs GCC, NVIDIA GeForce RTX 2080 (driver 617.14), Release build with BUILD_TESTING=ON, on this branch (main f7e84c4cf plus this commit, merge 340e579a3):

  • A new TextureTiling case lays out the 68x68 chain (pitch 128, seven levels): level 0 is 0x10000 bytes, level 1 starts at 0x10000 and level 2 at 0x14000; a single level of the same texture stays 128 * 72 texels. agc_driver_graphics passes; with TextureTiling.cpp reverted to the base it fails (a POW2_PAD PS4 mip chain pads the rows of level 0).
  • Focused tests pass, three runs each: agc_driver_graphics, agc_driver_gcn_detile, agc_driver_ds_swizzle, agc_driver_image_volume_address_planar_texture, agc_driver_image_xor_swizzle_volume, agc_driver_packed_mip_tail_target, agc_driver_view_past_last_mip, agc_driver_resource_cache_replaced_texture, texture_format_lookup.
  • Knowledge is Power: Decades, on my bring-up branch with this change (before the refresh on main; the change itself is unchanged):
    • The title's DMA copies into the icon go to the texture base (0x10000 bytes) and base + 0x10000 (0x4000 bytes), matching the new level offsets.
    • Level 1 decoded from the new offset is the clean icon (a white circle with an exclamation mark, stored upside down); decoded from the old offset +0x9000 it is noise.
    • A phone joining the running title shows the "a player joined" notification with a clean "!" icon; before this change the same join showed it as coloured noise.
  • tools/check_conventions.py from main, --base f7e84c4cf with this title and description: no findings.
  • Paired validation-layer run of the focused tests: main (f7e84c4cf) and this branch (all nine), 100% passed on both, with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ANYPS5_NO_SHADER_CACHE=1, ANYPS5_REQUIRE_VULKAN=1 and VK_LOADER_DEBUG=warn,error, ctest -V, on the NVIDIA GeForce RTX 2080, driver 617.14, Windows 11 (10.0.26200): both logs carry the loader's adding layers "VK_LAYER_KHRONOS_validation" line (14 times each) and neither reports was not found but was requested by env var VK_INSTANCE_LAYERS; VUID- ids on main: 0, on this branch: 0, new on this branch: 0.

Checklist

  • Based on current main; no other open PR implements the same functions (searched open and closed boykopovar/AnyPS5 PRs for pow2, POW2_PAD, pow2pad, mip padding and TextureTiling on 2026-10-22)
  • 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 (#9431 is merged)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 2080, driver 617.14, Windows 11 (10.0.26200)
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4971432694 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9842). Originally posted by [ntamas94](https://github.com/ntamas94) on 2026-10-22T17:27:15Z. --- ### What A GCN T# with `POW2_PAD` set and more than one level has every level padded to power-of-two dimensions, level 0 included. Level 0's pitch already is a power of two; its rows are padded too. `ComputeGcnMipLayout` padded only levels 1 and up, so level 1 started after the micro-tile-aligned height of level 0 instead of its padded height. Knowledge is Power: Decades (CUSA12435, Unity) hits it with the 68x68, seven-level, `Thin_1dThin` icon of its PlayLink notifications ("a player joined / left") and of the AWAY badge. The title's CPU tiler writes the chain the way its DMA copies place it: level 0 is 128x128 texels (0x10000 bytes), level 1 starts at +0x10000, level 2 at +0x14000. The driver read level 1 at +0x9000 (128 * 72 texels), which is in level 0's padding rows. The notification shows the icon downscaled, so it sampled level 1 and showed the stale texture data left there as coloured noise. shadPS4 pads every level, level 0 included, and shows the icon clean. Level 0's rows are now padded too when the chain has more than one level. Level 0's width stays the T# pitch. A single `POW2_PAD` level keeps its micro-tile-aligned rows. #9674 (tile mode 19, `Thick_1dThick`) adds a volume layout that pads its levels the same way; once both are in, its level 0 rows and depth need the same change, which I will make there. ### Tested Windows 11 Pro (10.0.26200), WinLibs GCC, NVIDIA GeForce RTX 2080 (driver 617.14), Release build with `BUILD_TESTING=ON`, on this branch (`main` `f7e84c4cf` plus this commit, merge `340e579a3`): - A new `TextureTiling` case lays out the 68x68 chain (pitch 128, seven levels): level 0 is 0x10000 bytes, level 1 starts at 0x10000 and level 2 at 0x14000; a single level of the same texture stays 128 * 72 texels. `agc_driver_graphics` passes; with `TextureTiling.cpp` reverted to the base it fails (`a POW2_PAD PS4 mip chain pads the rows of level 0`). - Focused tests pass, three runs each: `agc_driver_graphics`, `agc_driver_gcn_detile`, `agc_driver_ds_swizzle`, `agc_driver_image_volume_address_planar_texture`, `agc_driver_image_xor_swizzle_volume`, `agc_driver_packed_mip_tail_target`, `agc_driver_view_past_last_mip`, `agc_driver_resource_cache_replaced_texture`, `texture_format_lookup`. - Knowledge is Power: Decades, on my bring-up branch with this change (before the refresh on `main`; the change itself is unchanged): - The title's DMA copies into the icon go to the texture base (0x10000 bytes) and base + 0x10000 (0x4000 bytes), matching the new level offsets. - Level 1 decoded from the new offset is the clean icon (a white circle with an exclamation mark, stored upside down); decoded from the old offset +0x9000 it is noise. - A phone joining the running title shows the "a player joined" notification with a clean "!" icon; before this change the same join showed it as coloured noise. - `tools/check_conventions.py` from `main`, `--base f7e84c4cf` with this title and description: no findings. - Paired validation-layer run of the focused tests: `main` (`f7e84c4cf`) and this branch (all nine), 100% passed on both, with `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, `ANYPS5_NO_SHADER_CACHE=1`, `ANYPS5_REQUIRE_VULKAN=1` and `VK_LOADER_DEBUG=warn,error`, `ctest -V`, on the NVIDIA GeForce RTX 2080, driver 617.14, Windows 11 (10.0.26200): both logs carry the loader's `adding layers "VK_LAYER_KHRONOS_validation"` line (14 times each) and neither reports `was not found but was requested by env var VK_INSTANCE_LAYERS`; `VUID-` ids on `main`: 0, on this branch: 0, new on this branch: 0. ### 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 (searched open and closed boykopovar/AnyPS5 PRs for pow2, `POW2_PAD`, pow2pad, mip padding and `TextureTiling` on 2026-10-22) - [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 (#9431 is merged) - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: NVIDIA GeForce RTX 2080, driver 617.14, Windows 11 (10.0.26200) - [x] AI-assisted: yes
MarcZX10 commented 2026-10-29 09:57:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T09:57:31Z.

Review: CHANGES_REQUESTED


Review — changes requested

The title/texture report and the old-base GPU results are useful, but the integration point this PR was stacked on has moved: dependency #9431 merged into current main at eefa50841267. Head efeba42f30665ae59c29ab1eeae36f0a5ff77e95 does not contain that merge and conflicts with current main in State.hpp, DepthSurface.cpp, State.cpp, TextureTiling.cpp, and TextureTiling.cpp's test.

The latest main change to DepthSurface.cpp removed the layered-depth pitch restriction that this PR modifies. The resulting combined PS4 mip-layout path and its tests need a deliberate resolution; preserving the old patch mechanically could restore a restriction that main removed. The PR’s reported runs are on the older #9431 stack (26d651d3e), so they do not validate the post-merge integration.

Please merge the current #9431 result/current main, retain the intended POW2_PAD level-0 row layout without reintroducing the removed layered-depth restriction, reconcile the overlapping layout tests, and rerun the focused GPU/tiling tests with validation on the resulting head. I checked the current merge preview and git diff --check; the preview has those five conflicts and the whitespace check passes. I did not run the GPU tests locally.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5695865935 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9842#pullrequestreview-5695865935). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-29T09:57:31Z. **Review:** CHANGES_REQUESTED --- # Review — changes requested The title/texture report and the old-base GPU results are useful, but the integration point this PR was stacked on has moved: dependency #9431 merged into current `main` at `eefa50841267`. Head `efeba42f30665ae59c29ab1eeae36f0a5ff77e95` does not contain that merge and conflicts with current `main` in `State.hpp`, `DepthSurface.cpp`, `State.cpp`, `TextureTiling.cpp`, and `TextureTiling.cpp`'s test. The latest `main` change to `DepthSurface.cpp` removed the layered-depth pitch restriction that this PR modifies. The resulting combined PS4 mip-layout path and its tests need a deliberate resolution; preserving the old patch mechanically could restore a restriction that main removed. The PR’s reported runs are on the older #9431 stack (`26d651d3e`), so they do not validate the post-merge integration. Please merge the current #9431 result/current `main`, retain the intended POW2_PAD level-0 row layout without reintroducing the removed layered-depth restriction, reconcile the overlapping layout tests, and rerun the focused GPU/tiling tests with validation on the resulting head. I checked the current merge preview and `git diff --check`; the preview has those five conflicts and the whitespace check passes. I did not run the GPU tests locally.
MarcZX10 commented 2026-10-29 11:12:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T11:12:30Z.

Review: CHANGES_REQUESTED


Re-checked — changes requested

The update explains that the extra depth fields and DepthSurface.cpp pitch line came from the old #9431 stack, not this PR, and reports three focused runs plus a paired validation-layer comparison. The branch remains based on f7e84c4cf1; current main is ba5b5330b3. Please update the branch to current main and provide a clean merge preview plus conventions on the resulting tree before merge. The current-main diff does not touch the PR's two implementation/test files, so the reported focused runs remain relevant if the refreshed diff confirms they are unchanged.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5696756776 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9842#pullrequestreview-5696756776). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-29T11:12:30Z. **Review:** CHANGES_REQUESTED --- ## Re-checked — changes requested The update explains that the extra depth fields and `DepthSurface.cpp` pitch line came from the old #9431 stack, not this PR, and reports three focused runs plus a paired validation-layer comparison. The branch remains based on `f7e84c4cf1`; current `main` is `ba5b5330b3`. Please update the branch to current main and provide a clean merge preview plus conventions on the resulting tree before merge. The current-main diff does not touch the PR's two implementation/test files, so the reported focused runs remain relevant if the refreshed diff confirms they are unchanged.
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!9842
No description provided.