fix(agc): honour primitive restart in mesh-path triangle fans #12125

Merged
Oscar45397 merged 2 commits from upstream-pr/12125 into main 2026-11-04 05:34:04 +00:00
Oscar45397 commented 2026-10-27 22:09:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Oscar45397 on 2026-10-27T22:09:39Z.


What

An indexed triangle fan drawn through the mesh path (NGG, inputPrimitive 5) refused any draw whose index buffer held the restart index (primitive restart in a triangle fan geometry draw is unsupported). This follows 8c06af0ad9 (mesh-path strips) and reuses its restart table:

  • Each index position records the start of its segment (one past the last restart at or before it). A fan primitive whose segment starts after its first rim vertex spans a restart and is made degenerate; the others take the segment's first vertex as their centre.
  • The centre is the group's slot 0 when the segment began at or before the group's first position, so lane 0 now fetches the centre of the segment holding that position (instead of always the draw's first index); otherwise it is the slot at the segment start's offset, which the group already fetched.
  • Restart indices are skipped in the highest-index scan as for strips, and fetch vertex 0.
  • Draws without a restart index are unchanged: the table is absent, MeshRestartStart yields 0, so the centre stays at slot 0 and lane 0 still fetches the first index.

Tested

Windows 11 Home 26300, Ryzen 9 5900X, NVIDIA GeForce RTX 3080 (driver 610.88), WinLibs GCC 15.2.0 r7, Release, rebased onto main b28bb77217, which now has #7893. The InstructionTranslator.cpp conflict with #7893's provoking-vertex fan order is resolved as in @thuanquang's merge 88c90472f3 (https://github.com/boykopovar/AnyPS5/pull/7893#issuecomment-6572457124): the fan centre slot takes #7893's u32(0u) places (first with the last provoking vertex, third with the first), and each fan slot goes through unlessRestarted.

  • Mesh.cpp: the refusal check is replaced by drawing quads as four-index fans each followed by a restart (16- and 32-bit indices, and an indirect draw starting mid-buffer), with three primitives per group so segments cross group boundaries and with front faces culled, so every quad must render whole with the strips' winding while the gaps stay clear; plus a whole fan followed by a restart. With the translator change reverted the first new check fails (16-bit triangle fans with restarts: quad 0 right half pixel (69, 253, 200, 255)).
  • MeshProvokingVertex.cpp (@thuanquang's commit aec17935c7, kept as is): two fans split by a restart, {1, 0, 2, 0xffff, 2, 3, 1}, drawn through a geometry program in both provoking modes; the second fan's centre is vertex 2, so its triangle takes vertex 1's colour with the last provoking vertex and vertex 3's with the first. Their run shows that taking either side of the conflict fails this case or #7893's strip case.
  • ctest --test-dir build -R "mesh|provoking|barycentric|agc_driver_graphics$" -V (14 tests) with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation on main b28bb77217 and on this branch (head 1ad6fe9894), same machine, 3 runs each: 14 of 14 pass on both in every run, and the branch's agc_driver_mesh_provoking_vertex success line names the new restart case. Neither log has a VUID- line, a Validation Error or the missing-layer message, and both log the same 20 WARNING- lines per run.
  • Overlaps: #7893 has landed and is merged in above. #9875 adds inputs.minIndex = lowest; above the inputPrimitive check this PR widens in Draw.cpp; keeping both lines resolves it.
  • No title was run: no bring-up thread reports this stop.

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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 3080, driver 32.0.16.1088, Windows 11
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5041865354 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12125). Originally posted by [Oscar45397](https://github.com/Oscar45397) on 2026-10-27T22:09:39Z. --- ### What An indexed triangle fan drawn through the mesh path (NGG, `inputPrimitive` 5) refused any draw whose index buffer held the restart index (`primitive restart in a triangle fan geometry draw is unsupported`). This follows 8c06af0ad9 (mesh-path strips) and reuses its restart table: - Each index position records the start of its segment (one past the last restart at or before it). A fan primitive whose segment starts after its first rim vertex spans a restart and is made degenerate; the others take the segment's first vertex as their centre. - The centre is the group's slot 0 when the segment began at or before the group's first position, so lane 0 now fetches the centre of the segment holding that position (instead of always the draw's first index); otherwise it is the slot at the segment start's offset, which the group already fetched. - Restart indices are skipped in the highest-index scan as for strips, and fetch vertex 0. - Draws without a restart index are unchanged: the table is absent, `MeshRestartStart` yields 0, so the centre stays at slot 0 and lane 0 still fetches the first index. ### Tested Windows 11 Home 26300, Ryzen 9 5900X, NVIDIA GeForce RTX 3080 (driver 610.88), WinLibs GCC 15.2.0 r7, Release, rebased onto `main` b28bb77217, which now has #7893. The `InstructionTranslator.cpp` conflict with #7893's provoking-vertex fan order is resolved as in @thuanquang's merge `88c90472f3` (https://github.com/boykopovar/AnyPS5/pull/7893#issuecomment-6572457124): the fan centre slot takes #7893's `u32(0u)` places (first with the last provoking vertex, third with the first), and each fan slot goes through `unlessRestarted`. - `Mesh.cpp`: the refusal check is replaced by drawing quads as four-index fans each followed by a restart (16- and 32-bit indices, and an indirect draw starting mid-buffer), with three primitives per group so segments cross group boundaries and with front faces culled, so every quad must render whole with the strips' winding while the gaps stay clear; plus a whole fan followed by a restart. With the translator change reverted the first new check fails (`16-bit triangle fans with restarts: quad 0 right half pixel (69, 253, 200, 255)`). - `MeshProvokingVertex.cpp` (@thuanquang's commit `aec17935c7`, kept as is): two fans split by a restart, `{1, 0, 2, 0xffff, 2, 3, 1}`, drawn through a geometry program in both provoking modes; the second fan's centre is vertex 2, so its triangle takes vertex 1's colour with the last provoking vertex and vertex 3's with the first. Their run shows that taking either side of the conflict fails this case or #7893's strip case. - `ctest --test-dir build -R "mesh|provoking|barycentric|agc_driver_graphics$" -V` (14 tests) with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` on `main` b28bb77217 and on this branch (head 1ad6fe9894), same machine, 3 runs each: 14 of 14 pass on both in every run, and the branch's `agc_driver_mesh_provoking_vertex` success line names the new restart case. Neither log has a `VUID-` line, a `Validation Error` or the missing-layer message, and both log the same 20 `WARNING-` lines per run. - Overlaps: #7893 has landed and is merged in above. #9875 adds `inputs.minIndex = lowest;` above the `inputPrimitive` check this PR widens in `Draw.cpp`; keeping both lines resolves it. - No title was run: no bring-up thread reports this stop. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: NVIDIA GeForce RTX 3080, driver 32.0.16.1088, Windows 11 - [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!12125
No description provided.