feat(agc): support last provoking vertex for native primitives #2322

Merged
jweidenh merged 3 commits from upstream-pr/2322 into main 2026-10-10 06:36:55 +00:00
jweidenh commented 2026-10-09 15:28:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jweidenh on 2026-10-09T15:28:42Z.


What

PA_SU_SC_MODE_CNTL.PROVOKING_VTX_LAST (bit 19) previously rejected a draw. This change decodes it as first/last provoking vertex and uses VK_EXT_provoking_vertex for native primitive pipelines, including flat P0 inputs already emitted as SPIR-V Flat. Keep first-vertex mode usable without the extension. Include the mode in the pipeline cache key and split render-pass instances when the device cannot mix modes within one pass.

This addresses the raster-state rejection reported in #2026, with PA_SU_SC_MODE_CNTL = 0x00080244. Another contributor reported that execution; I have not run the showcase. Bit 19 follows opengnm's flatshade_first mapping at db752da. Pipeline state and pass separation follow Khronos's provoking-vertex requirements.

The merged implementation rejects last mode when the device feature is unavailable, for rectangle lists, decoded geometry/mesh/tessellation paths or unsupported topologies, for explicit per-vertex flat inputs, and for triangle strips with any explicit per-vertex inputs. The latter need a verified mapping for device-dependent barycentric vertex ordering. These limitations and the absence of console measurements are recorded in TechnicalDebt. No shader instruction lowering changes.

A separate integration gap remains: #1547 inserts a geometry stage for barycentric emulation while leaving the decoded path as Vertex. The merged guard does not inspect that inserted stage, so it does not reject every generated-geometry pipeline. Last mode on that fallback remains unverified; the follow-up described below adds explicit rejection.

Tested

The maintainer rebased this PR to 03cb1147792090a37c03a7e25307af7f49201381 and merged it on October 10, 2026, at 06:36:55 UTC as d43d50be. The maintainer reported both graphics and provoking-vertex tests passing on the rebased head. Our local results below apply to explicitly identified revisions.

Tested revision 3f5691adfd248044ec420db5102ed9c8c6c23051 was based on main 691c0c3b35da50d3ef5a75231b9b0bd5d4e4388d. The raster-mask conflict retains upstream #1915's conditional lineOffset acceptance and this PR's bit-19 exclusion. Its point/line rejection assertion remains; the expected message now reads polygon mode, depth bias or nonstandard rasterization. The provoking-vertex rendering test and shader fixtures are unchanged.

Private validation run 38028219729 validated 3f5691ad on a locally managed self-hosted Ubuntu 24.04 x86-64 runner (GCC 13.3.0, CMake 3.28.3, Mesa 25.2.8 lavapipe/LLVM 20.1.2): Release, BUILD_TESTING=ON, ANYPS5_ENABLE_SPIRV_TOOLS=ON, explicit lavapipe ICD, Xvfb, fresh shader cache, and ANYPS5_REQUIRE_VULKAN=1. Its logs are not publicly accessible.

  • Full Release build and patched libs target passed.
  • The unmodified test-registration checker passed: 507 configured test executables, none left unregistered. Upstream #2537 is now in the base, so the earlier private checker accommodation has been removed.
  • Targeted CTest: 2 passed, 0 failures, 0 CTest skips; agc_driver_graphics: 7.3733 s; agc_driver_provoking_vertex: 0.093926 s (7.40 s total). Both used 30-second limits. Graphics reported its heap-mirror branches untested because the guest arena was unavailable or not write-watched; the provoking-vertex rendering fixture passed. The full suite was not rerun for this rebase.
  • Conventions against the pinned base and git diff --check passed.

Validated follow-up, not merged:

Guard patch 6bf6e3bf, on a separate validation branch based on 0aaadd6457c3f413563ba8f27171baa433627ff3, adds a compiled-stage Geometry check. Its regression uses the actual barycentric-emulation geometry fixture: first mode remains accepted without the provoking-vertex feature, and last mode rejects even when the feature is available. This guard is not included in merged head 03cb1147 or merge d43d50be.

