[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
This commit is contained in:
Jonah Williams 2023-07-10 18:44:08 -07:00 committed by GitHub
parent dbf987a9f5
commit f64349bfa8

View File

@ -18,12 +18,6 @@ std::unique_ptr<SurfaceVK> 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> SurfaceVK::WrapSwapchainImage(
msaa_tex_desc.usage = static_cast<uint64_t>(TextureUsage::kRenderTarget);
std::shared_ptr<Texture> 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();
}