fix(shader): decide resource branch conditions from their uniform operand #8518
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8518"
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 JJenkx on 2026-10-20T14:44:18Z.
What
A resource block's branch condition was kept in the resource plan only when it was fully evaluable at capture. A VALU compare that feeds
s_cbranch_vccz/s_cbranch_vccnzbecomesLogicalAnd(<the lane's EXEC bit>, <compare>)in the IR, so the lane-mask operand made the whole condition unevaluable even when the compare reads only SRT/constant-buffer values. The plan then dropped the condition, both successors stayed active, and an image read in the skipped block had to have a valid T#. On hardware no lane executes that read.Tetris Effect: Connected (PPSA07923) compute shader
0x200ae40000loads a T# from SRT+0x80behindv_cmp_neq_f32 vcc, 0, s8(s8from its constant buffer) ands_cbranch_vccz. When the title leaves that texture unbound it stores other constants at+0x80(43700000 43070000 3b888889 ..., i.e. 240.0, 135.0, 1/240, ...) and the flag is 0.0, so the dispatch stopped withruntime image descriptor is invalidshortly after the main menu appeared.LogicalAndandLogicalOrin the SRT interpreter and in the SRT tape yield their result from one operand when that operand alone decides it (false forLogicalAnd, true forLogicalOr), whether or not the other operand is evaluable. When both are evaluable the result is unchanged.ExtractPlankeeps a block condition that can be decided this way (MayDecide), not only one that is fully evaluable. A condition that does not decide at capture still keeps both successors active, as before.FPUnordLessThanEqual32andFPUnordGreaterThanEqual32are evaluated beside their ordered counterparts. A compare against zero is translated as a compare of the magnitude against the smallest normal (CompareInstructions.cpp), sov_cmp_neq_f32with a zero operand becomesFPUnordGreaterThanEqual32(|x|, min normal).Tested
Linux 7.2.9-arch1-1, Ryzen 9 7950X, AMD Radeon RX 6650 XT, RADV Mesa 26.2.4.
New
verifyLaneMaskGuardedDescriptorSourcesinagc_shader_memory: RDNA code that loads a mode word, guards an image sample withv_cmp_neq_f32_e64 vcc, 0, s16ands_cbranch_vccz, and holds an invalid T#. With the change, the plan keeps the VCC condition; a mode of +0.0 or -0.0 leaves the T# null; 1.0 still refuses the invalid T# and reads a valid one. The test fails on main (the VCC branch around the image kept no condition) and passes with the change, including withAPS5_VERIFY_SRT_TAPE=1andAPS5_VERIFY_SRT_COMPACT=1.Focused tests on main
52f7807a55and on this change based on it, withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(loader confirmed inserting the layer; nowas not found but was requestedline):agc_shader_memory,agc_shader_disk_cache,agc_shader_control_flow*,agc_shader_srt_read_patching,agc_shader_table_snapshot_reuse,agc_shader_type_zero_image_materialization,agc_guarded_memory_loads,agc_driver_guarded_null_pointer,agc_driver_buffer_descriptor_runtime,agc_driver_prepared_shaders*,agc_shader_replay_*,agc_driver_graphics: 33/33 pass on both, 0VUID-on both.Full
ctest -j8with the same environment on both: 1702 tests, the same 5 failures on main and on the change (agc_driver_bda_device,agc_driver_guest_memory_lifetime,agc_driver_image_array_window_past_layer_limit,agc_driver_tessellationsegfault,guest_named_shm_concurrency), and identicalVUID-sets and counts (VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605x26,VUID-VkImageViewCreateInfo-usage-02275x6,VUID-vkCmdCopyBuffer-srcBuffer-00118x2,VUID-VkImageCreateInfo-imageCreateMaxMipLevels-02251x2,VUID-vkResetFences-pFences-01123x2).PPSA07923 02.000.021 natively, with
APS5_PLAYGO_UNLISTED_CHUNKS=installed(the dump has no PlayGo metadata). Main alone runs this title at about 2-4 FPS because host imports fail withVK_ERROR_INVALID_EXTERNAL_HANDLEand collapse the import budget, so the scene was not reachable in a bounded run; the runs below add #8091, which addresses that. The same scripted input reached the main menu and stopped at about 96-100 s withcompute shader 0x200ae40000: runtime image descriptor is invalidin 4 of 4 runs on main + #8091 (also with #8077 added). With this change + #8091 the same input reached gameplay and ran to the 260 s and 450 s limits at about 60 FPS without the stop.Not verified on a console: which lanes the title executes there. The change relies only on the compare's value: when it is false no lane takes the guarded block, whatever EXEC is.
Independent Windows data point (Windows 10 19045, MinGW GCC 15.2): the new test passes with the change and fails with the library files restored, 3 of 3 each (comment).
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 JJenkx on 2026-10-20T19:07:22Z.
Rebased onto main
b85d972f42(no conflicts). Re-ran on the rebased commit1c9a522bef(RX 6650 XT, RADV Mesa 26.2.4, Linux 7.2.9) withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation: the same focused set passes 33/33 with noVUID-; fullctest -j8runs 1719 tests with 4 failures (agc_driver_guest_memory_lifetime,agc_driver_image_array_window_past_layer_limit,agc_driver_tessellationsegfault,guest_named_shm_concurrency), each of which also failed on main75787d2f64in the comparison above.Bring-up discussion for the title this unblocks: #8613.
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-21T04:47:46Z.
Windows data point for
1c9a522bemerged ontomain05f999570(clean,git merge-treerc 0): Windows 10.0.19045, MinGW-w64 GCC 15.2.0, Release.ctest -N -R '^agc_shader_memory$'lists exactly that one test;ctest --no-tests=error -R '^agc_shader_memory$'was run three times per tree.SrtEvaluator.hpp/.cpp,SrtTape.hpp/.cpp,ResourceMaterializer.cpp) restored tomain(the new test cases kept): fails 3 of 3 (ordinary test failure, not a crash).Not tested: other platforms, a title run.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-21T05:39:54Z.
Independent Windows composition validation of unchanged
1c9a522bef304eff3ec51d21b881101c411c6a38, with your authorship preserved.2e844131db5603a86e1b967adb878625a0bc1638, incorporating main7d7b097407. This is not a literal-main or original-PR-head run.c7ce2ceafb: the new fixture fails 3/3 atthe VCC branch around the image kept no condition.962e14c1d9: range-diff matches your commit; the fixture is byte-identical to the control.agc_shader_memorypasses 3/3 each in default,APS5_VERIFY_SRT_TAPE=1,APS5_VERIFY_SRT_COMPACT=1, and both verifiers together. Seven neighboring CPU groups pass 3/3: 33 CPU processes total.guarded_null_pointer,guarded_direct_root,native_color_draw_recipe,native_fmask,native_depth_bda_clear) pass 3/3 on each physical RTX 5080 and Radeon Graphics: 30 GPU processes, no skips/timeouts/VUIDs/validation warnings/errors. The new uniform-VCC case itself is CPU capture proof; these GPU groups are neighboring regressions, not a new dedicated VCC device fixture.Windows 11 Enterprise 26200, Ryzen 9950X3D, WinLibs GCC15.2.0 r7/UCRT Release, SPIRV-Tools ON; NVIDIA610.62 and AMD32.0.21036.18. Required Vulkan, disabled application shader cache/journal, verbose serial CTest, actual adapter and loaded Khronos1.4.363 confirmed. Full default Windows build and explicit libraries/relinker build pass. The trusted main-a07 conventions checker reports no errors, retaining four inherited debt-length warnings. Cppcheck/clang-tidy findings were reviewed at unchanged parent contexts; one inherited GCC negative-fixture warning remains in both control and candidate builds.
This adds composition/backend and two-vendor coverage alongside the earlier Windows main comparison; it does not establish a Sonic fix, full-suite result, performance gain or console semantics. AI-assisted: yes (Codex); author responsible.