[Impeller] Make RenderTarget::CreateOffscreen utilities have a stencil by default (flutter/engine#39636)

This commit is contained in:
Brandon DeRosier
2023-02-14 17:04:39 -08:00
committed by GitHub
parent b833a44acf
commit 229f0f82c1
2 changed files with 19 additions and 8 deletions

View File

@@ -306,9 +306,13 @@ std::shared_ptr<Texture> ContentContext::MakeSubpass(
RenderTarget subpass_target;
if (context->GetDeviceCapabilities().SupportsOffscreenMSAA() &&
msaa_enabled) {
subpass_target = RenderTarget::CreateOffscreenMSAA(*context, texture_size);
subpass_target = RenderTarget::CreateOffscreenMSAA(
*context, texture_size, "Contents Offscreen MSAA",
RenderTarget::kDefaultColorAttachmentConfigMSAA, std::nullopt);
} else {
subpass_target = RenderTarget::CreateOffscreen(*context, texture_size);
subpass_target = RenderTarget::CreateOffscreen(
*context, texture_size, "Contents Offscreen",
RenderTarget::kDefaultColorAttachmentConfig, std::nullopt);
}
auto subpass_texture = subpass_target.GetRenderTargetTexture();
if (!subpass_texture) {

View File

@@ -32,31 +32,38 @@ class RenderTarget {
StoreAction store_action;
};
static constexpr AttachmentConfig kDefaultAttachmentConfig = {
static constexpr AttachmentConfig kDefaultColorAttachmentConfig = {
.storage_mode = StorageMode::kDevicePrivate,
.load_action = LoadAction::kClear,
.store_action = StoreAction::kStore};
static constexpr AttachmentConfigMSAA kDefaultAttachmentConfigMSAA = {
static constexpr AttachmentConfigMSAA kDefaultColorAttachmentConfigMSAA = {
.storage_mode = StorageMode::kDeviceTransient,
.resolve_storage_mode = StorageMode::kDevicePrivate,
.load_action = LoadAction::kClear,
.store_action = StoreAction::kMultisampleResolve};
static constexpr AttachmentConfig kDefaultStencilAttachmentConfig = {
.storage_mode = StorageMode::kDeviceTransient,
.load_action = LoadAction::kClear,
.store_action = StoreAction::kDontCare};
static RenderTarget CreateOffscreen(
const Context& context,
ISize size,
const std::string& label = "Offscreen",
AttachmentConfig color_attachment_config = kDefaultAttachmentConfig,
std::optional<AttachmentConfig> stencil_attachment_config = std::nullopt);
AttachmentConfig color_attachment_config = kDefaultColorAttachmentConfig,
std::optional<AttachmentConfig> stencil_attachment_config =
kDefaultStencilAttachmentConfig);
static RenderTarget CreateOffscreenMSAA(
const Context& context,
ISize size,
const std::string& label = "Offscreen MSAA",
AttachmentConfigMSAA color_attachment_config =
kDefaultAttachmentConfigMSAA,
std::optional<AttachmentConfig> stencil_attachment_config = std::nullopt);
kDefaultColorAttachmentConfigMSAA,
std::optional<AttachmentConfig> stencil_attachment_config =
kDefaultStencilAttachmentConfig);
RenderTarget();