feat(libSceAgcDriver): draw PS4 (GCN) command buffers #9431
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9431"
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 Get-fix on 2026-10-21T21:51:02Z.
What
Part 3 of the PS4 Limbo stack, split out of #6977 (the whole stack is listed in #6978). Only the last two commits are this PR; the three below them are #9430.
PS4 color and depth targets (
CB_COLOR_ATTRIB/DB_Z_INFOtile mode indices) as resident targets, PS4 graphics EOP events registered per queue, and the PS4 display buffer read as Display2DThin.PS4 tile modes as XOR equations in the existing GPU detiler:
Layered surfaces with several mip levels are stored level by level for sampled textures. 3D and thick modes, and storage or depth views of mipmapped PS4 arrays, throw.
A 1920x1080 PS4 render target is a 1920x1088 surface; a texture over its top-left corner with the same pitch and tiling is a GPU block copy instead of a trip through guest memory.
The PS4 SDK pattern-fill compute kernel runs as a GPU fill when it repeats one dword, so render targets and HTILE are cleared without a CPU drain. Two-dword patterns keep running the kernel. Run as fills, Limbo's clears of its 64-bit target made its gameplay advance about half as far per frame (same input and save, every frame dumped), although the stored values are equal. The cause is not known yet, so the shortcut is left out.
The 4 KiB display-buffer alignment error now names linear and PS4 buffers, and
video_out_flip_ps4expects that text (26d651d3e).Sources and limits are in
docs/dev/debt/libSceAgcDriver.md(addrlib formulas and shadPS4's GB_TILE_MODE tables, not console measurements).Tested
Windows 11, WinLibs GCC 15.2, NVIDIA GeForce RTX 5060 Ti (driver 610.88), on
main7e2ba73e4with #9430:agc_driver_graphics: the GCN address equations against a separate implementation of addrlib'sComputeSurfaceAddrFromCoordMicroTiled/MacroTiledfor every mode and element size, Limbo's depth layout, and a level-by-level array layout.agc_driver_gcn_detile(new, GPU): a PS4-tiled pattern through the real detiler shader for every mode, including depth split and PRT, at 1 to 16 bytes per element.agc_driver_pattern_buffer_fill: Limbo's captured clear decodes to its 44-bit target.main7e2ba73e4on this machine:agc_driver_sample_orderand its--grid-referenceand--recipe-depth-locationscases.video_out_flip_ps4passes, as onmain.main. The 3 that fail also fail onmain7e2ba73e4on this machine:agc_driver_sample_orderand its--grid-referenceand--recipe-depth-locationscases.ctest -R "^(agc|video_out|shader|recompiler|gcn)" -VwithANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(Vulkan SDK 1.4.363), onmain7e2ba73e4and on this branch with #9430, same machine and GPU. Both builds use-DANYPS5_VIDEO_OUT_TEST_DRIVER=windows, so the 14 VideoOut flip tests get a real display.main: 913 tests; 907 pass, 3 skip and 3 fail (theagc_driver_sample_ordercases).agc_gcn_decodeandagc_driver_gcn_detile, which pass.VUID-errors in the same 8 existing PS5 tests, with the same IDs and counts test for test (agc_driver_prepared_exports, the threeagc_driver_sample_ordercases and four others). This PR adds none.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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T04:48:27Z.
Review: DISMISSED
The address-equation comparison against addrlib, GPU detiler tests, Limbo run, and paired Vulkan validation are detailed and useful. I found two repository checklist gaps before this change can be considered ready:
The PR description claims the 1920×1080 target optimization increased Limbo from 42 fps to 57–58 fps. The contribution rules require performance claims to include the
trace_digestsummary lines frommainand the change on the same machine and scene, with the traces attached. I could not find those summary lines or trace attachments in the PR description/comments. Please attach the paired report, or remove the comparative speed claim and retain only the functional correctness evidence.The branch is 534 commits behind current
main; the reported tests usececb540a6. Please update the dependency stack to currentmain, refresh the overlap/conventions/intake checks, and rerun the focused AGC/shader/VideoOut tests against that same current baseline with the required validation-layer environment. The current paired GPU report is strong for the older baseline, but does not cover the present merge base.The hosted eligibility, intake, labels, and report checks pass; full Linux/Windows/relinker jobs are skipped. I did not rerun the author's Windows/NVIDIA tests locally because this workspace has no checkout/build matching the PR head.
Imported from boykopovar/AnyPS5. Originally posted by Get-fix on 2026-10-22T11:06:51Z.
@MarcZX10 thanks, both points are done:
Speed claim: removed from the description. I have no
trace_digestpair frommainand the change for it, so only the functional evidence stays.Rebase and reruns: the stack is rebased onto
main7e2ba73e4. On that base I reran, onmainand on the change, same machine and GPU:The conventions and overlap checks are refreshed. Results are in the description.
The rerun found one real problem in this PR. It renamed the 4 KiB alignment error to "only supported for linear and PS4 buffers", but
video_out_flip_ps4still looked for the old text, so the test failed with this PR. The new commit26d651d3eupdates the expected text. My earlier description wrongly saidvideo_out_flip_ps4also failed onmain: on7e2ba73e4it passes, and it passes with this PR.Overlap report, beyond the #9430 entries answered there. Some open PRs change the same lines as this one:
DecodeShaderStages, the block this PR's PS4 legacy-vertex branch is placed before.TextureDetile.compwhere this PR adds the depth tile-split offset. If #6905 lands first, the split offset goes before itsranged = tiledOffset, so the range covers the split slice.blockUnitscondition inTexture.cpp.AgcDriverDeliverEopInterruptand the graphics event trigger. This PR registers those events by queue and ident instead of by id; both changes combine.layeredDepthStorage. The refusal this PR adds there, for PS4 arrays stored level by level, has to stay.DrawKeyRegisters, as this PR does. The ranges add up and the array size becomes their sum.Other open PRs only add lines at the same place: #7948 (@Amoenus) next to the new
GuestTextureResourcefields, and #9020 and #9335 next toDecodeGcnColorBuffer.None of these needs the other first. Whichever of them lands before this stack, I rebase the stack onto it and merge by hand as noted above, so none of the authors has to change anything. That is why
Depends onstays #9430 only. If any of you would rather this stack go first, say so and I'll note the order.AI-assisted: yes (Claude Code)
🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-22T11:20:00Z.
@Get-fix the rebase onto
mainlooks right to me. The newRequireindecodeDepththat refuses PS4 depth targets with mip levels sits behindgcnlike the rest of that function's PS4 branches, so PS5 depth decoding is stillmain's code. The flip-test update for the "linear and PS4 buffers" message matches theDisplayBuffer.cppchange.One blocker, though: this commit doesn't compile on Linux x86-64 with GCC and libstdc++.
bool legacyVertexinShaderStages(Graphics/include/State.hpp:35) trips the two size checks inGraphics/src/PipelineJournal.cpp:38-39:The checks only exist under
__linux__ && __x86_64__ && __GLIBCXX__, so a Windows or macOS build doesn't see them. The CI here hasn't run on this head yet, which is why nothing flagged it.Could you:
legacyVertex, as the assert asks. As far as I can see, pipeline creation doesn't read it: it only picks the vertex program inDrawDecode.cpp, andPipeline.cppnever reads it. If so,CanonicalPipelineStatecan leave it atfalseand the recipe codec doesn't need to carry it, and a short comment next to the size checks saying so would help the next person. If pipeline creation does depend on it, it needs to go intoCanonicalPipelineStateand be encoded and decoded next totessellation(PipelineJournal.cpp:172-176and:226-228), with the journal version bumped.We'll run the full CI on the new head once that's in.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-24T02:30:28Z.
Review: CHANGES_REQUESTED
Two things block this head, both already reported above and not yet done:
bool legacyVertexinShaderStages(Graphics/include/State.hpp:35) trips the size checks atGraphics/src/PipelineJournal.cpp:38-39(116 vs 112, 792 vs 784). Update the sizes, and decide whetherlegacyVertexbelongs inCanonicalPipelineStateand the recipe codec (it selects the vertex program inDrawDecode.cpp, so either encode it with a journal version bump, or show with a test that the selected shader identity already separates the two cases).main:GuestTextureResource.hpp(keepfmaskCmaskAddressand the newgcnPitch/gcnPow2Pad/gcnLinearGeneral).mainnow hasStateat 824 bytes and journal format 8, so the asserts need the values from the rebased tree.After the rebase, rerun the focused AGC tests and the validation-layer comparison on the new head; the Linux Build run will be the gate.
Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-29T05:50:33Z.
Review: APPROVED
Reviewed — approved
The head merges cleanly into current
mainand builds on Linux x86-64 with GCC/libstdc++, including the updatedPipelineJournal.cppsize asserts. The focused AGC tests pass under the validation layer with noVUID-lines, and mutating the new tiling, detile and fill code makes the new tests fail.What I ran
eefa50841267cd0bd5352af17248139445fb0613main:52c09d567d2fa453494dd720fcf53a98149468e4mainwith the head merged (--no-ff), in a clean worktree. Release, GCC 16.2.1, Ninja.Results
mainBufferFill.cpp,VulkanDevice.cpp,DepthSurface.cpp,ShaderReplay.cpp,Flip.cpp, the debt doc)git diff --checkcheck_conventions.py --base origin/mainAll conventions checks passed.sizeof(State) == 920/sizeof(ShaderStages) == 164asserts hold, so the build failure reported on26d651d3eis fixedvideo_out_flip_ps4: no display in the sandbox)mainvideo_out_flip_ps4, same reason)VUID-linesmainwas not found but was requested by env var VK_INSTANCE_LAYERSVK_LAYER_KHRONOS_validationin both runsagc_driver_pipeline_journalat 6.9 s;agc_driver_gcn_detile1.0 sMerged tree, ctest summary
video_out_flip_ps4:skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platformmain, ctest summaryNegative control
Reverting all production files does not give a useful control here, because the new tests call
GcnTiling,ComputeGcnMipLayoutandMatchesGcnPatternFillKernel, which only exist in this PR, so the tests would just fail to compile. Instead, on the merged tree I changed one thing in each of three production spots, rebuilt and ran the three tests:TextureTiling.cppGcnTiling: bank rotation per split slice(banks / 2 + 1)changed to(banks / 2).TextureDetile.comp: dropped thesplit * params.splitStrideoffset.BufferFill.hppDecodeGcnPatternFillRange: high address mask0xfffwidened to0xffff.All three tests failed, each on the change aimed at it:
So the addrlib reference in
tests/TextureTiling.cppcatches errors in the equation builder on its own, and the GPU test catches a missing split offset in the shader. I restored the files afterwards.Findings
Blocking
None.
On the earlier
legacyVertexquestion (@oneandonlydean, @ntamas94):legacyVertexis read in only one place,DrawDecode.cpp:170, where it picks the vertex program. Nothing inPipeline.cppor the journal reads it. So leaving it out ofCanonicalPipelineStatematches what pipeline creation uses, and the size-only update ineefa508412is enough for the guards. The build confirms the new sizes.Non-blocking
Eq/src/Event.cpp:50-51,AddEventde-duplicates on(eq, ident)only. If anidentthat is already registered on an equeue is added again with a differentqueue, the kqueue entry is updated (EV_ADD), butg_registrationskeeps the first queue.AgcDriverDeliverEopInterruptthen fires that ident for the old queue and never for the new one. With the PS5 entry point,queue == ident, so this cannot happen there; it can happen throughAgcDriverAddQueueEqEvent_nid_postfix. Suggested fix: updatequeueon the existing registration, or throw when it differs.AgcDriverAddQueueEqEvent_nid_postfix/AgcDriverDeleteQueueEqEvent_nid_postfix(Event.hpp:11-12) andAgcDriverSubmitGraphics_nid_postfix/AgcDriverUseGcnShaders_nid_postfix(EntryPoints.cpp:95-102). The same goes for thetilingMode == 2display-buffer path (DisplayBuffer.cpp:150-154): only the error text is exercised, byvideo_out_flip_ps4. I assume the callers arrive with #9432. A smallagc_driver_eop_interruptscase for queue/ident registration, and aDisplayBufferSize/DecodeDisplayBuffercase for a 1920x1080 PS4 buffer (expected 1920x1088 bytes), would cover them here.<array>is included twice inGuestTextureResource.cpp:8-10. Drop the new line 8.docs/dev/debt/libSceAgcDriver.md:79, and it links shadPS4'stiling.cppatblob/main. That source is what the GB_TILE_MODE tables are taken from, so a commit permalink would keep the citation stable. The same applies to theimage_info.cppmention two entries below, which has no link at all.eefa508412(the journal guard fix). TheTestedsection still describesmain7e2ba73e4and26d651d3e. Please refresh it so it matches the head that gets merged.Not verified
video_out_flip_ps4and the real PS4 flip/present path: the sandbox has no display, so the test skipped on both trees. I checked the expected string againstDisplayBuffer.cpp:147by reading the code only.libstarget and the full suite: I built and ran only the targets listed above.