feat(agc): emulate barycentrics of mesh draws run as compute in the readback vertex shader #28142
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/28142"
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 yuriy1337 on 2026-11-28T18:21:10Z.
What
Depends on #17611. Until it merges, this diff also shows #17611's commits; only the top commit is this PR.
Problem. On a GPU with neither
VK_EXT_mesh_shadernorfragmentShaderBarycentric, #17611 runs mesh draws as compute, but a pixel shader that reads barycentrics still stops the draw:Recompiler.cppcompiles that pixel shader for the mesh stage, which putsSPV_EXT_mesh_shaderin a SPIR-V 1.3 module, and the validator refuses it. This is the stage-5 stop in the GTX 1050 Ti run on #17611 (25 of 47 titles, Lantern Miner PPSA58001 in the log).MeshComputeStagesrefuses barycentric emulation without native mesh shaders. This is the refusal that stops ccleste and PSteroid5 in #17611's reports.Fix.
BuildMeshBarycentricReadbackVertexShader). Each corner writes its one-hot weights, the 1/w-scaled weights for offset reads, all three corners' per-vertex values and the provoking corner's flat values.This is an alternative to #9387 (the tessellation route) for draws run as compute. The native mesh path and
main's native barycentric pairing are untouched. Debt: edits to #17611's fragmentagc-mesh-fallback-compute.md.Overlap with other PRs
tools/pr_overlap.pymeasures frommain, so it reports #17611's footprint too, and it fails closed. Counting only this PR's commit:tests/Mesh.cppwith #7642, #9508 and #10193, which already conflict withmain.tests/execution/LayeredVolumeDraw.cppconflicts withmain's3867c1e89c. I will resolve it when I rebase onto #17611 after #17611 itself is rebased.Tested
Linux, A/B against #17611's head
59203ed861on the same machine, withANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1.Full ctest (6844 tests), RTX 3070: native and
APS5_NO_MESH_SHADER=1have 0 failures on both heads.APS5_FORCE_MESH_COMPUTE=1fails the same 2 tests on both heads (agc_driver_tessellation_geometry,agc_driver_viewport_index).Focused set, 26 tests, under the validation layer:
APS5_NO_MESH_SHADER=1mesh_barycentric_emulationskippedAPS5_FORCE_MESH_COMPUTE=1mesh_barycentric_emulationskippedmesh_barycentric_emulationskippedThe PR adds no
VUID-lines: there are 0 on each device except Intel, which logs the same 48maxCombinedClipAndCullDistances-00710on both heads.The new tests catch the bug. Applied to #17611 without the fix, all three fail in every compute-path config: Intel and no-mesh with the SPIR-V 1.4 error from the GTX 1050 Ti logs, forced compute with
graphics interfaces disagree at location 0.Not tested: titles, AMD. Windows: build only.
Test details
-DANYPS5_ENABLE_SPIRV_TOOLS=ON.ctest -V -R 'agc_driver_mesh|barycentric|layered_volume|mesh_output|request_serializer|agc_driver_graphics'withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer, using the layer from LunarG SDK 1.4.363.0. Every log showsInsert instance layer "VK_LAYER_KHRONOS_validation", and none showswas not found but was requested.agc_driver_mesh_barycentric_emulationused to skip there. It now checks perspective, linear and iterated (offset) I/J pixels and raw per-vertex values against the reference: 932 pixels each on RTX 3070 (no mesh, forced) and Intel.agc_driver_meshadds non-indexed and indexed draws, front and back culling compared with the ordinary readback draw, and a flat input with the first and last provoking vertex.agc_driver_layered_volume_drawadds a layered mesh draw run as compute.objcopy --rename-sectionstep ("Invalid argument"), the same 36 on #17611's head. Tests can't run on this machine: its CPU (i7-3770K) lacks AVX2/BMI, and the host-CPU check stops them on both heads.Checklist
main; no other open PR implements the same functions (stacked on #17611, which is on currentmain; #9387 covers the same draws through tessellation)NotImplemented_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
https://claude.ai/code/session_01Kn5E2jBvwSg6P3XXp7MUJt
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-28T18:44:23Z.
Review: COMMENTED
Reviewed — no blocking findings
The mesh compute fallback and barycentric readback changes were inspected at head
b496c74cc5726bf928a75f33d5c00864f0743cbe; I did not run tests, and the review is incomplete because several changed files were not fully read.What I ran
No commands or tests were run. Author-reported test results in the PR description were not independently verified.
Results
Findings
Blocking
None verified in the code inspected.
Non-blocking
None.
Not verified
The full text of
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp,core/libs/prx/libSceAgcDriver/tests/Graphics.cpp, andcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppwas excluded from the review folder; I did not read those files through the pinned reader. Other included changed files were not all fully read. I did not independently verify the reported test results, title behavior, or Windows build.To get this to a good state
Nothing is required. The optional next step is to complete inspection of the excluded and unread changed files and run the relevant checks on this head.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T20:38:01Z.
Review: COMMENTED
The new fixture explicitly skips llvmpipe before inspecting which mesh path it will use. Could the skip be limited to native mesh compilation if the compute fallback works there? That would let the software Vulkan job exercise the readback vertex shader, while the existing pixel-count checks identify which native and iterated cases ran.
Source review at
b496c74cc5. The trial merge conflicts in the device and graphics draw code. Native GPU execution remains unverified here.AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.