mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[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:  https://github.com/flutter/flutter/issues/129392
This commit is contained in:
parent
dbf987a9f5
commit
f64349bfa8
@ -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();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user