fix(recompiler): read P20 of a flat input as the provoking vertex #8538
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8538"
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 LeandroLP23 on 2026-10-20T15:39:17Z.
What
A FLAT_SHADE input without pass-through that a pixel shader reads through
v_interp_mov_f32P20 and not P10 now returns the provoking vertex's value, like P0, and like P10 since #4030. Before, P20 kept the input explicitly per vertex and read vertex 2 minus vertex 0. For a flat value, that difference is 0 on every vertex, and with the first provoking vertex nothing refused the draw.Why. ps5-opengl lowers every flat input to a load of a single vertex in
lower_flat_input_vertex(toolchain/opengnm-psbc-ps5.patch, mirror):ps5_last_provoking_vertex(primitive_type): vertex 2 for triangles, 1 for lines, 0 for points.That driver passes the GL 4.6 CTS on a PS5, the argument #4030 rests on (#1413).
Seen in SuperTuxKart. SuperTuxKart (PPSA69421) draws its deferred point lights this way. All 12 flat inputs of
pointlight.frag(center,energy,col,radius,direction_scale_offset) are read through P20 under the first provoking vertex, so onmainthey are all 0.att = energy * 20. / (1. + d * d) * (radius - d) / radiusis then0 * -inf, which is NaN;if (att <= 0.) discard;is false for NaN, so nothing is discarded. The light's whole screen-space quad writes NaN into the light accumulation targets, and the starting-line referee and everything behind it render black. Details in #8364:pointlight.fragalso fixes it;Changes.
ShaderInfoCollectorkeeps a flat input per vertex only when it is read through both P10 and P20. The existing "differences to vertex 0" cases inagc_driver_graphicsandagc_shader_memoryread both, and are unchanged.FragmentParametergainsflatP20, set the same way asflatP10and stored in the shader disk cache.ValidateProvokingVertexthrowsv_interp_mov p20 of a flat input with the last provoking vertex is not measuredwith the last provoking vertex. Neither combination was measured on a console, so the pairing that ps5-opengl doesn't produce throws, as for P10 under the first.Tested
Windows 11 Home 26300, AMD Radeon 860M (
1002:1114, driver 32.0.13058.8001), WinLibs GCC 15.2.0, Release,ANYPS5_REQUIRE_VULKAN=1, based onmain75787d2f6.agc_driver_graphicsgets a P20 case mirroring #4030's P10 one. The input compiles to a flat input;flatP20is set andflatP10is not; first mode passes; last mode throws. Negative control: withmain'sShaderInfoCollector.cpp,SpirvInputOutput.cppandPipeline.cpp, it fails withflat v_interp_mov P20 did not compile to a flat input.ctest -R "agc|shader|spirv|recomp" -j4 --timeout 120: 840 of 841 pass, 3 skipped for device features. The one left isagc_driver_image_array_window_past_layer_limit, Not Run because it does not compile with MinGW (requested alignment '65536' exceeds object file maximum 8192, also onmain).The 35 tests matching
provok|flat|interp|barycentric|rect_list|strip: all 32 that build here pass.SuperTuxKart (PPSA69421 00.001.000), tutorial race started through
APS5_PAD_INPUT_FILE, unmodified game files. The referee during "Ready! / Set! / Go!":main: black rectangle and black bird on every run (more than 10 today, on severalmaincommits);Other ps5-opengl titles, 60 s each, no input,
mainand this PR:The only refusal logged is the existing P10 one (
shader library prebuild skipped: ... p10 of a flat input with the first provoking vertex is not measured), on both trees.Not run: the Khronos validation layer (not installed on this machine), and GPUs other than the 860M.
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)1002:1114), AMD driver 32.0.13058.8001, Windows 11 26300Overlap from
tools/pr_overlap.py: #6741 and #7426 change the last-provoking-vertex checks in the sameValidateProvokingVertex. #6741, #7426, #7883, #7893 and #8083 edit the same debt line. None of them reads P20 of a flat input.Imported from boykopovar/AnyPS5. Originally posted by simonbbby on 2026-10-20T16:32:07Z.
Verified the title fix on Linux / NVIDIA at
97f60203523e062aca107ca77eabfcff4a7a6359.SuperTuxKart PPSA69421 00.001.000, unchanged
pointlight.frag, RTX 3090 / NVIDIA 595.99.02, Ubuntu 24.04, GCC 13.3 Release. Same relinked homebrew and scripted scene (-N -t tutorial --numkarts=1), fresh processes, shader cache and pipeline journal disabled:5f7e30233ShaderInfoCollector.cpp,SpirvInputOutput.cppandPipeline.cpprestored from its parentEach counted process completed the same approximately 67-second capture window and exited normally after SIGINT. The restored-head run was made after the negative-control process had fully exited.
Linux prerequisite: every title arm includes only #7897's
ApplicationHeap.cppproduction hunk, needed here to get past the unrelated empty allocator-table startup failure. The PR and reverted arms use byte-identicallibc.prx. This is not a claim that unmodified Linux main reaches the race.Focused control: temporarily adding a dispatch directly to the existing
ProvokingVertexTests()gives 3/3 failures with those three production files reverted (flat v_interp_mov P20 did not compile to a flat input) and 3/3 passes after restoring them. The full stockagc_driver_graphicsandagc_shader_memoryCTests also pass, 2/2, after removing the temporary entry point and allocator prerequisite and rebuilding.This supports the flat-input correction, rather than our earlier kill/target-preservation hypotheses. No Khronos validation layer is installed here; no validation-layer or console-semantics claim. No retail titles tested. The temporary edits are removed.
Imported from boykopovar/AnyPS5. Originally posted by dantdmdarealguy on 2026-10-20T20:21:52Z.
Windows 11 Pro, Intel Core i9-14900K, 128 GB, NVIDIA GeForce RTX 5080 (driver 32.0.16.1742), WinLibs GCC 15.2.0, Release,
BUILD_TESTING=ON. Head97f6020352and its merge base75787d2f64, built one after the other in the same build directory. Every test log namesSelected GPU name=NVIDIA GeForce RTX 5080 vendor=0x10de device=0x2c02 subgroup=32. This adds Windows + NVIDIA to the description's Windows/Radeon 860M and simonbbby's Linux/RTX 3090 results.SuperTuxKart (PPSA69421 00.001.000, catalog release)
relinker --windows --registry --trap-sdk-syscall-stubsand started asapp.exe -N -t tutorial --numkarts=1withANYPS5_NO_SHADER_CACHE=1. Each run was 60 s with no input and a screenshot every 4 s.Tests, with
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1ctest -R "^(agc_driver_graphics|agc_shader_memory|patched_libraries)$|provok|interp|barycentric|rect_list|strip": 17 of 17 pass on both base and head. That set includesagc_driver_provoking_vertex,agc_driver_mesh_provoking_vertex,agc_driver_mesh_provoking_layer, bothagc_driver_rect_list_*,agc_driver_interpolation_modes,agc_driver_interpolation_f16and both barycentric emulation tests.agc_driver_graphicsandagc_shader_memorywithVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(Khronos 1.4.363;VK_LOADER_DEBUGshows it loading). Both pass on base and head. Neither log has aVUID-line orwas not found but was requested by env var VK_INSTANCE_LAYERS.Graphics.cppwith the base'sShaderInfoCollector.cpp,SpirvInputOutput.cppandPipeline.cppfails: So the new case fails without the change on NVIDIA too.-Wstringop-overreadin libstdc++'sstl_algobase.hwhile compiling the untouchedPipelineLibrary.cpp, which the base build also prints.tools/check_conventions.py --base 75787d2f6: 0 errors. Its only finding is thedebt-lengthwarning on the provoking-vertex entry, which was already over 1000 characters before this change. The branch merges into currentmainaa1b1bfcewithout conflicts.75787d2f6, 30 s97f602035, 30 sVerdict: works on Windows with an RTX 5080. The SuperTuxKart black rectangle is gone, the new test fails without the change, and no related test or validation result changed.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T23:25:05Z.
Review: APPROVED
The P20 handling is consistent with the existing P10 model: flat inputs read only through P20 remain flat, the collector marks P20 use separately, and pipeline validation rejects the unmeasured provoking-vertex combination. The cache artifact stores the new flag, and its generated source-version hash covers the recompiler/cache sources. The added focused graphics test checks first/last provoking behavior, and the independent Linux/NVIDIA and Windows/NVIDIA title reports on this head confirm the SuperTuxKart symptom is fixed with the shader unchanged. Hosted runtime/build jobs were skipped, so I am relying on those reported exact-head runs plus static review.
Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-21T14:37:28Z.
Rebased onto
main2c4b116da9as3d4a230d16. The conflict was with the barycentric-patches early return thatmainadded toValidateProvokingVertex. The P20 check now runs before it, so a last-provoking pipeline whose pixel shader has a P20-only flat read still throws when the generated barycentric stages are used. The debt entry keepsmain's barycentric exception and this PR's P20 sentences.Radeon 860M, Windows 11, AMD 32.0.13058.8001,
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1, built with-k 0; the only target that doesn't build isImageArrayWindowPastLayerLimit.cpp, as onmain:agc_driver_graphics,agc_driver_provoking_vertex,agc_driver_mesh_provoking_*,agc_driver_interpolation_*,agc_shader_disk_cache*andagc_driver_flat_*.tessellation|barycentric|rect_list.