Skip to content

Commit 5f97c7f

Browse files
authored
Fixes MSAA on the linux embedder. (flutter#191379)
fixes flutter#191171 This is the linux equivalent of the windows change: flutter#190256 On desktop we normally need to have an explicit resolution step for MSAA to work, this adds that explicit step. On linux we were already blitting from this framebuffer so we didn't need to provide an explicit resolve step, it already existed. I also removed code about using bgra. This was impeding our usage of MSAA render buffers, on linux I don't think there is a reason we have to use BGRA. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. 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](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot 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. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [AI contribution guidelines]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
1 parent 1f2af33 commit 5f97c7f

10 files changed

Lines changed: 715 additions & 36 deletions

File tree

‎engine/src/flutter/shell/platform/linux/BUILD.gn‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ executable("flutter_linux_unittests") {
255255
"fl_method_codec_test.cc",
256256
"fl_method_response_test.cc",
257257
"fl_mouse_cursor_handler_test.cc",
258+
"fl_opengl_frame_test.cc",
258259
"fl_pixel_buffer_texture_test.cc",
259260
"fl_platform_channel_test.cc",
260261
"fl_platform_handler_test.cc",

‎engine/src/flutter/shell/platform/linux/fl_engine.cc‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,15 +287,16 @@ static bool create_opengl_backing_store(
287287
return false;
288288
}
289289

290-
GLint sized_format = GL_RGBA8;
291290
GLint general_format = GL_RGBA;
291+
GLint sized_format = GL_RGBA8;
292292
if (epoxy_has_gl_extension("GL_EXT_texture_format_BGRA8888")) {
293-
sized_format = GL_BGRA8_EXT;
294293
general_format = GL_BGRA_EXT;
294+
sized_format = GL_BGRA8_EXT;
295295
}
296296

297-
FlFramebuffer* framebuffer = fl_framebuffer_new(
298-
general_format, config->size.width, config->size.height, FALSE);
297+
FlFramebuffer* framebuffer = fl_framebuffer_new_multisample(
298+
general_format, config->size.width, config->size.height,
299+
fl_dart_project_get_enable_impeller(self->project));
299300
if (!framebuffer) {
300301
g_warning("Failed to create backing store");
301302
return false;
@@ -306,7 +307,8 @@ static bool create_opengl_backing_store(
306307
backing_store_out->open_gl.framebuffer.user_data = framebuffer;
307308
backing_store_out->open_gl.framebuffer.name =
308309
fl_framebuffer_get_id(framebuffer);
309-
backing_store_out->open_gl.framebuffer.target = sized_format;
310+
backing_store_out->open_gl.framebuffer.target =
311+
fl_framebuffer_get_texture_id(framebuffer) != 0 ? sized_format : GL_RGBA8;
310312
backing_store_out->open_gl.framebuffer.destruction_callback = [](void* p) {
311313
// Backing store destroyed in fl_compositor_opengl_collect_backing_store(),
312314
// set on FlutterCompositor.collect_backing_store_callback during engine

‎engine/src/flutter/shell/platform/linux/fl_engine_test.cc‎

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88

99
#include "flutter/shell/platform/embedder/test_utils/proc_table_replacement.h"
1010
#include "flutter/shell/platform/linux/fl_engine_private.h"
11+
#include "flutter/shell/platform/linux/fl_framebuffer.h"
1112
#include "flutter/shell/platform/linux/public/flutter_linux/fl_engine.h"
1213
#include "flutter/shell/platform/linux/public/flutter_linux/fl_json_message_codec.h"
1314
#include "flutter/shell/platform/linux/public/flutter_linux/fl_string_codec.h"
15+
#include "flutter/shell/platform/linux/testing/mock_epoxy.h"
1416
#include "flutter/shell/platform/linux/testing/mock_renderable.h"
1517

1618
// MOCK_ENGINE_PROC is leaky by design
@@ -1060,6 +1062,126 @@ TEST_F(FlEngineTest, EnableFlutterGpu) {
10601062
EXPECT_TRUE(called);
10611063
}
10621064

1065+
namespace {
1066+
1067+
// Helper to start the engine with Impeller enabled, create an OpenGL backing
1068+
// store, verify its target and texture presence, and collect it.
1069+
void test_impeller_backing_store(FlEngine* engine,
1070+
FlDartProject* project,
1071+
uint32_t expected_target,
1072+
bool expect_texture) {
1073+
FlutterCompositor compositor = {};
1074+
fl_engine_get_embedder_api(engine)->Initialize = MOCK_ENGINE_PROC(
1075+
Initialize,
1076+
([&compositor](size_t version, const FlutterRendererConfig* config,
1077+
const FlutterProjectArgs* args, void* user_data,
1078+
FLUTTER_API_SYMBOL(FlutterEngine) * engine_out) {
1079+
if (args->compositor != nullptr) {
1080+
compositor = *args->compositor;
1081+
}
1082+
return kSuccess;
1083+
}));
1084+
fl_engine_get_embedder_api(engine)->RunInitialized =
1085+
MOCK_ENGINE_PROC(RunInitialized, ([](auto engine) { return kSuccess; }));
1086+
1087+
fl_dart_project_set_enable_impeller(project, TRUE);
1088+
1089+
g_autoptr(GError) error = nullptr;
1090+
EXPECT_TRUE(fl_engine_start(engine, &error));
1091+
EXPECT_EQ(error, nullptr);
1092+
ASSERT_NE(compositor.create_backing_store_callback, nullptr);
1093+
1094+
FlutterBackingStoreConfig config = {
1095+
.struct_size = sizeof(FlutterBackingStoreConfig),
1096+
.size = {.width = 800.0, .height = 600.0},
1097+
};
1098+
FlutterBackingStore backing_store = {};
1099+
EXPECT_TRUE(compositor.create_backing_store_callback(&config, &backing_store,
1100+
compositor.user_data));
1101+
EXPECT_EQ(backing_store.type, kFlutterBackingStoreTypeOpenGL);
1102+
EXPECT_EQ(backing_store.open_gl.type, kFlutterOpenGLTargetTypeFramebuffer);
1103+
EXPECT_EQ(backing_store.open_gl.framebuffer.target, expected_target);
1104+
1105+
FlFramebuffer* fb =
1106+
FL_FRAMEBUFFER(backing_store.open_gl.framebuffer.user_data);
1107+
EXPECT_NE(fb, nullptr);
1108+
if (expect_texture) {
1109+
EXPECT_NE(fl_framebuffer_get_texture_id(fb), 0u);
1110+
} else {
1111+
EXPECT_EQ(fl_framebuffer_get_texture_id(fb), 0u);
1112+
}
1113+
1114+
EXPECT_TRUE(compositor.collect_backing_store_callback(&backing_store,
1115+
compositor.user_data));
1116+
}
1117+
1118+
} // namespace
1119+
1120+
TEST_F(FlEngineTest, CreateOpenGLBackingStoreWithImpellerMSAA) {
1121+
::testing::NiceMock<flutter::testing::MockEpoxy> epoxy;
1122+
ON_CALL(epoxy, epoxy_gl_version).WillByDefault(::testing::Return(30));
1123+
ON_CALL(epoxy, epoxy_has_gl_extension(::testing::_))
1124+
.WillByDefault(::testing::Return(false));
1125+
ON_CALL(epoxy, glGetIntegerv(GL_MAX_SAMPLES, ::testing::_))
1126+
.WillByDefault(::testing::SetArgPointee<1>(4));
1127+
1128+
EXPECT_CALL(epoxy, glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4,
1129+
GL_RGBA8, 800, 600));
1130+
EXPECT_CALL(epoxy, glRenderbufferStorageMultisample(
1131+
GL_RENDERBUFFER, 4, GL_DEPTH24_STENCIL8, 800, 600));
1132+
EXPECT_CALL(epoxy,
1133+
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
1134+
GL_RENDERBUFFER, ::testing::_));
1135+
EXPECT_CALL(epoxy,
1136+
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
1137+
GL_RENDERBUFFER, ::testing::_));
1138+
EXPECT_CALL(epoxy,
1139+
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
1140+
GL_RENDERBUFFER, ::testing::_));
1141+
1142+
test_impeller_backing_store(engine, project, GL_RGBA8,
1143+
/*expect_texture=*/false);
1144+
}
1145+
1146+
TEST_F(FlEngineTest, CreateOpenGLBackingStoreWithImpellerMSAAAndBgraExtension) {
1147+
::testing::NiceMock<flutter::testing::MockEpoxy> epoxy;
1148+
ON_CALL(epoxy, epoxy_gl_version).WillByDefault(::testing::Return(30));
1149+
ON_CALL(epoxy, epoxy_has_gl_extension(::testing::_))
1150+
.WillByDefault(::testing::Return(false));
1151+
ON_CALL(epoxy, epoxy_has_gl_extension(
1152+
::testing::StrEq("GL_EXT_texture_format_BGRA8888")))
1153+
.WillByDefault(::testing::Return(true));
1154+
ON_CALL(epoxy, glGetIntegerv(GL_MAX_SAMPLES, ::testing::_))
1155+
.WillByDefault(::testing::SetArgPointee<1>(4));
1156+
1157+
// GL_EXT_texture_format_BGRA8888 only defines BGRA for textures, not
1158+
// renderbuffers. When explicit offscreen MSAA is used without
1159+
// GL_EXT_multisampled_render_to_texture, a multisample renderbuffer is
1160+
// created which must use GL_RGBA8.
1161+
EXPECT_CALL(epoxy, glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4,
1162+
GL_RGBA8, 800, 600));
1163+
EXPECT_CALL(epoxy, glRenderbufferStorageMultisample(
1164+
GL_RENDERBUFFER, 4, GL_DEPTH24_STENCIL8, 800, 600));
1165+
1166+
test_impeller_backing_store(engine, project, GL_RGBA8,
1167+
/*expect_texture=*/false);
1168+
}
1169+
1170+
TEST_F(FlEngineTest, CreateOpenGLBackingStoreWithImplicitMSAAAndBgraExtension) {
1171+
::testing::NiceMock<flutter::testing::MockEpoxy> epoxy;
1172+
ON_CALL(epoxy, epoxy_has_gl_extension(::testing::_))
1173+
.WillByDefault(::testing::Return(false));
1174+
ON_CALL(epoxy, epoxy_has_gl_extension(
1175+
::testing::StrEq("GL_EXT_texture_format_BGRA8888")))
1176+
.WillByDefault(::testing::Return(true));
1177+
ON_CALL(epoxy, epoxy_has_gl_extension(
1178+
::testing::StrEq("GL_EXT_multisampled_render_to_texture")))
1179+
.WillByDefault(::testing::Return(true));
1180+
1181+
test_impeller_backing_store(engine, project, GL_BGRA8_EXT,
1182+
/*expect_texture=*/true);
1183+
}
1184+
10631185
TEST_F(FlEngineTest, ChildObjects) {
10641186
// Check objects exist before engine started.
10651187
EXPECT_NE(fl_engine_get_binary_messenger(engine), nullptr);

‎engine/src/flutter/shell/platform/linux/fl_framebuffer.cc‎

Lines changed: 127 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ struct _FlFramebuffer {
2424
// Texture backing framebuffer.
2525
GLuint texture_id;
2626

27-
// Stencil buffer associated with this framebuffer.
27+
// Color renderbuffer backing framebuffer (if using offscreen MSAA).
28+
GLuint color_renderbuffer;
29+
30+
// Depth and stencil renderbuffer associated with this framebuffer.
2831
GLuint depth_stencil;
2932

3033
// EGL image for this texture.
@@ -36,9 +39,22 @@ G_DEFINE_TYPE(FlFramebuffer, fl_framebuffer, G_TYPE_OBJECT)
3639
static void fl_framebuffer_dispose(GObject* object) {
3740
FlFramebuffer* self = FL_FRAMEBUFFER(object);
3841

39-
glDeleteFramebuffers(1, &self->framebuffer_id);
40-
glDeleteTextures(1, &self->texture_id);
41-
glDeleteRenderbuffers(1, &self->depth_stencil);
42+
if (self->framebuffer_id != 0) {
43+
glDeleteFramebuffers(1, &self->framebuffer_id);
44+
self->framebuffer_id = 0;
45+
}
46+
if (self->texture_id != 0) {
47+
glDeleteTextures(1, &self->texture_id);
48+
self->texture_id = 0;
49+
}
50+
if (self->color_renderbuffer != 0) {
51+
glDeleteRenderbuffers(1, &self->color_renderbuffer);
52+
self->color_renderbuffer = 0;
53+
}
54+
if (self->depth_stencil != 0) {
55+
glDeleteRenderbuffers(1, &self->depth_stencil);
56+
self->depth_stencil = 0;
57+
}
4258
g_clear_object(&self->image);
4359

4460
G_OBJECT_CLASS(fl_framebuffer_parent_class)->dispose(object);
@@ -50,6 +66,40 @@ static void fl_framebuffer_class_init(FlFramebufferClass* klass) {
5066

5167
static void fl_framebuffer_init(FlFramebuffer* self) {}
5268

69+
static bool check_supports_implicit_msaa() {
70+
return epoxy_has_gl_extension("GL_EXT_multisampled_render_to_texture");
71+
}
72+
73+
static bool check_supports_offscreen_msaa() {
74+
if (epoxy_gl_version() >= 30) {
75+
GLint max_samples = 0;
76+
glGetIntegerv(GL_MAX_SAMPLES, &max_samples);
77+
return max_samples >= 4;
78+
}
79+
return false;
80+
}
81+
82+
static GLuint create_texture(GLint format, size_t width, size_t height) {
83+
GLuint texture_id;
84+
glGenTextures(1, &texture_id);
85+
glBindTexture(GL_TEXTURE_2D, texture_id);
86+
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
87+
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
88+
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
89+
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
90+
glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, format,
91+
GL_UNSIGNED_BYTE, nullptr);
92+
glBindTexture(GL_TEXTURE_2D, 0);
93+
return texture_id;
94+
}
95+
96+
static void attach_depth_stencil(GLuint depth_stencil) {
97+
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
98+
GL_RENDERBUFFER, depth_stencil);
99+
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
100+
GL_RENDERBUFFER, depth_stencil);
101+
}
102+
53103
FlFramebuffer* fl_framebuffer_new(GLint format,
54104
size_t width,
55105
size_t height,
@@ -60,19 +110,10 @@ FlFramebuffer* fl_framebuffer_new(GLint format,
60110
self->width = width;
61111
self->height = height;
62112

63-
glGenTextures(1, &self->texture_id);
64113
glGenFramebuffers(1, &self->framebuffer_id);
65-
66114
glBindFramebuffer(GL_FRAMEBUFFER, self->framebuffer_id);
67115

68-
glBindTexture(GL_TEXTURE_2D, self->texture_id);
69-
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
70-
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
71-
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
72-
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
73-
glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, format,
74-
GL_UNSIGNED_BYTE, NULL);
75-
glBindTexture(GL_TEXTURE_2D, 0);
116+
self->texture_id = create_texture(format, width, height);
76117

77118
if (shareable) {
78119
self->image = fl_egl_image_new(self->texture_id);
@@ -83,15 +124,78 @@ FlFramebuffer* fl_framebuffer_new(GLint format,
83124

84125
glGenRenderbuffers(1, &self->depth_stencil);
85126
glBindRenderbuffer(GL_RENDERBUFFER, self->depth_stencil);
86-
glRenderbufferStorage(GL_RENDERBUFFER, // target
87-
GL_DEPTH24_STENCIL8, // internal format
88-
width, // width
89-
height // height
90-
);
91-
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
92-
GL_RENDERBUFFER, self->depth_stencil);
93-
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
94-
GL_RENDERBUFFER, self->depth_stencil);
127+
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height);
128+
attach_depth_stencil(self->depth_stencil);
129+
130+
return self;
131+
}
132+
133+
FlFramebuffer* fl_framebuffer_new_multisample(GLint format,
134+
size_t width,
135+
size_t height,
136+
gboolean use_msaa) {
137+
FlFramebuffer* self =
138+
FL_FRAMEBUFFER(g_object_new(fl_framebuffer_get_type(), nullptr));
139+
140+
self->width = width;
141+
self->height = height;
142+
143+
glGenFramebuffers(1, &self->framebuffer_id);
144+
glBindFramebuffer(GL_FRAMEBUFFER, self->framebuffer_id);
145+
146+
if (use_msaa) {
147+
if (check_supports_implicit_msaa()) {
148+
// Implicit MSAA uses GL_EXT_multisampled_render_to_texture, where the
149+
// OpenGL driver automatically resolves multisamples into the attached
150+
// texture when rendering is completed.
151+
self->texture_id = create_texture(format, width, height);
152+
glFramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
153+
GL_TEXTURE_2D, self->texture_id, 0,
154+
4);
155+
156+
glGenRenderbuffers(1, &self->depth_stencil);
157+
glBindRenderbuffer(GL_RENDERBUFFER, self->depth_stencil);
158+
glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, 4,
159+
GL_DEPTH24_STENCIL8, width, height);
160+
attach_depth_stencil(self->depth_stencil);
161+
} else if (check_supports_offscreen_msaa()) {
162+
// Offscreen MSAA uses a multisample renderbuffer instead of a texture.
163+
// The multisample resolve occurs in fl_compositor_opengl_composite_layers
164+
// via glBlitFramebuffer (or composite_layer) into the compositor's
165+
// single-sample framebuffer texture.
166+
glGenRenderbuffers(1, &self->color_renderbuffer);
167+
glBindRenderbuffer(GL_RENDERBUFFER, self->color_renderbuffer);
168+
glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_RGBA8, width,
169+
height);
170+
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
171+
GL_RENDERBUFFER, self->color_renderbuffer);
172+
173+
glGenRenderbuffers(1, &self->depth_stencil);
174+
glBindRenderbuffer(GL_RENDERBUFFER, self->depth_stencil);
175+
glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_DEPTH24_STENCIL8,
176+
width, height);
177+
attach_depth_stencil(self->depth_stencil);
178+
} else {
179+
self->texture_id = create_texture(format, width, height);
180+
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
181+
GL_TEXTURE_2D, self->texture_id, 0);
182+
183+
glGenRenderbuffers(1, &self->depth_stencil);
184+
glBindRenderbuffer(GL_RENDERBUFFER, self->depth_stencil);
185+
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width,
186+
height);
187+
attach_depth_stencil(self->depth_stencil);
188+
}
189+
} else {
190+
self->texture_id = create_texture(format, width, height);
191+
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
192+
self->texture_id, 0);
193+
194+
glGenRenderbuffers(1, &self->depth_stencil);
195+
glBindRenderbuffer(GL_RENDERBUFFER, self->depth_stencil);
196+
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height);
197+
attach_depth_stencil(self->depth_stencil);
198+
}
95199

96200
return self;
97201
}

0 commit comments

Comments
 (0)