Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit f64cd0d

Browse files
committed
Gracefully fallback to not using MSAA when normal MSAA is not supported.
1 parent 10ef5b4 commit f64cd0d

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

lib/gpu/context.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,18 @@
1010
#include "flutter/lib/ui/ui_dart_state.h"
1111
#include "fml/make_copyable.h"
1212
#include "impeller/core/platform.h"
13+
#include "impeller/renderer/context.h"
1314
#include "tonic/converter/dart_converter.h"
1415

1516
namespace flutter {
1617
namespace gpu {
1718

19+
bool SupportsNormalOffscreenMSAA(const impeller::Context& context) {
20+
auto& capabilities = context.GetCapabilities();
21+
return capabilities->SupportsOffscreenMSAA() &&
22+
!capabilities->SupportsImplicitResolvingMSAA();
23+
}
24+
1825
IMPLEMENT_WRAPPERTYPEINFO(flutter_gpu, Context);
1926

2027
std::shared_ptr<impeller::Context> Context::default_context_;
@@ -114,5 +121,5 @@ extern int InternalFlutterGpu_Context_GetMinimumUniformByteAlignment(
114121

115122
extern bool InternalFlutterGpu_Context_GetSupportsOffscreenMSAA(
116123
flutter::gpu::Context* wrapper) {
117-
return wrapper->GetContext()->GetCapabilities()->SupportsOffscreenMSAA();
124+
return flutter::gpu::SupportsNormalOffscreenMSAA(*wrapper->GetContext());
118125
}

lib/gpu/context.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
namespace flutter {
1414
namespace gpu {
1515

16+
bool SupportsNormalOffscreenMSAA(const impeller::Context& context);
17+
1618
class Context : public RefCountedDartWrappable<Context> {
1719
DEFINE_WRAPPERTYPEINFO();
1820
FML_FRIEND_MAKE_REF_COUNTED(Context);

lib/gpu/render_pass.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "impeller/renderer/pipeline.h"
2121
#include "impeller/renderer/pipeline_descriptor.h"
2222
#include "impeller/renderer/pipeline_library.h"
23+
#include "lib/gpu/context.h"
2324
#include "lib/ui/ui_dart_state.h"
2425
#include "tonic/converter/dart_converter.h"
2526

@@ -242,6 +243,14 @@ Dart_Handle InternalFlutterGpu_RenderPass_SetColorAttachment(
242243
tonic::DartConverter<flutter::gpu::Texture*>::FromDart(
243244
resolve_texture_wrapper);
244245
desc.resolve_texture = resolve_texture->GetTexture();
246+
247+
// If the backend doesn't support normal MSAA, gracefully fallback to
248+
// rendering without MSAA.
249+
if (!flutter::gpu::SupportsNormalOffscreenMSAA(*wrapper->GetContext())) {
250+
desc.texture = desc.resolve_texture;
251+
desc.resolve_texture = nullptr;
252+
desc.store_action = impeller::StoreAction::kStore;
253+
}
245254
}
246255
wrapper->GetRenderTarget().SetColorAttachment(desc, color_attachment_index);
247256
return Dart_Null();

0 commit comments

Comments
 (0)