fix(agc): give a layered depth storage view only its viewed slices #23880

Merged
milescoviello merged 1 commit from upstream-pr/23880 into main 2026-11-27 05:56:32 +00:00
milescoviello commented 2026-11-19 20:37:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-11-19T20:37:14Z.


What

A storage view of a 2D array over a depth surface (DepthSurfaceStorage → layeredDepthStorage) built its layered storage image from the view as given: every slice from the array's first slice up to the view's last, whichever slices the view uses. A view of the last slice of a large array therefore got an image of the whole array. The sampled path already narrows such views to their slice window with ViewedArrayWindow (ShaderResources.cpp); the storage path did not.

Crimson Desert (PPSA25286) was the reason I looked here: with #22534, #22609 and #22778 its log has a 2306x10113 array view at slice 416 and, soon after, a 39,397,711,872-byte storage texture placed in host memory. Correction: a later Crimson Desert run with this change (on main 0626a8334 with #22534, #22609, #22778, #22690, #22703, #22692 and #23864) still makes that 39 GB allocation, three times, so it does not come from this path, and this PR does not address it. This PR stands on its own test: a storage view of one slice of a layered depth array now gets an image of that slice instead of the whole array.

The change:

  • DepthSurfaceStorage passes ViewedArrayWindow(resource, true) to layeredDepthStorage instead of the view itself, so a view starting at slice N gets an image that starts at the first slice of its window (slice N for a linear or slice-free swizzle).
  • layeredDepthStorage addresses its slice lookup from the window's base (a copy of the depth surface's target with the window's address), so layeredSlices still finds the depth surface of each viewed slice.
    A view from slice 0 is unchanged.

Tested

