Repository navigation
[Impeller] Use separate uniform buffers on VMware SVGA3D - #196022
Conversation
The Mesa SVGA3D driver used on VMware keeps a separate copy of a buffer when it is used for uniforms, and does not update that copy when the buffer is changed later. Impeller stores uniforms and vertices in the same buffer, so shaders kept reading old uniform values and windows rendered blank or black. On SVGA3D, upload uniform data to its own GL buffer so the driver always sees the latest values. Fixes flutter#192915
There was a problem hiding this comment.
Code Review
This pull request introduces support for separate uniform buffers in the GLES backend of Impeller to address issues on drivers like Mesa's SVGA (VMware) where updates are not synchronized when a buffer is shared as both a uniform and vertex/index buffer. It adds capability detection for SVGA3D, manages separate handles and dirty ranges in DeviceBufferGLES, and updates binding logic and unit tests accordingly. Feedback suggests replacing a ternary operator inside std::swap with an explicit if-else block to prevent Clang thread-safety analysis warnings, and moving the MergeRange helper function into an unnamed namespace to comply with the Google C++ Style Guide.
| { | ||
| Lock lock(dirty_range_mutex_); | ||
| std::swap(dirty_range_, dirty); | ||
| std::swap(uses_uniform_buffer ? uniform_dirty_range_ : dirty_range_, dirty); |
There was a problem hiding this comment.
Using a ternary operator inside std::swap on variables annotated with IPLR_GUARDED_BY can confuse Clang's thread-safety analysis, potentially leading to compilation warnings or errors depending on the compiler version and configuration. Replacing this with an explicit if-else block is safer and ensures robust compilation with thread-safety analysis enabled.
| std::swap(uses_uniform_buffer ? uniform_dirty_range_ : dirty_range_, dirty); | |
| if (uses_uniform_buffer) { | |
| std::swap(uniform_dirty_range_, dirty); | |
| } else { | |
| std::swap(dirty_range_, dirty); | |
| } |
| static void MergeRange(std::optional<Range>& dirty_range, Range range) { | ||
| if (dirty_range.has_value()) { | ||
| dirty_range = dirty_range->Merge(range); | ||
| } else { | ||
| dirty_range = range; | ||
| } | ||
| } |
There was a problem hiding this comment.
According to the Google C++ Style Guide, unnamed namespaces are preferred over file-scope static functions for declarations that do not need to be visible outside the file. Placing MergeRange in an unnamed namespace aligns with this style guideline.
namespace {
void MergeRange(std::optional<Range>& dirty_range, Range range) {
if (dirty_range.has_value()) {
dirty_range = dirty_range->Merge(range);
} else {
dirty_range = range;
}
}
} // namespaceReferences
- Google C++ Style Guide: Use unnamed namespaces or declare key members static in .cc files to prevent them from being visible outside the file. Do not use file-scope static. (link)
|
autosubmit label was removed for flutter/flutter/196022, because - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label. |
|
Merging from master to resolve google testing failures |
|
autosubmit label was removed for flutter/flutter/196022, because - The status or check suite Dashboard Checks has failed. Please fix the issues identified (or deflake) before re-applying this label. |
|
autosubmit label was removed for flutter/flutter/196022, because - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label. |
flutter/flutter@b98afb5...9c427b5 2026-11-12 [email protected] Roll Skia from d67d0f22e3ec to 9aa2513a4ac9 (2 revisions) (flutter/flutter#196429) 2026-11-12 [email protected] [flutter_tools] Move CpuArch to flutter_tools_core and define HostPlatform by osName and cpuArch (flutter/flutter#195841) 2026-11-12 [email protected] Roll Skia from 23e7e63789b8 to d67d0f22e3ec (2 revisions) (flutter/flutter#196424) 2026-11-12 [email protected] Uber compactify (flutter/flutter#196392) 2026-11-12 [email protected] Roll Skia from 3d7e335da165 to 23e7e63789b8 (12 revisions) (flutter/flutter#196422) 2026-11-12 [email protected] Roll Dart SDK from 13af329ea4f2 to e5add7a25b32 (1 revision) (flutter/flutter#196413) 2026-11-12 [email protected] Don't terminate the shared EGL display when an engine is disposed (flutter/flutter#194520) 2026-11-11 [email protected] Adds manifest flag to turn on SDFs for Android. (flutter/flutter#196056) 2026-11-11 [email protected] Remove bringup from Linux_pixel_7pro integration_ui_keyboard_inset_jump (flutter/flutter#196334) 2026-11-11 [email protected] Uses system default locale for text rendering when preferred locale isn't supported (flutter/flutter#195997) 2026-11-11 [email protected] [android]: prewarms shaders when the context is created (flutter/flutter#196069) 2026-11-11 [email protected] iOS: Recomposite platform views only if their parameters change (flutter/flutter#196287) 2026-11-11 [email protected] [flutter_tools] Forward encoding in ErrorHandlingFile.readAsStringSync (flutter/flutter#196136) 2026-11-11 [email protected] Roll Skia from b89c24bbab8c to 3d7e335da165 (8 revisions) (flutter/flutter#196390) 2026-11-11 [email protected] Add Flutter Gardener instructions on how to disable a test (flutter/flutter#196312) 2026-11-11 [email protected] [Impeller] Enable malioc analysis for framebuffer_blend shaders (flutter/flutter#196343) 2026-11-11 [email protected] [flutter_tools] Migrate general.shard Android, asset, and build tests off globals (flutter/flutter#196125) 2026-11-11 [email protected] Roll Dart SDK from 8f15c4ca2d41 to 13af329ea4f2 (1 revision) (flutter/flutter#196386) 2026-11-11 [email protected] [Impeller] Do not clamp the local coverage limit to the root render target (flutter/flutter#195860) 2026-11-11 [email protected] [Impeller] Use separate uniform buffers on VMware SVGA3D (flutter/flutter#196022) 2026-11-11 [email protected] [flutter_tools] Introduce AndroidSdkProvider for lazy native_assets SDK lookup (flutter/flutter#196122) 2026-11-11 [email protected] Moves linux to ThinLTO. (flutter/flutter#196314) 2026-11-11 [email protected] [flutter_tools] Migrate bin/fuchsia_tester.dart off globals and runInContext (flutter/flutter#196074) 2026-11-11 [email protected] Changes the tolerances for frame_rate_main_test.dart. (flutter/flutter#196304) 2026-11-11 [email protected] Roll Packages from 08faf64 to 653628e (16 revisions) (flutter/flutter#196381) 2026-11-11 [email protected] Allow SliverCrossAxisGroup children to lay out with zero cross-axis extent instead of asserting (flutter/flutter#191287) 2026-11-11 [email protected] Roll Skia from cc4c54f752ba to b89c24bbab8c (4 revisions) (flutter/flutter#196375) 2026-11-11 [email protected] [Linux] Fix layer offset when compositing with glBlitFramebuffer (flutter/flutter#196189) 2026-11-11 [email protected] [flutter_tools] Inject CrashReportSender into SwiftPM migration (flutter/flutter#196315) 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
The Mesa SVGA3D driver used on VMware keeps a separate copy of a buffer when it is used for uniforms, and does not update that copy when the buffer is changed later. Impeller stores uniforms and vertices in the same buffer, so shaders kept reading old uniform values and windows rendered blank or black.
On SVGA3D, upload uniform data to its own GL buffer so the driver always sees the latest values. There is a proposed fix in mesa in https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/45908, but this will take some time for operating systems to include this. This makes a workaround in Flutter a reasonable compromise.
Fixes #192915