Private self-hosted run 38031414843, workflow 1ff7598f2904f828a9fd132436e6dde03d877b0f, passed for candidate 6bf6e3bfe7aa74b616eba5239897a2c8d508971d on Ubuntu 24.04, GCC 13.3, CMake 3.28.3 and Mesa 25.2.8 lavapipe/LLVM 20.1.2:

  • Full Release build and patched libraries passed.
  • The unmodified registration checker passed: 530 configured test executables, none unregistered.
  • All three focused tests passed with zero failures, disabled tests or CTest skips: graphics 3.98526 s, provoking vertex 0.0541438 s, pixel barycentric emulation 0.156106 s; total wall time 4.00 s. Vulkan was required, the lavapipe ICD explicit, caches fresh and timeouts unchanged at 30 seconds.
  • Graphics reported two internal heap-mirror subcases untested because guest arena/write-watch was unavailable. Both rendering fixtures passed. The full CTest suite was not run for this follow-up.
  • Conventions, description-template and diff checks passed; the guard and regression were independently reviewed.

These results apply to the separate candidate, not to merged head 03cb1147. The private workflow artifacts require repository access; the linked patch is public.

Earlier validation and limitations:

On dda8a724, based on main d70b8998, a full Release build and patched libs target succeeded on Ubuntu 24.04 x86-64 with GCC 13.3, CMake 3.28.3, and Mesa 25.2.8 lavapipe. CTest reported 490 passed, 26 capability skips, one baseline timeout, out of 517 tests.

  • agc_driver_graphics passed in 3.84 s: register decode/reset, existing flat P0 lowering, unsupported-path rejection, and production render-pass keys for both provokingVertexModePerPipeline values.
  • agc_driver_provoking_vertex passed in 0.034 s: exact triangle-list and triangle-strip pixel colors, first/last/first, with both reference GLSL and an actual recompiled guest v_interp_mov P0 fragment shader. Stable shader variants exercise pipeline-cache separation. Render-pass continuation identity is tested on the CPU; rendering uses synchronous linear targets.
  • Forcing first-vertex rasterization made the last-mode pixel assertion fail (red channel 255, expected 0); restoring the implementation passed.
  • agc_driver_flat_store timed out at 30.05 s waiting on a GPU fence. It independently reproduced on unmodified main d70b8998 with the same toolchain and Vulkan settings (30.07 s). This remains a recorded failure; no timeout increase or exclusion was used.

Independent Windows validation reported by popcoder565 passed agc_driver_provoking_vertex and agc_driver_graphics on Windows 10, RTX 3060 Laptop, NVIDIA 616.92, and MinGW-w64 GCC 15.2.0. That used dda8a724 merged onto main f8c2f072 alongside nine other PRs. The combined suite was 512/513; the reporter attributes its sole failure, agc_driver_depth_fast_clear_submit, to #2325 and reports it also fails intermittently alone. This was a combined build; no title was run.

Local validation uses Linux/lavapipe. No title execution, PS5 hardware measurement, or local Windows runtime test was performed.

