-
Notifications
You must be signed in to change notification settings - Fork 29.9k
[Impeller] Fix perspective clips with a large perspective bias #181434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Impeller] Fix perspective clips with a large perspective bias #181434
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request fixes incorrect clipping for geometries under a perspective transform with a large bias. The main change is in the clip.vert shader, which now correctly lets the GPU handle perspective division and clipping by not dividing gl_Position by w in the vertex shader. Instead, it sets gl_Position.z relative to w. Complementing this, FillRectGeometry::GetCoverage is updated to use TransformAndClipBounds for accurate coverage calculation with perspective transforms. A new playground test is also added for visual verification. The changes are correct and address the issue effectively.
gaaclarke
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. The math should be equivalent. Previously the weight was set to 1 by applying the division, then undoing that for the z component to maintain the clip depth. This works similarly but keeps the weight value intact by just multiplying it by the weight instead. My intuition here is that we are getting different results by delaying the weight division instead of doing it here.
flutter/flutter@bfc9041...def9ca9 2026-01-25 engine-flutter-autoroll@skia.org Roll Skia from f1433eb44a50 to 2830fbe8bafe (1 revision) (flutter/flutter#181464) 2026-01-25 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from 6xoKGIry6Y8T8x5Sa... to T4qTEa3T5CCSCIoJY... (flutter/flutter#181458) 2026-01-24 engine-flutter-autoroll@skia.org Roll Skia from b6d396a151bc to f1433eb44a50 (1 revision) (flutter/flutter#181449) 2026-01-24 engine-flutter-autoroll@skia.org Roll Dart SDK from 29918a54dd5c to 60553fc4c04f (1 revision) (flutter/flutter#181437) 2026-01-24 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from n7NohL9DPpEuPjNt9... to 6xoKGIry6Y8T8x5Sa... (flutter/flutter#181438) 2026-01-24 flar@google.com [Impeller] Fix perspective clips with a large perspective bias (flutter/flutter#181434) 2026-01-24 engine-flutter-autoroll@skia.org Roll Dart SDK from e82d7ad1855e to 29918a54dd5c (4 revisions) (flutter/flutter#181435) 2026-01-24 engine-flutter-autoroll@skia.org Roll Skia from 32b52343e757 to b6d396a151bc (4 revisions) (flutter/flutter#181431) 2026-01-24 flar@google.com [Impeller] Fix interpolation error in Rect::TransformAndClipBounds (flutter/flutter#181420) 2026-01-23 engine-flutter-autoroll@skia.org Roll Skia from 6d438894c2a8 to 32b52343e757 (2 revisions) (flutter/flutter#181419) 2026-01-23 120639059+Enderjua@users.noreply.github.com [Material] modernize Typography._withPlatform with Dart 3 switch expression (flutter/flutter#181398) 2026-01-23 58190796+MitchellGoodwin@users.noreply.github.com CupertinoSheetRoute with scrolling and dragging (flutter/flutter#177337) 2026-01-23 30870216+gaaclarke@users.noreply.github.com Adds contents of keys file when a skia gold error occurs. (flutter/flutter#181401) 2026-01-23 engine-flutter-autoroll@skia.org Roll Skia from e4bd0a355e68 to 6d438894c2a8 (3 revisions) (flutter/flutter#181405) 2026-01-23 116356835+AbdeMohlbi@users.noreply.github.com bump KGP and AGP max known versions (flutter/flutter#181325) 2026-01-23 engine-flutter-autoroll@skia.org Roll Skia from db10db8bd55f to e4bd0a355e68 (3 revisions) (flutter/flutter#181391) 2026-01-23 engine-flutter-autoroll@skia.org Roll Packages from 9010299 to 5af5f50 (4 revisions) (flutter/flutter#181388) 2026-01-23 w.albert221@gmail.com Look for project root for FeatureFlags manifest (flutter/flutter#180689) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC louisehsu@google.com,stuartmorgan@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Fixes: #173104
We were precomputing the perspective adjustment inside the clipping vertex shader, which prevented the GPU from performing correct clipping against the camera plane.