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

Commit 35baefc

Browse files
authored
[Impeller] Allow 3D scenes to render when MSAA is not supported. (#47217)
Before, Impeller Scene would render nothing on the GLES backend when used through Aiks.
1 parent fe3882e commit 35baefc

File tree

1 file changed

+38
-17
lines changed

1 file changed

+38
-17
lines changed

impeller/entity/contents/scene_contents.cc

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,44 @@ bool SceneContents::Render(const ContentContext& renderer,
4444
coverage = Rect::MakeSize(pass.GetRenderTargetSize());
4545
}
4646

47-
RenderTarget subpass_target = RenderTarget::CreateOffscreenMSAA(
48-
*renderer.GetContext(), // context
49-
*renderer.GetRenderTargetCache(), // allocator
50-
ISize(coverage.value().size), // size
51-
"SceneContents", // label
52-
RenderTarget::AttachmentConfigMSAA{
53-
.storage_mode = StorageMode::kDeviceTransient,
54-
.resolve_storage_mode = StorageMode::kDevicePrivate,
55-
.load_action = LoadAction::kClear,
56-
.store_action = StoreAction::kMultisampleResolve,
57-
}, // color_attachment_config
58-
RenderTarget::AttachmentConfig{
59-
.storage_mode = StorageMode::kDeviceTransient,
60-
.load_action = LoadAction::kDontCare,
61-
.store_action = StoreAction::kDontCare,
62-
} // stencil_attachment_config
63-
);
47+
RenderTarget subpass_target;
48+
if (renderer.GetContext()->GetCapabilities()->SupportsOffscreenMSAA()) {
49+
subpass_target = RenderTarget::CreateOffscreenMSAA(
50+
*renderer.GetContext(), // context
51+
*renderer.GetRenderTargetCache(), // allocator
52+
ISize(coverage.value().size), // size
53+
"SceneContents", // label
54+
RenderTarget::AttachmentConfigMSAA{
55+
.storage_mode = StorageMode::kDeviceTransient,
56+
.resolve_storage_mode = StorageMode::kDevicePrivate,
57+
.load_action = LoadAction::kClear,
58+
.store_action = StoreAction::kMultisampleResolve,
59+
}, // color_attachment_config
60+
RenderTarget::AttachmentConfig{
61+
.storage_mode = StorageMode::kDeviceTransient,
62+
.load_action = LoadAction::kDontCare,
63+
.store_action = StoreAction::kDontCare,
64+
} // stencil_attachment_config
65+
);
66+
} else {
67+
subpass_target = RenderTarget::CreateOffscreen(
68+
*renderer.GetContext(), // context
69+
*renderer.GetRenderTargetCache(), // allocator
70+
ISize(coverage.value().size), // size
71+
"SceneContents", // label
72+
RenderTarget::AttachmentConfig{
73+
.storage_mode = StorageMode::kDevicePrivate,
74+
.load_action = LoadAction::kClear,
75+
.store_action = StoreAction::kStore,
76+
}, // color_attachment_config
77+
RenderTarget::AttachmentConfig{
78+
.storage_mode = StorageMode::kDeviceTransient,
79+
.load_action = LoadAction::kClear,
80+
.store_action = StoreAction::kDontCare,
81+
} // stencil_attachment_config
82+
);
83+
}
84+
6485
if (!subpass_target.IsValid()) {
6586
return false;
6687
}

0 commit comments

Comments
 (0)