From f64349bfa84e308055cfb0e4e551ac5b2aef28f3 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Mon, 10 Jul 2023 18:44:08 -0700 Subject: [PATCH] [Impeller] Unconditionally cache swapchain msaa texture. (flutter/engine#43529) Even on the Pixel 6 pro device which supports memoryless textures, I can observe creating the memoryless texture sometimes takes a few hundred microseconds, possibly due to stalls in the driver allocating the texture metadata. Lets just unconditionally cache this texture to avoid making the driver do more work. Here is an example of this happening: ![image](https://github.com/flutter/engine/assets/8975114/a2d0fed7-7a25-4652-9932-2464b272d80c) https://github.com/flutter/flutter/issues/129392 --- .../impeller/renderer/backend/vulkan/surface_vk.cc | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/engine/src/flutter/impeller/renderer/backend/vulkan/surface_vk.cc b/engine/src/flutter/impeller/renderer/backend/vulkan/surface_vk.cc index ab1100664d4..95846affdc1 100644 --- a/engine/src/flutter/impeller/renderer/backend/vulkan/surface_vk.cc +++ b/engine/src/flutter/impeller/renderer/backend/vulkan/surface_vk.cc @@ -18,12 +18,6 @@ std::unique_ptr SurfaceVK::WrapSwapchainImage( return nullptr; } - // Some Vulkan devices may not support memoryless (lazily allocated) textures. - // In this case we will cache the MSAA texture on the swapchain image to avoid - // thrasing the VMA heap. - bool supports_memoryless = - context->GetCapabilities()->SupportsMemorylessTextures(); - TextureDescriptor msaa_tex_desc; msaa_tex_desc.storage_mode = StorageMode::kDeviceTransient; msaa_tex_desc.type = TextureType::kTexture2DMultisample; @@ -33,16 +27,14 @@ std::unique_ptr SurfaceVK::WrapSwapchainImage( msaa_tex_desc.usage = static_cast(TextureUsage::kRenderTarget); std::shared_ptr msaa_tex; - if (supports_memoryless || !swapchain_image->HasMSAATexture()) { + if (!swapchain_image->HasMSAATexture()) { msaa_tex = context->GetResourceAllocator()->CreateTexture(msaa_tex_desc); msaa_tex->SetLabel("ImpellerOnscreenColorMSAA"); if (!msaa_tex) { VALIDATION_LOG << "Could not allocate MSAA color texture."; return nullptr; } - if (!supports_memoryless) { - swapchain_image->SetMSAATexture(msaa_tex); - } + swapchain_image->SetMSAATexture(msaa_tex); } else { msaa_tex = swapchain_image->GetMSAATexture(); }