fix(agc): key shader modules by the pipeline library mode #6436
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6436"
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 LeandroLP23 on 2026-10-15T15:04:44Z.
What
Carries @PYTHONRETARDE's workaround for #4768 (and #5271), with his authorship. He offered it in #4768 while he can't open another PR.
AMD's Windows driver compiles pipelines differently when
VK_EXT_graphics_pipeline_libraryis enabled on the device. Its on-disk cache (%LOCALAPPDATA%\AMD\VkCache) doesn't key on that, a finding by @simonbronk. A process in one mode is then served pipelines compiled in the other, and their writes never land. That's why identical test executables pass or fail depending on which GPL mode filled the cache first, and whyagc_driver_layered_volume_vertex_no_gplfails in every full run on AMD Windows.6d25bbe34(PYTHONRETARDE): with the library feature off, every shader module flips bit 15 of the SPIR-V generator word (header word 2) beforevkCreateShaderModule. No driver interprets that word, but it changes the module bytes, so the two modes get separate cache entries. It covers the recompiled compute and graphics programs and the embedded shaders (colour transfer, detile, CMASK clear, sample counter and dumps, mesh arguments, presentation), throughGraphics::CacheKeyedSpirvinContext.hpp.28ce7bc0b(mine, after review):Graphics::CreateShaderModuleinContext.hppnow keys the word and creates the module in one place. Every module the driver creates goes through it: the sites above, the six added tomainsince (splitComputePipeline, multisample readback, dispatch arguments, texture repack, the performance overlay), and the inline copies inPipeline.cppandcreateComputePipeline.agc_driver_graphicschecks the key through a mockvkCreateShaderModule.f7b8ea1cb(mine): the compute pipeline replay (ComputePipelineReplay) creates its module the same way, so a replay with the feature off hits the same cache entries as the run it reproduces. That module creation was added tomainafter the original commit.The cost is one copy of the SPIR-V per module creation with the feature off. Nothing changes with it on.
Tested
RX 7800 XT (RDNA 3,
1002:747e, driver 32.0.31041.1004, Windows 11 Pro 26200), by @PYTHONRETARDE on839d2424. Each sequence starts from an emptyVkCacheand runs the four fixtures of #4768 in every step:mainHe also ran a full CTest from an empty
VkCache: 1245 of 1247, both failures unrelated.Radeon 860M (RDNA 3.5,
1002:1114, driver 32.0.13058.8001, Windows 11 26300), WinLibs GCC 15.2.0, Release:d92a8dad3(#4768):mainfails the mode that differs from the one that filled the cache, 4/4. The commit passes 4/4 in every step of both sequences.mainff23657f3+ both commits): the same two sequences pass 4/4 in every step, 24 of 24 runs.ctest -R '^agc_' -j 1from an emptyVkCacheandtests/shader_cache: 593 of 596 pass.agc_driver_layered_volume_vertex_no_gplpasses; it fails in every full run onmainon this machine. The three failures are unrelated:agc_driver_quad_pixel_mask: AMD, fixed by #6255;agc_driver_store_over_untracked(the first result was not stored): #6347;agc_driver_pm4_replay_tool: a staleagc_pm4_replaybinary from an earlier build. It passes once the tool is rebuilt.tools/check_conventions.py --base origin/mainpasses;git diff --checkis clean.Not tested: NVIDIA, Intel, any title. @thuanquang ran the four #4768 fixtures and the full suite on an RX 6700 XT (RDNA 2): every GPL sequence passes,
agc_driver_layered_volume_vertex_no_gplfails on the base and passes here. @savvaniss ran both sequences on an RX 9070 XT (RDNA 4, driver 32.0.31041.1004): the base fails the mode that differs from the one that filled the cache, this head passes 4/4 in every step.Fork CI (run): linux (including
agc_compute_pipeline_replay), windows and the three relinker jobs pass everything exceptconventions_ci_gateandbuild_eligibility, which fail only on the fork's older workflow.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 github-actions[bot] on 2026-10-15T15:12:33Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libSceAgcDriver/Execution/src/PresentationPass.cppL73-80core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppL4874-4878core/libs/prx/libSceAgcDriver/Graphics/include/Context.hppL22core/libs/prx/libSceAgcDriver/Graphics/src/GpuColorTransfer.cppL31-34core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppL361-365core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppL2078-2081, L2097-2099, L2394-2397core/libs/prx/libSceAgcDriver/Graphics/src/TextureDetiler.cppL92-95, L171-174, L350-354core/libs/prx/libSceAgcDriver/Graphics/include/Context.hppL339core/libs/prx/libSceAgcDriver/Graphics/src/TextureDetiler.cppL170-174Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Context.hppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Context.hppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/src/TextureDetiler.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GpuColorTransfer.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Context.hppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Context.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/src/TextureDetiler.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Context.hppcore/libs/prx/libSceAgcDriver/Graphics/src/TextureDetiler.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Context.hppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Context.hppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppImported from boykopovar/AnyPS5. Originally posted by PYTHONRETARDE on 2026-10-15T17:40:57Z.
Thanks for carrying it and for the 860M runs. Keep #6436 open, no need to wait for #6173.
Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-15T19:35:21Z.
An RDNA2 run, the architecture #4768 was first seen on: with this change both GPL modes work on a discrete RX 6700 XT.
Setup: AMD Radeon RX 6700 XT (gfx1031,
1002:73df), Adrenalin 26.8.1 (driver 32.0.21045.5002), Windows 11 26200, WinLibs GCC 15.2.0 r7, Release,BUILD_TESTING=ON,ANYPS5_REQUIRE_VULKAN=1. Base:mainfa9365ca7with #6452 merged, becausemaindoes not compileGpuIndirectArgumentsMisalignedWriterAhead.cppwith MinGW (requested alignment '65536' exceeds object file maximum 8192); this headf7b8ea1cbmerged on top.VkCachewas not emptied; earlier full-suite runs on this machine had filled it.The four fixtures of #4768 (
agc_driver_alpha_to_coverage,agc_driver_buffer_load_store,agc_driver_wave32_exec_lane_bits,agc_driver_layered_volume_vertex),ANYPS5_NO_SHADER_CACHE=1,ctest --parallel 1per step, each sequence twice:The base's GPL-off runs report
buffer load store wave32: lane 0 load_ubyte is 0xdeadbeef, expected 0x00000000,wave32 lane 0 is 3735928559, expected 64andvertex draw: slice 1 texel (0, 0) channel 0 is 64, expected 255 (the band of layer 0).Full suite,
ctest --parallel 4 --timeout 120, 1296 tests on both:agc_driver_layered_volume_vertex_no_gplfails on the base and passes with this change (5/5 alone).agc_driver_pixel_interlockandagc_driver_lds_mixed_width_atomicsfail on both (#5271).agc_driver_same_queue_label_waitfailed once in this change's run. It is intermittent on the base too: 1 of 20 alone fail there, 20 of 20 pass alone with this change.conventions_function_bodies*andhardware_oracle_comparehit their 30 s and 20 s limits on this machine in both runs; unrelated.Not tested: a run from an empty
VkCache, and any title.AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-16T13:58:38Z.
Rebased onto
main82ddae75b: #5875 moved compute pipeline creation intocreateComputePipeline, so the keyed module now lives there. The journal's prebuild goes through it as well.Retested on the rebased head
719f8dffe, Radeon 860M (driver 32.0.13058.8001, Windows 11 26300), WinLibs GCC 15.2.0, Release:VkCache(off → on → off, on → off → on), with the four #4768 fixtures in every step: 4/4 pass in every step, 24 of 24 runs.agc_pipeline_library_off,agc_driver_layered_volume_vertex_no_gplandagc_compute_pipeline_replaypass. The failures areconventions_ci_gateandbuild_eligibility(fork-only) andagc_driver_graphics, which fails onmaintoo (#6792, fixed by #6789).GpuIndirectArgumentsMisalignedWriterAhead.cpp(alignas(65536)over MinGW's 8192 limit), unchanged frommainand addressed by #6452. Everything else builds.Imported from boykopovar/AnyPS5. Originally posted by savvaniss on 2026-10-16T20:58:33Z.
RDNA 4 data point: with this change both GPL modes work on an RX 9070 XT.
AMD Radeon RX 9070 XT (
1002:7550), driver 32.0.31041.1004 (Vulkan driver info 26.8.1), Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release. Base:maina7f108030+ #6452 (4fe92c9c2, needed to build on Windows); this head719f8dffemerged on top. The four #4768 fixtures (agc_driver_alpha_to_coverage,agc_driver_buffer_load_store,agc_driver_wave32_exec_lane_bits,agc_driver_layered_volume_vertex),ANYPS5_NO_SHADER_CACHE=1,ctest --parallel 1,VkCacheemptied at the start of each sequence.The base failures are those of #4768:
lane 0 load_ubyte is 0xdeadbeef,wave32 lane 0 is 3735928559, expected 64,holds half 0x0000, expected 0.5andslice 1 texel (0, 0) channel 0 is 64, expected 255.agc_pipeline_library_off,agc_driver_layered_volume_drawandagc_driver_layered_volume_vertex_no_gplpass ×3. Full CTest with this PR, #6255 and #6647 together, from an emptyVkCache: 1338 of 1339 (select_tests, symlink privilege on this machine). Onmain406fd9ea9the full run failedagc_driver_layered_volume_vertex_no_gpl.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-18T20:33:01Z.
Another data point, on current
main: this PR fixesagc_driver_layered_volume_vertex_no_gplon the Radeon 860M. That test fails onmainthere every time (#5271).Radeon 860M (RDNA 3.5), driver 32.0.13058.8001, Windows 11 26300, WinLibs GCC 15.2.0 r7, Release. Same
maincommitfb9a1eb8f, with and without this PR (719f8dffe), clean merge. I rebuilt the test executable each time I switched, and went main → PR → main → PR.layered_volume_vertex_no_gpllayered_volume_draw,_vertex,_submitmainslice 1 texel (0, 0) channel 0 is 64, expected 255)main+ this PRmain)This matches @thuanquang's RX 6700 XT measurement in #7376: the layered-volume failures are the GPL cache-order effect, and with this PR they're gone. Together with #7623, that is what #7376 needs before #7351's AMD
robustBufferAccess2exclusion can go.AI-assisted
Imported from boykopovar/AnyPS5. Originally posted by MaxLikesCode on 2026-10-19T03:38:00Z.
A non-AMD check that the flipped generator word is harmless: NVIDIA GeForce RTX 4090, driver 617.42, Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release,
BUILD_TESTING=ONwith every execution test built. This head (719f8dffe) merged intomainad502d717.*_no_gpltests in the selection pass, so NVIDIA's driver accepts the modules with bit 15 of the generator word flipped.tools/select_tests.pyselects: 955 pass, 15 skip and 5 fail.agc_driver_bda_device(#7584),agc_driver_image_table_reuse(#7710) andagc_driver_pixel_lds(#7708) fail onmainon this GPU too.agc_driver_flip_stores_small_resultsandagc_driver_storage_file_writefailed once in the parallel run, at about 6 s, and pass when rerun alone (6 of 6 for the first). I take them for load-dependent.tools/check_skips.py --job windowsaccepts the skips.#6262 makes the same change; this result should hold for it too.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-19T08:10:36Z.
Another test this fixes on AMD's Windows driver, with a harder symptom than wrong pixels:
agc_driver_stencil_replay(the executable behindagc_driver_stencil_replayandagc_driver_stencil_replay_no_gpl). RX 6700 XT (gfx1031), driver 32.0.21045.5002, Windows 11 26200. Each sequence runs one renamed copy of the executable, so the driver cache starts empty:main7f596df48+ #7769main7f596df48+ #7074 + #7725 + this PR (719f8dffe)vkQueueSubmit recorder: Vulkan result -4So without this change the second GPL mode loses the device here, not only renders wrong. The other PRs in both trees touch neither pipelines nor shader modules: #7769 is a storage-flush wait, #7074 the f16 fma NaN translation, #7725 one stencil refusal.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T15:43:59Z.
Thanks for carrying this.
mainhas added sixvkCreateShaderModulecalls since this branch's base, and they don't go throughCacheKeyedSpirvyet:splitComputePipelineinExecution/src/VulkanDevice.cpp(recompiled compute programs),Graphics/src/MultisampleReadback.cpp(readback depth/uint), the dispatch-arguments module inGraphics/src/Recorder.cpp, the texture-repack module inGraphics/src/TextureDetiler.cpp, and the two modules inExecution/src/PerformanceOverlay.cpp. On AMD's Windows driver these would still share cache entries across GPL modes. Could you rebase and key them too? Routing every module creation, including the inline copies inPipeline.cppandcreateComputePipeline, through the one helper would keep new call sites from missing it.Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-20T16:41:37Z.
Done. The branch is rebased onto
main75787d2f6; the two original commits applied cleanly. A new commit,28ce7bc0b, routes every module creation through one helper.Graphics::CreateShaderModule(create, device, graphicsPipelineLibrary, code, bytes, operation)keys the generator word, creates the module and checks the result. AContextoverload fills in the first three arguments. It replacesCacheKeyedSpirv, so the key now exists in a single place.splitComputePipeline, the two multisample readback modules, dispatch arguments, texture repack, and both performance overlay modules.Pipeline.cpp(graphics programs) andcreateComputePipeline, the compute pipeline replay, and the sites that already usedCacheKeyedSpirv: color transfer, detile, detile image, CMASK clear, sample counter and dumps, mesh arguments, presentation.VkShaderModuleCreateInfonow appears only in test fixtures.agc_driver_graphics, through a mockvkCreateShaderModule: with libraries on, the module bytes are unchanged; without, only bit 15 of word 2 flips; the source words stay intact. Negative control: with the flip disabled, it fails witha shader module without graphics pipeline libraries kept the generator word of the other mode.Tested on a Radeon 860M (
1002:1114, AMD driver 32.0.13058.8001), Windows 11 26300, WinLibs GCC 15.2.0, Release,ANYPS5_REQUIRE_VULKAN=1:ctest -R "agc|shader|spirv|recomp" -j4: 841 of 842 pass, 3 skipped for device features. The one left isagc_driver_image_array_window_past_layer_limit, which doesn't compile under MinGW (requested alignment '65536' exceeds object file maximum 8192), also onmain.agc_driver_layered_volume_draw_tests.exeso the driver cache starts empty, run twice each. Every step exits 0:--vertex-only), on, on (--vertex-only), off (--vertex-only);--vertex-only), off (--vertex-only), on.--vertex-onlyalone withAPS5_NO_GPL=1: passes, 3 of 3.One caveat. Before I cleared the driver cache, this machine's existing AMD cache for
agc_driver_layered_volume_draw_tests.exemadeagc_driver_layered_volume_vertex_no_gplfail 3 of 3 with the rebased original commits:vertex draw: slice 1 texel (0, 0) channel 0 is 64, expected 255.mainpassed 3 of 3 on that same cache. With%LOCALAPPDATA%\AMD\VkCachemoved aside (and restored afterwards), the PR passed 3 of 3. That cache had been filled by many builds of the same test binary today, and I couldn't reproduce how the bad entry got there, not even with concurrent runs. Flagging it in case it shows up for someone else as a first-run failure after switching to this branch.AI-assisted: yes (Claude Code)