Linux (Ubuntu 26.04.1, kernel 7.0), GCC 15.2, Ninja, Release, -DBUILD_TESTING=ON, RTX 4070 Ti on NVIDIA 615.71:

  • agc_driver_depth_storage (tests/execution/DepthStorage.cpp): its existing 2D array view from layer 1 of a two-layer array over the depth plane now also checks that its storage image has one layer (two on main).
  • agc_driver_depth_storage passes 3 runs on 3f2f9e09bc.
  • Negative control: with main's DepthSurface.cpp and the new check, agc_driver_depth_storage fails.
  • AMD: tablefrogpillow's run of 3f2f9e09bc (Mesa 26.2.6 RADV, Khronos validation layer 1.4.363): agc_driver_depth_storage with the new check passes 3 of 3 on an RX 7900 GRE (gfx1100), a Ryzen 7800X3D iGPU (gfx1036) and an RX Vega 56 (gfx900), with the layer inserted and no VUID- lines; main's test passes the same way on each.
  • Windows 11 (VM, GeForce GT 1030, WinLibs GCC 16.2, Ninja, Release, ANYPS5_REQUIRE_VULKAN=1): agc_driver_depth_storage passes 3 runs on 3f2f9e09bc.
  • git merge-tree against main is clean, and git apply -3 of this diff onto main with #23864 or #22778 merged is clean. #22778 does the same narrowing for the sampled path's depth plane copies; this PR is the storage-view side. tools/check_conventions.py passes on the branch and this body.
  • AbuMshMsh24's Windows run on an AMD Radeon RX 9070 XT (RDNA4, AMD Software 26.11.2, Windows 10 22H2, WinLibs GCC 15.2.0, Khronos validation layer 1.4.363.1) of 3f2f9e09bc merged onto main 42f6354612: agc_driver_depth_storage passes with no VUID- lines, and with main's DepthSurface.cpp and this PR's test it fails 3 of 3.
  • kiwe147's batch run of 3f2f9e09bc, applied with 28 other PRs onto main fd4aeed483 (one combined tree, not this PR alone), Windows 11, WinLibs GCC 15.2.0 r7, Release, no validation layer: the 6 agc_driver_depth_storage* tests pass on an NVIDIA GeForce RTX 3080 (driver 621.24) and on the AMD Radeon iGPU of a Ryzen 7 9800X3D (gfx1036).

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 RTX 4070 Ti (Linux), NVIDIA GeForce GT 1030 (Windows); AMD RX 7900 GRE, Ryzen 7800X3D iGPU and RX Vega 56 (Linux RADV, tablefrogpillow); AMD RX 9070 XT (Windows, AMD Software 26.11.2, AbuMshMsh24); NVIDIA RTX 3080 and Ryzen 7 9800X3D iGPU (Windows, kiwe147, batch tree)
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5402560462 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23880). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-11-19T20:37:14Z. --- ### What A storage view of a 2D array over a depth surface (`DepthSurfaceStorage` → `layeredDepthStorage`) built its layered storage image from the view as given: every slice from the array's first slice up to the view's last, whichever slices the view uses. A view of the last slice of a large array therefore got an image of the whole array. The sampled path already narrows such views to their slice window with `ViewedArrayWindow` (`ShaderResources.cpp`); the storage path did not. Crimson Desert (PPSA25286) was the reason I looked here: with #22534, #22609 and #22778 its log has a 2306x10113 array view at slice 416 and, soon after, a 39,397,711,872-byte storage texture placed in host memory. **Correction:** a later Crimson Desert run with this change (on `main` `0626a8334` with #22534, #22609, #22778, #22690, #22703, #22692 and #23864) still makes that 39 GB allocation, three times, so it does not come from this path, and this PR does not address it. This PR stands on its own test: a storage view of one slice of a layered depth array now gets an image of that slice instead of the whole array. The change: - `DepthSurfaceStorage` passes `ViewedArrayWindow(resource, true)` to `layeredDepthStorage` instead of the view itself, so a view starting at slice N gets an image that starts at the first slice of its window (slice N for a linear or slice-free swizzle). - `layeredDepthStorage` addresses its slice lookup from the window's base (a copy of the depth surface's target with the window's address), so `layeredSlices` still finds the depth surface of each viewed slice. A view from slice 0 is unchanged. ### Tested Linux (Ubuntu 26.04.1, kernel 7.0), GCC 15.2, Ninja, Release, `-DBUILD_TESTING=ON`, RTX 4070 Ti on NVIDIA 615.71: - `agc_driver_depth_storage` (`tests/execution/DepthStorage.cpp`): its existing 2D array view from layer 1 of a two-layer array over the depth plane now also checks that its storage image has one layer (two on `main`). - `agc_driver_depth_storage` passes 3 runs on `3f2f9e09bc`. - Negative control: with `main`'s `DepthSurface.cpp` and the new check, `agc_driver_depth_storage` fails. - AMD: tablefrogpillow's [run](https://github.com/boykopovar/AnyPS5/pull/23880#issuecomment-7021624023) of `3f2f9e09bc` (Mesa 26.2.6 RADV, Khronos validation layer 1.4.363): `agc_driver_depth_storage` with the new check passes 3 of 3 on an RX 7900 GRE (gfx1100), a Ryzen 7800X3D iGPU (gfx1036) and an RX Vega 56 (gfx900), with the layer inserted and no `VUID-` lines; `main`'s test passes the same way on each. - Windows 11 (VM, GeForce GT 1030, WinLibs GCC 16.2, Ninja, Release, `ANYPS5_REQUIRE_VULKAN=1`): `agc_driver_depth_storage` passes 3 runs on `3f2f9e09bc`. - `git merge-tree` against `main` is clean, and `git apply -3` of this diff onto `main` with #23864 or #22778 merged is clean. #22778 does the same narrowing for the sampled path's depth plane copies; this PR is the storage-view side. `tools/check_conventions.py` passes on the branch and this body. - AbuMshMsh24's [Windows run](https://github.com/boykopovar/AnyPS5/pull/23880#issuecomment-7059358599) on an AMD Radeon RX 9070 XT (RDNA4, AMD Software 26.11.2, Windows 10 22H2, WinLibs GCC 15.2.0, Khronos validation layer 1.4.363.1) of `3f2f9e09bc` merged onto `main` `42f6354612`: `agc_driver_depth_storage` passes with no `VUID-` lines, and with `main`'s `DepthSurface.cpp` and this PR's test it fails 3 of 3. - kiwe147's [batch run](https://github.com/boykopovar/AnyPS5/pull/23880#issuecomment-7062681382) of `3f2f9e09bc`, applied with 28 other PRs onto `main` `fd4aeed483` (one combined tree, not this PR alone), Windows 11, WinLibs GCC 15.2.0 r7, Release, no validation layer: the 6 `agc_driver_depth_storage*` tests pass on an NVIDIA GeForce RTX 3080 (driver 621.24) and on the AMD Radeon iGPU of a Ryzen 7 9800X3D (gfx1036). ### 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) 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 RTX 4070 Ti (Linux), NVIDIA GeForce GT 1030 (Windows); AMD RX 7900 GRE, Ryzen 7800X3D iGPU and RX Vega 56 (Linux RADV, tablefrogpillow); AMD RX 9070 XT (Windows, AMD Software 26.11.2, AbuMshMsh24); NVIDIA RTX 3080 and Ryzen 7 9800X3D iGPU (Windows, kiwe147, batch tree) - [x] AI-assisted: yes
MarcZX10 commented 2026-11-20 12:06:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T12:06:54Z.

Review: APPROVED


Reviewed — looks good

The depth storage path now limits the image to the viewed array window and aligns depth-slice lookup with that window; I found no verified blocking defects.

What I ran

Reviewed head 3f2f9e09bcfd3887f34b40511ae4bb7e233cd45c. I read the prepared description, commit list, manifest, diff, both changed files at the relevant ranges, and the ViewedArrayWindow implementation. I did not run commands or tests.

Results

Check Result Note
Changed code review passed Both changed files read
Tests not run Author reports hardware runs
Negative control not run Author reports a failing control

Findings

Blocking

None.

Non-blocking

None.

Not verified

I did not independently run the execution test or validate the author-reported GPU, OS, merge, and convention-check results. No changed files were excluded by the prepared manifest.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5992390810 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23880#pullrequestreview-5992390810). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T12:06:54Z. **Review:** APPROVED --- # Reviewed — looks good The depth storage path now limits the image to the viewed array window and aligns depth-slice lookup with that window; I found no verified blocking defects. ## What I ran Reviewed head `3f2f9e09bcfd3887f34b40511ae4bb7e233cd45c`. I read the prepared description, commit list, manifest, diff, both changed files at the relevant ranges, and the `ViewedArrayWindow` implementation. I did not run commands or tests. ## Results | Check | Result | Note | |---|---|---| | Changed code review | passed | Both changed files read | | Tests | not run | Author reports hardware runs | | Negative control | not run | Author reports a failing control | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified I did not independently run the execution test or validate the author-reported GPU, OS, merge, and convention-check results. No changed files were excluded by the prepared manifest. ## To get this to a good state Nothing is required.
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!23880
No description provided.