Skip to content

fix(agc): draw compacted restart lists and restart-free strips through the barycentric patches - #12706

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
Gonic0:fix/agc-barycentric-patches-restart
Oct 29, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
Gonic0:fix/agc-barycentric-patches-restart

Conversation

@Gonic0

@Gonic0 Gonic0 commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

What

On a device with neither fragmentShaderBarycentric nor geometry shaders (MoltenVK), a pixel shader that reads barycentrics is emulated through generated tessellation stages. Until now, Driver::draw and Pipeline refused every such draw with the primitive restart bit set, but two of those draws never restart on the host:

Both now take the patches. These still throw:

  • an indexed strip with restart;
  • a list with restart on a device that has the extension, where the host would restart and a patch list cannot.

Pipeline does not know whether a draw is indexed, so it accepts any strip. Graphics::Draw, which does know, now refuses an indexed strip with restart next to its existing indirect-strip check. Driver::draw refuses it too.

The pipeline keeps primitiveRestartEnable off for patch lists. Vulkan requires that without primitiveTopologyPatchListRestart (VUID-VkPipelineInputAssemblyStateCreateInfo-topology-06253).

The docs/dev/debt/shader.md and libSceAgcDriver.md entries for this path now say what is accepted and what throws. check_conventions.py warns about the length of the shader entry. That entry was already over 1000 characters on main; this PR only rewrites two of its clauses.

Overlap

Tested

Apple M5 Pro, macOS 27.2, MoltenVK from Vulkan SDK 1.4.363 (no geometry shaders, no primitiveTopologyListRestart), x86-64 Release under Rosetta 2, ANYPS5_NO_SHADER_CACHE=1.

main alone does not build libkernel or the driver on macOS, so I ran the tests in a tree with the open macOS port PRs. In that tree the changed functions match this branch exactly, and main has not touched the three source files between that tree's base and b433c40f2f.

agc_driver_pixel_barycentric_emulation_tests passes 3 of 3 with VK_LAYER_KHRONOS_validation loaded and no VUID- messages. It now draws through the tessellation stages, with the restart bit set:

  • a triangle strip;
  • a non-indexed triangle list;
  • the indexed list 2 R 0 1 2 0 1, where R is the restart index and only 0 1 2 is a complete triangle;
  • an indexed strip with restart, which must be refused.

It checks the I/J of every interior pixel as for the draws without restart: 864 and 864 pixels for the strip's two triangles, and 932 for each list. The list cases run only on a device without the extension. The strip cases run wherever tessellation does.

Negative controls (each fails, or reports, as expected):

  • The old Pipeline check fails at that check.
  • Skipping feat(agc): emulate list primitive restart without VK_EXT_primitive_topology_list_restart #12180's compaction for patch draws fails: "pixel (16, 6) channel 0 is 0.967349, expected 0.004731". This one ran on the previous base; the others ran on the current one.
  • Without the new Graphics::Draw check, the run fails with "an indexed triangle strip with primitive restart was not refused".
  • Without !patches in primitiveRestartEnable, the run passes but the validation layer reports VUID-...-06253 4 times.

agc_driver_list_restart_tests passes. agc_driver_graphics_tests passed 7 of 9 runs; both failures were "two ranges under a budget for two were not imported" from the host-import budget check in BdaResources.cpp. This PR does not touch that code, and the test then passed 5 runs in a row. agc_driver_mesh_barycentric_emulation_tests skips because there is no VK_EXT_mesh_shader.

Not covered by a test: the changed require in Driver::draw. The tests call VulkanDevice::Draw directly, and no execution test sends a barycentric draw through Driver::draw.

ASTRO BOT (PPSA21564 01.007.000): in a local tree that also emulates mesh shaders, the title aborted about 10 s in, while loading the UI, at this require without this change. With it, it ran for 300 s. Which of the three cases its draws use was not logged.

