feat(shader): read hull inputs at a control point chosen by a select or phi #6551
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6551"
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 yash27git on 2026-10-15T20:13:29Z.
What
A hull program that reads its input control points from LDS at an index it computes from data is accepted only while its address arithmetic folds. One that chooses between two computed control points, or merges them in a phi, is refused:
The strict evaluator takes
SelectU32andPhionly when every operand is the same affine value (Same), and the dynamic term does not pass through either, so the read's multiple falls back to 1 andderiverefuses it. #4727's description records exactly this: "The dynamic term never passes through masks, shifts right, disjoint ORs, selects or phis whose arms differ." This PR closes the selects and phis half of it.CommonMultiplekeeps the multiple when the operands of a select or a phi agree on their vertex, relative and constant terms: the value is that affine part plus whichever operand's multiple the choice picks, so a multiple of the greatest common divisor of those multiples.std::gcddoes: it is zero multiples away from the affine part, so its sibling's multiple passes through.derivestill requires the multiple to be a whole number of control points (dynamicScale % localStride == 0).address + 0. The values are the same:TessellationPointerdivides and masks the address to recover the control point, attribute and component either way, and a component with no offset saves its add. It also keeps the emitted address equal to the address the evaluator proved, which is what the test asserts. (TessellationPointer's one-OpAccessChainfast path needs an immediate byte offset as the add's second operand, so it does not apply to a computed index in either form.)ShiftLeftLogical32andBitFieldUExtracttook the shift and the bit count of a folded constant unguarded, whereShiftRightLogical32already refuses a negative shift, and the count feeds1ll << count. Both now refuse and fail the lowering. These two change no shader:boundedkeeps every folded constant in[0, 0xffffffff], so they are hardening for a later relaxation of that invariant.gl_inclamp a computed index already relies on stays as recorded indocs/dev/debt/shader.md.CMakeLists.txt+13/-0,tests/TessellationLowering.cpp+197/-0,TessellationLowering.cpp+22/-8. Nothing is deleted, including theagc_frame_dump_ioregistration an earlier head of this branch dropped and9f429e65arestored.Tested
New offline test
agc_tessellation_lowering(hand-built IR, no device, no shader binary): the read isds_read_b32ofLdsat pc 0x40, addressed bymin(inv, 2) * 32(or a choice of computed control points) added to the patch termrelative patch * 96, with a reference that keeps it alive. Six cases: three reads that must lower and carry the program's own address, three that must stay refused as not a whole number of control points.Windows, MinGW-w64 GCC 16.2.0, Ninja,
-DBUILD_TESTING=ON:The warnings that build prints are in
core/libs/prx/libcand3rdparty/glslang; none come from the changed files.jotitadev ran both heads on a device:
ece802dmerged onto44df216, withTessellationLowering.cppfrommainand only the test and its CMake registration,agc_tessellation_loweringfails on the three reads above, refused at pc 0x40 with the same message. With the whole change,agc_tessellation_lowering,agc_tessellation_factor_ringandagc_driver_tessellationpass 3/3 each.9f429e65amerged onto0615cd2b8,agc_frame_dump_iois registered again and passes; the test-only head still fails; with the change all four pass 3/3. Actest -R "^agc|shader|recompiler" -E "agc_display_buffer_dcc|agc_driver_flip|agc_driver_lds_atomics64|display|flip" -j1 --timeout 60sweep of 614 tests has one failure,agc_driver_store_over_untracked, which also fails on unchangedmainthere and is tracked as #6347. Their machine is on theGPUs testedline.The before and after below were produced on Linux (g++ 14.2.0,
-O0) by compiling the IR, the two passes and the test directly, so the same test could be run againstmain:On
main:The first case lowers on
main, but the emitted address isaddress + 0rather than the program's own address, which is what that case asserts; the other two are refused at pc 0x40. With this change all six cases pass and the run prints nothing (exit 0).The three refusals stay refused on both sides: a select arm at
* 16(half a slot), a phi arm at* 16, and select arms at two different offsets.-Wall -Wextraon both changed C++ files adds no warning;TessellationLowering.cppkeeps its four pre-existing ones, none on the changed lines.Not run by anyone: the four test patterns jotitadev excluded from the sweep (
agc_display_buffer_dcc,agc_driver_flip,agc_driver_lds_atomics64,display,flip), and the rest of the ctest suite on Windows. No title was measured for the two shapes this accepts; the test's IR is what the lowering sees for such a read, not a captured shader.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 repositoryece802d(three tessellation tests 3/3) and9f429e65a(those three andagc_frame_dump_io, plus the 614-test sweep)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T20:24:20Z.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/Optimization/src/TessellationLowering.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtImported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-15T20:32:07Z.
Review: COMMENTED
The
CMakeLists.txthunk in ece802dc4 drops theagc_frame_dump_iotest registration (lines 319-329 onmain44df21632), which has nothing to do with tessellation lowering. That test came in with #5800 (6541db004, "disable optional BMP dumps after host I/O failures").tests/FrameDumpIo.cppis still in the tree at this head, so after a merge the file is still there but nothing builds or runs it. The test would disappear from ctest without any failure to show it.It looks like a leftover from resolving a conflict in that
if(BUILD_TESTING)block. Restoring the eleven removed lines and keeping only the newagc_tessellation_loweringblock should be enough.Checked by reading
git diff 44df21632 ece802dc4 -- core/libs/prx/libSceAgcDriver/CMakeLists.txtandgit ls-tree ece802dc4 core/libs/prx/libSceAgcDriver/tests/FrameDumpIo.cpp. Nothing was built.Written with AI assistance (Claude Code). The commands above were run on my machine; no build or test was run.
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-15T21:27:32Z.
Review: COMMENTED
Linux run, including the two GPU tessellation tests the description lists as not run.
Machine: NVIDIA GeForce RTX 3070, driver 595.99.02, Vulkan 1.4.329, Ubuntu 26.04 (kernel 7.0.0-38), i7-8700. GCC 15.2, Release,
BUILD_TESTING=ON. Headece802dc4merged ontomain44df21632, no conflicts.ANYPS5_GPU="NVIDIA GeForce RTX 3070".GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02), Linux
TessellationLowering.cppfrommain):agc_tessellation_loweringfails. The three reads that should lower are refused withthe hull shader reads LDS at a computed offset that is not a whole number of control points at pc 0x40, for the computed index, the data-selected point and the phi-merged point.agc_tessellation_lowering,agc_tessellation_factor_ringandagc_driver_tessellationpass 3/3 each.Written with AI assistance (Claude Code). I ran the tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by yash27git on 2026-10-16T11:01:25Z.
Confirmed, and thank you for the ls-tree cross-check. My CMakeLists.txt was built from a copy taken before #5800 landed, so the hunk in ece802d really does drop lines 319–329 while tests/FrameDumpIo.cpp stays in the tree. Rebuilt the file against current main and pushed: git diff origin/main --numstat -- core/libs/prx/libSceAgcDriver/CMakeLists.txt is 13 0, and agc_frame_dump_io is back at line 319. agc_frame_dump_io_tests builds and its test registers and runs again; ctest -N lists both it and agc_tessellation_lowering. Sorry for the noise!
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-16T15:30:00Z.
Review: COMMENTED
Re-ran the current head after the
CMakeLists.txtfix.Machine: NVIDIA GeForce RTX 3070, driver 595.99.02, Vulkan 1.4.329, Ubuntu 26.04 (kernel 7.0.0-38), i7-8700, GCC 15.2, Release,
BUILD_TESTING=ON. Head9f429e65amerged ontomain0615cd2b8, clean merge (maindid not build at the time, #6784).ANYPS5_GPU="NVIDIA GeForce RTX 3070".GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02), Linux
agc_frame_dump_iois registered again and passes.TessellationLowering.cppfrommain):agc_tessellation_loweringstill fails;agc_tessellation_factor_ring,agc_driver_tessellationandagc_frame_dump_iopass.ctest -R "^agc|shader|recompiler" -E "agc_display_buffer_dcc|agc_driver_flip|agc_driver_lds_atomics64|display|flip" -j1 --timeout 60: 614 tests, onlyagc_driver_store_over_untrackedfails, which also fails on unchangedmainhere (#6347).Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by yash27git on 2026-10-16T16:07:48Z.
Confirmed on my side too: the merge-base diff is
+13/-0,+197/-0,+22/-8, so the branch deletes nothing now. Folded your re-run into the description, attributed to you:agc_frame_dump_ioregistered and passing, the test-only head still refused at pc 0x40, all four tests 3/3 with the change, and the 614-test sweep whose only failure isagc_driver_store_over_untracked, which also fails on unchangedmainand is tracked as #6347. I have left #6347 alone — it is not touched by this change, and I would rather not widen this PR. Thank you for the two runs; that is more coverage than the PR had when you first read it.Imported from boykopovar/AnyPS5. Originally posted by yash27git on 2026-10-17T04:26:05Z.
Dear jotitadev,
If you could take a final decision on my PR #6551, I'll be thankful.
You decide to merge or describe the problem with PR So i could work on different parts of 'ANYPS5' code as soon as possible. Thanks.
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-17T16:23:36Z.
@yash27git I'm not a maintainer, so I can't merge or reject it; that decision is theirs. From my side there is nothing left open: on the RTX 3070 the current head passes, the test fails without the fix, and the two GPU tessellation tests pass, as in my last run above. A maintainer review is what it needs now.
Imported from boykopovar/AnyPS5. Originally posted by yash27git on 2026-10-17T16:28:33Z.
Thanks for the thorough testing and for clarifying the review status! I really appreciate the time you took to validate the current head, reproduce the regression without the fix, and check the related tessellation tests. I understand the final decision is up to the maintainers, so I'll wait for their review. Thanks again for your help and for confirming that everything looks good from your side!