fix(agc): select the first level of a single-level depth view #11098

Merged
edubox merged 1 commit from upstream-pr/11098 into main 2026-10-28 00:50:58 +00:00
edubox commented 2026-10-25 17:30:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by edubox on 2026-10-25T17:30:48Z.


What

decodeDepth threw when DB_DEPTH_VIEW.MIPID selected a level above zero on a surface whose DB_Z_INFO.MAXMIP is zero. Flashback (PPSA08546) reaches that state: DB_Z_INFO is 0xa0000181 (128x128 D16 Z_X with HTILE, MAXMIP 0) and DB_DEPTH_VIEW selects mips 1 to 6 over six slices while its colour target has MAXMIP 7. The depth allocation is six 64 KiB slices: the next allocation starts 0x61000 bytes later, too small for a mip tail, and every view uses the same base and extent, so the field has no other depth level to select. The driver now decodes the first level instead of throwing.

The agc_driver_graphics case that expected "on a surface without mips" now checks that the decoded address and extent are level 0's. The same line is edited by #10435, which keeps that throw for PS4 depth targets; either order needs a rebase from one of us (Depends on is none because #10435 is CONFLICTING). The console behaviour of the ignored view mip is recorded in the libSceAgcDriver debt file and is not measured.

Tested

CachyOS Linux 7.3.0-3-cachyos, GCC 16.2.1, Release with BUILD_TESTING=ON.

agc_driver_graphics passes on the change and on current main (4718dedcf8) with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, on both the AMD Radeon Graphics (RADV RAPHAEL_MENDOCINO, Mesa 26.2.5-arch3.1) and the NVIDIA GeForce RTX 4080 SUPER (615.78.08). Neither log reports was not found but was requested by env var VK_INSTANCE_LAYERS or a VUID- error. python3 tools/check_conventions.py --base origin/main passes.

