From f03f05b51a45a2dad9c791241f2da49a34ebc009 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Tue, 12 Nov 2024 13:09:50 -0800 Subject: [PATCH] [Impeller] In canvas_unittests, only create an MSAA offscreen texture if the platform supports MSAA (flutter/engine#56542) --- .../impeller/display_list/canvas_unittests.cc | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/engine/src/flutter/impeller/display_list/canvas_unittests.cc b/engine/src/flutter/impeller/display_list/canvas_unittests.cc index 2a762653b5..fc04272715 100644 --- a/engine/src/flutter/impeller/display_list/canvas_unittests.cc +++ b/engine/src/flutter/impeller/display_list/canvas_unittests.cc @@ -34,20 +34,23 @@ std::unique_ptr CreateTestCanvas( context.GetContext()->GetResourceAllocator()->CreateTexture( onscreen_desc); - TextureDescriptor onscreen_msaa_desc = onscreen_desc; - onscreen_msaa_desc.sample_count = SampleCount::kCount4; - onscreen_msaa_desc.storage_mode = StorageMode::kDeviceTransient; - onscreen_msaa_desc.type = TextureType::kTexture2DMultisample; - - std::shared_ptr onscreen_msaa = - context.GetContext()->GetResourceAllocator()->CreateTexture( - onscreen_msaa_desc); - ColorAttachment color0; - color0.resolve_texture = onscreen; - color0.texture = onscreen_msaa; - color0.store_action = StoreAction::kMultisampleResolve; color0.load_action = LoadAction::kClear; + if (context.GetContext()->GetCapabilities()->SupportsOffscreenMSAA()) { + TextureDescriptor onscreen_msaa_desc = onscreen_desc; + onscreen_msaa_desc.sample_count = SampleCount::kCount4; + onscreen_msaa_desc.storage_mode = StorageMode::kDeviceTransient; + onscreen_msaa_desc.type = TextureType::kTexture2DMultisample; + + std::shared_ptr onscreen_msaa = + context.GetContext()->GetResourceAllocator()->CreateTexture( + onscreen_msaa_desc); + color0.resolve_texture = onscreen; + color0.texture = onscreen_msaa; + color0.store_action = StoreAction::kMultisampleResolve; + } else { + color0.texture = onscreen; + } RenderTarget render_target; render_target.SetColorAttachment(color0, 0);