Repository navigation
fix(agc): bound tessellation patch records by the draw's patch count - #4114
Conversation
|
GTA V (PPSA04264) data point for this PR and #4082. Windows 11, RTX 4090, MinGW GCC 15.2. GTA's hull stores its patch constants downward from 0x8000 (the The next stop is the domain program, which reads those constants: I opened #4175 for that, stacked on this PR (its last commit only). With it, GTA's Story mode runs past that draw. AI-assisted (Claude Code). |
|
Rebase handoff — this branch was ~362 commits behind Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release,
To pick it up: Head is |
|
Independent verification of your rebase — the new head builds and passes the full local suite on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, |
d3f88f9 to
6b15b72
Compare
|
Thanks for the rebase handoffs across the chain, blawesom. I used your That second point is easy to miss. Your heads kept the chain's request versions at 17/18/19, but About listing every link under "Depends on" on #4222: each PR names only its direct parent, and the stack order follows from that. Details
|
|
Evidence from another title, and a bound that may help this PR. GTA V (PPSA04264, #1203) hits exactly this refusal: a hull shader with 3 control points stores its patch constants downward from the top of a 32 KiB off-chip area, at 0x8000 minus 0x150 × (relative patch + 1). That form is affine; it is refused only by the range check, because The hardware bound is smaller than 256 regardless of I have a small branch that applies only that hardware bound, without touching the request format or the keys, with a hull test using 336-byte records from 0x8000 and an IR test that checks the lowered offsets for several patches: fdfawef324:fix/recompiler-hull-patch-range. I am not opening it as a separate PR since this one covers the same refusal; feel free to take anything from it, or tell me if you would rather I open it so the two bounds can be combined. |
|
GTA V (PPSA04264) with this PR and #4163. Windows Server 2025, RTX 3060, MinGW-w64 GCC 15.2.0. Base. An integration branch on Conflicts. Against current Tests. GTA V. The tessellated draw has
The next stop is outside this PR.
|
6b15b72 to
c3f418f
Compare
|
Checked: the request version is written as 21 and read up to 21 (older requests read 256), the new field is in the draw, validation and pipeline keys and in the hull/domain cache keys only. |
TessellationLowering proved ring and LDS addresses affine over a relative patch index of up to 256. A hull that lays its patch-constant records out downwards, at 0x8000 - 208 * (rel + 1) like the quad particle hull in Ghost of Yotei, then reached a negative address for the last slot and aborted as "not affine". The relative patch index of hull and domain programs stays below VGT_LS_HS_CONFIG.NUM_PATCHES (bits 7:0, patches per threadgroup), which is 63 for that draw. DecodeShaderStages now carries NUM_PATCHES as patchesPerGroup in the tessellation configuration (draw keys, hull and domain cache keys, recompile request version 22) and refuses zero, and the lowering bounds the relative patch index by it. Configurations without it keep 256.
c3f418f to
25a8372
Compare
|
@adriadam10 I rebased the tessellation chain onto current main, and one thing in this PR had to change: #3763 moved main's recompile requests to version 21 without adding a field, and this PR also used 21 for the new This PR now writes version 22 and reads Details
|
|
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.
|
|
Checked the |
What
Tessellation lowering proves that every ring and LDS address is affine in the control point and the relative patch, with the relative patch bounded by a fixed 256. A hull that lays its patch records out downwards from a base, such as
0x8000 - 208 * (rel + 1), then fails as "not affine", because record 255 would be negative even though the draw never has that many patches.DecodeShaderStagesreadsVGT_LS_HS_CONFIG.NUM_PATCHES(bits 7:0, the patches per hull threadgroup) into the tessellation configuration aspatchesPerGroup, and refuses 0.SharpEmu decodes the field the same way (
PatchesPerGroup = configuration & 0xFF, 0 rejected). PPSA26344's first terrain hull (VGT_LS_HS_CONFIG0x1043f, 63 patches) stores its patch constants at exactly that descending stride and stopped there after #4082.#4451 also adds a request version; whichever lands second renumbers.
Tested
Based on
mainc63dd44. 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 on every branch and onmain;patched_librariescannot loadmain'slibkernel_sys.prx); merged withmain14036cb,agc_driver_tessellation,agc_driver_graphics,agc_shader_memory,agc_driver_bda_deviceandagc_tessellation_factor_ringpass (5/5)main14036cb: 1047/1049 pass;agc_driver_depth_compare_copyandguest_mathalso fail onmainagc_driver_tessellationgains a hull storing patch constants at0x8000 - 208 * (rel + 1): refused at 256 and 158 patches, rendered correctly at 157 (the boundary).agc_driver_graphicsdecodes 63 and 85 patches and refuses 0;agc_shader_memorycovers version 22 and the hull/domain-only key. Each fails without it.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)