feat(shader): translate NGG geometry programs to mesh shaders #133
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/133"
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 oneandonlydean on 2026-09-29T00:33:18Z.
What
The geometry path compiles merged ES/GS (NGG) programs as mesh-stage programs, but
BuildShaderStageInputInfonever filled the mesh input metadata and theShaderMeshInputInfohelpers threw "not implemented", so every such draw failed with "mesh shader translation configuration is not supported (... primitives per group 0 ...)".Recompiler:
BuildShaderStageInputInfotakes the draw'sMeshConfiguration; the primitive size/step/count helpers are implemented.GS_TG_INFO, s3 merged wave info per wave, GS vertex offsets (ES thread ×VGT_ESGS_RING_ITEMSIZE, odd strip triangles swapped), primitive id, ES vertex and instance ids. An indexed draw's vertex id comes from the index buffer through a raw V# the driver places in hidden user words 4..7.s_sendmsg GS_ALLOC_REQbecomesMeshAllocate. The epilogue zeroes the allocation first, clamps it to the output limits, culls primitives no thread exported and decodes the 9-bit vertex indices.MeshDrawPushOffsetBytes). A BDA fault in a mesh program no longer stops the invocation: as for other programs with barriers, the fault is recorded and the read returns zero, so every invocation reaches the subgroup barriers.MeshConfigurationgainsesgsItemSize, soRequestSerializermoves to version 4 (main is at 3 since #153). Mesh requests before version 4 read back with an item size of 4, which is what main's prologue assumed (<< 2).Driver:
DecodeShaderStagesreadsVGT_ESGS_RING_ITEMSIZE(0x2ab, added toDrawKeyRegisters) and sizes the subgroup for its ES vertices, GS primitives and outputs. It throws on an item size of 0 or one that overflows the 16-bit offsets.PatchPushConstants) before the draw parameters are added. The index-buffer V# is set per draw, and per record on the CPU-resolved indirect path. The index-buffer alias check now applies only to written elements, in bothaddGuestBufferandCheckBufferAliases.APS5_SINGLE_LANEswitch still validates. Mesh draws may carry a first vertex/instance.MeshDrawPushOffsetBytes), so its SPIR-V always declares the push-constant variable, even when its user data do not fit the push range andRecompileResult::pushConstantsis empty. Validation refused such a draw with "invalid push constant interface". It still requires the block to match the recompiler's metadata for the other stages.Still throws: wave32 NGG programs, subgroups over 15 waves, inconsistent vertex/primitive counts, and GPU-side indirect mesh draws (unchanged).
RequestSerializer: #136 also moves the format to version 4 with different fields. Whichever PR merges second must rebase to version 5 and gate its own field on>= 5.Tested
agc_driver_mesh_tests(EXCLUDE_FROM_ALL, needs a GPU withVK_EXT_mesh_shader, so it is not in ctest) recompiles a hand-assembled merged ES/GS program in the PS5 compiler's layout and draws it throughVulkanDevice::Draw: indexed and non-indexed triangle lists in one- and two-wave subgroups (full and partial), and a triangle strip across odd-starting subgroups, with pixel readback. All pass. Main never fills the mesh input metadata, so these draws fail its configuration check (primitives per group 0).agc_shader_memorygainsverifyMeshConfiguration: helper sizes for list/strip/line/point,esgsItemSizesurvives serialization, cache key and context hash change with it. It does not compile on main (noesgsItemSize) and the helpers throw there.agc_driver_graphics_tests(ShaderStageTests: subgroup outputs,esgsItemSizedecode, invalid item size throws): run on a throwaway merge with #113, where 65/65 pass.agc_driver_mesh_testsalso draws the non-indexed triangle list with a geometry program given no push range for its own data (its user data then reach it through a buffer). Without the validation change it fails with "invalid push constant interface".ctest: 64/64 pass.agc_driver_mesh_testsandagc_driver_recorder_testspass.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