[Impeller] In canvas_unittests, only create an MSAA offscreen texture if the platform supports MSAA (flutter/engine#56542)

This commit is contained in:
Jason Simmons 2024-11-12 13:09:50 -08:00 committed by GitHub
parent 157b28e3a9
commit f03f05b51a

View File

@ -34,20 +34,23 @@ std::unique_ptr<Canvas> 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<Texture> 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<Texture> 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);