fix(shader): number an instanced draw's hull patches across its instances #4450
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4450"
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 Pipodi on 2026-10-12T11:56:34Z.
What
When GE_CNTL.BREAK_WAVE_AT_EOI is clear, the instances of a tessellated draw share hull threadgroups. The relative patch index then counts on through the instances, while the host's PrimitiveID restarts with each one. #4201 rebuilds the index from PrimitiveID alone, which is only right when every instance starts a threadgroup.
InstanceIndex - BaseInstance) to one more interface slot. The hull reads it from control point 0, andgroupedPatchnumbers the patchesinstance * patchesPerInstance + PrimitiveIDbefore taking(mod PRIM_GRP_SIZE) mod NUM_PATCHES.GE_CNTL.BREAK_WAVE_AT_EOIintoTessellationConfiguration::breakAtInstance(request serialization, draw and pipeline keys) and refuses a hull or domain that uses its relative index as data while the bit is clear. This PR builds on that decode and replaces the refusal with the numbering above; it no longer decodes or serializes the bit itself.TessellationInstancePatches) and go into the hull and domain cache keys, in place of #4201'sbreakAtInstancekey: the bit changes the compiled program only through the patches per instance.shaderDrawParameterswhen it has it, andShaderDeviceProfileand shader validation acceptBaseInstanceandDrawParametersin vertex stages. Without the feature, a hull that uses its relative index as data in such a draw is refused.Tested
Windows 11, RTX 4090.
agc_driver_tessellation. NewRequireInstancedRelativePatchestest: two instances of three patches, first instance 1, (patches per group, primitive group) = (4, 8). The test reads back the relative index that the second instance's patches 0 and 2 carry. The counted-through numbering, a per-instance restart and the absolute instance each give different values. Also checked: the (3, 3) and BREAK_WAVE_AT_EOI restart cases, the domain refusal, and the refusal without DrawParameters.agc_shader_memory. The patches per instance change only the hull and domain keys, and BREAK_WAVE_AT_EOI survives serialization and leaves the key as for one instance.maine34c47921(#4222 merged). The tessellation levels live in the draw state, so the instanced test draws pass their levels inPatchDraw. #4201's two "BREAK_WAVE_AT_EOI is clear" refusal cases are dropped, as this PR replaces that refusal; the instanced refusals above cover the domain and the missing DrawParameters. Two lists onmaingained entries next to this PR's:StageInputKindkeepsLayerExportedand addsBaseInstance, and the shader validation keeps main's mesh ClipDistance condition next to this PR's DrawParameters one.ctest, Windows, RTX 4090): of 1198 tests, 1183 pass, among themagc_driver_tessellation, and 14 hardware- or display-dependent tests skip.check_main_syncfailstest_paths_with_spaces_and_unicode_are_reported_verbatimbecause this machine's console code page printséasé; it does not touch this change.0x8040(BREAK_WAVE_AT_EOI 0). Its terrainDRAW_INDIRECTrecords hold 4 vertices and 2 to 3,157 instances of one 4-point patch each. With this change the hull compiles for every record and the title renders past these draws to its post-load popover.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt (the unimplemented domain case is a refusal).mdfiles or images added to the repository🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-12T15:04:10Z.
Rebase handoff — this PR is the 6th link of the hull/tessellation chain (it contains #4222 underneath), so I stacked the rebase on the already-rebased chain through
rebase/4222. Authorship unchanged.One conflict in
ShaderValidation.cpp: both sides add conditions to the same capability whitelist — kept main's ClipDistance condition and this PR's DrawParameters condition together.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 (whole chain):
Head is
5d64d741a. Worth listing Depends on: #4114 → #4163 → #4172 → #4201 → #4222 so the chain merges in order.Imported from boykopovar/AnyPS5. Originally posted by Pipodi on 2026-10-13T09:46:29Z.
@Celegans12 @blawesom thanks both for the rebase offers. I've rebased this onto #4222's current head (
3f165b6db) the way Celegans12 described: the commit now builds on #4201'sbreakAtInstancedecode and serialization instead of adding its own, the hull and domain keys holdTessellationInstancePatchesinstead of the bit, and #4201's refusal is replaced by the numbering. #4201's two "BREAK_WAVE_AT_EOI is clear" refusal cases are dropped fromagc_driver_tessellation, and the instanced copy inagc_shader_memoryclearsbreakAtInstance. New head26ff6ad16. On Windows (RTX 4090),agc_driver_tessellation,agc_driver_graphics,agc_shader_memoryandagc_shader_bindlesspass. No need for either rebase branch now.Tested and written by Claude (AI assistant) on a contributor's machine.
Imported from boykopovar/AnyPS5. Originally posted by Pipodi on 2026-10-14T16:31:37Z.
Rebased onto
maine34c47921now that #4222 is merged. This PR is now its one commit, with head10337ce9e.Three spots conflicted only because
mainadded entries next to this PR's, so both are kept:StageInputKindkeepsLayerExportedand addsBaseInstance.ShaderValidationkeeps the mesh ClipDistance condition next to the DrawParameters one.Draw.cppkeeps the dereferencedmaterializeDrawStageresult with the hull and domain draw arguments.On Windows (RTX 4090), the full suite gives 1183 pass and 14 skip, with
agc_driver_tessellationamong the passes. The one failure ischeck_main_sync's unicode-path case, from this machine's console code page. Conventions pass.Tested and written by Claude (AI assistant) on a contributor's machine.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T17:05:51Z.
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.mdL106-107docs/dev/debt/shader.mdL107-108core/libs/prx/libSceAgcDriver/Execution/src/ShaderDeviceProfile.cppL32core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cppL176Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T17:16:59Z.
Checked on the PR merged onto main: build,
agc_shader_memory, andagc_driver_tessellationon CI's lavapipe (it segfaults on local RADV on plain main too). Dropping the cross-instance numbering ingroupedPatchmakes the newRequireInstancedRelativePatchesfail, so the test pins it.Added one commit: the TechnicalDebt line for the relative patch index said it throws when
BREAK_WAVE_AT_EOIis clear, which this PR makes false; it now describes the instance numbering and the remaining refusals (domain, noshaderDrawParameters). Merging once the full Build is green.