fix(shader): run tessellation evaluation stages one lane per invocation on devices without subgroups there #13807
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/13807"
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 frankea on 2026-10-31T07:30:20Z.
What
MoltenVK and lavapipe leave the tessellation evaluation stage out of
subgroupSupportedStages. MoltenVK 1.4.2 on an Apple M5 Max reportsTESSELLATION_CONTROL | FRAGMENT | COMPUTE(vulkaninfo; MVKDevice.mm adds only the control stage to fragment and compute), and lavapipe reportsFRAGMENT | COMPUTE | TASK | MESH(lvp_device.c). The recompiler lays every tessellation evaluation program out for the device's subgroup width, so a domain program with lane operations declaresGroupNonUniformandValidateShadersrefuses the draw:AGC graphics: subgroup capability 61 is unsupported for shader stage 4. #4470 handled the same refusal for the vertex stage.SpirvTarget::tessellationEvaluationSubgroups(defaulttrue) records whether the device has subgroups in that stage;VulkanDevice::buildTargetsets it fromsubgroupSupportedStages, next tovertexSubgroups. When it isfalse,HostSubgroupSizegives tessellation evaluation programs a host subgroup width of 1, so they take the one-lane rules #4470 added for vertex programs: the lane id is 0, a ballot is the invocation's own bit, a shuffle returns the invocation's own value and an elect is true. Av_readlane_b32of another lane named by a constant throws; a lane selector held in a register is not checked and reads the invocation's own value, as on the vertex path (recorded in the debt entry; a check for it, on both paths, is left for a follow-up). Devices with subgroups in the stage emit the same SPIR-V as before.graphics->meshset (tessellation followed by a guest geometry program: the domain program feeds the generated capture geometry stage and the geometry half runs on the mesh path) keeps the device width. That path needs geometry and mesh shaders, which MoltenVK does not have, and it is not exercised here.RecompileCacheKey, and the request serialization moves to version 51 with the flag as its last byte; older requests read it astrue, and version 50 is rejected. I skipped 50 because 12 open pull requests already write it (#7410, #9020, #9335, #9748, #10359, #10547, #10846, #11351, #11483, #11551, #12662, #12980), and they are the only open pull requests whose changes conflict with this one (the version lines and the serialization tests). The shader disk cache format is unchanged: its key already holds theRecompileCacheKeywords and the host subgroup width, and no encoded field changes.docs/dev/debt/shader.mdfor the one-lane tessellation evaluation waves.Title: Gran Turismo 7 (PPSA01317) on an Apple M5 Max through MoltenVK stops with this error at the Used Car dealership's car showcase, about 870 s into a run, on its own domain programs. The new
Tessellation.cppdraw reproduces that refusal on MoltenVK without this change and passes with it (see Tested); I have no GT7 run with this change that has reached the dealership yet.Tested
Windows 11 on an RTX 4090 (driver 616.92, Vulkan 1.4.341), winlibs GCC 15.2.0, Release with
BUILD_TESTING=ON. The 4090 has subgroups in the tessellation evaluation stage, so its draws keep the subgroup path; the one-lane path runs there only inverifySingleLaneDomainWave, which compiles for explicit targets.53e4e8e796, and again at32a6bdb6d3) and onmain833be4af8d:request_serializer, the 21 entries ofagc_shader_memory_tests,agc_driver_tessellation,agc_driver_tessellation_depth_range_remap,agc_tessellation_pipeline_cache,agc_tessellation_factor_ring,agc_tessellation_lowering,agc_depth_range_remap,agc_driver_pixel_barycentric_emulation,agc_driver_mesh_barycentric_emulation,agc_driver_rect_list_corner,agc_driver_provoking_vertexandagc_driver_vertex_elected_atomic_max(skipped: the 4090 has vertex subgroups). They pass once more underVK_LAYER_KHRONOS_validationwithANYPS5_NO_SHADER_CACHE=1andANYPS5_REQUIRE_VULKAN=1(ctest -V) on both, with noVUID-lines and nowas not found but was requested by env var VK_INSTANCE_LAYERS; the loader log foragc_driver_tessellationin that environment shows the layer inserted.Apple M5 Max, macOS 27.0.1, MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0), x86-64 under Rosetta 2:
request_serializerand the 21agc_shader_memory_testsentries pass 3 times in a row on this branch, built natively. Two local build aids that are not part of this pull request were needed for that: the duplicatewrite_watchtest registration removed as in #13220, and theGuestMemory.cpppart of #11447.maindoes not build the AGC driver on macOS by itself, so the GPU check runs on my macOS tree (main102b7a5cfwith the open macOS host pull requests and my open GT7 pull requests) at48539c856b, which carries the same change (serialization version 52 there), with this pull request'sTessellation.cppchange applied. The new draw passes, andagc_driver_tessellationthen stops at a later check,did not take its blue channel from the hull's relative patch index across instances, which fails the same way on that tree with neither the change nor the new draw. With only theHostSubgroupSizeline removed, the new draw stops withAGC graphics: subgroup capability 61 is unsupported for shader stage 4, the error GT7 hits. UnderVK_LAYER_KHRONOS_validation(inserted, perVK_LOADER_DEBUG=layer) the run with the change has noVUID-lines.New checks:
verifySingleLaneDomainWave(tests/ShaderMemory.cpp): domain programs with lane operations and with av_readlane_b32waterfall loop declare no subgroup capability, built-in or instruction without tessellation evaluation subgroups, whatever the device's subgroup width, and still use subgroup operations with them; turning off vertex subgroups leaves a domain program on subgroups and turning off tessellation evaluation subgroups leaves a vertex program on them; a read of lane 31 throws; the flag survives serialization and changes the cache key. With theHostSubgroupSizeline removed it fails witha domain program without tessellation evaluation subgroups declared a subgroup capability, built-in or instruction.RequestSerializerTests.cpp: both values round-trip at version 51 as its last byte, a version 51 request without it is rejected as truncated, a version 49 request readstrueand is written back as version 51 with the flag set, and a version 50 request is rejected in either layout (as isNVNQQTIAAAA=inShaderMemory.cpp's unsupported-version list); both rejection checks fail with the version 50 check removed. The existing layout checks move by the one trailing byte.DomainFirstLaneCount(tests/execution/Tessellation.cpp):DomainCodewith its depth taken fromv_cvt_f32_u32ofv_readfirstlane_b32ofv_mbcnt(0 at any wave width), drawn throughRequirePatches. It runs on subgroups on the 4090 and one lane per invocation on MoltenVK; lavapipe in CI takes the one-lane path too, which I could not run here.tools/check_conventions.py --base origin/mainpasses, and the branch merges cleanly withmain828ac0b2ae, whose 19 new commits touch none of its files.tools/pr_overlap.py --branch fix/tes-single-lane-without-subgroupsagainstmainde83e8f270finds only the 12 version 50 pull requests above; 51 pull requests that conflict withmainthemselves share files with this branch and could not be compared.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 jotitadev on 2026-10-31T15:08:40Z.
Review: COMMENTED
The lavapipe run the description says it couldn't get, of head
32a6bdb6d3. Lavapipe has no subgroups in the tessellation evaluation stage, so it takes the new one-lane path. That path works, and the new draw catches the refusal without the change.Setup: Ubuntu 26.04, GCC 15.2, Release. Lavapipe from Mesa 26.0.3; its
subgroupSupportedStageshere isFRAGMENT | COMPUTE | TASK | MESH. An RTX 3070 with NVIDIA 595.99.02 serves as a control, since it has subgroups in that stage. The head is merged--no-ffontomain809c7fa2dfwith no conflicts.ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1,ctest -j1.agc_driver_tessellation_tests,agc_shader_memory_testsandrequest_serializer_testspass 3/3 with VVL 1.4.341, with noVUID-lines.agc_driver_tessellationruns all the way toTessellation tests passed, with no skip of the new draw. The only skips are the two unmapped hull-read checks that llvmpipe always skips.mainplus only this PR'sTessellation.cppfailsagc_driver_tessellationwithAGC graphics: subgroup capability 61 is unsupported for shader stage 4. That's the GT7 error. On the 3070, the same red passes, as expected.^agcon lavapipe (minus dcc/flip/lds_atomics64): 1132/1132 with the PR.GPUs tested: Mesa 26.0.3 lavapipe, Ubuntu 26.04 (one-lane path); NVIDIA GeForce RTX 3070, 595.99.02, Ubuntu 26.04 (subgroup path)
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.