fix(shader): fall back to barycentrics for a pixel input read through both I/J pairs #15793

Merged
root-over merged 2 commits from upstream-pr/15793 into main 2026-11-05 08:24:28 +00:00
root-over commented 2026-11-04 15:28:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by root-over on 2026-11-04T15:28:04Z.


What

On a device that takes the host interpolation path, Genesis Plus GX (PPSA99921, catalog v2.2.1) stops before its menu. On lavapipe, which has mesh shaders but not VK_KHR_fragment_shader_barycentric, main stops with:

shader 0x200bc1200 stage 5: ShaderRecompiler::Recompile: pixel input 0 is interpolated through both a perspective and a linear I/J pair

The pixel shader reads attribute 0's x and y through one I/J pair (v_interp_p1/p2 ... v0/v1) and its z through the other (v2/v3). Host interpolation gives each input one Vulkan interpolation decoration, so it can't express that. Recompile already has a way out: when HostInterpolationChecker::Lower returns false, the shader is translated again with barycentrics (native or emulated), and each v_interp is then computed from the pair it reads. The checker never got that far, because it called ShaderPixelInputInfo::InputIsLinear, which throws for an input in both masks.

  • HostInterpolationChecker::Lower returns false when pixelLinearInputs & pixelPerspectiveInputs is non-zero, so such a shader takes the barycentric path.
  • agc_shader_memory used to expect the throw for its two-pair shader. It now requires the compile to succeed with barycentric emulation active for both the smooth and the linear barycentrics.

A device with neither native barycentrics nor mesh shaders still can't run this shader, and stops at the existing "reads barycentrics, and this device has neither ..." error. #9387 covers that case.

Tested

Ubuntu, kernel 7.0, GCC 15.2.0, Release. Ryzen 5 5625U iGPU (Vega/GCN 5, RADV RENOIR, Mesa 26.0.8) and lavapipe (Mesa 26.0.8, LLVM 21.1.8) on the same machine.

Title. Genesis Plus GX v2.2.1 (catalog zip, SHA-256 matches), no ROMs, 45 s:

lavapipe RADV Vega
main aborts with the error above device does not support mesh shaders / barycentrics stop (no mesh, no barycentrics)
this PR library screen ("No games found", Internal / Network tabs), alive at 45 s same stop as main

Focused tests. The same 11 tests on main and this PR, ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest -V -j1: agc_interpolant_mapping, agc_driver_interpolation_f16, agc_driver_interpolation_modes, agc_driver_mesh_barycentric_emulation, agc_driver_mesh_provoking_vertex, agc_driver_pixel_barycentric_emulation, agc_driver_pixel_exec_interpolation, agc_driver_mesh, agc_fragment_barycentric, agc_shader_memory, interpolation_reference_range.