Checklist

  • Based on main; maintainer-rebased head 03cb1147 merged as d43d50be
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • No silent stubs added; unsupported-path checks and the remaining fallback gap are described above
  • No notes, investigation files or images added to the repository
  • New third-party code is a submodule built from source; none added
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes, Codex
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4802487422 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2322). Originally posted by [jweidenh](https://github.com/jweidenh) on 2026-10-09T15:28:42Z. --- ### What `PA_SU_SC_MODE_CNTL.PROVOKING_VTX_LAST` (bit 19) previously rejected a draw. This change decodes it as first/last provoking vertex and uses `VK_EXT_provoking_vertex` for native primitive pipelines, including flat P0 inputs already emitted as SPIR-V `Flat`. Keep first-vertex mode usable without the extension. Include the mode in the pipeline cache key and split render-pass instances when the device cannot mix modes within one pass. This addresses the raster-state rejection [reported in #2026](https://github.com/boykopovar/AnyPS5/issues/2026#issuecomment-6075329161), with `PA_SU_SC_MODE_CNTL = 0x00080244`. Another contributor reported that execution; I have not run the showcase. Bit 19 follows [opengnm's `flatshade_first` mapping at db752da](https://github.com/blackbearreloaded/ps5-opengl/blob/db752da4c89380af228497b5b6852163a4e61069/src/gallium/ps5/ps5_screen.c#L2244). Pipeline state and pass separation follow [Khronos's provoking-vertex requirements](https://docs.vulkan.org/refpages/latest/refpages/source/VkPipelineRasterizationProvokingVertexStateCreateInfoEXT.html). The merged implementation rejects last mode when the device feature is unavailable, for rectangle lists, decoded geometry/mesh/tessellation paths or unsupported topologies, for explicit per-vertex flat inputs, and for triangle strips with any explicit per-vertex inputs. The latter need a verified mapping for [device-dependent barycentric vertex ordering](https://docs.vulkan.org/refpages/latest/refpages/source/VkPhysicalDeviceFragmentShaderBarycentricPropertiesKHR.html). These limitations and the absence of console measurements are recorded in TechnicalDebt. No shader instruction lowering changes. A separate integration gap remains: [#1547](https://github.com/boykopovar/AnyPS5/pull/1547) inserts a geometry stage for barycentric emulation while leaving the decoded path as Vertex. The merged guard does not inspect that inserted stage, so it does not reject every generated-geometry pipeline. Last mode on that fallback remains unverified; the follow-up described below adds explicit rejection. ### Tested The maintainer rebased this PR to `03cb1147792090a37c03a7e25307af7f49201381` and merged it on October 10, 2026, at 06:36:55 UTC as [d43d50be](https://github.com/boykopovar/AnyPS5/commit/d43d50beb1ee86b1df14569e0780257ab87d6903). The maintainer [reported both graphics and provoking-vertex tests passing on the rebased head](https://github.com/boykopovar/AnyPS5/pull/2322#issuecomment-6094684029). Our local results below apply to explicitly identified revisions. Tested revision `3f5691adfd248044ec420db5102ed9c8c6c23051` was based on `main` `691c0c3b35da50d3ef5a75231b9b0bd5d4e4388d`. The raster-mask conflict retains upstream [#1915](https://github.com/boykopovar/AnyPS5/pull/1915)'s conditional `lineOffset` acceptance and this PR's bit-19 exclusion. Its point/line rejection assertion remains; the expected message now reads `polygon mode, depth bias or nonstandard rasterization`. The provoking-vertex rendering test and shader fixtures are unchanged. Private validation run `38028219729` validated `3f5691ad` on a locally managed self-hosted Ubuntu 24.04 x86-64 runner (GCC 13.3.0, CMake 3.28.3, Mesa 25.2.8 lavapipe/LLVM 20.1.2): Release, `BUILD_TESTING=ON`, `ANYPS5_ENABLE_SPIRV_TOOLS=ON`, explicit lavapipe ICD, Xvfb, fresh shader cache, and `ANYPS5_REQUIRE_VULKAN=1`. Its logs are not publicly accessible. - Full Release build and patched `libs` target passed. - The unmodified test-registration checker passed: **507 configured test executables**, none left unregistered. Upstream [#2537](https://github.com/boykopovar/AnyPS5/pull/2537) is now in the base, so the earlier private checker accommodation has been removed. - Targeted CTest: **2 passed, 0 failures, 0 CTest skips**; `agc_driver_graphics`: 7.3733 s; `agc_driver_provoking_vertex`: 0.093926 s (7.40 s total). Both used 30-second limits. Graphics reported its heap-mirror branches untested because the guest arena was unavailable or not write-watched; the provoking-vertex rendering fixture passed. The full suite was not rerun for this rebase. - Conventions against the pinned base and `git diff --check` passed. Validated follow-up, not merged: [Guard patch `6bf6e3bf`](https://github.com/jweidenh/AnyPS5/commit/6bf6e3bfe7aa74b616eba5239897a2c8d508971d), on a separate validation branch based on `0aaadd6457c3f413563ba8f27171baa433627ff3`, adds a compiled-stage Geometry check. Its regression uses the actual barycentric-emulation geometry fixture: first mode remains accepted without the provoking-vertex feature, and last mode rejects even when the feature is available. This guard is **not included** in merged head `03cb1147` or merge `d43d50be`. Private self-hosted [run `38031414843`](https://github.com/hammerlab-dev/anyps5-validation/actions/runs/38031414843), workflow `1ff7598f2904f828a9fd132436e6dde03d877b0f`, passed for candidate `6bf6e3bfe7aa74b616eba5239897a2c8d508971d` on Ubuntu 24.04, GCC 13.3, CMake 3.28.3 and Mesa 25.2.8 lavapipe/LLVM 20.1.2: - Full Release build and patched libraries passed. - The unmodified registration checker passed: 530 configured test executables, none unregistered. - All three focused tests passed with zero failures, disabled tests or CTest skips: graphics 3.98526 s, provoking vertex 0.0541438 s, pixel barycentric emulation 0.156106 s; total wall time 4.00 s. Vulkan was required, the lavapipe ICD explicit, caches fresh and timeouts unchanged at 30 seconds. - Graphics reported two internal heap-mirror subcases untested because guest arena/write-watch was unavailable. Both rendering fixtures passed. The full CTest suite was not run for this follow-up. - Conventions, description-template and diff checks passed; the guard and regression were independently reviewed. These results apply to the separate candidate, not to merged head `03cb1147`. The private workflow artifacts require repository access; the linked patch is public. Earlier validation and limitations: On `dda8a724`, based on `main` `d70b8998`, a full Release build and patched `libs` target succeeded on Ubuntu 24.04 x86-64 with GCC 13.3, CMake 3.28.3, and Mesa 25.2.8 lavapipe. CTest reported **490 passed, 26 capability skips, one baseline timeout**, out of 517 tests. - `agc_driver_graphics` passed in 3.84 s: register decode/reset, existing flat P0 lowering, unsupported-path rejection, and production render-pass keys for both `provokingVertexModePerPipeline` values. - `agc_driver_provoking_vertex` passed in 0.034 s: exact triangle-list and triangle-strip pixel colors, first/last/first, with both reference GLSL and an actual recompiled guest `v_interp_mov P0` fragment shader. Stable shader variants exercise pipeline-cache separation. Render-pass continuation identity is tested on the CPU; rendering uses synchronous linear targets. - Forcing first-vertex rasterization made the last-mode pixel assertion fail (red channel 255, expected 0); restoring the implementation passed. - `agc_driver_flat_store` timed out at 30.05 s waiting on a GPU fence. It independently reproduced on unmodified `main` `d70b8998` with the same toolchain and Vulkan settings (30.07 s). This remains a recorded failure; no timeout increase or exclusion was used. Independent [Windows validation reported by popcoder565](https://github.com/boykopovar/AnyPS5/pull/2322#issuecomment-6087420702) passed `agc_driver_provoking_vertex` and `agc_driver_graphics` on Windows 10, RTX 3060 Laptop, NVIDIA 616.92, and MinGW-w64 GCC 15.2.0. That used `dda8a724` merged onto `main` `f8c2f072` alongside nine other PRs. The combined suite was 512/513; the reporter attributes its sole failure, `agc_driver_depth_fast_clear_submit`, to #2325 and reports it also fails intermittently alone. This was a combined build; no title was run. Local validation uses Linux/lavapipe. No title execution, PS5 hardware measurement, or local Windows runtime test was performed. ### Checklist - [x] Based on `main`; maintainer-rebased head `03cb1147` merged as `d43d50be` - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] No silent stubs added; unsupported-path checks and the remaining fallback gap are described above - [x] No notes, investigation files or images added to the repository - [x] New third-party code is a submodule built from source; none added - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes, Codex
Kikoarl commented 2026-10-09 18:29:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Kikoarl on 2026-10-09T18:29:44Z.


Tested on Linux (CachyOS x86_64, Intel RPL-S iGPU / Mesa 26.3.0-devel / Vulkan 1.4.363, GCC 16.2.1) at dda8a724:

  • Build: Built cleanly in RAM (/tmp/anyps5_build) with zero warnings/errors.
  • Conventions: python3 tools/check_conventions.py --base origin/main --head HEAD -> PASS (0 errors).
  • Verification: Verified last provoking vertex primitive state handling in VulkanDevice.cpp and graphics pipeline. Required for correct flat shading across Vulkan drivers.

LGTM!

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6086889789 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2322#issuecomment-6086889789). Originally posted by [Kikoarl](https://github.com/Kikoarl) on 2026-10-09T18:29:44Z. --- Tested on Linux (CachyOS x86_64, Intel RPL-S iGPU / Mesa 26.3.0-devel / Vulkan 1.4.363, GCC 16.2.1) at `dda8a724`: - **Build**: Built cleanly in RAM (`/tmp/anyps5_build`) with zero warnings/errors. - **Conventions**: `python3 tools/check_conventions.py --base origin/main --head HEAD` -> **PASS (0 errors)**. - **Verification**: Verified last provoking vertex primitive state handling in `VulkanDevice.cpp` and graphics pipeline. Required for correct flat shading across Vulkan drivers. LGTM!
popcoder565 commented 2026-10-09 19:03:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T19:03:52Z.


Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), RTX 3060 Laptop (NVIDIA 616.92), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head dda8a724, merged onto main f8c2f072 in one build with 9 other PRs that had no Windows run.

  • This PR's tests pass: agc_driver_provoking_vertex, agc_driver_graphics.
  • Full ctest in that build: 512 of 513. The one failure is agc_driver_depth_fast_clear_submit from #2325, which fails intermittently on its own too. The test comes from #425, where I reported it.

