fix(shader): decide each resource branch condition once per plan #11506
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11506"
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 hugodearaujo on 2026-10-26T17:37:10Z.
What
MayDecide(#8518) checks whether a resource block's branch condition can be decided at capture time. ForLogicalAndandLogicalOrit recurses into both operands, and every step starts with a fullMayEvaluate. Nothing is kept between steps. A condition whose operands share their own operands is therefore walked once per path, and each level that reads the level before it twice doubles the work.This PR keeps each value's answer:
MayDecidetakes a record of what it has already decided, andExtractPlanpasses one record for all of a plan's blocks. An answer doesn't depend on the block (MayDecidecallsMayEvaluatewithout an active mask), so sharing the record doesn't change any result.@JJenkx, this is the walk from #8518. Its answers are the same; they're just kept now.
Tested
main522e32e3b6, 3 runs: the menus run at 60 fps. On the New Game loading screen, frames stop between 140 and 151 s, and the screen stays black until the timeout. Nothing is printed, andAPS5_STALL_WATCHDOG_SECS=15reports no stalled queue.sceAgcCreateInterpolantMapping→AgcDriverResolveShaderAbi→PrepareShader→ResourceMaterializer::ExtractPlan→MayDecide, 20 to 29 frames deep, underMayEvaluate.PrepareShaderWithDiagnostics(not in this PR) counted 3,818 preparations. Only one didn't finish: shader 0x122151a400, whose request I saved.main5ed5427bacwith this PR: the title gets past that point and stops at 155 s onguest cube texture descriptor holds fewer than 6 array slices (format 71, 512x512x5, ...). That's where it stopped onmain65ac1d3b50, before #8518 (see #10347).main5bdda3661ewith this PR: the same, at 156 s. With the cube descriptor fix in #11507 as well, it plays its opening, the cart ride to Helgen, until the 420 s limit of the run.main88795ed448, this branch's base, with this PR: the same, at 161 s; with #11507 as well, the opening until the 420 s limit.agc_shader_replay --prepareof the saved request,ANYPS5_NO_SHADER_CACHE=1: onmainit was still running when I stopped it at 60 s. With this PR it takes 18 ms (3 runs).agc_shader_memory, newverifyMayDecideSharedConditions: 64 levels, where each level'sLogicalOrreads twoLogicalAnds of the level before and a lane comparison. With only lane comparisons,MayDecideanswers false. With a uniform conjunct at the bottom, it answers true. A shared record gives the same answers.main's evaluator, the test times out at 60 s. With this PR it passes in 0.16 s.main88795ed448and this head0dc6d38295, same machine and GPU: Linux (Arch, kernel 7.2.11), AMD Radeon RX 9070 XT (gfx1201) with RADV, Mesa 26.2.5, GCC 16.2.1, Release.ctest -VwithVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(Khronos validation layer 1.4.363; the loader logsInsert instance layer "VK_LAYER_KHRONOS_validation"),ANYPS5_NO_SHADER_CACHE=1andANYPS5_REQUIRE_VULKAN=1, on the tests around resource plans and their branch conditions:agc_shader_memory,agc_shader_disk_cache,agc_driver_graphics,agc_driver_branch_past_endpgm,agc_driver_image_table,agc_driver_image_table_cache,agc_driver_image_table_cache_bounds,agc_driver_image_table_reuse,agc_driver_image_table_reuse_draw_pipeline,agc_driver_image_table_vouched_lookups,agc_driver_image_table_vouch_queued_draws,agc_driver_compute_table_calls,agc_driver_compute_fs_table_calls,agc_driver_vertex_table_read_orderandagc_driver_vopc_compare_table.main: 15 of 15 pass. This head: 15 of 15 pass.was not found but was requested by env var VK_INSTANCE_LAYERS, and neither has aVUID-line.tools/select_tests.pyonmain88795ed448,ANYPS5_REQUIRE_VULKAN=1: 1,500 of the 1,501 selected tests pass.agc_driver_tessellationsegfaults inside RADV, as it does onmainhere (#5444, Mesa 26.2.5).tools/check_conventions.pypasses.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 MarcZX10 on 2026-10-26T17:47:13Z.
Review: CHANGES_REQUESTED
The focused regression evidence is useful: the new shared-condition test times out with the old evaluator and passes with this change, and the full selected suite reports the same RADV tessellation failure as
main. The branch is based on currentmain(88795ed448), and local conventions plusgit show --checkpass.Before approval, please add the paired AGC/shader-recompiler validation required by
CONTRIBUTING.md: the same focusedctest -Vrun on currentmain(88795ed44801fa719eb2df990cbe1f11a1f9bd81) and this head (0dc6d3829544ec5b4933d59f3d2ef9819a703085), on the same machine/GPU, withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_NO_SHADER_CACHE=1andANYPS5_REQUIRE_VULKAN=1. Please include the GPU vendor/model, driver and OS, confirm neither log reports the requested-layer-missing message, and compare newVUID-lines. The current PR description reportstools/select_tests.pyresults but not this exact paired validation, and hosted product/relinker checks are skipped.I found no implementation defect in the memoization path; changes requested for the missing required validation record.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T19:13:35Z.
Review: APPROVED
The requested paired validation is now documented with the same RX 9070 XT/RADV/Mesa setup on
88795ed448and this head. Both focused runs pass (15/15); the loader confirms the validation layer was inserted, and neither log reports a missing layer or any lines. The reported suite failure is on the broader selected run only and is the same RADV tessellation segfault reproduced on . Applicable hosted checks (conventions, labels, eligibility, intake and report) pass; product/relinker jobs are skipped. I found no remaining blocking issue in the reviewed memoization change.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T19:13:39Z.
Review: APPROVED
The requested paired validation is now documented with the same RX 9070 XT/RADV/Mesa setup on main
88795ed448and this head. Both focused runs pass (15/15); the loader confirms the validation layer was inserted, and neither log reports a missing layer or any VUID- lines. The reported suite failure is on the broader selected run only and is the same RADV tessellation segfault reproduced on main. Applicable hosted checks (conventions, labels, eligibility, intake and report) pass; product/relinker jobs are skipped. I found no remaining blocking issue in the reviewed memoization change.