Not tested on Linux or Windows. Devices with geometry shaders do not take the patches.

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 (overlaps feat(agc): emulate mesh-fallback barycentrics through tessellation #9387 on the same lines, see Overlap)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: Apple M5 Pro, MoltenVK (Vulkan SDK 1.4.363), macOS 27.2
  • AI-assisted: yes

🤖 Generated with Claude Code

…h the barycentric patches

The barycentric tessellation path refused any draw with the primitive
restart bit set. A non-indexed strip ignores the bit, and on a device
without VK_EXT_primitive_topology_list_restart a list never restarts on
the host, since its indices are compacted on the CPU first, so both now
take the patches. Indexed strips with primitive restart still throw,
now also in Graphics::Draw, which knows the draw is indexed.
Patch-list pipelines never enable primitive restart, which Vulkan does not
allow for them without primitiveTopologyPatchListRestart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@adriadam10 adriadam10 self-assigned this Oct 29, 2026
@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

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
PR 7893 docs/dev/debt/libSceAgcDriver.md L181-182
PR 12619 core/libs/prx/libSceAgcDriver/tests/execution/PixelBarycentricEmulation.cpp L85

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 1368 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 1395 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 2434 docs/dev/debt/libSceAgcDriver.md
PR 4448 docs/dev/debt/libSceAgcDriver.md
PR 4449 docs/dev/debt/libSceAgcDriver.md
PR 5021 docs/dev/debt/shader.md
PR 5371 docs/dev/debt/shader.md
PR 5372 docs/dev/debt/libSceAgcDriver.md
PR 5609 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
PR 5925 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6185 docs/dev/debt/libSceAgcDriver.md
PR 6186 docs/dev/debt/libSceAgcDriver.md
PR 6188 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 6194 docs/dev/debt/libSceAgcDriver.md
PR 6223 docs/dev/debt/libSceAgcDriver.md
PR 6235 docs/dev/debt/shader.md
PR 6280 docs/dev/debt/libSceAgcDriver.md
docs/dev/debt/shader.md
PR 6300 docs/dev/debt/libSceAgcDriver.md
PR 6412 docs/dev/debt/libSceAgcDriver.md
docs/dev/debt/shader.md
PR 6481 docs/dev/debt/libSceAgcDriver.md
PR 6488 docs/dev/debt/shader.md
PR 6548 docs/dev/debt/libSceAgcDriver.md
PR 6549 docs/dev/debt/libSceAgcDriver.md
PR 6743 docs/dev/debt/libSceAgcDriver.md
PR 6804 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6808 docs/dev/debt/libSceAgcDriver.md
PR 6924 docs/dev/debt/shader.md
PR 6959 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
docs/dev/debt/libSceAgcDriver.md
docs/dev/debt/shader.md
PR 6970 core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
PR 6977 docs/dev/debt/libSceAgcDriver.md
PR 7085 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
docs/dev/debt/libSceAgcDriver.md
docs/dev/debt/shader.md
PR 7256 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7275 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
PR 7369 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 7449 docs/dev/debt/libSceAgcDriver.md
PR 7604 docs/dev/debt/libSceAgcDriver.md
PR 7642 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
core/libs/prx/libSceAgcDriver/tests/execution/PixelBarycentricEmulation.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7684 docs/dev/debt/shader.md
PR 7922 docs/dev/debt/shader.md
PR 7978 docs/dev/debt/libSceAgcDriver.md
PR 8004 docs/dev/debt/shader.md
PR 8014 docs/dev/debt/libSceAgcDriver.md
PR 8246 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 8319 docs/dev/debt/libSceAgcDriver.md
PR 8395 docs/dev/debt/libSceAgcDriver.md
PR 8542 docs/dev/debt/libSceAgcDriver.md
PR 8592 docs/dev/debt/libSceAgcDriver.md
PR 9020 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
docs/dev/debt/libSceAgcDriver.md
docs/dev/debt/shader.md
PR 9335 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
docs/dev/debt/libSceAgcDriver.md
docs/dev/debt/shader.md
PR 9356 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9387 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
docs/dev/debt/libSceAgcDriver.md
docs/dev/debt/shader.md
PR 9432 docs/dev/debt/libSceAgcDriver.md
PR 9489 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
PR 9508 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
core/libs/prx/libSceAgcDriver/tests/execution/PixelBarycentricEmulation.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9592 docs/dev/debt/libSceAgcDriver.md
PR 9700 docs/dev/debt/libSceAgcDriver.md
PR 9712 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 9748 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
docs/dev/debt/libSceAgcDriver.md
docs/dev/debt/shader.md
PR 9875 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 9889 docs/dev/debt/shader.md
PR 9891 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9892 docs/dev/debt/libSceAgcDriver.md
PR 9893 docs/dev/debt/libSceAgcDriver.md
PR 9895 docs/dev/debt/libSceAgcDriver.md
PR 9897 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 9898 docs/dev/debt/libSceAgcDriver.md
PR 9915 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9950 docs/dev/debt/libSceAgcDriver.md
PR 10049 docs/dev/debt/libSceAgcDriver.md
PR 10064 docs/dev/debt/libSceAgcDriver.md
PR 10193 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
core/libs/prx/libSceAgcDriver/tests/execution/PixelBarycentricEmulation.cpp
docs/dev/debt/libSceAgcDriver.md
PR 10233 docs/dev/debt/libSceAgcDriver.md
docs/dev/debt/shader.md
PR 10351 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
docs/dev/debt/libSceAgcDriver.md
PR 10435 docs/dev/debt/libSceAgcDriver.md
PR 10442 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 10472 docs/dev/debt/libSceAgcDriver.md
PR 10652 docs/dev/debt/shader.md
PR 10678 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 11280 docs/dev/debt/libSceAgcDriver.md
PR 11452 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 11483 docs/dev/debt/shader.md
PR 11551 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
docs/dev/debt/libSceAgcDriver.md
PR 11557 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
docs/dev/debt/libSceAgcDriver.md
docs/dev/debt/shader.md
PR 11825 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
docs/dev/debt/libSceAgcDriver.md
PR 12132 docs/dev/debt/shader.md

@oneandonlydean

Copy link
Copy Markdown
Collaborator

@Gonic0 reviewed at 95e7dee. Only devices without fragmentShaderBarycentric or geometry shaders change; elsewhere the output is identical (the Pipeline restartEnable && !patches term is a no-op off the patch path). Exactly two cases are unlocked: a list with restart on a device without list restart (compacted on the CPU since #12180, direct and indirect) and a non-indexed strip with restart (no index to match). An indexed strip with restart is still refused, now in prepareDrawInputs as well; Driver, Pipeline and Draw agree, and a patch list never enables restart. Independent of #12662 (clean both ways). No requests.

@adriadam10 we'll merge this once exact-head CI is green, unless you'd rather merge it yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants