fix(agc): load depth planes through a copy image on AMD integrated GPUs #15015
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15015"
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 sharveshprabhu on 2026-11-02T10:14:03Z.
What
On AMD's proprietary Windows driver, a
vkCmdCopyBufferToImageinto a depth image that was drawn, inVK_IMAGE_LAYOUT_GENERAL, leaves some 8x8 tiles that the next depth test treats as holding the depth drawn before the copy, although the copied values read back correctly. This is what failsagc_driver_depth_plane_partial_store_buffer_copyon a Radeon 780M (#13867).On integrated GPUs with that driver (
VK_DRIVER_ID_AMD_PROPRIETARYandVK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU),copyPlane's buffer path now copies the staging buffer into a transfer-only image of the depth format (TRANSFER_DST_OPTIMAL, thenTRANSFER_SRC_OPTIMAL) and from it into the depth plane withvkCmdCopyImage, with the same regions. The image is created once per depth surface, kept by the recorder while a copy uses it, and released with the surface. Copies into colour storage images and stencil planes are unchanged.APS5_NO_DEPTH_UPLOAD_IMAGE=1keeps the direct buffer copy (row added todocs/dev/ENVIRONMENT.md).SetDepthUploadImage(true)forces the path on any device;DepthUploadCount()counts its loads.agc_driver_depth_plane_partial_store_upload_imageruns the partial store test through the path on every device, so lavapipe exercises it too. The test now requires uploads when the path is forced.A standalone Vulkan program (no AnyPS5 code) that draws a 384x200
D32_SFLOATimage at 0.5, copies 0.75 into x 128-255, y 128-199 withvkCmdCopyBufferToImageinGENERAL, then draws at 0.6 withLESS, reproduces it; the validation layer with synchronization validation reports nothing for it:vkCmdCopyImageEach failure is 64 or 128 texels short inside the block and none outside. The program's source can be attached.
Discrete cards don't show it: an RX 9070 XT (RDNA 4, also 32.0.32015.7029) passes the AnyPS5 test and the standalone program at 1000 iterations, and an RX 6700 XT (RDNA 2) passes the AnyPS5 test. So the path is limited to integrated GPUs; if a discrete AMD card shows the stale tiles, the device-type check can be dropped. A Radeon 860M (RDNA 3.5) passes without the path on Adrenalin 26.10.2 (32.0.32015.12012) and with it, while the 780M still fails on that driver, so a driver version check would not separate them; both report Vulkan
driverVersion0x8001a0.Tested
Windows 11 Home 10.0.26300, AMD Ryzen 7 260 with Radeon 780M (
1002:1900,VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU, driver 32.0.32015.12012) and NVIDIA GeForce RTX 5060 Laptop GPU (driver 32.0.16.1742), Release,BUILD_TESTING=ON,ANYPS5_REQUIRE_VULKAN=1.On
main5b1d381d5a, WinLibs GCC 15.2.0 r7 (CI's package), separatectestruns:agc_driver_depth_plane_partial_store_buffer_copy(5 upload image loads per run)APS5_NO_DEPTH_UPLOAD_IMAGE=1(same binary)agc_driver_depth_plane_partial_store_upload_imageagc_driver_depth_plane_partial_store_image_copyagc_driver_depth_plane_partial_store_unimportedagc_driver_depth_plane_partial_store_buffer_copy(0 upload image loads)agc_driver_depth_plane_partial_store_upload_imagectest -R depth: 65 of 65 pass on both GPUs.main5b1d381d5a, MSYS2 UCRT64 GCC 16.2.0 build,ctest -R depth -VwithVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(MSYS2 1.4.363),ANYPS5_NO_SHADER_CACHE=1,VK_LOADER_DEBUG=layershowing the layer inserted in every test and nofailed to loadorwas not found but was requested by env var VK_INSTANCE_LAYERS:main63 of 64 and the change 64 of 65 pass on both GPUs, the rest skipped (agc_driver_native_depth_driver_queued_fill, on both sides), 0VUID-lines on either side.main88e804b0a7:_buffer_copy0 of 100, 8 of 40 withAPS5_NO_DEPTH_UPLOAD_IMAGE=1;ctest -R "agc_\|video_out\|shader"1315 of 1316 on the 780M (agc_driver_sample_order_grid_referencefails as in #12277, also without this change), 1316 of 1316 on the RTX 5060.main88e804b0a7, WSL Ubuntu 24.04 with lavapipe (Mesa 25.2.8), GCC 13.3, the Linux job's configure flags plus-DANYPS5_ENABLE_SPIRV_TOOLS=ON,ANYPS5_REQUIRE_VULKAN=1 GALLIUM_OVERRIDE_CPU_CAPS=avx ctest -R depth: 50 passed, 2 skipped (check_skips.py: expected);_upload_imagemade 5 loads through the image,_buffer_copynone.python3 tools/check_conventions.py --base origin/mainandpython3 tools/check_test_registration.pypass.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 BunnyFl on 2026-11-02T11:27:17Z.
Review: APPROVED
Looks right to me, with a data point from a second AMD generation on the same driver.
Code. The upload image goes
UNDEFINED → TRANSFER_DST_OPTIMAL → TRANSFER_SRC_OPTIMALfor each copy and only the copied regions are read back, so the undefined contents outside them never reach the depth plane. Re-entering fromUNDEFINEDwith source stageTRANSFERalso orders the reuse after the previous copy's read. Colour storage and stencil copies keep the direct path, the recorder keeps the image alive while a copy uses it, and it's released with the surface.Tested on Windows 11, WinLibs GCC 15.2.0, Release, AMD Radeon RX 9070 XT (RDNA4,
VK_DRIVER_ID_AMD_PROPRIETARY, driver 32.0.32015.7029, the same version as your 780M), withANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation:main,agc_driver_depth_plane_partial_store_buffer_copypassed 20 of 20 runs. The stale-tile bug doesn't reproduce on RDNA4 with this driver.59f84aa1e5merged ontomain, theunimported,buffer_copyand newupload_imagetests passed 20 of 20 runs each. The buffer cases report5 upload image loads, so the new path is taken on this device. No log has aVUID-orSYNC-HAZARDline.Non-blocking: since RDNA4 doesn't show the bug, the workaround could be keyed more narrowly than the whole driver ID. That said, it costs one extra image copy per depth upload and stays correct where it isn't needed, and the opt-out variable is there, so applying it to all AMD proprietary drivers seems a reasonable default until more devices are measured.
Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-04T15:37:53Z.
Review: APPROVED
@sharveshprabhu re-checked at
226d4869ff.git range-diffof my approved59f84aa1e5against this head shows two changes to this PR's own patch:core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp:1490addsdeviceType == VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU). That matches the runs in this thread: the 780M fails without it, and the 860M and discrete cards don't need it.main'simage_copyvariant next to the newupload_imageone, anddocs/dev/ENVIRONMENT.mddescribes the narrower scope.What I ran: head
226d4869ffmerged ontomainb11c7bf84f(merge8444a96394), Windows 11, WinLibs GCC, Release, AMD Radeon RX 9070 XT (discrete), driver 32.0.32015.12012, withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation:agc_driver_depth_plane_partial_store*: 5 of 5 pass on the merge, 4 of 4 onmain(theupload_imagetest is new). Neither log has aVUID-orSYNC-HAZARDline or a missing-layer line.main: 0 upload-image loads inagc_driver_depth_plane_partial_storeand_unimported, with the same shader-pass and direct-copy counts asmain._upload_image, which forces the path, reports 5 upload-image loads and passes. So this card exercises the path itself only through the forced test, not through the device check.pr_overlap.py --branch: 88 open PRs touch the same files, none the same exports.