fix(agc): build one compute pipeline when results differ only in a table's size #8212
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8212"
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 Ryongen on 2026-10-20T03:26:12Z.
What
Compute pipelines and their journal modules were keyed on
RecompileResult::Identity(), which includes the element count of every binding.DescribeSetLayoutsgives image, storage image and sampler tables a fixed-capacity layout, so two results that differ only in a table's size build the same pipeline, but each size got its ownVkPipelineand its own module inpipelines.journal. Compute pipelines and the journal's compute records now key onDescribedPipelineIdentity: the same hash with the element count of those three table roles left out. Other binding counts, kinds, specialization constants and the subgroup width still count. The hash lives in the driver, so the shader cache version is unchanged. The journal format goes from 9 to 10, so existing journals are started over. #6612, #6959 and draft #6947 also move the journal format; whichever lands first keeps 10 and the others take the next free number.Tested
main. Before it, one 1,539,381-word compute pipeline was created 327 times from byte-identical inputs (118 times by the journal replay, 209 in game), and the journal held that module 118 times: 1,328 MiB, 65 % of a 2 GiB cap, 976 modules of which 755 were distinct. With it, over three runs every compute pipeline was created once per distinct pipeline, and the journal kept one copy of each module.agc_pipeline_journal: the described identity ignores the element count of each table role, still changes with a buffer binding's count, with specialization constants and between a sampled and a storage image table, and equalsIdentity()for results without tables. Two compute results that differ only in an image table's size are recorded as one pipeline and one module and reload without drops. Negative control: with the count put back into the described identity,agc_pipeline_journalfails ("a table's element count entered the described identity").main(cecb540a6) and on this change, same machine, withANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation:ctest --test-dir build -R "agc_pipeline_journal|agc_driver_pipeline_journal|agc_pipeline_cache|compute" -V. 20 of 20 pass on both and the layer loads on both. Both logs have the same validation messages and no new ones: 102 ×VUID-VkDeviceCreateInfo-pNext-pNextand 51 ×VUID-VkPhysicalDeviceProperties2-pNext-pNext. (ImageArrayWindowPastLayerLimit.cppfrommaindoes not compile with MinGW GCC 15 here, "requested alignment '65536' exceeds object file maximum 8192", onmainas well; it is not one of these tests.)ctest -R agc -j8on this change before this rebase (a020d0256): 816 of 819. The three failures fail the same way onmainon this machine:agc_driver_msaa_dcc_clear_4andagc_driver_pass_input_hazard("multisampled DCC target reuse requires watched guest memory", checked on500cc640b), andagc_driver_indirect_arguments_pending_producer(device lost in a host import's settle wait, 3 of 3 ona020d0256).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 Ryongen on 2026-10-20T04:12:16Z.
Checked the pull requests the overlap check could not compare. None changes how compute pipelines are keyed. #5925 moves
ComputePipelineKeywithComputePipelineKey::Ofstill onshader.Identity(), so whichever of the two lands second needsOfto useDescribedPipelineIdentity; if #5925 goes first I'll rebase this one onto it.Imported from boykopovar/AnyPS5. Originally posted by wachi35676 on 2026-10-20T12:31:46Z.
Ran on the two GPUs not yet covered here: Windows 11 26300, RTX 5070 Ti (617.42) and AMD Radeon iGPU
1002:13c0(RDNA 2, AMD Windows driver 32.0.21042.62,ANYPS5_GPU=AMD). WinLibs GCC 15.2.0, Release,BUILD_TESTING=ON,ANYPS5_REQUIRE_VULKAN=1,main02fb1ce53with this PR (01bbd93c8) merged.DescribeSetLayoutstakes theImageTableandImageStorageTablebindings atimageTableCapacity/StorageTableCapacity(context)andSamplerTableatsamplerTableCapacity. Table counts don't add tostageResources, so they can't flipupdateAfterBind. SomainKey, and with it theComputePipelineObjects::layouta reused pipeline carries, doesn't depend on a table's count.ctest -R "agc_pipeline_journal|agc_driver_pipeline_journal|agc_pipeline_cache|compute": 20/20 pass on each GPU.DescribedPipelineIdentity,agc_pipeline_journalfails:a table's element count entered the described identity, which the fixed-capacity layout does not see.ctest -R "agc|shader|spirv|recomp" -j6, 833 tests: RTX failsagc_driver_pass_input_hazardandagc_driver_sgpr_pattern_fill_keys, the iGPU failsagc_driver_mul_lo_u16_high_halfandagc_driver_sgpr_pattern_fill_keys. Both sets are the same asmainon this machine, so no new failures.Not run here: a title (no PPSA26344).
AI-assisted: yes (Claude Code); results above were run on this machine.
Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-02T21:43:37Z.
Review: APPROVED
Reads right. On current
main,DescribeSetLayouts(core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp) describes the three table roles with fixed counts (context.samplerTableCapacity,context.imageTableCapacity,StorageTableCapacity(context)), and only the other roles usebinding.count. The image table'sVARIABLE_DESCRIPTOR_COUNTis chosen at descriptor-set allocation, not in the pipeline. So a table's element count never reaches the pipeline layout, and keying compute pipelines and their journal records onDescribedPipelineIdentitymerges only results the driver would build identically. The new identity mixes the same SPIR-V hash, specialization constants, subgroup settings, workgroup memory and per-binding set/binding/kind as before, leaving out only those three roles' counts, and the test checks that it equalsIdentity()for a result without tables.main's journalFileFormatis still 15 (Graphics/src/PipelineJournal.cpp), so the bump to 16 doesn't collide today.Tested on Windows 11, WinLibs GCC 15.2.0, with this head merged onto
main:agc_pipeline_journal,agc_pipeline_journal_long_pathsandagc_pipeline_journal_extended_pathspass, nothing skipped; the long-path run loads its journals through a\?\path.Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-02T22:02:03Z.
Review: APPROVED
Reviewed — approved
Compute pipelines and their journal records now use
DescribedPipelineIdentity, which leaves out the element count of image, storage image and sampler tables. The pipeline layout never sees those counts, so the change merges only pipelines that would be built identically. It builds, the focused tests pass, and both negative controls fail.What I ran
Head
b7954ac0acd413365165ec38de60ebd5f8850a02,main9090972b7e91fd266819cbd77a8b058e177b5682, merged with--no-ff(tree40c2dc871ed96e087eb833ee320cfadebc7a6316). Debian 13 VM (Xeon Gold 6136), GCC 14.2.0, Release, Vulkan on lavapipe (Mesa 26.1.6).Results
git diff --checkcheck_conventions.pylibsokagc_driver_division, the denormal-mode tests,unwrap_self,vector_constant_factor_tininess) also fail onmainVUID-lines compared withmainagc_pipeline_journal,agc_pipeline_journal_long_pathsagc_pipeline_cacheagc_driver_pipeline_journalFileFormatmain: no collisiongit status --porcelainemptyNegative control
Keying reverted. I restored
PipelineJournal.cppandVulkanDevice.cppfrommainand kept the newDescribedPipelineIdentityso the test still compiles.agc_pipeline_journalandagc_pipeline_journal_long_pathsfail:output
Table count put back. I put
binding.countback for the table roles inDescribedPipelineIdentity.--pipeline-journalfails:output
This confirms the author's negative control and wachi35676's. After restoring the merged files, both tests pass again and the worktree is clean.
Findings
Blocking
None.
Non-blocking
RecompileResult::Identity().DescribedPipelineIdentityrepeats the mixing code ofIdentity(), but its subgroup word (core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp:2522, at head) leaves out thefunctionLdsBuffer(0x20000) andmeshWindowBuffer(0x40000) bits thatIdentity()now mixes (core/shader/recompiler/Recompiler.hpp:839, at head). Those bits came in frommain(287b149950) after this branch first wrote the copy.Identity()that does matter for compute would be silently missing from the compute key. The PR's equality check ("described identity of a result without tables differs from its identity") only covers a result with these flags off, so it would not catch that. The ARCHITECTURE.md sentence "the same hash with the element count ... left out" is also not quite true now.RecompileResult::Identity(bool tableCounts)overload or a shared helper with a per-binding count filter. Or at least mix the same flag bits, and extend the equality check to a result withfunctionLdsBufferset.agc_driver_pipeline_journalis over the 30 s rule. It takes about 44 s here, and the NVIDIA and AMD CI comments show 120 s. It takes the same time with this PR's journal and device changes reverted, and this PR adds its new checks to the fastagc_pipeline_journal(0.02 s). So it does not count against this PR. I mention it only because the runs above show it.On the layout side, I agree with wachi35676 and BunnyFl:
DescribeSetLayoutsandShaderResourcesdescribe the three table bindings atimageTableCapacity,StorageTableCapacity(context)andsamplerTableCapacity.stageResources, so they cannot flipupdateAfterBind.verifySetLayouts(core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp:5866) would catch a resident pipeline whose set layout differs from the dispatch's.Not verified
VkPipelineon a real device. The new tests cover the key and the journal, notVulkanDevice::computePipelinereuse.Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-06T14:02:15Z.
Review: APPROVED
@Ryongen re-approved at
d8cb9cd4fc. My approval was onb7954ac0ac; the new head only mergesmain653b8efef0into it, andgit range-diffshows your own commits unchanged. I re-ran everything on this head merged into currentmainanyway.What I ran. Head merged onto
main1ff0fe98aa(merge9aa590d82b, clean), Windows 11 Pro, WinLibs GCC, Release, AMD Radeon RX 9070 XT, withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validationandctest -V:agc_pipeline_journal,agc_pipeline_journal_long_paths,agc_pipeline_journal_extended_pathsandagc_driver_pipeline_journal: 4 of 4 pass, none unbuilt or skipped.VUID-and noSYNC-HAZARDids.Graphics/src/PipelineJournal.cpptaken frommainfails the threeagc_pipeline_journal*tests withcompute results that differ only in their image table's element count were recorded as two pipelines, whileagc_driver_pipeline_journalstill passes. So the journal test reaches the change.tools/pr_overlap.py --branchat this head: no line or export conflicts with any pull request it could compare. 77 pull requests that touch the same AGC files conflict withmainand could not be compared, which is usual for these files.One note, not blocking
Your branch bumps the journal's
FileFormatfrom 15 to 16, andmainmade the same bump on its own ind1915dd746(line widths). Git merges two identical edits silently, so the merged tree hasFileFormat = 16u(Graphics/src/PipelineJournal.cpp:54onmain), the same number as a journal written bymaintoday. Your bump no longer starts such a journal over.From reading the load path, that looks harmless rather than wrong: when the load decodes a compute module record, it keeps it only if the decoded result's key equals the stored one (
PipelineJournal.cpp:939-944at this head), and for a result with a table the oldIdentity()key differs fromDescribedPipelineIdentity, so such a record is dropped rather than reused. I haven't run amain-written journal through this build, so that is a reading, not a measurement. If you meant the bump to discard those records up front, it would need to be 17 now.AI-assisted: yes (Claude Code)