Repository navigation
Fix Vulkan MSAA diagonal seam in FramebufferBlend - #196197
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the Vulkan implementation of ReadDestination in framebuffer_blend.frag to mask MSAA subpass loads using gl_SampleMaskIn, which prevents diagonal seams along triangle edges, and adds a regression test. The review feedback suggests unrolling the loop in the shader to use constant indices for subpassLoad to avoid compilation failures on certain Android Vulkan drivers, and adding a null check assertion for the readback buffer in the test to prevent potential crashes.
360a292 to
1b9e4a6
Compare
|
Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change). If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
Skia gold diffs show this was happening in our golden tests and is now cleaned up. |
gaaclarke
left a comment
There was a problem hiding this comment.
I would like the test removed and a moment to review this.
gaaclarke
left a comment
There was a problem hiding this comment.
Okay, I spent some time looking this over. Alternatively we could draw 1 triangle that draws over the whole area (with a stencil). That would also eliminate the seam and work the same across all platforms.
I don't think that is probably necessary and this is approach is fine. Gemini seems to think that the else branch can be simplified, it's worth trying out:
vec4 ReadDestination() {
#ifdef IMPELLER_TARGET_VULKAN
// Vulkan reads MSAA input attachments one sample at a time, and this shader
// runs once per pixel. Average only the samples covered by this primitive.
// Samples outside its coverage may already have been written earlier in
// this draw, e.g. along the shared edge of the quad's two triangles.
// https://github.com/flutter/flutter/issues/179547
int mask = gl_SampleMaskIn[0] & 0xf;
vec4 result = vec4(0.0);
for (int i = 0; i < 4; i++) {
if ((mask & (1 << i)) != 0) {
result += subpassLoad(uSub, i);
}
}
return result / float(max(bitCount(mask), 1));
#else
// On Metal and GLES, SPIRV-Cross turns this into framebuffer fetch and
// ignores the sample index. Sample variables such as gl_SampleMaskIn also
// aren't available in GLSL ES 1.00.
return subpassLoad(uSub, 0);
#endif
}lgtm modulo the redundant test.
|
It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging. If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If both you and the PR author believe this PR qualifies for a test exemption, escalate to the tech lead for the changed area to review and apply the |
|
In my local testing |
|
Golden file changes are available for triage from new commit, Click here to view. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
gaaclarke
left a comment
There was a problem hiding this comment.
lgtm (goldens included), thanks zach
|
test exempt: this is fixing artifacts in existing goldens |
flutter/flutter@d463821...fffd8c2 2026-11-10 [email protected] Roll Fuchsia Test Scripts from 8QcsP_SmbsT09VgUs... to PXc5D7S_q6sIYpfFJ... (flutter/flutter#196273) 2026-11-10 [email protected] [web] Accept the capped letter spacing line shift in kitchensink (flutter/flutter#196148) 2026-11-10 [email protected] Fix Vulkan MSAA diagonal seam in FramebufferBlend (flutter/flutter#196197) 2026-11-10 [email protected] Read back images on the raster thread on OpenGLES (flutter/flutter#195927) 2026-11-10 [email protected] [web] Unify ui.Paint across CanvasKit and Skwasm (flutter/flutter#196071) 2026-11-10 [email protected] Roll Fuchsia Test Scripts from p3N3B-Kchh1bthB6n... to 8QcsP_SmbsT09VgUs... (flutter/flutter#196249) 2026-11-09 [email protected] [Impeller] Reland clipped BackdropFilter square corners fix (flutter/flutter#195716) 2026-11-09 [email protected] [web] Recreate canvas and context on CkOffscreenSurface resize to fix WebGL clipping (flutter/flutter#192769) 2026-11-09 [email protected] Roll Dart SDK from ee0f66fa0ad2 to a2baae273bb2 (1 revision) (flutter/flutter#196245) 2026-11-09 [email protected] Add Mac web_tool_tests_1_2 and _2_2 in bringup (flutter/flutter#196241) 2026-11-09 [email protected] Roll pub packages (flutter/flutter#196246) 2026-11-09 [email protected] Increase number of 'Windows tool_integration_tests' subshards (flutter/flutter#196243) 2026-11-09 [email protected] Roll Fuchsia Test Scripts from Jo-ZgQSNDuPsjlZ4s... to p3N3B-Kchh1bthB6n... (flutter/flutter#196238) 2026-11-09 [email protected] Skip UIScene pre-migration test cases on Xcode 27 (flutter/flutter#194755) 2026-11-09 [email protected] [flutter_tools] Share Analytics.isBot and make isRunningOnBot sync (flutter/flutter#194744) 2026-11-09 [email protected] [flutter_tools] Retry chromedriver startup when its port is taken (flutter/flutter#196150) 2026-11-09 [email protected] Remove unused vulkan_provider.cc (flutter/flutter#195513) 2026-11-09 [email protected] Roll Dart SDK from 3b174b7217fe to ee0f66fa0ad2 (13 revisions) (flutter/flutter#196217) 2026-11-09 [email protected] Goma is dead, long live RBE! (Take 2) (flutter/flutter#196212) 2026-11-09 [email protected] Split DevTools customer tests into its own customer_testing_devtools shard (flutter/flutter#195871) 2026-11-09 [email protected] Split mac_host_{debug,profile,release}_arm64_tests into one step per type (flutter/flutter#196031) If this roll has caused a breakage, revert this CL and set the roller to dry run mode using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] 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
On Metal and OpenGL ES, SPIRV-Cross lowers
subpassInputMSto native framebuffer fetch, which the hardware/driver scopes to the current primitive's covered samples.On Vulkan,
subpassLoad(uSub, i)remains an explicit pixel-rate MSAA input-attachment read of samplei. Unconditionally averaging samples reads samples outside this primitive's coverage, including samples along a triangle strip's shared edge already written by the adjacent triangle.To address the issue, This PR averages only the samples indicated by the mask.
Fixes #179547
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.