fix(agc): let mesh-path list draws with primitive restart skip the list-restart emulation #17976

Merged
Gonic0 merged 1 commit from upstream-pr/17976 into main 2026-11-15 20:23:02 +00:00
Gonic0 commented 2026-11-10 02:09:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Gonic0 on 2026-11-10T02:09:37Z.


What

Draw.cpp emulates primitive restart in point, line and triangle lists on devices without VK_EXT_primitive_topology_list_restart by compacting the index buffer that the input assembler reads (#12180). That branch also stopped every mesh-path list draw with restart at a requirement for the extension. A mesh draw has no input assembler: its entry fetches the indices itself, so the compaction does not apply to it.

A mesh-path list draw with primitive restart now skips the emulation and takes the same path as on a device with the extension: skipRestart is set for it, so the index range is read with the restart index left out. The requirement is removed.

The fix and its diagnosis are imellag's (comment on #9356), and the commit carries their authorship. It is opened on its own at the request of the author of #17611 (comment): #17611 is what lets mesh-path draws reach devices without VK_EXT_mesh_shader, such as MoltenVK, and there the requirement stops PPSA21564 shortly after launch.

Not changed: the mesh entry handles the restart index only in triangle strips and fans. In a list it is fetched as an ordinary index, as it already was on devices with the extension.

Tested

macOS 27.3, Apple M5 Pro, Apple clang, x86-64 Release under Rosetta 2. Tree: main 81eb4e1935 with #17611 (7957c8eb77; its only conflict, FormatVersion in ShaderDiskCache.hpp, set to 69), and #16591, #17425, #17532 and #17767, which macOS needs to build. The game binary was relinked from the same tree.

PPSA21564 on MoltenVK 1.4.2 (which lists VK_EXT_primitive_topology_list_restart but reports primitiveTopologyListRestart as false), same save, cold shader cache, 150 s limit:

tree result
main stops 38 s after launch: AGC graphics: device does not support mesh shaders
main + #17611 stops 39 s after launch: primitive restart in a mesh list draw needs VK_EXT_primitive_topology_list_restart
main + #17611 + this change no error; reaches the world map at 72 s and is still rendering at the 150 s limit

ctest -R '^(agc_driver_(graphics|layered_[a-z_]+|mesh[a-z_]*|pass_break_reasons|pass_input_hazard)|agc_mesh_output_budget)$' on MoltenVK 1.4.2 and KosmicKrisp (Mesa main), on the same pull requests over main 6c03f737f0 (Draw.cpp is unchanged since), with and without this change: 10 run and pass, 8 skip. The 8 are the mesh execution tests, which skip on both drivers because neither has VK_EXT_mesh_shader, so no existing test reaches this path.

Linux, Windows, AMD and NVIDIA: not run. On a device that supports primitiveTopologyListRestart the change does nothing: skipRestart was already set for these draws.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none; it applies to main on its own, and #17611 is what makes the path reachable on devices without VK_EXT_mesh_shader
  • Fixes: none
  • Unblocks: none
  • GPUs tested: Apple M5 Pro with MoltenVK 1.4.2 and KosmicKrisp, macOS 27.3
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5234555695 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17976). Originally posted by [Gonic0](https://github.com/Gonic0) on 2026-11-10T02:09:37Z. --- ### What `Draw.cpp` emulates primitive restart in point, line and triangle lists on devices without `VK_EXT_primitive_topology_list_restart` by compacting the index buffer that the input assembler reads (#12180). That branch also stopped every mesh-path list draw with restart at a requirement for the extension. A mesh draw has no input assembler: its entry fetches the indices itself, so the compaction does not apply to it. A mesh-path list draw with primitive restart now skips the emulation and takes the same path as on a device with the extension: `skipRestart` is set for it, so the index range is read with the restart index left out. The requirement is removed. The fix and its diagnosis are imellag's ([comment on #9356](https://github.com/boykopovar/AnyPS5/pull/9356#issuecomment-6712461561)), and the commit carries their authorship. It is opened on its own at the request of the author of #17611 ([comment](https://github.com/boykopovar/AnyPS5/pull/17611#issuecomment-6756281917)): #17611 is what lets mesh-path draws reach devices without `VK_EXT_mesh_shader`, such as MoltenVK, and there the requirement stops PPSA21564 shortly after launch. Not changed: the mesh entry handles the restart index only in triangle strips and fans. In a list it is fetched as an ordinary index, as it already was on devices with the extension. ### Tested macOS 27.3, Apple M5 Pro, Apple clang, x86-64 Release under Rosetta 2. Tree: `main` `81eb4e1935` with #17611 (`7957c8eb77`; its only conflict, `FormatVersion` in `ShaderDiskCache.hpp`, set to 69), and #16591, #17425, #17532 and #17767, which macOS needs to build. The game binary was relinked from the same tree. PPSA21564 on MoltenVK 1.4.2 (which lists `VK_EXT_primitive_topology_list_restart` but reports `primitiveTopologyListRestart` as false), same save, cold shader cache, 150 s limit: | tree | result | |---|---| | `main` | stops 38 s after launch: `AGC graphics: device does not support mesh shaders` | | `main` + #17611 | stops 39 s after launch: `primitive restart in a mesh list draw needs VK_EXT_primitive_topology_list_restart` | | `main` + #17611 + this change | no error; reaches the world map at 72 s and is still rendering at the 150 s limit | `ctest -R '^(agc_driver_(graphics|layered_[a-z_]+|mesh[a-z_]*|pass_break_reasons|pass_input_hazard)|agc_mesh_output_budget)$'` on MoltenVK 1.4.2 and KosmicKrisp (Mesa `main`), on the same pull requests over `main` `6c03f737f0` (`Draw.cpp` is unchanged since), with and without this change: 10 run and pass, 8 skip. The 8 are the mesh execution tests, which skip on both drivers because neither has `VK_EXT_mesh_shader`, so no existing test reaches this path. Linux, Windows, AMD and NVIDIA: not run. On a device that supports `primitiveTopologyListRestart` the change does nothing: `skipRestart` was already set for these draws. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none; it applies to `main` on its own, and #17611 is what makes the path reachable on devices without `VK_EXT_mesh_shader` - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: Apple M5 Pro with MoltenVK 1.4.2 and KosmicKrisp, macOS 27.3 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!17976
No description provided.