fix(libSceAgcDriver): decode PS4 tiled scanouts in their own layout on the CPU path #9673
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9673"
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 ntamas94 on 2026-10-22T07:45:05Z.
What
DecodeDisplayBuffer's 4-byte loop worked out the tiled offset inline and only knew the linear (tilingMode == 1) and PS5 64 KiB layouts. A PS4 Display2D scanout (DisplayTilingGcn) fell into the 64 KiB branch and came out scrambled. The half-float loop andDisplayBufferOffsetalready go throughtexelOffset, which handles all three layouts, so the 4-byte loop now calls it too. For the linear and 64 KiB casestexelOffset(buffer, x, y, 4)gives the same offsets as the removed code.The CPU decode only runs when a flip has no pending image to blit: the first flip, or with
APS5_STORE_AT_LABEL=1/APS5_EAGER_WRITEBACK=1. That is why the default path looks fine and the knobs showed a broken image. The Display2D retile of the render target was correct; only this read was wrong.Note:
texelOffsetcomputes the GCN address of every texel one by one, so a 1080p CPU decode takes about 116 ms, against 9.4 ms for the old (wrong) 64 KiB formula. The half-float loop pays the same cost today. I left it as it is because this path only runs on the first flip or with the debug knobs. A new debt entry, "CPU scanout decode", records the cost and when the decode runs: for a linear buffer at every flip; for a tiled one only for a frame dump or screenshot read from guest memory, which is the case when no resident image is pending, that is the first flip, or every flip whileAPS5_STORE_AT_LABELorAPS5_EAGER_WRITEBACKwrites the results back before the flip. ThesceVideoOutRegisterBuffersentry indocs/dev/debt/libSceVideoOut.mdstill said that tiled PS4 buffers throw; it now points at the tiled-buffer entry and at the decode entry.mainnow carries theDisplayBuffer.cppchange itself (574321b323, which came in with #9432), so on this branch the PR's diff againstmainis theGcnDisplaytest inLinearDisplayBuffer.cppand the two debt-entry updates.This moves Get-fix/AnyPS5#18 (opened against
ps4/limbo-gpu) tomain, as Get-fix asked there. It was stacked on #9431, which is merged; the branch now has currentmainmerged in.Landing order: #9891 (
822a9eaa85) sends every GCN-tiled flip without a resident image throughReadDisplayBuffer, i.e. through the decode this PR fixes, so this PR should land before #9891 or with it; the "CPU scanout decode" debt entry then gains one sentence for that path.Tested
Windows 11 Pro (10.0.26200), WinLibs GCC, NVIDIA GeForce RTX 2080 (driver 617.14), Release build with
BUILD_TESTING=ON, on this branch with currentmain(f79ea3f893) merged in; #9431 is merged, so the branch's diff againstmainis this PR's own change:GcnDisplaycase inlinear_display_buffer: it fills a 1920x1024DisplayTilingGcnbuffer throughDisplayBufferOffsetand checks that every decoded pixel lands at its linear position. It passes; withDisplayBuffer.cppreverted to the base it fails.linear_display_buffer,agc_display_buffer_dccandvideo_out_hdr_presentpass, three runs each.APS5_STORE_AT_LABEL=1: before, the frames were scrambled; now the title screen, level0, level11 and the KiP intro and tutorial screens render correctly.tools/check_conventions.py --base main(f79ea3f893) with this title and description: no findings.mainf79ea3f893(100% of the 25 tests that exist there passed, the depth, display-buffer and graphics tests of this stack) and this branch with thatmainmerged in (100% tests passed out of 3:linear_display_buffer,agc_display_buffer_dcc,video_out_hdr_present) withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_NO_SHADER_CACHE=1,ANYPS5_REQUIRE_VULKAN=1andVK_LOADER_DEBUG=warn,error,ctest -V, on the NVIDIA GeForce RTX 2080, driver 617.14, Windows 11 (10.0.26200), Vulkan SDK 1.4.363.0: both logs carry the loader'sadding layers "VK_LAYER_KHRONOS_validation"line (62 and 2 times) and neither reportswas not found but was requested by env var VK_INSTANCE_LAYERS;VUID-ids onmain: 0, on this branch: 0, new on this branch: 0.Checklist
main; no other open PR implements the same functions (currentmainf79ea3f893merged in; #9431 is merged; searched open boykopovar/AnyPS5 PRs for scanout andDecodeDisplayBufferon 2026-10-22)NotImplemented_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 fogydes on 2026-10-22T08:47:25Z.
Reviewed; the CPU-path drop-in is exact. For the linear case
texelOffsetkeeps the byte-identical(y * pitch + x) * 4formula (samepitchInPixel == 0 → widthfallback), and for the newDisplayTilingGcnmode the 64 KiB tiling degenerates to the same{(y / 128) * blocksPerRow * 65536 + tileOffset(x,y)}the old branch computed by hand — the removal of the hoistedblocksPerRowis a pure move intotexelOffset. ThegcnLayouthelper is cached in athread_localkeyed on (pitch, height, texelBytes), so the decode loop doesn't rebuild the layout per texel; good touch. The new validations for the mode are the right guards (no DCC, no half-float texels, pitch padded to 128 pixels, pitch covering width, the 4 KiB alignment rule extended to this mode), andDecodeDisplayBufferpicks the mode up through the same function so no second tiling implementation exists. The test fills the full 1920x1024 buffer's every texel through the public offset function and reads it back, which is the right shape for a tiling change.One process note (from the stack): this PR's conflict surface is entirely #9431's — its own two topic files are untouched on main since the merge-base — so the rebase cost arrives with the stack, not with this commit.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T08:58:19Z.
Review: CHANGES_REQUESTED
The isolated change routes the 4-byte decode through the existing
texelOffsetpath, and the newlinear_display_buffercase exercises a full 1920x1024 GCN scanout mapping. Current-main conventions andgit diff --checkpass. The PR is currentlyCONFLICTINGwithmain; its declared dependency #9431 is also conflicting.Because this changes the AGC driver, CONTRIBUTING requires paired focused tests on
mainand the change withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_NO_SHADER_CACHE=1, andANYPS5_REQUIRE_VULKAN=1, usingctest -Von the same machine/GPU. Please confirm the requested layer loaded, compare the logs for newly introducedVUID-errors, and record the GPU on the checklist. The reported Windows/NVIDIA test and two title runs are useful but do not include the required validation-layer comparison.The description reports the CPU fallback as broken for Gang Beasts (CUSA04865) and Knowledge is Power: Decades (CUSA12435), but the checklist says
Unblocks: none. Please reconcile that checklist with the title evidence and link each applicable Game bring-up discussion; if a discussion is missing, follow the repository's title tracking rule. The report also measures 116 ms for a 1080p decode on this path; please keep that latency visible in the technical-debt/known-limit description and confirm whether it is confined to the first flip or can recur with the debug knobs.Imported from boykopovar/AnyPS5. Originally posted by ntamas94 on 2026-10-22T10:13:51Z.
Thanks. Two of the three points are addressed on the branch:
APS5_STORE_AT_LABELorAPS5_EAGER_WRITEBACKwrites the results back before the flip. So it does recur with the knobs, once per flip. ThesceVideoOutRegisterBuffersdebt entry still said tiled PS4 buffers throw; it now points at the tiled-buffer and decode entries.The conflict is #9431's (
Graphics/src/State.cpp); this commit's two files are untouched onmain. I will rebase once Get-fix has rebased #9431. Paired validation-layer run, now in the description:main(100% tests passed, main build7e2ba73e4) and this branch (100% tests passed) withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_NO_SHADER_CACHE=1,ANYPS5_REQUIRE_VULKAN=1andVK_LOADER_DEBUG=warn,error,ctest -V, on the NVIDIA GeForce RTX 2080, driver 617.14, Windows 11 (10.0.26200), Vulkan SDK 1.4.363.0: both logs carry the loader'sadding layers "VK_LAYER_KHRONOS_validation"line (78 and 2 times) and neither reportswas not found but was requested by env var VK_INSTANCE_LAYERS;VUID-ids onmain: 0, on this branch: 0, new on this branch: 0.AI-assisted: yes (Claude Code)
🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T12:31:52Z.
Review: COMMENTED
Thanks for updating the checklist with both title discussions and recording the repeated 116 ms decode cost, and for adding the paired validation-layer results. Those address the title-link, known-cost and validation-evidence points from the earlier review. The remaining blocker is the stack: #9431 still conflicts with current main, and this PR is based on its earlier head. The reported before/after runs use main
7e2ba73e4, while current main has advanced. Please rebase after #9431 is refreshed and rerun the focused display-buffer checks plus the affected title path against the resulting current-main merge base; then update the bring-up discussions if the furthest point or blocker changes. The host-report results are author-reported; I did not run a local build because no build tree is configured and the filesystem is full.Imported from boykopovar/AnyPS5. Originally posted by ntamas94 on 2026-10-22T13:21:55Z.
Rebased onto #9431's new head (
26d651d3e, onmain7e2ba73e4); both commits applied without conflicts.linear_display_bufferandvideo_out_hdr_presentpass on the new base. Paired validation-layer run, now in the description:main(100% tests passed, main build7e2ba73e4) and this branch (100% tests passed) withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_NO_SHADER_CACHE=1,ANYPS5_REQUIRE_VULKAN=1andVK_LOADER_DEBUG=warn,error,ctest -V, on the NVIDIA GeForce RTX 2080, driver 617.14, Windows 11 (10.0.26200), Vulkan SDK 1.4.363.0: both logs carry the loader'sadding layers "VK_LAYER_KHRONOS_validation"line (78 and 2 times) and neither reportswas not found but was requested by env var VK_INSTANCE_LAYERS;VUID-ids onmain: 0, on this branch: 0, new on this branch: 0.AI-assisted: yes (Claude Code)
🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-24T02:37:27Z.
Review: CHANGES_REQUESTED
Checked the two commits that are this PR's own (
68543e4d87,0eb1dce578). The change itself is right:texelOffset(buffer, x, y, 4u)covers linear, 64 KiB andDisplayTilingGcn, andGcnDisplaypins every pixel of a 1920x1024 GCN buffer throughDisplayBufferOffset, so it fails with the old 64 KiB formula.docs/dev/debt/libSceVideoOut.md:26says "registers asDisplayTilingGcn(next entry)", but there is no next entry in that file. Point it at the "PS4 (GCN) tiling" entry indocs/dev/debt/libSceAgcDriver.mdinstead.mainthrough its base #9431 (GuestTextureResource.hpp). Please rebase onto #9431's refreshed head and rerunlinear_display_buffer; it can merge once #9431 and #9672 have landed.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T10:05:18Z.
Review: APPROVED
Reviewed exact head
643057ce944c6a8c0d8d74eb278b376dd0010295. Currentmain(f7e84c4cf1) is an ancestor;check_main_syncreports a clean merge with no files changed on both sides. The remaining four-file diff routes the 4-byte decode throughtexelOffset, adds a full 1920x1024 GCN-layout round-trip test, and updates the two relevant debt descriptions. Current-main conventions andgit diff --checkpass. The PR reports paired validation-layer runs on the same RTX 2080/Windows setup: the layer was loaded on both trees, 0VUID-IDs on either, plus three focused tests passing on the branch. I did not independently run the GPU tests locally. The prior blockers about #9431/current-main integration, title links, decode-cost documentation, and validation evidence are addressed; approving this head.