agc_driver_pixel_sample_iteration fails on RADV without fragmentShaderBarycentric: InterpolateAtOffset of perspective barycentrics is extrapolated #7825

Closed
opened 2026-10-19 09:08:16 +00:00 by root-over · 0 comments
root-over commented 2026-10-19 09:08:16 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by root-over on 2026-10-19T09:08:16Z.


What

agc_driver_pixel_sample_iteration fails on main (6b8228b2b) on RADV with an AMD Vega iGPU and passes on lavapipe on the same machine:

AGC graphics: 4x PERSP_SAMPLE, POS and ANCILLARY run once per pixel: pixel (0, 0) slot 0 read the barycentrics (0.001464, 0.998083), expected (0.001473, 0.997545) at (0.375000, 0.125000)

The test allows 1e-5; the error is about 5e-4.

Cause

RADV evaluates the GLSLstd450InterpolateAtOffset the recompiler emits for an offset barycentric (EmitOffsetBarycentricU32 in SpirvModuleEmitter.cpp) as the value at the pixel center plus the one-pixel quad differences times the offset. Using the test's triangle (Barycentrics, Corners, 64x16):

i j
exact at (0.375, 0.125), what the test expects 0.001473 0.997545
center (0.5, 0.5) + ddx·(-0.125) + ddy·(-0.375), one-pixel differences 0.001464 0.998083
measured on RADV 0.001464 0.998083

The model reproduces the measurement to six digits. That extrapolation is exact for linear barycentrics and not for perspective-correct ones: with the PERSP_SAMPLE and PERSP_CENTER passes skipped locally, the LINEAR_SAMPLE pass passes on RADV and the next failure is the upper-left-position pass, which also reads perspective barycentrics, with the same numbers.

This device has no fragmentShaderBarycentric (agc_driver_interpolation_f16 skips for that reason), so the pixel shader takes the barycentric emulation path. On RADV with an RX 9070 XT the full suite passed except agc_driver_tessellation (#6877 comment, 2026-10-17, after this test was added in a61c30bff), so devices with native barycentrics look unaffected; I have no such device to check.

Options

  • Keep the shader as it is and accept the driver's precision for perspective barycentrics read away from the default position on devices that extrapolate, with a matching tolerance in the test.
  • On the emulation path, interpolate the no-perspective barycentrics at the offset (exact under linear extrapolation) and apply the perspective division in the shader from the vertices' 1/w, which would need w passed from the emulation geometry shader.

Environment

  • Ubuntu, kernel 7.0, GCC 15.2.0, Release, BUILD_TESTING=ON
  • AMD Ryzen 5 5625U iGPU (Vega, RADV RENOIR), Mesa 26.0.8; lavapipe (Mesa 26.0.8, LLVM 21.1.8) passes
  • Deterministic, 3/3

agc_driver_image_table_vouched_lookups also fails on this device with the same message as #7766 and passes on lavapipe, so #7766 is not specific to RDNA 4.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5921015877 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/7825). Originally posted by [root-over](https://github.com/root-over) on 2026-10-19T09:08:16Z. --- ### What `agc_driver_pixel_sample_iteration` fails on `main` (`6b8228b2b`) on RADV with an AMD Vega iGPU and passes on lavapipe on the same machine: ``` AGC graphics: 4x PERSP_SAMPLE, POS and ANCILLARY run once per pixel: pixel (0, 0) slot 0 read the barycentrics (0.001464, 0.998083), expected (0.001473, 0.997545) at (0.375000, 0.125000) ``` The test allows 1e-5; the error is about 5e-4. ### Cause RADV evaluates the `GLSLstd450InterpolateAtOffset` the recompiler emits for an offset barycentric (`EmitOffsetBarycentricU32` in `SpirvModuleEmitter.cpp`) as the value at the pixel center plus the one-pixel quad differences times the offset. Using the test's triangle (`Barycentrics`, `Corners`, 64x16): | | i | j | |---|---|---| | exact at (0.375, 0.125), what the test expects | 0.001473 | 0.997545 | | center (0.5, 0.5) + ddx·(-0.125) + ddy·(-0.375), one-pixel differences | 0.001464 | 0.998083 | | measured on RADV | 0.001464 | 0.998083 | The model reproduces the measurement to six digits. That extrapolation is exact for linear barycentrics and not for perspective-correct ones: with the `PERSP_SAMPLE` and `PERSP_CENTER` passes skipped locally, the `LINEAR_SAMPLE` pass passes on RADV and the next failure is the upper-left-position pass, which also reads perspective barycentrics, with the same numbers. This device has no `fragmentShaderBarycentric` (`agc_driver_interpolation_f16` skips for that reason), so the pixel shader takes the barycentric emulation path. On RADV with an RX 9070 XT the full suite passed except `agc_driver_tessellation` (#6877 comment, 2026-10-17, after this test was added in a61c30bff), so devices with native barycentrics look unaffected; I have no such device to check. ### Options - Keep the shader as it is and accept the driver's precision for perspective barycentrics read away from the default position on devices that extrapolate, with a matching tolerance in the test. - On the emulation path, interpolate the no-perspective barycentrics at the offset (exact under linear extrapolation) and apply the perspective division in the shader from the vertices' 1/w, which would need w passed from the emulation geometry shader. ### Environment - Ubuntu, kernel 7.0, GCC 15.2.0, Release, `BUILD_TESTING=ON` - AMD Ryzen 5 5625U iGPU (Vega, RADV RENOIR), Mesa 26.0.8; lavapipe (Mesa 26.0.8, LLVM 21.1.8) passes - Deterministic, 3/3 `agc_driver_image_table_vouched_lookups` also fails on this device with the same message as #7766 and passes on lavapipe, so #7766 is not specific to RDNA 4.
Sign in to join this conversation.
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#7825
No description provided.