feat(agc): emulate barycentrics in rect-list draws #8339
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8339"
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 DavidSamir on 2026-10-20T10:23:47Z.
What
On a device without
VK_KHR_fragment_shader_barycentric, a pixel shader that reads barycentrics takes them from generated stages. A rect-list draw is itself built from generated tessellation stages and the barycentric path refused it:a pixel shader that reads barycentrics without VK_KHR_fragment_shader_barycentric needs a vertex shader before it.The rect-list control and evaluation stages now carry what the pixel shader needs. The evaluation stage writes the barycentric weights for each interpolated point of the rectangle (the three corner weights, with the fourth corner of the rectangle weighted the way the rect-list stage already derives it), and it passes the three raw vertex values of each pixel input that reads them per vertex (
v_interp_movof P10/P20).Draw.cppstops refusing a rect list with an active barycentric emulation and the recompiler'sRectListShaders.cppbuilds the extra interface locations. A plainv_interp_p1/p2pixel shader is unchanged and needs no generated outputs.The debt entry for barycentric emulation now says that a rect-list draw takes them from its generated tessellation stages and that this was checked on MoltenVK only.
Tested
macOS 26 (Darwin 25.6), Apple M2, MoltenVK and the Khronos validation layer from Vulkan SDK 1.4.363.0, x86-64 build under Rosetta, Ninja Release. The tree is main
35fa2bdd82plus the macOS port series and my other open macOS and barycentric PRs (not a clean main); the baseline below is the same tree with this change's two production files restored to their previous contents.pixel_barycentric_emulation, rect-list case, run asANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest -R pixel_barycentric_emulation -V:AGC graphics: graphics interfaces disagree at location 0 (stage 2 output missing, stage 3 input vertex:f32x3 ...).barycentric emulation through the rect-list stages passed: 1518 perspective and 1518 linear I/J pixels, raw vertex values, host interpolation. The tessellation-stage cases of the same test still pass.was not found but was requested by env var VK_INSTANCE_LAYERS, and neither contains aVUID-line.--macos --to-rosetta --macos-fixed-base 0x400000(without a low fixed base it faults before drawing):[gpu] driver failure: AGC driver: a pixel shader that reads barycentrics without VK_KHR_fragment_shader_barycentric needs a vertex shader before it, on a rect-list draw.driver failure, noterminating. The frames were not inspected, so correct rendering is not claimed.087c1f40a4, which also adapts the test to main's flat and provoking-vertex cases): Windows 11, AMD Radeon 680M (driver 32.0.21030.2001), WinLibs GCC 15.2.0, Release, the same three variables:agc_driver_graphics,agc_driver_pixel_barycentric_emulationandagc_driver_provoking_vertexpass, the layer loaded and the log has noVUID-line.Draw()with the rect-list case;a81f89fa6b): Windows 11, NVIDIA RTX 3070 (driver 610.60), WinLibs GCC 15.2.0, Release,ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1:agc_driver_graphics,agc_driver_pixel_barycentric_emulationandagc_driver_provoking_vertexpass. That run had no validation layer installed, so it has noVUID-check.VK_KHR_fragment_shader_barycentric, so on it the test runs the rect-list stages but titles do not take this path. Titles that stop later on the M2 for lack of mesh shaders or geometry-stage barycentrics are not affected by this change.tools/check_conventions.py --base origin/mainpasses with one warning on the existing barycentric debt entry, which was over 1000 characters before this change.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)Imported from boykopovar/AnyPS5. Originally posted by TheSovietWaffle on 2026-10-20T11:09:11Z.
Windows data point on NVIDIA and AMD: RTX 3080 (NVIDIA 617.42) and AMD Radeon RDNA 2 iGPU (
1002:164e, 32.0.21045.5002), Windows 10 Pro 22H2, WinLibs GCC 15.2.0, Release, head1713855fb:agc_driver_pixel_barycentric_emulationpasses 3 of 3 on both GPUs.AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-20T11:11:48Z.
Ran the focused test on lavapipe with validation, clean
mainvs this branch, same machine (WSL Ubuntu 24.04, Mesa lavapipe ICD, Khronos validation layer 1.3.275). Env:ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ctest -R pixel_barycentric_emulation -V. lavapipe has no fragment-shader-barycentric support, so the emulated paths ran; nothing skipped.main6bd02dd91with this PR'sPixelBarycentricEmulation.cppcopied in: Failed. Geometry stage passed (932/932 I/J pixels), tessellation stages passed (932/932). Then the test exits non-zero without a rect-list line.1713855fb: Passed. Geometry 932/932, tessellation 932/932, and "barycentric emulation through the rect-list stages passed: 1518 perspective and 1518 linear I/J pixels, raw vertex values, host interpolation".was not found but was requested by env var VK_INSTANCE_LAYERS.3 x VUID-VkDeviceCreateInfo-pNext-pNext. This is the 1.3.275 layer not knowing VkStructureType 1000574000 in the device create chain, which is unrelated to this PR. No newVUID-from the change.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by DavidAmsellem on 2026-10-20T19:00:43Z.
First Linux run of this PR on a hardware GPU: AMD with RADV. Head
1713855fbmerged ontomain2fee39f1b(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) at7e95dafc3: 1715/1716 with this PR, against 1715/1716 onmain. The one failure is the same on both, so this PR adds none:agc_driver_guest_memory_lifetime(#7784, which #7849 addresses).Comparing the JUnit output with
main: this PR adds no ctest entry, and none is skipped or removed. The test it changes,agc_driver_pixel_barycentric_emulation, runs and passes. It setsfragmentShaderBarycentricEnabled = false, so the emulation is used even though RADV has native barycentrics, and RADV exposesgeometryShaderandtessellationShader, so none of the test's stage skips apply.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 adriadam10 on 2026-10-21T11:14:21Z.
Review: CHANGES_REQUESTED
The change reads correctly: the rect-list control/evaluation stages emit the barycentric weights (fourth corner with the -1/1 weights the stage already derives) and the three raw vertex values, and the interface sizes are checked against the tessellation limits. One thing blocks it:
mainincore/libs/prx/libSceAgcDriver/tests/execution/PixelBarycentricEmulation.cppanddocs/dev/debt/shader.md.mainnow has the flat-input check (FlatBarycentricPixelCode,CheckFlat, provoking vertex,44b13e650) insideRunEmulation. After the rebase the rect-list case also runs it, andCheckFlatexpects the triangle corners andBarycentrics()without theemulationargument. Please rebase and either make the flat check useCorners(emulation)for the rect list (what the first/last vertex values must be there) or skip it forEmulation::RectListwith a reason.shader.md: after rebasing, keep main's new lines and update the barycentric entry; the RADV (7900 XT) and Windows NVIDIA/AMD runs in this thread can be cited next to the MoltenVK one.Thanks to @TheSovietWaffle and @DavidAmsellem for the hardware runs.
Imported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-21T20:33:22Z.
@adriadam10 thanks for the review. Both points are addressed on the current head:
main(merge, no force-push). The rect-list case skips the flat-input check:CheckFlatcompares against the first and last vertex of each triangle, and a rect list's provoking vertex has no triangle order to check against, so the check runs only for the triangle emulations.CheckFlatnow passesEmulation::Geometryexplicitly toClipPositionsandBarycentricsUnsnapped/Snapped, so main's flat cases run as before. Merged withmainagain today; nomaincommit since the tested merge touches this PR's files.docs/dev/debt/shader.md: kept main's lines and updated the barycentric entry to list where the rect-list test passed: MoltenVK 1.4.2 (Apple M2), RADV on a Radeon RX 7900 XT (Mesa 25.2.8, @DavidAmsellem), lavapipe, and Windows on an RTX 3080 and a Radeon RDNA 2 iGPU (@TheSovietWaffle) and a Radeon 680M.After the rebase, the Radeon 680M run (Windows 11, AMD 32.0.21030.2001, WinLibs GCC 15.2.0) under
VK_LAYER_KHRONOS_validationwithANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1passesagc_driver_graphics,agc_driver_pixel_barycentric_emulationandagc_driver_provoking_vertex, with noVUID-line.Could you take another look?