fix(shader): prove masked writes through guarded first-lane reads #3739
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3739"
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 eljackjoestar-cmd on 2026-10-11T16:14:26Z.
What
Lost Soul Aside (PPSA26358) aborts while recompiling a pixel shader because a masked copy keeps the packed ancillary input live. #3391 alone still fails on the captured 5,016-code-word wave64 request. With that dependency and this change, the same request recompiles into 306,669 SPIR-V words and a fresh title run progresses to the separate color-array-view refusal covered by #3633. That initial run remained black. Later integration runs reached menus, but the user still reports green flashes; gameplay and rendering correctness remain unverified.
Extend the existing mask proof to recognize boolean selects and independently rebuilt lane-bit predicates using the same mask words. Follow
ReadFirstLaneonly when its read mask implies the source write mask and a separate liveness proof shows its result is unobserved outside the read mask. Keep the source select for unguarded results, wider masks and results carried across iterations of a loop-local mask. Nested proofs share the remaining per-walk work budget and retain the existing depth limits.The first-lane behavior follows the existing
EmitReadFirstLanebackend and AMD's Vega ISA section 12.8, V_READFIRSTLANE_B32, page 127: a nonempty EXEC reads its lowest active lane; empty EXEC reads lane zero. The second proof prevents that fallback from becoming observable after removing the source select. Instruction lowering is unchanged. Console comparison is unverified and recorded in TechnicalDebt.#3391 supplied the whole-quad proof and has since merged into main. The current PR head is
fded8a7e7and contains only this proof extension; the original tested implementation wasd7066b678. #3550 overlaps the same pass with a separate per-shader budget; neither open PR implements these first-lane or boolean-select proofs.Tested
Windows x86-64, Ryzen 7 7800X3D, 32 GB RAM, NVIDIA RTX 5070, WinLibs GCC 15.2.0, Release, BUILD_TESTING=ON. Built the full default target and the explicit
libstarget.guest_kernel_sys,windows_exceptions,guest_filesystem,agc_driver_emulated_color_compare) also fail with the original main implementation. The skips are existing display/no-Vulkan cases. Full CI is not green.agc_masked_selectandpixel_ancillarypass in about 0.04 s each. New positive cases cover guarded first-lane reads, boolean selectors, identical mask words and same-iteration loop uses; negative cases cover empty read EXEC with observable fallback, wider read/consumer masks, mismatched wave64 high words and loop phi escape. Restoring the #3391 implementation fails four new positive cases and the captured request; restoring this fix passes both tests and recompiles the request.AGC graphics: color views of several array slices are unsupported. No copyrighted request or game binary is included in the branch.python tools/check_conventions.py --base origin/mainandgit diff --checkpass.The exact captured-request output also passes standalone
spirv-val --target-env vulkan1.1spv1.4, built from the repository's bundled SPIRV-Tools and SPIRV-Headers. Local emulator build used SPIRV-Tools OFF.Rebased onto main
bca7a29d2, preserving both sides of an adjacent TechnicalDebt addition. The pass and regression source files are byte-identical to84cf71319. The current source passesagc_masked_selectandpixel_ancillaryin the separately built #4150 dependency stack, alongside its relative-addressing GPU tests. The full-suite and initial title results above are historical evidence on the original base, not a new full-suite run on this head.Not tested: Linux/lavapipe, console hardware or collaborator-triggered full CI.
Checklist
main; no other open PR implements the same functions (proof additions are distinct; overlaps with #3391 and #3550 described above)NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt (none added).mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by Cor3Duo on 2026-10-11T16:26:40Z.
A second title for this: The Exit 9 (PPSA20955 v01.000.000, Unreal Engine) stops on
maina11c8f7fat a 3720-code-word wave64 pixel shader with the samepacked pixel ancillary input has an unsupported live use (used by SelectU32 ? ?). #3391 alone does not fix it. With this PR's head d7066b678 the saved request recompiles (245293 SPIR-V words) inagc_shader_replay.Tested on Windows 11 (26200), WinLibs GCC 15.2.0 r7, Release, AMD Radeon Graphics (Ryzen 5 7600X, RDNA2, driver 32.0.21043.5001).
In this shader the first-lane reads sit inside a loop and their exec goes through a
SelectU1, so it exercises the same-iteration and boolean-select proofs.I had reached the same rules independently before seeing this PR (Cor3Duo/AnyPS5
fix/masked-select-first-lane, 0087537), so I am not opening a duplicate. That branch is there if an independent cross-check of the proofs is useful.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T22:21:26Z.
#3391 is merged, so I rebased this onto current
main(only your commitd7066b678remains; one adjacency conflict indocs/dev/TechnicalDebt.md, both lines kept). Checked merged onto main: the libSceAgc/AgcDriver tests pass on RADV,agc_masked_selectfails without the change, andv_readfirstlane_b32measured on RDNA2 (gfx1035, wave32 and wave64) reads the lowest active lane, lane 0 with EXEC empty. Merging once CI is green.