feat(agc): read hull patch constants in tessellation domain programs #4163
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4163"
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 Celegans12 on 2026-10-12T00:18:32Z.
What
Stacked on #4114; please review the last commit only.
Tessellation lowering refuses domain programs that read the hull's patch constants ("domain shader reads of patch constants or other patches are unsupported"), so a domain stage that consumes per-patch data from its hull cannot be drawn.
PatchInputkind, read throughPatch-decorated inputs that match the hull'sPatchoutputs.tessPatchBaseis gone.A domain read of a field the hull never writes cannot be detected, because the stages compile separately;
debt/shader.mdrecords that.PPSA26344's first terrain domain program reads its patch's constants at
0x8000 - 208 * (rel + 1)plus offsets 96-192, all of which its hull writes.Tested
Based on
main4bb2c7f3plus #4082 and #4114. Windows 11 (MinGW-w64 GCC 15.2.0) and Linux: configure -DBUILD_TESTING=ON, full build, --target libs, ctest. Measured on #4222's head, which contains this PR:log_macrosfails here on every branch and onmain, andpatched_librariescannot loadmain'slibkernel_sys.prx(error 127), which this chain does not touchmain8299b2f7: 1033/1034 pass;agc_driver_depth_compare_copyalso fails onmainIn
agc_driver_tessellation,DomainPatchReadis now a rendering check (the domain colours each patch from a constant its hull wrote at a wrapping record offset), and three refusals are new: a neighbour's record, a fixed-address patch read, and a neighbour's control point. The descending-record hull from #4114 now renders at 128 patches per group and is refused at 129, where its lowest record would overlap the last patch's control points. They fail on #4114's head with the old refusal or bound.Not tested: console behaviour.
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 tibzejoker on 2026-10-12T01:17:21Z.
GTA V (PPSA04264) on this PR's head (b3d525ea7), Windows 11, RTX 4090, on
main325e0a8bdwith #4082, #4114 and the unrelated PRs GTA needs to reach Story mode: the domain program that stopped at pc 0x9c (domain shader reads of patch constants or other patches are unsupported) compiles, and a 150 s Story run has no tessellation error. So this PR covers GTA's domain too, and I am closing my #4175 in its favour.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-12T12:52:13Z.
Rebase handoff — rebased onto the freshly rebased #4114 (so the chain stays stackable), which itself sits on current
main. Your commit's authorship is unchanged; the rebase applied cleanly (no conflicts).Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release,
BUILD_TESTING=ON, AMD RX 9070 XT / RADV):tools/check_conventions.py --base origin/mainpassesTo pick it up (note: this builds on the rebased #4114, so pull that first if you take both):
Heads:
rebase/4114=d0ea5f4d1,rebase/4163=652f2763d. I'll do #4172 and #4201 on top of this next if the chain order holds.Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-13T01:44:34Z.
One behaviour change here after Pipodi's review on #4201. The hull's own check for patch-constant writes used to accept anything above one patch's control points. The domain's check, added in this PR, wants everything above the control points of all NUM_PATCHES patches. The hull now uses the domain's bound too, so a hull whose records would reach into another patch's control points is refused instead of lowered.
That moved one test from #4114: the hull with descending records now draws at 128 patches per group and is refused at 129, which is where its lowest record first overlaps the last patch's control points. Replayed offline, Yōtei's terrain hull passes the new bound and recompiles completely. I couldn't check its two domains the same way: offline they stop earlier, at their known image-table lookups.
@tibzejoker, GTA V's domain already passed the same bound, so I expect its hull to pass as well. If you have a moment to recheck Story mode on this head, I'd be glad to hear either way.
Details
agc_driver_tessellation:HullDescendingRecordsat 129 patches is refused with "outside its control points and patch constants"; at 128 it renders as before.log_macrosfails here on every branch). Linux (upstream's job in WSL), #4222's head merged withmaind1fd9372: 1003/1004 pass;agc_driver_depth_compare_copyalso fails onmain.Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-13T09:20:52Z.
GTA V (PPSA04264) on this PR's head f4aa18dc. On the open question: GTA's hull passes the new bound. Windows Server 2025, RTX 3060, MinGW-w64 GCC 15.2.0.
Base. An integration branch on
main7e181fccwith #4082 rebased (7e3eefae), #4114 (6b15b72e) and this PR cherry-picked, plus other open PRs.Conflicts. Against current
main(fc1f063f) this head conflicts in two files, both because of #4727 (hull inputs at a computed control-point index):core/libs/prx/libSceAgcDriver/tests/execution/Tessellation.cpp, the list inmain(): #4727'sHullHalfSlotIndexandHullDynamicIndexlines next to this PR's lines (HullDescendingRecordsat 128/129,RequirePatchConstants).core/shader/recompiler/Optimization/src/TessellationLowering.cpp,componentAddress(): #4727 returns early for a computed (dynamic) address. I kept that return ahead of this PR's modulo placement. Only control-point inputs are evaluated as dynamic, so patch records never take that path.derive()merges cleanly next to #4727'sagreeline for dynamic inputs.Tests.
agc_driver_tessellation(includingRequirePatchConstantsand the 128/129 boundary),agc_driver_graphics,agc_shader_memoryandagc_tessellation_factor_ringpass.check_conventions.pypasses.GTA V.
VGT_LS_HS_CONFIG0xc338 (3/3 control points, NUM_PATCHES 56). Domain 0x25cb33200 reads, at pc 0x9c, the 336-byte record that hull 0x25cb4ea00 writes at0x8000 - 0x150 * (rel + 1).The next stop is not tessellation.
sceAgcCreateInterpolantMapping, where the driver prepares each program synchronously inResolveShaderAbi: about 4,100 from the disk cache and 3,300 new compiles.GetImageResource dword 0 is not a valid runtime value.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T12:20:17Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)docs/dev/debt/shader.mdL87-88Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T14:04:34Z.
Checked on this PR merged onto current
main: build, the libSceAgc/libSceAgcDriver ctest scope, andagc_driver_tessellationon CI's lavapipe (Mesa 25.2.8): passes, including the newRequirePatchConstantsrender and the three new refusals. Without the non-test changes the test fails. ThePatchInputrecords, the modulo-stride placement and the shared hull/domain bound read correctly, and the debt line sits mid-section. Also confirmed by @tibzejoker and @fdfawef324 on GTA V (RTX 4090 / 3060). Merging after the full Build.