fix(agc): COPY_DATA to and from GDS #6549
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6549"
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 notaxeltv on 2026-10-15T20:01:29Z.
What
COPY_DATArejected SRC_SEL/DST_SEL 3 (AMD: GDS). The same host GDS buffer DMA_DATA already uses (GdsAddress, 64 KiB) now serves those selects: validate the offset range, execute the copy, and keep stores into GDS out of ResolveStore/DecodeStores like DMA.PPSA03541 copies a dword from GDS offset 0x20 into guest memory, runs compute, then clears that offset with an immediate. Previously aborted on GDS destination not implemented.
Tested
Windows 10, WinLibs GCC 15.2.0. agc_driver_pm4 passes. tools/check_conventions.py --base upstream/main passes. PPSA03541 (hardlinked Engine modules): past COPY_DATA GDS and HDR present; next stop is MSAA_ENABLE on a single-sample target for primitives other than triangles (register 0x242 = 7, rect list).
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)Made with Cursor
Imported from boykopovar/AnyPS5. Originally posted by coltken95 on 2026-10-15T21:43:07Z.
Tested on Linux x86-64 (Release build, lavapipe / llvmpipe LLVM 20.1.2), with be68cb5a6 merged into main
31cbb55d7:agc_driver_pm4,agc_driver_pm4_failure,agc_driver_pm4_failure_inlineandagc_driver_pm4_priority_refusedpass.agc_driver_pm4fails withCOPY_DATA to GDS resolved as a memory store.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by klosixgaming-arch on 2026-10-17T18:47:26Z.
Tested on PPSA03541 (EA SPORTS UFC 5, content version 01.031.000): Windows 11, RTX 5090, NVIDIA 617.42, WinLibs GCC 15.2.0. I applied the source changes of this PR (Pm4.hpp and Pm4.cpp, without the test, tool and docs changes) to main
66702f1cff. Without it the title aborts about 20 s in with "COPY_DATA at DWORD 71: COPY_DATA GDS or performance-counter destination is not implemented"; with it that abort is gone and the next stop is the MSAA_ENABLE rect list (#6563), as you predicted. With #6563 and #6572 on top the title reaches the logos and the main menu at about 34 fps. Full results are in #7239.AI-assisted: yes. Written with AI assistance and reviewed by me.
Imported from boykopovar/AnyPS5. Originally posted by Neithennn on 2026-10-17T19:39:00Z.
Windows NVIDIA run, since the description lists
agc_driver_pm4only.Windows 11 Pro 26200, NVIDIA GeForce RTX 4080 (driver 617.42), AMD Ryzen 7 5800X, WinLibs GCC 15.2.0 r7, Ninja, Release, bundled dependencies,
BUILD_TESTING=ON,ANYPS5_NO_SHADER_CACHE=1. Headeea461ae3merged onto mainf51724078; full build succeeds.agc_driver_pm4and the otheragc_driver_pm4_*tests (ring, failure, replay, stall watchdog),agc_driver_gds_append_consume: 16/16 pass, withANYPS5_REQUIRE_VULKAN=1.ctest -j 8: 1398/1398. Unchanged main on the same machine: 1398/1398.No title run.
AI-assisted: yes (runs done with Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by janzezno on 2026-10-20T21:25:14Z.
Linux run on AMD; the Tested section covers Windows only.
Host: Arch Linux, kernel 7.2.11, AMD Radeon RX 7900 GRE (RADV NAVI31), Mesa 26.2.5, GCC 16.2.1, Release,
BUILD_TESTING=ON.mainca74ef217; PR head7c9dd449fapplied on top.ctest --test-dir build -R '^agc_driver_pm4.*$' --repeat until-fail:3: 15 of 15 pass, 3 repeats, as onmain. These tests do not open a Vulkan device.ctest -j12: no new failures. The three that fail also fail onmainon this machine:agc_driver_guest_memory_lifetime(#7849),agc_driver_image_array_window_past_layer_limit(#8361) andagc_driver_tessellation(Mesa, #5444).Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-02T21:28:46Z.
Review: DISMISSED
The GDS select is right: select 3 is GDS for both
SRC_SELandDST_SEL(Mesa'ssid.hdefinesCOPY_DATA_GDSas 3 for both).CopyDataSource's(sel << 1) | bit 30gives yourCopyDataSelectGds(6) for select 3, andgdsRangecan't overflow (it checksoffset <= GdsBytesbeforeGdsBytes - offset). Two things need changing, though.It doesn't build on current
main. On Windows 11, WinLibs GCC 15.2.0, with this head merged ontomain,core/libs/prx/libSceAgcDriver/tests/Pm4.cpp:657fails withconflicting declaration 'const auto gdsStore'.main's6ab3606963(2026-10-21) added its ownconst auto gdsStorein the same test function (tests/Pm4.cpp:641onmain). The merge has no textual conflict, and GitHub lists the PR as mergeable. Renaming yours (e.g.copyGdsStore) fixes the build.The "keep stores into GDS out of ResolveStore/DecodeStores like DMA" premise now holds only for
DecodeStores.mainstill dropsDMA_DATAGDS destinations there (Execution/src/Pm4.cpp:780), but since6ab3606963ResolveStoreresolves aDMA_DATAGDS destination toGdsAddress()plus the offset (Execution/src/Pm4.cpp:702onmain), so the store goes throughWriteLabelOnGpuinstead of draining the device, per that commit's message. With this PR, aCOPY_DATAinto GDS still returnsstd::nulloptthere. Could it resolve the same way? Then both GDS writers would take the same path. The same commit's message notes that "every packet that reads the GDS on the CPU drains the pipeline first". Please check thatCOPY_DATAfrom GDS, which reads the GDS block on the CPU incopyDataSource, also drains first, or a GPU-queuedDMA_DATAfill of the GDS could still be in flight when it reads.I haven't run PPSA03541; the above comes from the merged build and
main's source.Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-02T22:14:44Z.
Review: DISMISSED
Reviewed — changes requested
The merged tree does not build:
tests/Pm4.cppdeclaresgdsStoretwice in the same function. With that one name changed locally, the GDS select works,agc_driver_pm4passes, and the test fails as it should when main's production code is put back.What I ran
Head
c74b9dc01c5b9d40e9ff961fae6be8b682580910, merged with--no-ffintomain9090972b7e91fd266819cbd77a8b058e177b5682(merged tree23853b2392a64ad8c3bce2e2d65e237edbbb6bdf). Debian 13 VM, 2× Xeon Gold 6136, GCC 14.2.0, Release, Ninja, lavapipe (Mesa 26.1.6).Results
git diff --checkcheck_conventions.pytests/Pm4.cpp:657: conflicting declaration 'const auto gdsStore'agc_driver_pm4with the local renameBuild error
Negative control output
Negative control
I restored
Execution/include/Pm4.hppandExecution/src/Pm4.cppfrommainand kept the PR's test, with only the local rename so it compiles.agc_driver_pm4failed withCOPY_DATA to GDS resolved as a memory store, so the test covers the change. Afterwards I restored the merged files and rebuilt.git status --porcelainshowed a clean worktree.Findings
Blocking
core/libs/prx/libSceAgcDriver/tests/Pm4.cpp:594, conflicting with:657). This confirms BunnyFl's first point, on Linux with GCC 14.2.0 as well.mainalready declaresconst auto gdsStorefor theDMA_DATAGDS check later intestCopies(). Renaming the PR's variable at lines 594-595 (for example tocopyGdsStore) is the only change needed: with it, the test builds and passes here.Non-blocking
COPY_DATAinto GDS still never resolves as a store, whileDMA_DATAinto GDS now does (core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp:696against:706). This adds detail to BunnyFl's second point. InDriver/Packets/PacketMemory.cpp:175-184, only opcode 0x50 gets thegdsDestination/gdsWritesPending/GdsImportablehandling. ACOPY_DATAto GDS returnsstd::nulloptfromResolveStore, so it always drains and writes on the CPU. That is still correctly ordered, but slower, and it no longer matches the description's "like DMA". A fix: resolve it asGdsAddress() + packet[4]the wayDMA_DATAdoes, and apply the samegdsDestinationchecks to opcode 0x40. Alternatively, update the description and the debt entry to say thatCOPY_DATAinto GDS always drains.COPY_DATAfrom GDS reads throughcopySource, which usesGuestMemory::Read(Execution/src/Pm4.cpp:214,:152-160). This is the same checked path thatDMA_DATAGDS sources use (:170), and opcode 0x40 is not inkeepsDrawPipeline, so the draw pipeline drains before the packet. From reading the code, that answers BunnyFl's concern about reading GDS on the CPU behind a queuedDMA_DATAfill. I did not exercise it on a GPU device.core/libs/prx/libSceAgcDriver/tests/Pm4.cpp:588). oneandonlydean already asked for thisexpectFailureon0x405to be removed, and it is still there at this head.Fixes:checklist line is missing, as fogydes noted. AddFixes: none.Not verified
main: build.json skipped it because no test ran. The changed code is a CP copy path with no shader or pipeline change.agc_driver_pm4_*tests andagc_driver_gds_append_consume: I only rebuilt and ranagc_driver_pm4.To get this to a good state
gdsStoredeclared attests/Pm4.cpp:594, rebase onto currentmain, and confirm the merged tree builds.expectFailure, as requested before.COPY_DATAinto GDS through the same store-resolution path asDMA_DATA, or update the description and debt entry to say it always drains.Fixes:line to the checklist.Imported from boykopovar/AnyPS5. Originally posted by Superseabas on 2026-11-06T13:06:32Z.
Review: APPROVED
Windows run of the current head,
570b4c0307, the first Windows build since thegdsStorerename. The merged tree builds with GCC 16, the GDS round trips pass on an RTX 5070 Ti and on the integrated Radeon of a Ryzen 7 7700X, and each part of the fix but one is caught by the test. One non-blocking suggestion for that part.Head merged onto
main921621976c(clean merge, local only). Windows 11 Home 10.0.26200, WinLibs GCC 16.2.0 (x86_64-ucrt-posix-seh, r3), Release.ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, no missing-layer line,ANYPS5_GPUselecting the device:10de:2c05), 621.011002:164e, integrated), AMD 26.10.2 (32.0.21045.20006)Build. The merged tree builds;
copyFromGdsStoreno longer clashes withmain'sgdsStoreintestCopies(). No compiler warnings in the files this PR changes.Pm4 and GDS tests. The 20 tests matching
pm4|gds(agc_driver_pm4and the otheragc_driver_pm4_*entries,agc_driver_gds_append_consume,agc_driver_gds_dma_fill,_dma_fill_private,agc_atomic_gds_size) pass 3 of 3 on both GPUs, onmainand on this PR.Red checks on
agc_driver_pm4, each a local edit ofExecution/src/Pm4.cppin the merged tree, 3 runs per GPU:Pm4.cppfrommainCOPY_DATA to GDS resolved as a memory storeResolveStore: GDS destinationreturn std::nulloptremovedExecute: destination alwaysaddress(packet[4], packet[5])guest memory is not readable at 0x20 (range 0x20+0x4)copyDataSource: GDS source line removedDecodeStores: GDS destination check removedNon-blocking. The
DecodeStoreschange isn't covered. Without it, aCOPY_DATAinto GDS offset0x20decodes as a store at guest address0x20, andLabelHistory(Driver/Synchronization/LabelHistory.cpp:59) takes that address as a label store. One line after theResolveStorecheck covers it:I tried it locally:
agc_driver_pm4passes with it on this head, and fails with that message once theDecodeStoreschange is removed.Whole AGC set.
ctest -R '^agc' -j 8 --timeout 300, 1,392 tests: 1,390 pass on the RTX and 1,389 on the Radeon. NoVUID-lines. The failures are the onesmainhas on this machine, all tracked:agc_driver_direct_write_completion(#15564),agc_driver_quad_pixel_maskon the RTX (#14341), and on the Radeonagc_driver_scratch_pool(#15566) andagc_driver_sample_order_grid_reference(#9503).check_conventions.py --base mainpasses. PPSA03541 isn't tested here, and neither is BunnyFl's second point, aCOPY_DATAfrom GDS after a GPU-queuedDMA_DATAfill of it.AI-assisted: yes (Claude Code)