Flashback (PPSA08546) on the AMD iGPU: on the build before the branch switch, with a temporary switch selecting level 0 in the same decode branch, the title passed the cubemap mip pass at about 35 s and ran to 150 s, where the unpatched build aborts at about 115 s with [videoout] presentation failed: AGC graphics: depth view mip 1 on a surface without mips; dumped frames after the pass show the scene. The shader-cache version changed with current main, so the runs made from this branch spent their 150 s compiling/streaming and did not reach the pass yet; the decode path is the same. The console was not measured.

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: PPSA08546 #11097
  • GPUs tested: AMD Radeon Graphics (RADV RAPHAEL_MENDOCINO), Mesa 26.2.5-arch3.1, CachyOS Linux 7.3.0-3-cachyos; NVIDIA GeForce RTX 4080 SUPER, 615.78.08, CachyOS Linux 7.3.0-3-cachyos
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5007003615 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11098). Originally posted by [edubox](https://github.com/edubox) on 2026-10-25T17:30:48Z. --- ### What `decodeDepth` threw when `DB_DEPTH_VIEW.MIPID` selected a level above zero on a surface whose `DB_Z_INFO.MAXMIP` is zero. Flashback (PPSA08546) reaches that state: `DB_Z_INFO` is `0xa0000181` (128x128 D16 Z_X with HTILE, `MAXMIP` 0) and `DB_DEPTH_VIEW` selects mips 1 to 6 over six slices while its colour target has `MAXMIP` 7. The depth allocation is six 64 KiB slices: the next allocation starts 0x61000 bytes later, too small for a mip tail, and every view uses the same base and extent, so the field has no other depth level to select. The driver now decodes the first level instead of throwing. The `agc_driver_graphics` case that expected "on a surface without mips" now checks that the decoded address and extent are level 0's. The same line is edited by #10435, which keeps that throw for PS4 depth targets; either order needs a rebase from one of us (`Depends on` is `none` because #10435 is CONFLICTING). The console behaviour of the ignored view mip is recorded in the libSceAgcDriver debt file and is not measured. ### Tested CachyOS Linux 7.3.0-3-cachyos, GCC 16.2.1, Release with `BUILD_TESTING=ON`. `agc_driver_graphics` passes on the change and on current `main` (`4718dedcf8`) with `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, on both the AMD Radeon Graphics (RADV RAPHAEL_MENDOCINO, Mesa 26.2.5-arch3.1) and the NVIDIA GeForce RTX 4080 SUPER (615.78.08). Neither log reports `was not found but was requested by env var VK_INSTANCE_LAYERS` or a `VUID-` error. `python3 tools/check_conventions.py --base origin/main` passes. Flashback (PPSA08546) on the AMD iGPU: on the build before the branch switch, with a temporary switch selecting level 0 in the same decode branch, the title passed the cubemap mip pass at about 35 s and ran to 150 s, where the unpatched build aborts at about 115 s with `[videoout] presentation failed: AGC graphics: depth view mip 1 on a surface without mips`; dumped frames after the pass show the scene. The shader-cache version changed with current `main`, so the runs made from this branch spent their 150 s compiling/streaming and did not reach the pass yet; the decode path is the same. The console was not measured. ### 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: PPSA08546 #11097 - [x] GPUs tested: AMD Radeon Graphics (RADV RAPHAEL_MENDOCINO), Mesa 26.2.5-arch3.1, CachyOS Linux 7.3.0-3-cachyos; NVIDIA GeForce RTX 4080 SUPER, 615.78.08, CachyOS Linux 7.3.0-3-cachyos - [x] AI-assisted: yes
MarcZX10 commented 2026-10-25 17:32:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T17:32:19Z.

Review: APPROVED


Reviewed the single-level depth-view fallback and the regression assertion. With MAXMIP == 0, selecting level zero keeps the same base address and extent; the existing level-selection path is unchanged for mipmapped surfaces. The PR records the specific Flashback allocation evidence and leaves console equivalence unverified.

The author reports agc_driver_graphics on both main 4718dedcf8 and this head with the required validation-layer settings on the same two GPUs; those AGC files have no changes between that main commit and the current PR base 2e1c72239b. Exact-head conventions, eligibility, intake, labels and report checks pass. #10435’s author confirmed either landing order and will rebase #10435 if this one lands first, so there is no unresolved dependency. Approved.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5644361177 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11098#pullrequestreview-5644361177). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T17:32:19Z. **Review:** APPROVED --- Reviewed the single-level depth-view fallback and the regression assertion. With `MAXMIP == 0`, selecting level zero keeps the same base address and extent; the existing level-selection path is unchanged for mipmapped surfaces. The PR records the specific Flashback allocation evidence and leaves console equivalence unverified. The author reports `agc_driver_graphics` on both main `4718dedcf8` and this head with the required validation-layer settings on the same two GPUs; those AGC files have no changes between that main commit and the current PR base `2e1c72239b`. Exact-head conventions, eligibility, intake, labels and report checks pass. #10435’s author confirmed either landing order and will rebase #10435 if this one lands first, so there is no unresolved dependency. Approved.
klosixgaming-arch commented 2026-10-25 21:45:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by klosixgaming-arch on 2026-10-25T21:45:42Z.

Review: APPROVED


Reviewed head f1fb9d6eaf by reading the diff and the existing review thread. I did not build or run this, so everything below is from the code, not from a test of mine.

What it does. For a depth target whose DB_Z_INFO.MAXMIP is 0, a non-zero DB_DEPTH_VIEW.MIPID is ignored (viewMip is forced to 0) instead of failing with "depth view mip N on a surface without mips". The maxMip != 0 path is untouched.

Checked: maxMip is now read before viewMip, the removed Require(false, ...) is the only behavioural difference, and the diagnostic snprintf below it only runs for maxMip != 0, so it cannot print a forced zero. The regression test changes the old expectFailure into an assertion that address and extent equal the base level, which is the correct property for "selects the first level".

Notes:

  • The justification is a Flashback allocation, recorded in the debt entry. That is one title, and nothing here says what the console does when the view mip is above zero on a single-level surface other than "titles do it". The entry says exactly that, which is acceptable.
  • The test only asserts address and extent for MIPID = 1. A second case with MIPID = 15 would show the value is ignored rather than clamped.
  • The old error was a useful tripwire for malformed state. Removing it is justified by a real title, but it does mean a genuinely corrupt DB_DEPTH_VIEW on a mip-less surface is now accepted without a trace. A one-time log line would keep the tripwire. Optional.

Approving.

AI-assisted: yes. Written with AI assistance and reviewed by me.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5645479512 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11098#pullrequestreview-5645479512). Originally posted by [klosixgaming-arch](https://github.com/klosixgaming-arch) on 2026-10-25T21:45:42Z. **Review:** APPROVED --- Reviewed head `f1fb9d6eaf` by reading the diff and the existing review thread. I did not build or run this, so everything below is from the code, not from a test of mine. **What it does.** For a depth target whose `DB_Z_INFO.MAXMIP` is 0, a non-zero `DB_DEPTH_VIEW.MIPID` is ignored (`viewMip` is forced to 0) instead of failing with "depth view mip N on a surface without mips". The `maxMip != 0` path is untouched. **Checked:** `maxMip` is now read before `viewMip`, the removed `Require(false, ...)` is the only behavioural difference, and the diagnostic `snprintf` below it only runs for `maxMip != 0`, so it cannot print a forced zero. The regression test changes the old `expectFailure` into an assertion that address and extent equal the base level, which is the correct property for "selects the first level". **Notes:** - The justification is a Flashback allocation, recorded in the debt entry. That is one title, and nothing here says what the console does when the view mip is above zero on a single-level surface other than "titles do it". The entry says exactly that, which is acceptable. - The test only asserts address and extent for `MIPID = 1`. A second case with `MIPID = 15` would show the value is ignored rather than clamped. - The old error was a useful tripwire for malformed state. Removing it is justified by a real title, but it does mean a genuinely corrupt `DB_DEPTH_VIEW` on a mip-less surface is now accepted without a trace. A one-time log line would keep the tripwire. Optional. Approving. AI-assisted: yes. Written with AI assistance and reviewed by me.
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!11098
No description provided.