fix(agc): render a color view of several array slices into its first slice #3633

Merged
tv7 merged 2 commits from upstream-pr/3633 into main 2026-10-13 04:51:59 +00:00
tv7 commented 2026-10-11 14:29:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by tv7 on 2026-10-11T14:29:09Z.


What

DecodeColorBuffer rejected every CB_COLOR_VIEW whose SLICE_MAX is past SLICE_START ("color views of several array slices are unsupported"). The layer a primitive lands in is SLICE_START plus its render target index, which is 0 when the draw does not export one. So for a 2D array target, such a view renders into SLICE_START, the same as a one-slice view of that slice. This accepts it that way.

Still rejected:

  • the same view when PA_CL_VS_OUT_CNTL enables the render target index export (bit 18): layered draws are not routed (existing comment above LayerExports), and sending them all to the first slice would be wrong;
  • views of several 3D slices (#1077 implements layered draws into 3D targets);
  • a SLICE_MAX below SLICE_START, or past the last array slice.

Marvel's Wolverine (PPSA03671) binds 2D array color targets through views of several slices, without the render target index export. On main its first presentation stops on this check.

Tested

Windows 11, RTX 3070, GCC 15.2.0 UCRT, Release, on main a11c8f7f7.

  • agc_driver_graphics (DepthStencilTests): a 0..1 view of a 2D array target renders into slice 0; the same view with the render target index export, a view past the last array slice, a reversed view and a view of several 3D slices still throw. Fails on main ("color views of several array slices are unsupported"), passes with the fix.
  • ctest 832/836. The other 4 (guest_kernel_sys, windows_exceptions, guest_filesystem, agc_driver_emulated_color_compare) fail the same way on main on this machine.
  • tools/check_conventions.py passes.
  • Wolverine, on main plus open #757 and #3588 (and a cap on #757's image table size): without the fix it stops on this check about a minute in; with it, it runs 10 minutes without an error.

Checklist

  • Based on current main; no other open PR implements the same functions (#1077 touches the same check for 3D targets only)
  • 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 in TechnicalDebt
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes, Claude Code

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4819781115 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3633). Originally posted by [tv7](https://github.com/tv7) on 2026-10-11T14:29:09Z. --- ### What `DecodeColorBuffer` rejected every `CB_COLOR_VIEW` whose `SLICE_MAX` is past `SLICE_START` ("color views of several array slices are unsupported"). The layer a primitive lands in is `SLICE_START` plus its render target index, which is 0 when the draw does not export one. So for a 2D array target, such a view renders into `SLICE_START`, the same as a one-slice view of that slice. This accepts it that way. Still rejected: - the same view when `PA_CL_VS_OUT_CNTL` enables the render target index export (bit 18): layered draws are not routed (existing comment above `LayerExports`), and sending them all to the first slice would be wrong; - views of several 3D slices (#1077 implements layered draws into 3D targets); - a `SLICE_MAX` below `SLICE_START`, or past the last array slice. Marvel's Wolverine (PPSA03671) binds 2D array color targets through views of several slices, without the render target index export. On main its first presentation stops on this check. ### Tested Windows 11, RTX 3070, GCC 15.2.0 UCRT, Release, on main `a11c8f7f7`. - `agc_driver_graphics` (`DepthStencilTests`): a 0..1 view of a 2D array target renders into slice 0; the same view with the render target index export, a view past the last array slice, a reversed view and a view of several 3D slices still throw. Fails on main ("color views of several array slices are unsupported"), passes with the fix. - ctest 832/836. The other 4 (`guest_kernel_sys`, `windows_exceptions`, `guest_filesystem`, `agc_driver_emulated_color_compare`) fail the same way on main on this machine. - `tools/check_conventions.py` passes. - Wolverine, on main plus open #757 and #3588 (and a cap on #757's image table size): without the fix it stops on this check about a minute in; with it, it runs 10 minutes without an error. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions (#1077 touches the same check for 3D targets only) - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes, Claude Code 🤖 Generated with [Claude Code](https://claude.com/claude-code)
blawesom commented 2026-10-11 15:19:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-11T15:19:56Z.


Independent pre-review on Linux (full CI runs only happen on manual trigger, so recording one): CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON.

  • Builds; tools/check_conventions.py --base origin/main passes.
  • Full suite: 832/832 passed (all tests including the Vulkan suites on AMD RX 9070 XT / RADV).
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6110519102 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3633#issuecomment-6110519102). Originally posted by [blawesom](https://github.com/blawesom) on 2026-10-11T15:19:56Z. --- Independent pre-review on **Linux** (full CI runs only happen on manual trigger, so recording one): CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, `BUILD_TESTING=ON`. - Builds; `tools/check_conventions.py --base origin/main` passes. - Full suite: **832/832 passed** (all tests including the Vulkan suites on AMD RX 9070 XT / RADV).
tv7 commented 2026-10-11 17:53:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by tv7 on 2026-10-11T17:53:45Z.


Note on overlap: #3524 (XairRrR) touches the same lines in DecodeColorBuffer. The two are complementary, not duplicates. #3524 addresses a one-slice view of a 2D array through the array's swizzle, and this PR accepts a view whose SLICE_MAX is past SLICE_START (rendered into SLICE_START). They conflict textually on the beyond the array surface line. If both land, the check should test lastSlice and keep #3524's arraySlice = SLICE_START.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6111936656 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3633#issuecomment-6111936656). Originally posted by [tv7](https://github.com/tv7) on 2026-10-11T17:53:45Z. --- Note on overlap: #3524 (XairRrR) touches the same lines in `DecodeColorBuffer`. The two are complementary, not duplicates. #3524 addresses a one-slice view of a 2D array through the array's swizzle, and this PR accepts a view whose `SLICE_MAX` is past `SLICE_START` (rendered into `SLICE_START`). They conflict textually on the `beyond the array surface` line. If both land, the check should test `lastSlice` and keep #3524's `arraySlice` = `SLICE_START`. AI-assisted: yes (Claude Code)
oneandonlydean commented 2026-10-11 23:15:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-11T23:15:51Z.


A view of several slices on a target with no array slices is now accepted. In DecodeColorBuffer the lastSlice bound is only checked inside else if ((attrib3 & 0x1fffu) != 0), and the test row that covered this case (0x31b = 1u << 13u on the plain target) was changed to a reversed view. Please check lastSlice for every non-3D target and keep that row, expecting beyond the array surface.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6114994689 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3633#issuecomment-6114994689). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-11T23:15:51Z. --- A view of several slices on a target with no array slices is now accepted. In `DecodeColorBuffer` the `lastSlice` bound is only checked inside `else if ((attrib3 & 0x1fffu) != 0)`, and the test row that covered this case (`0x31b = 1u << 13u` on the plain target) was changed to a reversed view. Please check `lastSlice` for every non-3D target and keep that row, expecting `beyond the array surface`.
Pacuka commented 2026-10-12 16:18:30 +00:00 (Migrated from github.com)

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


Data point from Minecraft (PPSA17221), Linux / RX 6650 XT (RADV), on main d592d54e1 + #4215 #4218 #454: without this PR the title aborts about 2.5 minutes in, from the presenter, with AGC graphics: color views of several array slices are unsupported. With it, the title keeps running: menu, world load and rendering of the world. #1077 conflicts with current main in 13 files, so this was the change I could apply. It merged cleanly.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6128188447 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3633#issuecomment-6128188447). Originally posted by [Pacuka](https://github.com/Pacuka) on 2026-10-12T16:18:30Z. --- Data point from Minecraft (PPSA17221), Linux / RX 6650 XT (RADV), on main `d592d54e1` + #4215 #4218 #454: without this PR the title aborts about 2.5 minutes in, from the presenter, with `AGC graphics: color views of several array slices are unsupported`. With it, the title keeps running: menu, world load and rendering of the world. #1077 conflicts with current main in 13 files, so this was the change I could apply. It merged cleanly.
tv7 commented 2026-10-12 17:20:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by tv7 on 2026-10-12T17:20:34Z.


Fixed in 7215ff34f: a target with no array slices now requires the view to cover one slice, so a view of several slices on it throws beyond the array surface. One-slice views on such a target (the existing "move the target by one slice" case) still work. The 0x31b = 1u << 13u row on the plain target is back, expecting beyond the array surface, next to the reversed-view row. Also rebased on main 2a5eca11c. Windows/MinGW: 973/973.

Thanks @Pacuka for the Minecraft data point.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6129135775 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3633#issuecomment-6129135775). Originally posted by [tv7](https://github.com/tv7) on 2026-10-12T17:20:34Z. --- Fixed in 7215ff34f: a target with no array slices now requires the view to cover one slice, so a view of several slices on it throws `beyond the array surface`. One-slice views on such a target (the existing "move the target by one slice" case) still work. The `0x31b = 1u << 13u` row on the plain target is back, expecting `beyond the array surface`, next to the reversed-view row. Also rebased on main 2a5eca11c. Windows/MinGW: 973/973. Thanks @Pacuka for the Minecraft data point.
tv7 commented 2026-10-12 20:39:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by tv7 on 2026-10-12T20:39:24Z.


@oneandonlydean I need to take back part of 7215ff34f. Running Marvel's Wolverine (PPSA03671) on main 3e0e01f35 showed a title that uses exactly the case it refused. It draws into a 256x256 mipmapped 2D target with no array slices (CB_COLOR_ATTRIB3=0x4dc6c000, CB_COLOR_ATTRIB2=0x503fc0ff) through CB_COLOR_VIEW=0x4046000: slices 0 to 35 at mip 1. With the plain-target bound it stops at the color view slice is beyond the array surface in the presenter, within the first minute. Without the bound it renders into slice 0 and continues.

So the branch (rebased on 44ab0c39e) now leaves a view's last slice unbounded on a target with no array slices. That target has only one slice to render into. Instead of the beyond the array surface row, there is a test with Wolverine's shape: a view of slices 0 to 35 on the plain target decodes to the same address, size and slice range as a one-slice view. Array targets keep the bound, 3D targets still refuse several slices, and a reversed view still throws. Windows/MinGW: 1006/1006.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6132223163 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3633#issuecomment-6132223163). Originally posted by [tv7](https://github.com/tv7) on 2026-10-12T20:39:24Z. --- @oneandonlydean I need to take back part of 7215ff34f. Running Marvel's Wolverine (PPSA03671) on main `3e0e01f35` showed a title that uses exactly the case it refused. It draws into a 256x256 mipmapped 2D target with no array slices (`CB_COLOR_ATTRIB3=0x4dc6c000`, `CB_COLOR_ATTRIB2=0x503fc0ff`) through `CB_COLOR_VIEW=0x4046000`: slices 0 to 35 at mip 1. With the plain-target bound it stops at `the color view slice is beyond the array surface` in the presenter, within the first minute. Without the bound it renders into slice 0 and continues. So the branch (rebased on `44ab0c39e`) now leaves a view's last slice unbounded on a target with no array slices. That target has only one slice to render into. Instead of the `beyond the array surface` row, there is a test with Wolverine's shape: a view of slices 0 to 35 on the plain target decodes to the same address, size and slice range as a one-slice view. Array targets keep the bound, 3D targets still refuse several slices, and a reversed view still throws. Windows/MinGW: 1006/1006.
github-actions[bot] commented 2026-10-13 02:17:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T02:17:18Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#3763 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp L1011, L1023-1024, L1026-1030
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp L1345
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6136755636 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3633#issuecomment-6136755636). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-13T02:17:18Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #3763 | `core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp` [L1011](https://github.com/boykopovar/AnyPS5/blob/e15c316ead335690a6693b711a5c5e33cfda7652/core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp#L1011), [L1023-1024](https://github.com/boykopovar/AnyPS5/blob/e15c316ead335690a6693b711a5c5e33cfda7652/core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp#L1023-L1024), [L1026-1030](https://github.com/boykopovar/AnyPS5/blob/e15c316ead335690a6693b711a5c5e33cfda7652/core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp#L1026-L1030)<br>`core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` [L1345](https://github.com/boykopovar/AnyPS5/blob/e15c316ead335690a6693b711a5c5e33cfda7652/core/libs/prx/libSceAgcDriver/tests/Graphics.cpp#L1345) | | |
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!3633
No description provided.