feat(shader): implement triangle-patch tessellation #1491
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1491"
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-08T09:08:22Z.
What
Every tessellated draw throws today:
DecodeShaderStagesrejects PRIMGEN_PASSTHRU_EN, the local program ends in an unresolvables_setpc_b64, and hull and domain programs keep unlowered ring bases. Since #639 a title's local programs also stop registration.VGT_TF_PARAMbits except DISTRIBUTION_MODE, and needs HOS levels that keep [1, 63] (AMD's Sea Islands 3D register reference); 0x286-0x287 join the draw key.ResolveGraphicsStagesAbimerges the headers over one set of defaults, which used to reset the hull's LS_HS_CONFIG and TF_PARAM. A local program the hull header leaves at address 0 is prepared at its first draw.TessellationLoweringlowers LDS and ring addresses affine in the control point and relative index, with strides from the code; accesses outside the patch, per-patch writes not from control point 0, other relative-index uses and a non-passthrough primitive export throw.decodeDraw.Tested
main4b6ab6bb: configure-DBUILD_TESTING=ON, full build,--target libs,ctest:ctest --output-on-failure)VK_DRIVER_FILES): 479/479 pass;agc_driver_flat_storeis left out there because it takes several minutes on Windows llvmpipeagc_driver_tessellation: level-1, 0 and 5 patches through hand-assembled programs (coverage, culling, interior points, winding), six refusals, and title-shaped LS/HS/DS headers through registration andResolveGraphicsStagesAbi; fails on main.agc_driver_prepared_graphics: a hull ABI without its local program, then that program prepared at its first draw; new rows inagc_driver_graphics; both fail on main.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by yahya308 on 2026-10-08T15:28:51Z.
Tested on top of main
9e2ffe0d, Windows 11, MinGW-w64 GCC 16.2.0, full ctest withANYPS5_REQUIRE_VULKAN=1 --repeat until-fail:3, NVIDIA RTX 4070 Laptop (32.0.16.1074) and AMD Radeon 780M (32.0.31041.1004).vopc_compare_tablefails on the 780M on main too (#825, #1473).Head
680c2028: NVIDIA 458/458, 780M 457/458. The newagc_driver_tessellationran and passed on both.AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T23:51:19Z.
Review: CHANGES_REQUESTED
agc_driver_tessellationcrashes on RADV, so this can't go in as is. The crash happens inside the driver, but onmainthese draws throw a clean error, while with this PR the whole process dies on the default Linux AMD driver.main787239ec. The test segfaults invkCreateGraphicsPipelineson its first draw (RequirePatches→Graphics::Pipeline::Pipeline). It fails the same way under ACO and underRADV_DEBUG=llvm,nonggandnooptimizations. It passes on CI's lavapipe (Mesa 25.2.8).spirv-val --target-env vulkan1.3accepts all four modules, and the Khronos validation layer (1.4.357) reports nothing before the crash. So this is a RADV bug, but this PR is the first thing that sends tessellation pipelines to it.MESA_SPIRV_READ_PATH): the crash needs both the hull module and the domain module this PR emits. If either one is swapped for a hand-written GLSL stage with the same interface, the crash goes away. If both are run throughspirv-opt -O(which folds the runtime-computed indices, e.g.(32752 - 32752) >> 4for the patch output, and theUMod/UDivcomponent indices into constant access chains), the crash also goes away, but then the level-0 patch is not culled. I haven't checked whether that last part comes from spirv-opt or RADV.To reproduce:
MESA_SPIRV_DUMP_PATH=<dir> ctest -R agc_driver_tessellationon RADV dumps the four modules (.vert/.tesc/.tese/.frag). Put modified copies with the same names in a directory and pointMESA_SPIRV_READ_PATHat it to swap them.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T09:40:24Z.
Review: APPROVED
Since there was no new push, I went through the points from my last review myself and pushed them to this branch on top of a rebase onto current
main:DecodeStageProgramnow feedsPreparedControlFlow), the embedded-fetchdrawIndex(v3 keeps the relative index), the per-address shader registry, andmain's preparation at first use, which replaces the special case for local programs.DrawKeyRegistersis now 48.Tessellation.cppuses the fixed per-stage push constant slots (PixelPushLayout/PixelPushOffset).PreparedGraphics.cppnow expects a second tessellation configuration of a local program to be prepared at its draw rather than throw, which matches whatmaindoes now.MESA_SPIRV_READ_PATH. RADV 26.2.4 crashes when the slot index of a hull per-vertex input ((address % stride) >> 4) is dynamic. A dynamic component index is fine. The lowering always producesinvocation * stride + cfor those reads, soTessellationPointernow indexes them as[invocation + c / stride][c % stride / 16][c % 16 / 4]with constant slot and component.agc_driver_tessellationpasses on RADV (660M, gfx1035), including the level-0 patch being culled. It also passes on CI's lavapipe (Mesa 25.2.8), and the Khronos validation layer reports nothing.Checked: scoped build + ctest on RADV, 570/570 passed (VideoOut window tests skipped, no display).