No title was run.

🤖 Addressed by Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6087420702 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2322#issuecomment-6087420702). Originally posted by [popcoder565](https://github.com/popcoder565) on 2026-10-09T19:03:52Z. --- Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), RTX 3060 Laptop (NVIDIA 616.92), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head `dda8a724`, merged onto `main` f8c2f072 in one build with 9 other PRs that had no Windows run. - This PR's tests pass: `agc_driver_provoking_vertex`, `agc_driver_graphics`. - Full ctest in that build: 512 of 513. The one failure is `agc_driver_depth_fast_clear_submit` from #2325, which fails intermittently on its own too. The test comes from #425, where I reported it. No title was run. _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
oneandonlydean commented 2026-10-10 05:18:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-10T05:18:41Z.


The new head conflicts with main in State.cpp; please rebase.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6094143790 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2322#issuecomment-6094143790). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-10T05:18:41Z. --- The new head conflicts with main in `State.cpp`; please rebase.
adriadam10 commented 2026-10-10 06:32:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T06:32:28Z.


Rebased onto current main (conflicts only in libSceAgcDriver/CMakeLists.txt and docs/dev/TechnicalDebt.md, both kept) and moved the validation text under ### Tested so the conventions check finds it. No code changes.

Checked agc_driver_graphics and agc_driver_provoking_vertex on the rebased head (Linux, lavapipe); both pass. Merging once the full Build workflow is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6094684029 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2322#issuecomment-6094684029). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-10T06:32:28Z. --- Rebased onto current `main` (conflicts only in `libSceAgcDriver/CMakeLists.txt` and `docs/dev/TechnicalDebt.md`, both kept) and moved the validation text under `### Tested` so the conventions check finds it. No code changes. Checked `agc_driver_graphics` and `agc_driver_provoking_vertex` on the rebased head (Linux, lavapipe); both pass. Merging once the full Build workflow is green.
github-actions[bot] commented 2026-10-10 06:34:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T06:34:47Z.


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.

Pull request Conflicting files (lines on main) Same exports Same new files
#1607 docs/dev/TechnicalDebt.md L341-342
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6094701019 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2322#issuecomment-6094701019). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-10T06:34:47Z. --- <!-- pr-overlap --> 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**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #1607 | `docs/dev/TechnicalDebt.md` [L341-342](https://github.com/boykopovar/AnyPS5/blob/8f693fc82c90ff4a09146e277019b1f014826a1d/docs/dev/TechnicalDebt.md#L341-L342) | | |
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!2322
No description provided.