fix(agc): skip the pixel interlock test where BDA atomics are not atomic #8014
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8014"
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 011010 on 2026-10-19T17:42:29Z.
What
A global (flat) atomic reaches its target through a Vulkan buffer device address (
OpConvertUToPtrover aPhysicalStorageBufferpointer), so the read-modify-write is atomic only where the driver guarantees atomics on such an address. MoltenVK does not: Metal has no atomic on a device pointer, so the update becomes a load and a store and concurrent updates to one address are lost.agc_driver_pixel_interlockis the only test that counts overlapping updates to one address, and it cannot run on MoltenVK: the fragment shader updates a storage buffer atomically, so SPIRV-Cross puts a raster order group on that buffer, and MoltenVK passes the descriptor set as an argument buffer, where Metal rejects the attribute. The test checks that first (RasterOrderGroupUsable) and skips with the reason the run actually fails, then checks the atomics (BdaAtomicsUsable) for a device that compiles the pipeline but cannot order the update. Both limitations are recorded in the technical-debt file.No other test covers the contended case:
agc_driver_global_atomicsgives every lane its own address (op * OpStride + tid * 8u), so it checks the value of an uncontended read-modify-write and cannot tell an atomic from a load and a store. A title that counts or locks through a flat atomic on macOS therefore sees lost updates; no title has been measured to quantify it.The argument-buffer compile error that also fails this test on MoltenVK is not fixed here: the
raster_order_groupis added by MoltenVK's own SPIRV-Cross, and resolving the atomic to a descriptor-bound buffer instead of a device address would change the BDA table ABI (BdaAbi::Rangecarries a flat device address).Tested
Linux (Ubuntu 24.04.5, x86-64, GCC 13.3.0, CMake 3.28.3, Ninja 1.11.1), device: lavapipe (Mesa 25.2.8, LLVM 20.1.2, Vulkan 1.4.318), with
ANYPS5_REQUIRE_VULKAN=1andANYPS5_NO_SHADER_CACHE=1:main, before the change:agc_driver_pixel_interlockpasses — the counter counts all 64 overlapping read-modify-writes and the killed BDA fault is reported (pixel interlock tests passed: 10 draws of 64 overlapping triangles over 2048 pixels, 2 of them with a killed BDA fault in every 8th column).VK_DRIVER_ID_MESA_LLVMPIPE.agc_bda_atomicsandagc_raster_order_grouppass.VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validationon both: the same singleVUID-VkDeviceCreateInfo-pNext-pNext(the validation layer of Vulkan 1.3.275 does not know a structure type the driver passes) before and after, so the change adds no validation error.macOS (Apple M4, macOS 27.0.1 (26A434), x86-64 under Rosetta 2, Apple clang 21.0.0, CMake 4.4.4, Ninja 1.13.2), device: MoltenVK 1.4.2 from the LunarG Vulkan SDK 1.4.363.0, with
ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(the loader inserted the layer in both runs; neither log containswas not found but was requested by env var VK_INSTANCE_LAYERS):mugurc/ci/macos-series-2ata0a9e8398plus theJit.cppandGuestMemoryLifetimeSupport.hppparts of #7332, because the series does not build on macOS without them (MFD_CLOEXECis Linux-only inlibkernel/DirectMemory/Jit.cpp).agc_driver_pixel_interlockfails withAGC graphics: vkCreateGraphicsPipelines: Vulkan result -3, after MoltenVK reportstype 'const constant spvDescriptorSetBuffer0 &' is not valid for attribute 'buffer'withfield with illegal attribute 'raster_order_group' declared here. The run never reaches the counter, so it shows no lost update.skipped, the device does not support the raster order group the pixel interlock needs.VUID-errors in both logs, so the change adds no validation error.python3 tools/check_skips.py <junit> --job linuxaccepts the skip as a device limitation.Windows (Windows 11 Home 26300, WinLibs GCC 15.2.0, Release,
BUILD_TESTING=ON, RTX 5070 Ti NVIDIA 617.42 and the AMD Radeon iGPU RDNA2 with the AMD proprietary driver 2026.04.17,ANYPS5_REQUIRE_VULKAN=1, by @wachi35676):agc_bda_atomics,agc_raster_order_group,agc_driver_pixel_interlockand the fouragc_driver_global_atomics*tests pass on both GPUs, andagc_driver_pixel_interlockruns rather than skips.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 wachi35676 on 2026-10-19T23:12:58Z.
Windows NVIDIA and AMD check, and two points about the skip.
Windows 11 Home 26300, WinLibs GCC 15.2.0, Release,
BUILD_TESTING=ON. The base ismain9127ea36dwith4fcacc95amerged. The head conflicts withmainindocs/dev/debt/libSceAgcDriver.md, where its entry meets the entries added at the end of the file. I kept both sides to build.GPUs: RTX 5070 Ti (NVIDIA 617.42) and the AMD Radeon iGPU (RDNA2,
1002:13c0, AMD proprietary driver 2026.04.17,ANYPS5_GPU=AMD). Run withANYPS5_REQUIRE_VULKAN=1.agc_bda_atomics,agc_driver_pixel_interlockand the fouragc_driver_global_atomics*tests pass on both GPUs.agc_driver_pixel_interlockruns rather than skips, as it should off MoltenVK:pixel interlock tests passed: 10 draws of 64 overlapping triangles over 2048 pixels, 2 of them with a killed BDA fault in every 8th column.Points from the description itself:
vkCreateGraphicsPipelines: Vulkan result -3, which is MoltenVK'sraster_order_groupargument-buffer error. That run never reaches the counter, so it shows no lost update. The test fails for another reason than the skip message gives (the device does not support atomics on buffer device addresses), and the skip hides that pipeline failure too.BdaAtomicsUsable. On MoltenVK the driver still runs flat atomics through a BDA without refusing, so the lost-update case is a silent stub. The debt entry describes it, but it is not listed under silent stubs.AI-assisted: yes (Claude Code); results above were run on this machine.
Imported from boykopovar/AnyPS5. Originally posted by 011010 on 2026-10-20T04:34:52Z.
Rebase done, both points addressed, re-verified
Rebased onto current
main(6da6637b4, two commits, no conflicts). The conflict indocs/dev/debt/libSceAgcDriver.mdis resolved by keeping the entries that landed there and appending this one.The skip and the failure it hides. You are right that they are different failures and that the macOS before/after shows only the second one turning into a skip. The functional entry now says it instead of leaving it implicit: on MoltenVK
agc_driver_pixel_interlockfails atvkCreateGraphicsPipelineswithVulkan result -3, because SPIRV-Cross refusesraster_order_groupin an argument buffer, and the skip covers that failure too, so on macOS neither it nor the lost updates are visible. The atomics claim no longer rests on that run; it rests on the mechanism, Metal having no atomic on a device pointer, so the read-modify-write becomes a load and a store. I did not move the skip past the pipeline creation, because that would make the test fail on macOS for something it does not measure, and the pipeline failure is now recorded as a separate unfixed item.The driver not refusing. Now listed under "Silent stubs", with why
agc_driver_global_atomicscannot cover it (every lane has its own address). Making the driver refuse is a larger change than this pull request: the shader recompiler would have to reject a flat atomic whenBdaAtomicsUsableis false, and a title that only increments a counter would then throw at compile time instead of counting wrong. I would rather do that in its own pull request with the titles it affects measured; say the word and I will open it.Re-verified on the rebased head
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1:agc_bda_atomics, the fouragc_driver_global_atomics*andagc_driver_pixel_interlock→ 6/6 passed. The interlock runs rather than skipping and passes in 2.83 s.agc_bda_atomicspassed in 0.07 s andagc_driver_pixel_interlockpassed in 1.47 s, both running rather than skipping.Thanks for the NVIDIA and AMD check; it is the only Windows evidence in the thread.
Imported from boykopovar/AnyPS5. Originally posted by 011010 on 2026-10-20T05:02:13Z.
mainmoved again while this was open, adding two entries to the same debt file, so this is rebased again ontob1ad467da(9e1e23d8f, one commit, the two of us squashed into one as in the original head). Re-ran the same checks on the new base:agc_bda_atomics, the fouragc_driver_global_atomics*andagc_driver_pixel_interlock-> 6/6 passed.agc_bda_atomicspassed in 0.04 s andagc_driver_pixel_interlockpassed in 1.07 s, both running rather than skipping.Imported from boykopovar/AnyPS5. Originally posted by 011010 on 2026-10-20T19:56:06Z.
Adding the half that was still missing from your first point, on top of the response above rather than in place of it.
The skip now names the failure the run reaches, and the check that decides it is separate from the atomics:
RasterOrderGroup.hpp/RasterOrderGroupUsable(VkDriverId)covers the pipeline failure: SPIRV-Cross putsraster_order_groupon the storage buffer the fragment shader updates atomically, MoltenVK passes the descriptor set as an argument buffer, and Metal rejects the attribute.BdaAtomics.hpp/BdaAtomicsUsable(VkDriverId)stays behind it for a device that compiles the pipeline but cannot order the update, with its own message.agc_raster_order_groupandagc_bda_atomics.The technical-debt entry keeps the account you and I converged on — the skip covers the argument-buffer failure and neither is fixed here — and records which check fires first, so the reason in the output and the reason in the entry agree.
Re-verified on the rebased head:
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1:agc_bda_atomicspassed,agc_raster_order_grouppassed, andagc_driver_pixel_interlockran rather than skipped (pixel interlock tests passed: 10 draws of 64 overlapping triangles over 2048 pixels, 2 of them with a killed BDA fault in every 8th column).VK_LAYER_KHRONOS_validationinserted andVK_LAYER_PATHset: the test skips with the new message, 0VUID-errors, and both unit tests pass.python3 tools/check_conventions.py --base origin/main: all conventions checks passed.check_skips.pyaccepts the new message as a device limitation.The driver still does not refuse, and the global atomics entry stays under Silent stubs as you asked. The refusal remains the separate change I offered above, and it is unaffected by this one.
Imported from boykopovar/AnyPS5. Originally posted by 011010 on 2026-10-21T02:59:45Z.
Rebased onto
main5d10ea9ea; a duplicated debt entry removedWhile re-checking the branch I found a defect from the previous rebase:
docs/dev/debt/libSceAgcDriver.mdlisted the same Global atomics on buffer device addresses bullet twice under Silent stubs, the earlier wording and the final one. The head now carries the final wording once, and the blank line the rebase had dropped before the Long Windows pipeline-cache paths entry is back. The diff againstmainis additions only (9 files, 136 insertions, 0 deletions).The branch is rebased onto
main5d10ea9eaas two commits (6d0d7d30b,cdabc0f83), with no conflicts.Re-verified on the rebased head
Windows 11, WinLibs GCC 15.2.0, RTX 3050,
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1:agc_bda_atomicspassed (0.03 s).agc_raster_order_grouppassed (0.03 s).agc_driver_pixel_interlockpassed (0.62 s) and ran rather than skipping:pixel interlock tests passed: 10 draws of 64 overlapping triangles over 2048 pixels, 2 of them with a killed BDA fault in every 8th column.The rebase changes only that debt file, so the code is unchanged from the previous head and the Linux/lavapipe and macOS validation evidence above still applies. I could not repeat the validation-layer runs here: this Windows machine has
vulkan-1.dllbut noVkLayer_khronos_validation.dll.tools/check_conventions.py --base origin/maindoes not complete on Windows for this tree, unrelated to this branch; I filed #8848 with the traceback and a verifiedgit grep -falternative. Conventions is therefore the CI result, which is green on this head.