fix(agc): prefer host interpolation on RADV to avoid the quad seam #10547

Merged
mrfelek merged 2 commits from upstream-pr/10547 into main 2026-11-02 12:25:39 +00:00
mrfelek commented 2026-10-24 09:32:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mrfelek on 2026-10-24T09:32:06Z.


What

On RADV, a pixel shader that reads its inputs through VK_KHR_fragment_shader_barycentric (PerVertexKHR + gl_BaryCoordKHR) gets the second triangle of a full-screen quad with per-vertex values in an order that does not match gl_BaryCoordKHR. Full-screen passes then show a diagonal seam where one triangle's UVs are swapped. Hollow Knight: Silksong's final copy pass shows it on a Radeon 780M on Linux; NVIDIA and the AMD Windows driver are clean.

The device now sets a new SpirvTarget::hostInterpolationFirst flag on RADV. With it, a pixel shader is first translated with host interpolation, and only a shader that HostInterpolationChecker cannot lower is translated again with native KHR barycentrics (never the geometry or mesh emulation, since the device has the extension). Other drivers are unchanged. The flag is part of the shader cache key, and APS5_NO_HOST_INTERPOLATION_FIRST turns it off.

Turning KHR barycentrics off on RADV entirely also removes the seam, but sends shaders that need barycentrics to the emulation paths, which aborts Diablo II Resurrected (a pixel shader reading barycentrics without a vertex shader) and Hot Wheels Infinite Rush (mesh-path emulation needs more than 32 KiB of mesh output), so this keeps KHR for those.

Tested

Linux, Radeon 780M (RADV PHOENIX, Mesa 26.0.8), main 15e71dbe11 vs this change on it (rebased onto fe204e1a8d since, no conflicts in these files):

  • Silksong (PPSA12544): main menu and tut_01 seam gone; with APS5_NO_HOST_INTERPOLATION_FIRST=1 the seam is back. 600 presents / 10 s on both.
  • Diablo II Resurrected (PPSA03912): save loads, Rogue camp renders as on main. Speed over 10 alternating starts: 13.0 vs 15.7 presents / 10 s (main), within this title's run-to-run spread (7 to 28 on both builds; the slow state, long resident-target lookups and driver lock waits, hit 3 of 5 starts on each build); 0 pipeline cache misses in the measured windows on both.
  • Hot Wheels Infinite Rush (with a local sceGameUpdateCreateRequest revert): reaches the garage as on main.
  • agc_shader_memory (new verifyHostInterpolationFirst), agc_fragment_barycentric, request_serializer, agc_shader_disk_cache, agc_shader_device_profile pass on fe204e1a8d.
  • With ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, the 13 tests matching interpolation, barycentric emulation, sample order/iteration, implicit derivatives, shader memory, serializer and disk cache pass on main and on the change; both logs have the same two VUIDs from agc_driver_sample_order (already on main), the change adds none.

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
  • Fixes: none
  • Unblocks: PPSA12544 #726
  • GPUs tested: AMD Radeon 780M (RADV PHOENIX), Mesa 26.0.8, Linux
  • AI-assisted: yes

AI-assisted. Tested by me on my own machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4994261485 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10547). Originally posted by [mrfelek](https://github.com/mrfelek) on 2026-10-24T09:32:06Z. --- ### What On RADV, a pixel shader that reads its inputs through VK_KHR_fragment_shader_barycentric (PerVertexKHR + gl_BaryCoordKHR) gets the second triangle of a full-screen quad with per-vertex values in an order that does not match gl_BaryCoordKHR. Full-screen passes then show a diagonal seam where one triangle's UVs are swapped. Hollow Knight: Silksong's final copy pass shows it on a Radeon 780M on Linux; NVIDIA and the AMD Windows driver are clean. The device now sets a new `SpirvTarget::hostInterpolationFirst` flag on RADV. With it, a pixel shader is first translated with host interpolation, and only a shader that `HostInterpolationChecker` cannot lower is translated again with native KHR barycentrics (never the geometry or mesh emulation, since the device has the extension). Other drivers are unchanged. The flag is part of the shader cache key, and `APS5_NO_HOST_INTERPOLATION_FIRST` turns it off. Turning KHR barycentrics off on RADV entirely also removes the seam, but sends shaders that need barycentrics to the emulation paths, which aborts Diablo II Resurrected (a pixel shader reading barycentrics without a vertex shader) and Hot Wheels Infinite Rush (mesh-path emulation needs more than 32 KiB of mesh output), so this keeps KHR for those. ### Tested Linux, Radeon 780M (RADV PHOENIX, Mesa 26.0.8), main 15e71dbe11 vs this change on it (rebased onto fe204e1a8d since, no conflicts in these files): - Silksong (PPSA12544): main menu and tut_01 seam gone; with `APS5_NO_HOST_INTERPOLATION_FIRST=1` the seam is back. 600 presents / 10 s on both. - Diablo II Resurrected (PPSA03912): save loads, Rogue camp renders as on main. Speed over 10 alternating starts: 13.0 vs 15.7 presents / 10 s (main), within this title's run-to-run spread (7 to 28 on both builds; the slow state, long resident-target lookups and driver lock waits, hit 3 of 5 starts on each build); 0 pipeline cache misses in the measured windows on both. - Hot Wheels Infinite Rush (with a local sceGameUpdateCreateRequest revert): reaches the garage as on main. - `agc_shader_memory` (new `verifyHostInterpolationFirst`), `agc_fragment_barycentric`, `request_serializer`, `agc_shader_disk_cache`, `agc_shader_device_profile` pass on fe204e1a8d. - With `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, the 13 tests matching interpolation, barycentric emulation, sample order/iteration, implicit derivatives, shader memory, serializer and disk cache pass on main and on the change; both logs have the same two VUIDs from `agc_driver_sample_order` (already on main), the change adds none. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: PPSA12544 #726 - [x] GPUs tested: AMD Radeon 780M (RADV PHOENIX), Mesa 26.0.8, Linux - [x] AI-assisted: yes AI-assisted. Tested by me on my own machine.
MarcZX10 commented 2026-10-24 10:39:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T10:39:24Z.

Review: APPROVED


Reviewed the driver gate, fallback path, cache-key addition, and shader-memory coverage. The target flag is enabled only for RADV and only when KHR fragment barycentrics are available; host interpolation is attempted first, and shaders the checker cannot lower are translated again with native barycentrics without entering emulation. The cache key includes the new target choice, and the environment override is documented. I manually checked the overlap warning against #10046: it changes the tessellation pipeline-cache policy at the same Vulkan initialization area, but does not duplicate or depend on this interpolation behavior. The contributor reports the 13-test Vulkan validation set and title checks described in the PR passing; hosted eligibility/conventions/intake/labels/report pass, while hosted build jobs were skipped. I did not rerun GPU tests locally.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5637952476 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10547#pullrequestreview-5637952476). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T10:39:24Z. **Review:** APPROVED --- Reviewed the driver gate, fallback path, cache-key addition, and shader-memory coverage. The target flag is enabled only for RADV and only when KHR fragment barycentrics are available; host interpolation is attempted first, and shaders the checker cannot lower are translated again with native barycentrics without entering emulation. The cache key includes the new target choice, and the environment override is documented. I manually checked the overlap warning against #10046: it changes the tessellation pipeline-cache policy at the same Vulkan initialization area, but does not duplicate or depend on this interpolation behavior. The contributor reports the 13-test Vulkan validation set and title checks described in the PR passing; hosted eligibility/conventions/intake/labels/report pass, while hosted build jobs were skipped. I did not rerun GPU tests locally.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!10547
No description provided.