Repository navigation
Conversation
…out mesh shaders A mesh-path draw (the NGG primitive shader path) needed VK_EXT_mesh_shader. On a device without it, or for a draw whose targets have more layers than the device's maxMeshOutputLayers, the mesh program is now compiled as a GLCompute shader (SpirvTarget::meshAsCompute) that writes the draw's primitives and vertex records to a device buffer behind a VkDrawIndirectCommand header. A generated readback vertex shader (BuildMeshReadbackVertexShader) reads the records back for a triangle or line list drawn with vkCmdDrawIndirect, carrying position, parameters, clip and cull distances and the provoking vertex's layer. - The compute pass has its own pipeline layout with a compute push range; the draw's independent-sets layout lost the device on RDNA1. - The pass pins the program's subgroup size where the device allows it and refuses compute subgroups narrower than the wave, except the 32-lane subgroups that run a wave-64 program in paired lanes. - MeshDrawRunsAsCompute decides per draw: always without mesh shaders, and on a device with them when MeshDrawLayers exceeds maxMeshOutputLayers. - APS5_NO_MESH_SHADER=1 leaves VK_EXT_mesh_shader off. - Serialization version 43 stores meshAsCompute; the shader disk cache format is 45 for the record layout field. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…nd it From review of the mesh compute fallback: - An indirect mesh draw run as compute sized its output buffer for four instances, and a record with more drew nothing. Its record is now read on the CPU (IndirectDrawPath::MeshCompute, which waits for the producer like the other CPU-read paths), and the buffer is sized from the groups and instances it resolves to. Mesh.cpp draws an indirect record with six instances. - The output buffer is bounded: a draw that needs more than 256 MiB (MeshComputeOutputLimitBytes) or maxStorageBufferRange throws. - docs/dev/ARCHITECTURE.md describes the compute pass and the readback vertex stage. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
main gained mesh-path point output with register and exported point sizes. The compute fallback's vertex record carries no point size and its readback draws triangle or line lists, so a mesh program with point output run as compute now throws instead of failing to emit; agc_driver_mesh runs its point cases on the native mesh stage only, and the debt file lists it. Rebased onto main: serialization version 45 after main's point and fused arithmetic fields, shader disk cache format 46. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Route mesh shaders that run through the compute fallback into the barycentric tessellation emulation when the device lacks fragmentShaderBarycentric, reusing the readback vertex shader. The pixel shader of such a draw follows the tessellation evaluation stage, so it is no longer compiled in mesh mode when the request runs the mesh program as compute: its flat inputs stay per vertex instead of per primitive. These patches need no VK_EXT_provoking_vertex for the last provoking vertex: the generated evaluation stage writes the provoking vertex's flat values itself, as on the vertex path. AI-assisted: yes Co-authored-by: root-over <91559694+root-over@users.noreply.github.com>
|
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.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Builds on boykopovar#9356. On a device without
fragmentShaderBarycentric, a mesh-path draw that runs through the compute fallback and whose pixel shader reads barycentrics had no route. The barycentric tessellation emulation from boykopovar#7308 was limited to the vertex path. This PR feeds the mesh readback vertex shader from boykopovar#9356 intoBuildBarycentricTessellationShaders. The draw then runs as compute pass → readback VS → TCS → TES → fragment, drawn as a 3-control-point patch list.Execution/.../Draw.cpp: a compute-fallback mesh program takes the emulation branch. It requires triangle output, tessellation support and no clip, cull or layer exports, and passes the provoking vertex mode as in feat(agc): draw the last provoking vertex through the barycentric tessellation stages boykopovar/AnyPS5#7426.Graphics/src/Draw.cpp:MeshComputeStagesaccepts the two emulation stages after the mesh stage.Pipeline.cpp: patch-list topology andpatchControlPoints = 3for the emulation patches on the mesh path. Like the vertex path's patches, they need noVK_EXT_provoking_vertexfor the last provoking vertex, because the generated evaluation stage writes the provoking vertex's flat values itself (feat(agc): draw the last provoking vertex through the barycentric tessellation stages boykopovar/AnyPS5#7426).ShaderValidation.cpp: validates the five-stage mesh layout. The failure text stays "require a triangle list".Recompiler.cpp: a pixel shader whose request runs the mesh program as compute is no longer compiled in mesh mode. Its flat inputs then stay per vertex, as the tessellation evaluation stage in front of it provides them (from root-over, co-author).MeshReadbackVertexShader.cpp: copiesparameterExportsso the control stage sees the mesh outputs.core/shader/recompiler/CMakeLists.txt:MeshRecordClipDistances,MeshRecordCullDistancesandMeshRecordLayerare recorded inshaderCacheReviewedNames. They are inline decoders ofRecompileResult::meshRecordLayout, which is part of the cached result, andDraw.cpponly uses them to refuse draws. They do not reach aRecompileRequest.tests/Mesh.cpp:agc_driver_meshdraws through the compute fallback withfragmentShaderBarycentricdisabled, non-indexed and indexed, and compares front/back culling with the ordinary readback draw. A flat-input case with a different value per vertex checks the provoking vertex's value on every triangle, with the first and with the last provoking vertex. The emulated draws give the pixel request the meshGraphicsCompileContext, asDrawCapturedoes.docs/dev/debt/libSceAgcDriver.md:meshAsCompute.Overlap: boykopovar#8083 (now merged) and boykopovar#8339 each change a condition line in
Execution/.../Draw.cpp, and boykopovar#8083 also changes the triangle-list check inShaderValidation.cpp. This branch sits on boykopovar#9356's current head f49a25a, which itself conflicts with main again. Once boykopovar#9356 is rebased, I will rebase this commit onto it and keep the triangle-strip condition and its message next to the mesh stage count.Tested
Apple M4 (10-core GPU), macOS 27.2, MoltenVK (no mesh shaders, no fragment barycentrics, no
VK_EXT_provoking_vertex), x86_64 build under Rosetta 2. Currentmaindoes not build itslibcon macOS, so the runtime tests ran on the community macOS stack with boykopovar#9356 and the same changes applied:agc_driver_graphics,agc_driver_mesh(including the flat-input cases with the first and the last provoking vertex) andagc_driver_pixel_barycentric_emulationpass. The stack lacked feat(agc): draw the last provoking vertex through the barycentric tessellation stages boykopovar/AnyPS5#7426, so its three code commits were cherry-picked there.agc_driver_meshandagc_driver_pixel_barycentric_emulation, pass with and withoutVK_LAYER_KHRONOS_validation1.4.357.0, with no validation errors.agc_driver_graphicsis CPU-side. MoltenVK has noVK_EXT_provoking_vertex.Recompiler.cppline: the interface mismatch root-over's titles hit;Pipeline.cppexemption: theVK_EXT_provoking_vertexrequirement;tests/Graphics.cppcompile.ShaderCacheVersion.cmake) passes. Without the three reviewed names it reports the six uses that wachi35676 and MarcZX10 hit.tools/check_conventions.py --base origin/mainpasses.Independent runs on the previous head (thanks):
APS5_NO_MESH_SHADER=1.agc_driver_meshpasses there, and the negative control fails without the change.VUID-.Recompiler.cppchange that is now part of this PR. ccleste reaches its title screen.75fb6a509, 17 more catalog titles get past main's missing-mesh-shader abort and are still running at 40 s. Four still stop: FMASK in two titles, and Ruffle Flash and Dusklight on this PR's "needs a vertex shader before it" condition (under investigation).Not tested on titles on macOS (the macOS stack needs further work for ccleste).
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)