Repository navigation
feat(shader): read hull inputs at a control point chosen by a select or phi - #6551
Conversation
|
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.
|
jotitadev
left a comment
There was a problem hiding this comment.
The CMakeLists.txt hunk in ece802d drops the agc_frame_dump_io test registration (lines 319-329 on main 44df216), which has nothing to do with tessellation lowering. That test came in with #5800 (6541db0, "disable optional BMP dumps after host I/O failures"). tests/FrameDumpIo.cpp is 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 new agc_tessellation_lowering block should be enough.
Checked by reading git diff 44df21632 ece802dc4 -- core/libs/prx/libSceAgcDriver/CMakeLists.txt and git 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.
jotitadev
left a comment
There was a problem hiding this comment.
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. Head ece802dc4 merged onto main 44df21632, no conflicts. ANYPS5_GPU="NVIDIA GeForce RTX 3070".
GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02), Linux
- Test only (the new test and CMake registration,
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. - With the change:
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.
ece802d to
9f429e6
Compare
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! |
jotitadev
left a comment
There was a problem hiding this comment.
Re-ran the current head after the CMakeLists.txt fix.
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. Head 9f429e65a merged onto main 0615cd2b8, clean merge (main did 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.- Test only (
TessellationLowering.cppfrommain):agc_tessellation_loweringstill fails;agc_tessellation_factor_ring,agc_driver_tessellationandagc_frame_dump_iopass. - With the change: all four pass 3/3.
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.
Confirmed on my side too: the merge-base diff is |
|
@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. |
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! |
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 Windows: StoreOverUntracked fails at "the first result was not stored" #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)