feat(libSceAgcDriver): render color views of several 3D slices as layered attachments #4573

Closed
ee6aba54 wants to merge 2 commits from upstream-pr/4573 into main
ee6aba54 commented 2026-10-12 16:00:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ee6aba54 on 2026-10-12T16:00:06Z.


What

CB_COLOR_VIEW can select a range of slices (SLICE_START to SLICE_MAX); a draw into a 3D color target then addresses the slice per primitive through the render target index export. The decoder rejected every view whose last slice differs from its first ("color views of several array slices are unsupported"), and the index export was accepted but never routed.

Two commits:

  • A 3D target's view carries its slice count (clamped to the surface depth), the resident image's attachment view becomes a 2D array over those slices, and the framebuffer takes the layer count, which every color target of the draw must share. A depth target alongside a layered draw is still refused, and 2D array targets keep the single-slice rule.
  • For such a draw, PA_CL_VS_OUT_CNTL reaches the vertex stage info (and the draw hash, the recompile cache key and the request serialization, now version 18), so the render target index export becomes a gl_Layer output: per vertex, or per primitive in a mesh shader (the emitter already produced that output; the validation refused it). SPIR-V targets below 1.5 take the vertex built-in from SPV_EXT_shader_viewport_index_layer; the device enables VK_EXT_shader_viewport_index_layer, the validation accepts the vertex built-in with that capability or ShaderLayer and the mesh built-in, and dynamic rendering begins with the framebuffer's layer count instead of 1. Single-slice views keep ignoring the export, which lands on their slice as the hardware clamp would; the viewport index export stays ignored and keeps its one-time log line.

Tested

  • Ubuntu 24.04, Linux 7.0, GCC 13.3, Release, based on 33ae282e4. ctest of a tree combining this branch with #4499 and #4500: 954 tests pass; video_out_flip_* and agc_driver_stencil_ref_export are skipped on this machine.
  • New agc_vertex_layer_export (recompiler only) checks the SPIR-V 1.3 module takes gl_Layer from the extension without raising its version, the 1.5 module from ShaderLayer, and a misc vector export without the index declares no layer output. New agc_driver_layer_export_slices (RTX 5080) draws into slices 0-3 of a 128x128x4 R32 volume with a vertex shader exporting slice 2 and reads every slice back: only slice 2 changes, also after the volume is written back to guest memory and uploaded again. agc_driver_graphics covers the decode (slice range, clamping, inverted range) and the validation (the vertex Layer built-in needs the device flag). agc_shader_memory pins the new serialization version.
  • PPSA15304 (engine: Unreal Engine 5): the draw into a 48-slice 48x48x48 3D target that stopped the title is a mesh shader draw exporting the slice per primitive; it now runs with the export routed. Together with #4499, #4500 and a fix for the compute dispatch look-ahead submitted separately, the title reaches its main menu. The mesh built-in is covered only by this title run; no test builds a mesh module with a per-primitive Layer output.
  • Windows not built or tested.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4831901411 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4573). Originally posted by [ee6aba54](https://github.com/ee6aba54) on 2026-10-12T16:00:06Z. --- ### What `CB_COLOR_VIEW` can select a range of slices (`SLICE_START` to `SLICE_MAX`); a draw into a 3D color target then addresses the slice per primitive through the render target index export. The decoder rejected every view whose last slice differs from its first ("color views of several array slices are unsupported"), and the index export was accepted but never routed. Two commits: - A 3D target's view carries its slice count (clamped to the surface depth), the resident image's attachment view becomes a 2D array over those slices, and the framebuffer takes the layer count, which every color target of the draw must share. A depth target alongside a layered draw is still refused, and 2D array targets keep the single-slice rule. - For such a draw, `PA_CL_VS_OUT_CNTL` reaches the vertex stage info (and the draw hash, the recompile cache key and the request serialization, now version 18), so the render target index export becomes a `gl_Layer` output: per vertex, or per primitive in a mesh shader (the emitter already produced that output; the validation refused it). SPIR-V targets below 1.5 take the vertex built-in from `SPV_EXT_shader_viewport_index_layer`; the device enables `VK_EXT_shader_viewport_index_layer`, the validation accepts the vertex built-in with that capability or `ShaderLayer` and the mesh built-in, and dynamic rendering begins with the framebuffer's layer count instead of 1. Single-slice views keep ignoring the export, which lands on their slice as the hardware clamp would; the viewport index export stays ignored and keeps its one-time log line. ### Tested - Ubuntu 24.04, Linux 7.0, GCC 13.3, Release, based on `33ae282e4`. `ctest` of a tree combining this branch with #4499 and #4500: 954 tests pass; `video_out_flip_*` and `agc_driver_stencil_ref_export` are skipped on this machine. - New `agc_vertex_layer_export` (recompiler only) checks the SPIR-V 1.3 module takes `gl_Layer` from the extension without raising its version, the 1.5 module from `ShaderLayer`, and a misc vector export without the index declares no layer output. New `agc_driver_layer_export_slices` (RTX 5080) draws into slices 0-3 of a 128x128x4 R32 volume with a vertex shader exporting slice 2 and reads every slice back: only slice 2 changes, also after the volume is written back to guest memory and uploaded again. `agc_driver_graphics` covers the decode (slice range, clamping, inverted range) and the validation (the vertex `Layer` built-in needs the device flag). `agc_shader_memory` pins the new serialization version. - PPSA15304 (engine: Unreal Engine 5): the draw into a 48-slice 48x48x48 3D target that stopped the title is a mesh shader draw exporting the slice per primitive; it now runs with the export routed. Together with #4499, #4500 and a fix for the compute dispatch look-ahead submitted separately, the title reaches its main menu. The mesh built-in is covered only by this title run; no test builds a mesh module with a per-primitive `Layer` output. - Windows not built or tested. ### 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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-12 16:11:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T16:11:10Z.


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
#1077 core/libs/prx/libSceAgcDriver/tests/VertexLayerExport.cpp
#1313 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp L147
#3633 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp L996, L1009-1010
#3763 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp L147
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp L267
core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hpp L18, L50, L70, L126
core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp L57
core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp L163, L536
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp L740, L1968, L2156, L2532
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp L72, L84, L567, L582, L592, L605, L632
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp L48, L130, L136-138, L145, L245, L566, L587
core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp L100-102, L694-701, L972, L996, L1008-1014
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp L1329, L1335, L1342, L1345, L1348
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp L1319, L3325-3329
core/libs/prx/libSceAgcDriver/tests/VertexLayerExport.cpp
core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp L404, L407, L423, L568
core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvModuleSetup.cpp L109-111
core/libs/prx/libSceAgcDriver/tests/VertexLayerExport.cpp
#4451 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp L1640, L1645
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6128060553 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4573#issuecomment-6128060553). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-12T16:11:10Z. --- <!-- 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 | |---|---|---|---| | #1077 | | | `core/libs/prx/libSceAgcDriver/tests/VertexLayerExport.cpp` | | #1313 | `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp` [L147](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp#L147) | | | | #3633 | `core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp` [L996](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp#L996), [L1009-1010](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp#L1009-L1010) | | | | #3763 | `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp` [L147](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp#L147)<br>`core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` [L267](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp#L267)<br>`core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hpp` [L18](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hpp#L18), [L50](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hpp#L50), [L70](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hpp#L70), [L126](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hpp#L126)<br>`core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp` [L57](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp#L57)<br>`core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp` [L163](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp#L163), [L536](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp#L536)<br>`core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp` [L740](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp#L740), [L1968](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp#L1968), [L2156](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp#L2156), [L2532](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp#L2532)<br>`core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp` [L72](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp#L72), [L84](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp#L84), [L567](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp#L567), [L582](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp#L582), [L592](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp#L592), [L605](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp#L605), [L632](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp#L632)<br>`core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp` [L48](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp#L48), [L130](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp#L130), [L136-138](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp#L136-L138), [L145](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp#L145), [L245](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp#L245), [L566](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp#L566), [L587](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp#L587)<br>`core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp` [L100-102](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp#L100-L102), [L694-701](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp#L694-L701), [L972](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp#L972), [L996](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp#L996), [L1008-1014](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp#L1008-L1014)<br>`core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp` [L1329](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp#L1329), [L1335](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp#L1335), [L1342](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp#L1342), [L1345](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp#L1345), [L1348](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp#L1348)<br>`core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` [L1319](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/tests/Graphics.cpp#L1319), [L3325-3329](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/tests/Graphics.cpp#L3325-L3329)<br>`core/libs/prx/libSceAgcDriver/tests/VertexLayerExport.cpp` <br>`core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp` [L404](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp#L404), [L407](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp#L407), [L423](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp#L423), [L568](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp#L568)<br>`core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvModuleSetup.cpp` [L109-111](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvModuleSetup.cpp#L109-L111) | | `core/libs/prx/libSceAgcDriver/tests/VertexLayerExport.cpp` | | #4451 | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` [L1640](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp#L1640), [L1645](https://github.com/boykopovar/AnyPS5/blob/2a5eca11cd1bf583db39ce67034e8453842ac244/core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp#L1645) | | |
ee6aba54 commented 2026-10-12 16:23:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ee6aba54 on 2026-10-12T16:23:00Z.


Closing as a duplicate of #1077 (layered draws into 3D color targets, the render target index export routed to gl_Layer, VK_EXT_shader_viewport_index_layer) and #3763 (the dynamic rendering layer count). I missed both when I checked for overlapping pull requests.

For those pull requests, in case it helps: PPSA15304 (engine: Unreal Engine 5) renders into a 48-slice 48x48x48 3D target with a mesh shader that exports the slice per primitive, so the per-primitive Layer output of mesh shaders matters there as well as the vertex one. With an equivalent change, #4500 and #4586, the title reaches its main menu.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6128259286 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4573#issuecomment-6128259286). Originally posted by [ee6aba54](https://github.com/ee6aba54) on 2026-10-12T16:23:00Z. --- Closing as a duplicate of #1077 (layered draws into 3D color targets, the render target index export routed to `gl_Layer`, `VK_EXT_shader_viewport_index_layer`) and #3763 (the dynamic rendering layer count). I missed both when I checked for overlapping pull requests. For those pull requests, in case it helps: PPSA15304 (engine: Unreal Engine 5) renders into a 48-slice 48x48x48 3D target with a mesh shader that exports the slice per primitive, so the per-primitive `Layer` output of mesh shaders matters there as well as the vertex one. With an equivalent change, #4500 and #4586, the title reaches its main menu.

Pull request closed

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!4573
No description provided.