diff --git a/engine/src/flutter/impeller/entity/entity_pass.cc b/engine/src/flutter/impeller/entity/entity_pass.cc index c0e5c9ff14..7a55e4399f 100644 --- a/engine/src/flutter/impeller/entity/entity_pass.cc +++ b/engine/src/flutter/impeller/entity/entity_pass.cc @@ -153,13 +153,13 @@ static RenderTarget CreateRenderTarget(ContentContext& renderer, if (context->SupportsOffscreenMSAA()) { return RenderTarget::CreateOffscreenMSAA( - *context, // context - size, // size - "EntityPass", // label - StorageMode::kDeviceTransient, // color_storage_mode - StorageMode::kDevicePrivate, // color_resolve_storage_mode - LoadAction::kDontCare, // color_load_action - StoreAction::kDontCare, // color_store_action + *context, // context + size, // size + "EntityPass", // label + StorageMode::kDeviceTransient, // color_storage_mode + StorageMode::kDevicePrivate, // color_resolve_storage_mode + LoadAction::kDontCare, // color_load_action + StoreAction::kMultisampleResolve, // color_store_action readable ? StorageMode::kDevicePrivate : StorageMode::kDeviceTransient, // stencil_storage_mode LoadAction::kDontCare, // stencil_load_action diff --git a/engine/src/flutter/impeller/renderer/backend/metal/surface_mtl.mm b/engine/src/flutter/impeller/renderer/backend/metal/surface_mtl.mm index 071989f6d1..ee89074c9c 100644 --- a/engine/src/flutter/impeller/renderer/backend/metal/surface_mtl.mm +++ b/engine/src/flutter/impeller/renderer/backend/metal/surface_mtl.mm @@ -67,6 +67,7 @@ std::unique_ptr SurfaceMTL::WrapCurrentMetalLayerDrawable( color0_resolve_tex_desc.size = color0_tex_desc.size; color0_resolve_tex_desc.usage = static_cast(TextureUsage::kRenderTarget); + color0_resolve_tex_desc.storage_mode = StorageMode::kDevicePrivate; ColorAttachment color0; color0.texture = msaa_tex; diff --git a/engine/src/flutter/impeller/renderer/formats.cc b/engine/src/flutter/impeller/renderer/formats.cc index 28d82875a0..7c2c535328 100644 --- a/engine/src/flutter/impeller/renderer/formats.cc +++ b/engine/src/flutter/impeller/renderer/formats.cc @@ -4,6 +4,7 @@ #include "impeller/renderer/formats.h" +#include "impeller/base/strings.h" #include "impeller/base/validation.h" #include "impeller/renderer/texture.h" @@ -26,8 +27,6 @@ bool Attachment::IsValid() const { return false; } -// TODO(110385): Enable attachment validation. -#if 0 if (StoreActionNeedsResolveTexture(store_action)) { if (!resolve_texture || !resolve_texture->IsValid()) { VALIDATION_LOG << "Store action needs resolve but no valid resolve " @@ -36,16 +35,43 @@ bool Attachment::IsValid() const { } } - if (texture->GetTextureDescriptor().storage_mode == - StorageMode::kDeviceTransient) { - if (load_action != LoadAction::kDontCare && - store_action != StoreAction::kDontCare) { + if (resolve_texture) { + if (store_action != StoreAction::kMultisampleResolve && + store_action != StoreAction::kStoreAndMultisampleResolve) { + VALIDATION_LOG << "A resolve texture was specified, but the store action " + "doesn't include multisample resolve."; + return false; + } + + if (texture->GetTextureDescriptor().storage_mode == + StorageMode::kDeviceTransient && + store_action == StoreAction::kStoreAndMultisampleResolve) { VALIDATION_LOG - << "Load or store actions specified on device transient textures."; + << "The multisample texture cannot be transient when " + "specifying the StoreAndMultisampleResolve StoreAction."; + } + } + + auto storage_mode = resolve_texture + ? resolve_texture->GetTextureDescriptor().storage_mode + : texture->GetTextureDescriptor().storage_mode; + + if (storage_mode == StorageMode::kDeviceTransient) { + if (load_action == LoadAction::kLoad) { + VALIDATION_LOG << "The LoadAction cannot be Load when attaching a device " + "transient " + + std::string(resolve_texture ? "resolve texture." + : "texture."); + return false; + } + if (store_action != StoreAction::kDontCare) { + VALIDATION_LOG << "The StoreAction must be DontCare when attaching a " + "device transient " + + std::string(resolve_texture ? "resolve texture." + : "texture."); return false; } } -#endif return true; }