fix(agc): render a slice of a 2D array color target into that layer of the array #3524
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3524"
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 XairRrR on 2026-10-11T12:18:24Z.
What
A color view of slice N of a 2D array (
CB_COLOR_VIEWSLICE_START, withCB_COLOR_ATTRIB3MIP0_DEPTHas the last slice) was rendered as a plain 2D surface at the slice's address (#2626 moves the address by the slice size). The swizzle equations of the XOR tile modes take the slice index: the detiler feeds it to the equation's slice bits (TextureDetile.comp), so the driver samples slice N of an array in that layout. So the texels of slice N of an array are not where a 2D surface at that address puts them. A title that renders into array slices and then samples the array reads them scrambled.Measured with the new test: in slice 1 of a 128x128 R32
SW_64KB_R_Xarray, texel (0, 0) sits at dword 0x200 of the slice, where the 2D layout puts texel (0, 0) at dword 0.Changes:
DecodeColorBufferkeeps the array's address, its last slice and the view's slice in theColorTarget. The slice address is unchanged.AttachmentViewtakes a layer.Test
tests/execution/ArrayLayerTarget.cpp:On
mainit fails at the first read ("slice 1 read through the array after the draw: texel (0, 0) reads 0x5a5a5a5a, expected 0x3e800000").The titles of #2626 (VITA5 PPSA39410, Homebrew UI Lab PPSA99050) render through such slice views of an XOR-tiled array (
CB_COLOR_ATTRIB30x4dc6c001,MIP0_DEPTH1); I have not run them. PPSA05684 does not take this path: its layer targets are plain 2D views at the layers' addresses, so the change has no effect there (checked in its menu, no draw through a slice view).Tested
BUILD_TESTING=ON.a11c8f7f. Full ctest: 832/833. The one failure,agc_driver_emulated_color_compare, fails the same way on plain main. Conventions check passed.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)AttachmentView(see comment)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T12:38:35Z.
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/include/State.hppL56core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppL162, L532core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppL58-93, L1894core/libs/prx/libSceAgcDriver/Graphics/src/State.cppL873-874core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppL1320, L1324-1325, L1335, L1338core/libs/prx/libSceAgcDriver/Graphics/src/State.cppL874Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T13:10:10Z.
Review: CHANGES_REQUESTED
Thanks, the approach (sharing the array's image per layer instead of a separate 2D image) makes sense. Local scoped build and ctest for libSceAgcDriver are green and
agc_layer_aliaspasses. A few things before it can land:agc_layer_aliasonly covers alias resolution and the attachment view. Nothing exercises theDraw.cpp:1886-1899path: a 2D target attaching a layer, the former 2D image being flushed and evicted, and the result being visible when sampling the array. Please add a test that draws into a layer and samples the array.ShaderResources.cpp:848) the alias is silently skipped and the old path stays. Please list that in TechnicalDebt.md.The red
conventions/relinkerjobs are the imgui gitlink on main (fixed in #3511), unrelated to this PR; they pass after a rebase.Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-11T13:13:34Z.
On the overlap table above:
layerscount toStorageTexture::AttachmentViewand its view cache key, to render layered draws into 3D color targets. This PR adds alayerindex there, to attach one layer of a 2D array. Same lines, different features. Whichever lands second needs a rebase that keeps both arguments (layerselects the first layer,layersthe count).cachedStorageTexture. This PR changes the same function further down (the layer alias lookup), so that one should only be a textual conflict.Neither implements the same thing, so Depends on stays none. I'll rebase whichever way they land.
Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-11T14:11:49Z.
Thanks for the review. Writing the test you asked for turned up a bug on
main, so I've rewritten the PR around it (force-pushed, new title and description).The test showed that slice N of an XOR-tiled 2D array does not have the layout of a 2D surface at the slice's address: the swizzle equation, as the detiler applies it, takes the slice index. In slice 1 of a 128x128 R32
SW_64KB_R_Xarray, texel (0, 0) sits at dword 0x200 of the slice. Since #2626 turns a view of slice N into a 2D target at the slice's address, a draw into slice N wrote the 2D layout and the array read it back scrambled. My first version only covered this when the array happened to be cached first.On your three points:
tests/execution/ArrayLayerTarget.cppdraws into slice 1 of an array color view with a partial scissor and reads the slices back through the array, before and after a write-back. It fails onmain.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T21:30:04Z.
Review: APPROVED
Checked on the PR merged onto current
main: libSceAgcDriver build + ctest green,agc_driver_array_layer_targetpasses and fails with the array-layer branch inDraw.cppdisabled. CI green on this head. Merging.Note for whoever lands second between this and #1077: both change
StorageTexture::AttachmentView(layerhere,layersthere); the rebase keeps both.