diff --git a/engine/src/flutter/impeller/playground/backend/metal/playground_impl_mtl.mm b/engine/src/flutter/impeller/playground/backend/metal/playground_impl_mtl.mm index 3ba5f7c167a..1a66beac6c0 100644 --- a/engine/src/flutter/impeller/playground/backend/metal/playground_impl_mtl.mm +++ b/engine/src/flutter/impeller/playground/backend/metal/playground_impl_mtl.mm @@ -70,6 +70,7 @@ PlaygroundImplMTL::PlaygroundImplMTL() data_->metal_layer.device = ContextMTL::Cast(*context).GetMTLDevice(); // This pixel format is one of the documented supported formats. data_->metal_layer.pixelFormat = ToMTLPixelFormat(PixelFormat::kDefaultColor); + data_->metal_layer.framebufferOnly = NO; cocoa_window.contentView.layer = data_->metal_layer; cocoa_window.contentView.wantsLayer = YES; diff --git a/engine/src/flutter/impeller/playground/imgui/imgui_impl_impeller.cc b/engine/src/flutter/impeller/playground/imgui/imgui_impl_impeller.cc index d5a0a985151..70168bfe065 100644 --- a/engine/src/flutter/impeller/playground/imgui/imgui_impl_impeller.cc +++ b/engine/src/flutter/impeller/playground/imgui/imgui_impl_impeller.cc @@ -93,7 +93,6 @@ bool ImGui_ImplImpeller_Init(std::shared_ptr context) { auto desc = impeller::PipelineBuilder:: MakeDefaultPipelineDescriptor(*context); - desc->SetSampleCount(impeller::SampleCount::kCount4); auto stencil = desc->GetFrontStencilAttachmentDescriptor(); if (stencil.has_value()) { stencil->stencil_compare = impeller::CompareFunction::kAlways; diff --git a/engine/src/flutter/impeller/playground/playground.cc b/engine/src/flutter/impeller/playground/playground.cc index 3d0c02d5d34..dcf9036c1e9 100644 --- a/engine/src/flutter/impeller/playground/playground.cc +++ b/engine/src/flutter/impeller/playground/playground.cc @@ -242,9 +242,44 @@ bool Playground::OpenPlaygroundHere(Renderer::RenderCallback render_callback) { if (render_target.GetColorAttachments().empty()) { return false; } + auto color0 = render_target.GetColorAttachments().find(0)->second; color0.load_action = LoadAction::kLoad; + if (color0.resolve_texture) { + color0.texture = color0.resolve_texture; + color0.resolve_texture = nullptr; + color0.store_action = StoreAction::kStore; + } render_target.SetColorAttachment(color0, 0); + + { + TextureDescriptor stencil0_tex; + stencil0_tex.storage_mode = StorageMode::kDeviceTransient; + stencil0_tex.type = TextureType::kTexture2D; + stencil0_tex.sample_count = SampleCount::kCount1; + stencil0_tex.format = PixelFormat::kDefaultStencil; + stencil0_tex.size = color0.texture->GetSize(); + stencil0_tex.usage = + static_cast(TextureUsage::kRenderTarget); + auto stencil_texture = + renderer->GetContext()->GetResourceAllocator()->CreateTexture( + stencil0_tex); + + if (!stencil_texture) { + VALIDATION_LOG << "Could not create stencil texture."; + return false; + } + stencil_texture->SetLabel("ImguiStencil"); + + StencilAttachment stencil0; + stencil0.texture = stencil_texture; + stencil0.clear_stencil = 0; + stencil0.load_action = LoadAction::kClear; + stencil0.store_action = StoreAction::kDontCare; + + render_target.SetStencilAttachment(stencil0); + } + auto pass = buffer->CreateRenderPass(render_target); if (!pass) { return false;