RADV lavapipe
main 11/11 11/11
this PR 11/11 11/11
  • No log contains was not found but was requested, and every log has 0 VUID-.
  • tools/check_conventions.py passes.
  • tools/pr_overlap.py: no open PR touches HostInterpolationChecker.cpp; several touch the shared tests/ShaderMemory.cpp, none of them verifyPixelInputs.

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: PPSA99921 #13017 (Genesis Plus GX: reaches its library screen on lavapipe instead of stopping in the recompiler)
  • GPUs tested: AMD Radeon Vega iGPU (Ryzen 5 5625U, RADV RENOIR, Mesa 26.0.8, Ubuntu); lavapipe (Mesa 26.0.8, LLVM 21.1.8, Ubuntu)
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5156897302 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15793). Originally posted by [root-over](https://github.com/root-over) on 2026-11-04T15:28:04Z. --- ### What On a device that takes the host interpolation path, Genesis Plus GX (PPSA99921, catalog v2.2.1) stops before its menu. On lavapipe, which has mesh shaders but not `VK_KHR_fragment_shader_barycentric`, `main` stops with: ``` shader 0x200bc1200 stage 5: ShaderRecompiler::Recompile: pixel input 0 is interpolated through both a perspective and a linear I/J pair ``` The pixel shader reads attribute 0's x and y through one I/J pair (`v_interp_p1/p2 ... v0/v1`) and its z through the other (`v2/v3`). Host interpolation gives each input one Vulkan interpolation decoration, so it can't express that. `Recompile` already has a way out: when `HostInterpolationChecker::Lower` returns false, the shader is translated again with barycentrics (native or emulated), and each `v_interp` is then computed from the pair it reads. The checker never got that far, because it called `ShaderPixelInputInfo::InputIsLinear`, which throws for an input in both masks. - `HostInterpolationChecker::Lower` returns false when `pixelLinearInputs & pixelPerspectiveInputs` is non-zero, so such a shader takes the barycentric path. - `agc_shader_memory` used to expect the throw for its two-pair shader. It now requires the compile to succeed with barycentric emulation active for both the smooth and the linear barycentrics. A device with neither native barycentrics nor mesh shaders still can't run this shader, and stops at the existing "reads barycentrics, and this device has neither ..." error. #9387 covers that case. ### Tested Ubuntu, kernel 7.0, GCC 15.2.0, Release. Ryzen 5 5625U iGPU (Vega/GCN 5, RADV RENOIR, Mesa 26.0.8) and lavapipe (Mesa 26.0.8, LLVM 21.1.8) on the same machine. **Title.** Genesis Plus GX v2.2.1 (catalog zip, SHA-256 matches), no ROMs, 45 s: | | lavapipe | RADV Vega | |---|---|---| | `main` | aborts with the error above | `device does not support mesh shaders` / barycentrics stop (no mesh, no barycentrics) | | this PR | library screen ("No games found", Internal / Network tabs), alive at 45 s | same stop as `main` | **Focused tests.** The same 11 tests on `main` and this PR, `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest -V -j1`: `agc_interpolant_mapping`, `agc_driver_interpolation_f16`, `agc_driver_interpolation_modes`, `agc_driver_mesh_barycentric_emulation`, `agc_driver_mesh_provoking_vertex`, `agc_driver_pixel_barycentric_emulation`, `agc_driver_pixel_exec_interpolation`, `agc_driver_mesh`, `agc_fragment_barycentric`, `agc_shader_memory`, `interpolation_reference_range`. | | RADV | lavapipe | |---|---|---| | `main` | 11/11 | 11/11 | | this PR | 11/11 | 11/11 | - No log contains `was not found but was requested`, and every log has 0 `VUID-`. - `tools/check_conventions.py` passes. - `tools/pr_overlap.py`: no open PR touches `HostInterpolationChecker.cpp`; several touch the shared `tests/ShaderMemory.cpp`, none of them `verifyPixelInputs`. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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: PPSA99921 #13017 (Genesis Plus GX: reaches its library screen on lavapipe instead of stopping in the recompiler) - [x] GPUs tested: AMD Radeon Vega iGPU (Ryzen 5 5625U, RADV RENOIR, Mesa 26.0.8, Ubuntu); lavapipe (Mesa 26.0.8, LLVM 21.1.8, Ubuntu) - [x] AI-assisted: yes
Superseabas commented 2026-11-04 17:09:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Superseabas on 2026-11-04T17:09:45Z.

Review: APPROVED


Head 31317e522b merged onto current main b11c7bf84f (clean merge, local only): code read, red/green check and a Windows run on NVIDIA and on AMD's Windows driver.

Windows 11 Home 10.0.26200, WinLibs GCC 16.2.0 (x86_64-ucrt-posix-seh, r3), Release, BUILD_TESTING=ON. ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ctest -R '^(agc_shader_.*|agc_driver_.*interpol.*|agc_driver_.*barycentric.*)$', ANYPS5_GPU selecting the device (confirmed by Selected GPU):

GPU Driver main merged
NVIDIA GeForce RTX 5070 Ti (10de:2c05) 621.01 56 of 56 56 of 56
AMD Radeon Graphics, Ryzen 7 7700X iGPU (1002:164e) AMD 26.10.2 55 pass, 1 skip 55 pass, 1 skip
  • The skip is agc_driver_mesh_barycentric_emulation on the iGPU on both sides. There are no VUID- lines and no missing-layer line in any run.
  • Red check: the merged tree with only HostInterpolationChecker.cpp taken back from main fails agc_shader_memory with pixel input 0 is interpolated through both a perspective and a linear I/J pair. With the PR's checker it passes.
  • check_conventions.py --base main passes on the merge.
  • Both GPUs here report native fragment barycentrics: the device log has hostInterpolationFirst=0, and FragmentShaderBarycentricUsable holds for both drivers. So the real-device path is the one this change falls back to, not the host interpolation it fixes. This run checks for regressions on these drivers.

Read through the change: the new early return false in HostInterpolationChecker::Lower sends a shader with any input in both pixelLinearInputs and pixelPerspectiveInputs back to Recompile. There it is translated again with fragmentShaderBarycentricEnabled, as on a device with native barycentrics, before InputIsLinear (which throws for such an input) is reached at lines 84 and 98. The test now requires both smooth and linear barycentric emulation for the two-pair shader. A shader whose inputs each use one pair still goes through Lower as before. I found nothing to change.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5772536031 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15793#pullrequestreview-5772536031). Originally posted by [Superseabas](https://github.com/Superseabas) on 2026-11-04T17:09:45Z. **Review:** APPROVED --- Head `31317e522b` merged onto current `main` `b11c7bf84f` (clean merge, local only): code read, red/green check and a Windows run on NVIDIA and on AMD's Windows driver. Windows 11 Home 10.0.26200, WinLibs GCC 16.2.0 (`x86_64-ucrt-posix-seh`, r3), Release, `BUILD_TESTING=ON`. `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, `ctest -R '^(agc_shader_.*|agc_driver_.*interpol.*|agc_driver_.*barycentric.*)$'`, `ANYPS5_GPU` selecting the device (confirmed by `Selected GPU`): | GPU | Driver | `main` | merged | |---|---|---|---| | NVIDIA GeForce RTX 5070 Ti (`10de:2c05`) | 621.01 | 56 of 56 | 56 of 56 | | AMD Radeon Graphics, Ryzen 7 7700X iGPU (`1002:164e`) | AMD 26.10.2 | 55 pass, 1 skip | 55 pass, 1 skip | - The skip is `agc_driver_mesh_barycentric_emulation` on the iGPU on both sides. There are no `VUID-` lines and no missing-layer line in any run. - Red check: the merged tree with only `HostInterpolationChecker.cpp` taken back from `main` fails `agc_shader_memory` with `pixel input 0 is interpolated through both a perspective and a linear I/J pair`. With the PR's checker it passes. - `check_conventions.py --base main` passes on the merge. - Both GPUs here report native fragment barycentrics: the device log has `hostInterpolationFirst=0`, and `FragmentShaderBarycentricUsable` holds for both drivers. So the real-device path is the one this change falls back to, not the host interpolation it fixes. This run checks for regressions on these drivers. Read through the change: the new early `return false` in `HostInterpolationChecker::Lower` sends a shader with any input in both `pixelLinearInputs` and `pixelPerspectiveInputs` back to `Recompile`. There it is translated again with `fragmentShaderBarycentricEnabled`, as on a device with native barycentrics, before `InputIsLinear` (which throws for such an input) is reached at lines 84 and 98. The test now requires both smooth and linear barycentric emulation for the two-pair shader. A shader whose inputs each use one pair still goes through `Lower` as before. I found nothing to change. AI-assisted: yes (Claude Code)
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!15793
No description provided.