fix(shader): hand a geometry program strip and fan triangles in the order of its provoking vertex mode #7893
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7893"
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 thuanquang on 2026-10-19T12:44:48Z.
What
Title that needs it: MediEvil: Resurrection (PPSA07550) stops on
mainat its main menu's first draw withAGC graphics: last provoking vertex is unsupported for triangle fans assembled for a geometry program, the refusal this PR removes; with this PR it reaches gameplay in the first level (title test by beardsciences, NVIDIA RTX 3060 Ti).Follow-up to #7883, built on it. #7883 measured on an RX 6700 XT (probe source and output) the order in which AMD's geometry engine hands a geometry program its input triangles:
The translator's mesh entry gives odd strip triangles as (i+1, i, i+2) in both modes, so in first mode a geometry program's flat values for odd strip triangles come from v[i+1] instead of v[i]. It also gives fans as (i+1, i+2, 0) in both modes, which is why #7883 kept refusing last-mode fans.
This change makes the order follow the mode (
mesh.provokingVertex, which is 0 in first mode and the output's last slot in last mode):The refusal of last-mode fans assembled for a geometry program goes away. For strips and for fans, the two orders are rotations of each other, so each triangle keeps its winding and culling does not change. Restart handling and the parity reset are untouched.
mesh.provokingVertexis already part of every key that holds a translated module (pipeline, draw and register keys, pipeline journal and request serializer), and translated modules are keyed by the recompiler's source hash. So no key or format version changes.The console's order is not measured, and the debt entry says so. The entry also gets shorter, since this change closes the strip and fan part of the gap: 1449 characters against 1480 on
main. Both are over the 1000 at whichcheck_conventionswarns, because #6741 added a sentence on drawing a last provoking vertex that nothing observes without the extension.Tested
Windows 11 26200, AMD Radeon RX 6700 XT (gfx1031), WinLibs GCC 15.2.0 r7, Release,
BUILD_TESTING=ON,ANYPS5_NO_SHADER_CACHE=1; driver 32.0.21045.16010 on this head, 32.0.21045.5002 on the earlier heads below.Merged
mainbb04a4f1ea(2026-10-30) into the branch (headcf711c7281) for a conflict indocs/dev/debt/libSceAgcDriver.md: #12706 reworded the entry right after this PR'sPROVOKING_VTX_LASTentry (triangle strips through the barycentric tessellation stages, now with primitive restart). Both edits are kept as they are; the code files merged without conflicts, andgit diff bb04a4f1ea cf711c7281is the same five files as before. On this head the seven tests listed below pass 3 of 3 withANYPS5_NO_SHADER_CACHE=1andANYPS5_REQUIRE_VULKAN=1, AMD Windows driver 32.0.21045.16010. With the Khronos validation layer (VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,VK_LOADER_DEBUG=layer,ctest -V), onmainbb04a4f1eaand on this head: seven of seven pass on both, the loader inserts the layer six times on each, neither log has aVUID-line, aValidation Errororwas not found but was requested, and both have the same tenWARNING-lines.Before that: rebased again onto
main2ee8e9751a(2026-10-28) for a conflict indocs/dev/debt/libSceAgcDriver.md: #11364 added the 11_11_10 float CB resolve entry right before this PR'sPROVOKING_VTX_LASTentry. Both entries are kept as they are; the code files merged without conflicts, andgit diff origin/main HEADis the same five files as before. On this head (76bea988bf), one commit onmain, the seven tests listed below (agc_driver_graphics,agc_driver_unobserved_provoking_vertex,agc_driver_mesh,agc_driver_mesh_provoking_vertex,agc_driver_mesh_provoking_layer,agc_driver_provoking_vertex,agc_driver_pixel_barycentric_emulation) pass 3 of 3 withANYPS5_NO_SHADER_CACHE=1andANYPS5_REQUIRE_VULKAN=1, AMD Windows driver 32.0.21045.16010. With the Khronos validation layer (VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,VK_LOADER_DEBUG=layer,ctest -V) the same seven pass, the loader inserts the layer six times (the twoagc_driver_graphicstests create no instance), and no log has aVUID-line orwas not found but was requested.Earlier: rebased onto
main65ac1d3b50for the conflict with #6741 in thePROVOKING_VTX_LASTdebt entry, which now keeps #6741's sentence on drawing a last provoking vertex that nothing observes withoutVK_EXT_provoking_vertexasmainhas it and leaves geometry-program fans out of what throws with the extension. On that head (c790cd09fc), still one commit onmain:agc_driver_graphics,agc_driver_unobserved_provoking_vertex(#6741's, which also runsProvokingVertexTests, where this PR validates last-mode fans),agc_driver_mesh,agc_driver_mesh_provoking_vertex,agc_driver_mesh_provoking_layer,agc_driver_provoking_vertexandagc_driver_pixel_barycentric_emulationpass 3 of 3.main65ac1d3b50) and B (this head), the same seven tests withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_NO_SHADER_CACHE=1,ANYPS5_REQUIRE_VULKAN=1andctest -V: seven of seven pass on both, with noVUID-line and nowas not found but was requested. WithVK_LOADER_DEBUG=layer, the layer is inserted six times on each (the twoagc_driver_graphicstests create no instance), and its only output on both is the same tenWARNING-VkImageSubresourceRange-layerCount-compatibilitylines fromagc_driver_mesh_provoking_layer.python tools/check_conventions.py --base origin/main: no errors, and onedebt-lengthwarning for the 1449-character entry.The results below were measured on the previous head
40bd67bef.agc_driver_mesh_provoking_vertex:agc_driver_graphics: last-mode fans through a geometry program now validate.triangle strip, first provoking vertex, triangle 1 (the color of vertex 1): pixel (26, 48) channel 1 is 0, expected 255.triangle fan, last provoking vertex, triangle 0 (the color of vertex 2): pixel (12, 32) channel 1 is 255, expected 0.last provoking vertex is unsupported for triangle fans assembled for a geometry program.agc_driver_graphics,agc_driver_mesh,agc_driver_mesh_provoking_layer,agc_driver_mesh_provoking_vertexandagc_driver_provoking_vertexpass 3 of 3.VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_NO_SHADER_CACHE=1,ANYPS5_REQUIRE_VULKAN=1,ctest -V, same RX 6700 XT, onmain38de0a470(other test files modified locally; none of these tests' sources), on #788359cabc57band on #7893606321886:agc_driver_graphics,agc_driver_mesh,agc_driver_mesh_provoking_vertex,agc_driver_mesh_provoking_layerandagc_driver_provoking_vertexpass on all three. No log reportswas not found but was requestedor anyVUID-error. The layer's only output is the sameWARNING-VkImageSubresourceRange-layerCount-compatibilitywarning inagc_driver_mesh_provoking_layeron all three trees.mainas the red side, the last-provoking-vertex geometry draws fail onmainand pass here. The UHD 770 has no mesh shaders, so the mesh test skips there.main.main504ea3b53b2(wachi35676): 89 of 91 provoking-vertex, mesh, geometry, NGG, tessellation and pixel/subgroup tests pass on both,agc_driver_graphicsincluded; the two failures (agc_host_import_cut_lifetime, #10746, andagc_driver_depth_plane_partial_store, #10664) also fail without this change. Withmain'sInstructionTranslator.cppandPipeline.cpp, the strip and fan tests fail with the messages above on both GPUs.main66e1f7f993, arm B the samemainwith this headcf711c7281merged, onlylibSceAgcDriver.prxandlibSceVideoOut.prxswapped,ANYPS5_NO_SHADER_CACHE=1, runs A, B, A, B of 540 s with the same scripted pad input: bothmainruns stop at the menu's first draw (log 210 s and 158 s) withAGC graphics: last provoking vertex is unsupported for triangle fans assembled for a geometry program, exit0xc0000409; both runs with this PR have no stop: the menu, the opening movie, and the first level (Dan's Crypt) loads at 473 s and 353 s. A further interactive run reached gameplay there with no errors in the log.agc_driver_mesh_provoking_vertexpasses 2 of 2 with and 2 of 2 withoutVK_LAYER_KHRONOS_validationon that machine.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by savvaniss on 2026-10-19T14:04:26Z.
Intel and AMD Windows data: with this PR's test changes, the last-provoking-vertex geometry draws fail on
mainand pass with the PR, on an AMD RX 9070 XT and an Intel UHD 770.Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, every execution test built,
ANYPS5_NO_SHADER_CACHE=1, serial CTest. Intel UHD Graphics 770 (8086:a780), driver 32.0.101.7088. AMD Radeon RX 9070 XT (1002:7550), driver 32.0.31041.1004, withVkCacheemptied first. This head606321886(which carries #7883) merged intomain85029a00f. "Without" means only this branch's diff totests/Graphics.cppandtests/execution/MeshProvokingVertex.cpp, applied tomain85029a00f.agc_driver_mesh_provoking_vertexskips (no mesh shaders on this GPU)agc_driver_graphicsfails:last provoking vertex is unsupported for triangle strips or fans assembled for a geometry program; the mesh test skipsagc_driver_graphicsfails the same way, andagc_driver_mesh_provoking_vertexaborts with that errorAI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by DavidAmsellem on 2026-10-19T15:44:23Z.
First AMD-on-Linux (RADV) run of this PR. Merged onto
main43a2abaf7(clean merge), built in full and compared with the samemain, on the same machine.AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 (Ubuntu 24.04 base), kernel 7.0.0-38, GCC 13.3, Release.
Full suite (
ANYPS5_REQUIRE_VULKAN=1 ctest -j8): 1636/1638 with this PR, against 1636/1638 onmain. The failures are the same two on both, so this PR adds none:agc_driver_image_table_vouched_lookups(#7766, fixed by #7916) andagc_driver_guest_memory_lifetime(#7784). The PR adds no new ctest entry; every existing test it touches passed.GPUs tested: AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 / kernel 7.0.0-38
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-21T11:24:13Z.
@thuanquang a heads-up for the rebase:
mainhas since taken the last provoking vertex through the barycentric tessellation path (#7426), and that change touched the same checks this PR relies on, so the conflict needs a decision rather than keep-both.ValidateProvokingVertex(Pipeline.cpp),maindropped!BarycentricPatches(...)from the generated-primitiveRequireand added a new one:Require(!meshPrimitives || (topology != TRIANGLE_STRIP && topology != TRIANGLE_FAN), "last provoking vertex is unsupported for triangle strips or fans assembled for a geometry program"). That guard refuses exactly the case this PR implements, so after a plain merge your strip/fan ordering is unreachable in last mode. Please remove or narrow it as part of the rebase and check how it combines with your own triangle-stripRequireon the line after it.PA_SU_SC_MODE_CNTL.PROVOKING_VTX_LASTentry indocs/dev/debt/libSceAgcDriver.mdwas rewritten on both sides (yours from the first sentence,mainin a later part), so it needs one combined entry rather than both versions.A last-mode strip case through a geometry program that would have hit
main's new refusal would pin the result.Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-22T06:28:56Z.
@oneandonlydean thanks for the heads-up. The rebase to d054ce3afb handles it, and since #7883 has merged, this PR's diff against
mainis its one commit:ValidateProvokingVertex: #7426's refusal of last-mode triangle strips and fans assembled for a geometry program is removed.main's generated-primitiveRequirestays as it is.Requirestill refuses last mode with explicit per-vertex interpolation (theexpectFailureinProvokingVertexTests). Flat and smooth inputs validate for strips and fans.MeshProvokingVertexnow draws a triangle strip and a triangle fan in last mode through a geometry program, the casemain's refusal threw on, and the fan in first mode.PROVOKING_VTX_LASTdebt entry is one combined entry.The test runs are in the description.