feat(agc): render layered draws into 2D array color views #7254
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7254"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by gjonn on 2026-10-17T19:52:29Z.
What
PPSA01317 on
mainaborts in a 512x512 cube map pass withlayered draws into a color view of several array slices are unsupported. The draw's vertex shader exports the render target array index (PA_CL_VS_OUT_CNTLUSE_VTX_RENDER_TARGET_INDX) into aCB_COLOR_VIEWof slices 0 to 5. Only 3D color targets rendered several slices; a layered draw into any other slice range threw.Two commits:
lastSlice - slice + 1layers through a 2D array attachment view of the array's resident image, starting at the view's first slice. The draw marks every rendered slice dirty (MarkSliceDirtytakes a slice count). A layered draw into an array without its resident image throws.CB_COLOR_ATTRIB3declares one slice while the view covers slices 0 to 5, which then threw... of several slices of a surface that is not a 2D array are unsupported. The CB clamps the layer to the view'sSLICE_MAX, not to the surface's slice count, so each layer is written one slice pitch further on. Such a view now renders as a 2D array of the view's last slice + 1 slices. The "Layered color targets" debt entry is updated to match.Single-slice views and views without the layer export behave as before (the first slice of the range). A layered draw with a depth target still throws; #7256 handles that. #6959 also touches layered rendering (mesh layer windows) and keeps the refusals this PR removes; the two do not overlap.
Tested
Windows 11, NVIDIA GeForce RTX 5090 Laptop GPU, driver 616.92. Ninja/MinGW Release with
BUILD_TESTING=ON, rebased onmain922dc8999.agc_driver_graphics_tests: the two decode cases that expected the refusal now require two layers (a 2D array view of slices 0 to 1 and a one-slice surface viewed as slices 0 to 1).agc_driver_array_layer_target,agc_driver_depth_plane_guest_layers,agc_driver_layered_volume_draw,agc_driver_layered_volume_submit,agc_driver_layered_volume_vertex,agc_driver_layered_volume_vertex_no_gpl,agc_vertex_layer_exportand the decode state tests (agc_driver_msaa_dcc_state, the alpha-to-coverage state tests): 11/11 pass.tools/check_conventions.py --base origin/mainandtools/check_test_registration.pypass.main(checked in boots). It then stops atlayered rendering with a depth target is unsupportedon the same pass, which #7256 handles.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T20:16:52Z.
Thanks, this unblocks the first two PPSA01317 aborts nicely. We read through it: the change is confined to paths that threw on main (a layer export over a slice range), the dirty range from
MarkSliceDirty(slice, count)is exact, and volume targets are unchanged.One ask before it can merge, a test that runs the new path. The tests added here are decode-only (they check
layers,renderLayersandarrayLastSliceafterDecodeState).agc_driver_array_layer_targetuses single-slice views, and theagc_driver_layered_volume_*tests are 3D only. Nothing renders a layered draw into a 2D array yet, and the title stops at the next abort, so a wrong base layer, layer count or write-back range would go unnoticed, where main at least threw.Could you add an execution test modelled on
LayeredVolumeDrawthat draws with a layer-exporting VS into:CB_COLOR_VIEWof slices 1..3 of a 4-slice 2D array, andwith a distinct colour per layer, then checks guest memory per slice after write-back, including that slice 0 is untouched in case (a)? It needs to run on Linux llvmpipe (no early skip other than "no device"), since that's the only CI lane with a Vulkan device. It would also cover the colour side of #7256.
Two small optional points:
AttachmentView's secondRequirenow accepts anylayerfor a volume (|| volume), where main requiredlayer == 0. It's unreachable today, but(volume && layer == 0)would keep the guard.slice == 0the pitch check in the resident path inDraw.cppis trivially true, so nothing compares the synthesized array'slayerByteswith the per-slice sizeState.cppuses for slice offsets. Comparing them for every slice would be cheap hardening.Heads-up on merge order: this conflicts textually in
Draw.cppwith the native-multisample series (#6973, #6987, #6989, #6995, #7002); whichever lands second will need a rebase. #7256 builds on this one, so this merges first.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-17T20:34:23Z.
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.
main)core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppL2219core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppL1825-1826core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppL2857-2858Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdImported from boykopovar/AnyPS5. Originally posted by gjonn on 2026-10-17T21:02:19Z.
Thanks for the review. Pushed two follow-up commits:
Test:
agc_driver_layered_array_color_draw(tests/execution/LayeredArrayColorDraw.cpp, modelled onLayeredVolumeDraw). A VS exporting the render target index draws one full-screen quad per layer. The PS writes1 + layer / 2from the ancillary RT-index field, so each layer gets its own value. The colour view comes fromDecodeColorBufferwith the layer export set inPA_CL_VS_OUT_CNTL:CB_COLOR_VIEWof slices 1..3 of a four-slice 2D array (R32_FLOAT, 64 KiB R_X, one 64 KiB block per slice).After
FlushPendingover the surface it checks every word of all four slices in guest memory:It only skips with no device. The
VK_EXT_shader_viewport_index_layercheck is the same oneLayeredVolumeDrawmakes, and lavapipe exposes that extension. I ran it on llvmpipe (LLVM 21.1.8) under WSL Ubuntu and it passes there, not skipped. It also passes on Windows.Mutation check (one change at a time; each should make the test fail):
lastSlice - slice)MarkSliceDirtycovers one slice (inTexture.cpp)Draw.cpppasses a dirty count of 1 at every siteOne mutation didn't fail: shrinking only the attachment view's
layerCount, with the framebuffer still at 3 layers. That is undefined behaviour in Vulkan, and the NVIDIA driver still wrote the third layer, so I left it out of the table.Optional points, both done (
fix(agc): ...commit):AttachmentView's secondRequirenow uses(volume && layer == 0), so volumes keep main's guard.DecodeColorBufferoffsets slices by (ComputeSurfaceSizeof the surface's mip chain, one layer), not just slice 0. A mismatch throws. The view's ownsurfaceAddresscheck uses that same size.#7256 is rebased onto the new tip. Its tests, including
LayeredDepthTarget, pass again.On merge order: understood that this conflicts in
Draw.cppwith #6973, #6987, #6989, #6995 and #7002. If any of them lands first I'll rebase this one and #7256 on top.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by gjonn on 2026-10-17T21:27:11Z.
Rebased onto main
5f8d2a252(force-push, headebe289bdc). No conflicts; main's Draw.cpp/DepthSurface.cpp changes since the previous base (depth plane fill, 5_6_5 and unclamped normalized color targets) merged cleanly. Rebuilt; all 666 agc_* tests pass, including agc_driver_graphics, agc_driver_layered_array_color_draw, agc_driver_array_layer_target, agc_driver_layered_volume_, and the new agc_driver_color565_target, agc_driver_depth_plane_fill, agc_driver_native_depth_bda_clear and agc_pipeline_queue_failure_. check_conventions.py --base origin/main and check_test_registration.py are clean.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by frankea on 2026-10-18T04:15:19Z.
RTX 4090 data point on PPSA01317, continuing the chain from my #7243, #7238 and #7240 runs tonight, where the title stopped on
layered draws into a color view of several array slices are unsupportedin its cube map pass. Short version: with this PR the pass gets through its colour side on this GPU too, 3 of 3 runs, and the title stops on the depth side (layered rendering with a depth target is unsupported), exactly as the description of #7256 says.Setup. Gran Turismo 7 PPSA01317 01.000.001 (base package), Windows 11 (26200), RTX 4090 (NVIDIA 616.92), AMD Ryzen 7 5800X, MinGW-w64 GCC 15.2.0 r7 (UCRT), Release
libstarget only (no tests built).app.exeis the relink frommain31cbb55d7(--windows --registry --module-dir .); onlylibs/is swapped between runs. Tree: the stack from the earlier runs (maine1041f6a5+ #71372aa6bfca6+ #7207 ec28b6be8 + #7175 555b7e824 + #5958 87a9b8d28 + #7243da158d61f+ #72384aaf27699+ #72407c19c66de, ac5e28d17) merged with this PR's headebe289bdc(9ea37b61b). The merge brings the PR's base,main5f8d2a252, with it (115maincommits, none of them libSceHmd2, so the #7323 abort from the #7243 comment does not apply here). One conflict, inGraphics/src/State.cpp: theCOMP_SWAP > 1format list, where the stack's pr7207-branch line and the PR's pre-#7207mainline differ; resolved to currentmain's line (format != 7 ... && format != 16). With the PR's side taken instead, the title aborts onunsupported color format 7 number type 7 component swap 228 s in (3 runs), which is just #7207 missing again, not this PR. ThelibSceSsl.prxis the one from #7319 (1f267559e). No controller, no input, nobody at the keyboard; one-shot interactive task per run, 600 s cap, box otherwise idle.Result. All three runs get past the layered colour draw: splash, the black loading screen with the GT spinner (title-bar counter 27 FPS, 1,134 frames at the last capture of run 3), save data mounted, three
sceNetResolverStartNtoa -> host DNS lookup failed, 392 further shaders registered, and then, identically every time:No
several slices of a surface that is not a 2D arrayrefusal, nolayered draw into an array without its resident image, no device loss. With #7256 on top the depth stop goes away as well; that result is on #7256.layered draws into a color view of several array slices are unsupportedlayered rendering with a depth target is unsupportedstderr of run 3 (warm, box idle) from the second 10 s summary to the abort, the 392 per-shader
ShaderRegistrylines removedAI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-19T03:22:40Z.
Review: COMMENTED
Apple GPU / MoltenVK run.
agc_driver_layered_array_color_drawruns on Metal (no skip) and passes, fails without the fix with the original refusal, and the full^agcsuite is unchanged.Machine: Apple M2 Max, macOS 27.2, x86-64 build under Rosetta. Head
ebe289bdc. Drivers: MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0) and MoltenVK main + SPIRV-Cross #2704.Tested: the tree is
maina373e85e5+ mugurc's macOS series (ci/macos-series-2) + the PRs needed to build on macOS (#6667, #6668, #7524, #6969, and two files of #7332), not plainmain(it doesn't build on macOS yet). One textual conflict inDraw.cpp, in theDrawRecorddeclaration: that tree'smainalready hasmultisampleTargets, and this PR changestargetSlicesto a slice/count pair. I kept both. #7671 was applied in the same build (disjoint files: recompiler vs driver). Base on that tree: 40^agcfailures with MoltenVK 1.4.2 and 26 with MoltenVK main + #2704, the same known failures in every run below.VK_EXT_shader_viewport_index_layer, so the test takes the layered path here.agc_driver_layered_array_color_draw,agc_driver_graphics,agc_driver_array_layer_target, the fouragc_driver_layered_volume_*tests andagc_vertex_layer_exportpass 3 of 3 on MoltenVK 1.4.2; the new test andagc_driver_graphicsalso pass 3 of 3 on MoltenVK main + #2704.agc_driver_layered_array_color_drawfails on both drivers withlayered draws into a color view of several array slices are unsupported, andagc_driver_graphicsfails on the changed decode cases.^agcsuite with the PR: 40 of 729 fail on MoltenVK 1.4.2 and 26 of 729 on MoltenVK main + #2704, the same tests as the base on each driver.GPUs tested: Apple M2 Max (MoltenVK 1.4.2; MoltenVK main + SPIRV-Cross #2704)
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T20:07:00Z.
Rebased onto current main (one adjacency conflict in
Draw.cpp:targetSlicesnext to the newmultisampleTargets). Checked that every changed path threw on main, the per-slice pitch validation, the dirty-slice range fromMarkSliceDirty(slice, count), that multisampled targets still reject layers > 1, the debt entry, and thatagc_driver_layered_array_color_drawchecks each layer's value and the untouched slices. Thanks @oneandonlydean, @frankea and @jotitadev for the runs; merged.