fix(shader): carry a packed pixel ancillary through phis when every reader extracts a modelled field #1934
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1934"
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 fisherjoey on 2026-10-09T00:46:54Z.
Related: #1933. This PR covers only the phi case. The whole-word case from #1933 moved to a separate issue, #2548.
What
Since #1179,
lowerPackedAncillaryrebuilds the packed pixel ancillary word when it is passed through a move (Identity) or the data operand of aSelectU32, as long as every reader of the result extracts a range inside one modelled field (sample index or render target index). It does not follow aPhi. When the old value of the ancillary VGPR reaches a block merge, the phi counts as a reader, and shader info collection throwspacked pixel ancillary input has an unsupported live use (used by Phi ...)even when every value read after the phi is an in-field extract.This change treats a
Phioperand the same way as a select data operand: the word is forwarded through it, and the rule from #1179 is unchanged. Every reader past the phi must still be an extract inside one modelled field, or nothing is lowered and the shader is refused as before. The reader walk keeps a visited list, so a phi on a loop back edge ends the walk. The TechnicalDebt entry from #1179 now says "select, move or phi".The earlier version of this PR also let the word reach whole-word readers (float math, outputs) with the unmodelled bits read as 0. That part is dropped: it guesses those bits, which #1179's rule and #182 rule out. Stray's 26 shaders need that case, so this PR no longer fixes them. They are described in #2548.
Tested
Linux (Nobara 44, GCC), RTX 5070 Ti, NVIDIA 595.91.07.
New checks in
core/libs/tests/PixelAncillary.cpp:MergedValuesbuilds a diamond where aPhimerges the ancillary word with other data, and a loop where the phi's back edge goes through aSelectU32that reads the phi. Each case evaluates the extract against the packed word for every row.MergedRefusedchecks that a phi intoBitwiseOr32or into an extract outside the modelled fields still throws.ctest -R pixel_ancillarymain87be9489+ the test onlyshader info collection failed: packed pixel ancillary input has an unsupported live use (used by Phi 1513922071)79653e00)ctest -R 'agc_|pixel_ancillary' -j1on this branch: 290 of 291 pass. The one failure,agc_driver_dcc_keys_first_write, also fails onmainon this NVIDIA setup.Rebased onto
mainafter #1904, which touches the same function. Its masked-copy extract rewrite is kept as is.Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-09T14:31:37Z.
Overlap note: #1179 (open since 10-07) handles extracts reached through moves and selects. It refuses a word that reaches a phi or a whole-word reader by design, so it doesn't cover this PR's case: Stray's 26 pixel shaders where v4's old value, still the raw word, flows through
Phiinto float math. This PR rebuilds the word fromSampleIdandLayerfor those uses, with the other bits read as 0 (recorded in TechnicalDebt).Stray, with #1179 in place of this PR: 0 of the 26 compile (21 refused as
used by BitFieldUExtract 16 11, SelectU32 ? ?, 5 as... SelectU32 0 ?), and this PR's test fails withused by SelectU32 0 ?. With this PR, 26 of 26 compile. Details on #1179: https://github.com/boykopovar/AnyPS5/pull/1179#issuecomment-6082989392.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T15:23:27Z.
Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), RTX 3060 Laptop (NVIDIA 616.92), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head
9cf81e62, merged ontomaind70b8998in one build with 33 other AGC/shader PRs that had no Windows run.pixel_ancillary. None of them reported skipping a case.PATHsetup.No title was run.
🤖 Addressed by Claude Code
Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-10T04:29:15Z.
I narrowed this PR to fit #1179's rule. It now only lets the word pass through a
Phiinto readers that each extract a range inside one modelled field, the same rule #1179 applies to selects and moves. The reader walk stops at phis it has already visited, so loop back edges terminate. Any other reader still throws. I dropped the earlier path that let whole-word readers see the unmodelled bits as 0. That case, Stray's 26 shaders, is now #2548.New head: 7918aa11, on main
afb8cd22. The newMergedValues/MergedRefusedchecks inpixel_ancillaryfail on main with the test alone (unsupported live use (used by Phi 1513922071)) and pass on this branch.ctest -R 'agc_|pixel_ancillary' -j1passes 271 of 272. The one failure,agc_driver_dcc_keys_first_write, also fails on main on NVIDIA. It merges cleanly with #1904.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T07:05:44Z.
Re-checked on the rebased head
79653e00(merged onto current main): scoped build + ctest 334/334 green;pixel_ancillaryfails without theConstantFolder.cppchange and passes with it. The word only passes through a phi when every reader is an extract inside one modelled field, other readers still throw, and the visited list terminates loop back edges. No conflicts with main. Merging.