From e2094f6128ed745bf1e04518279e634e9999d84a Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Mon, 27 Feb 2023 15:16:00 -0800 Subject: [PATCH] [Impeller] Add texture->texture blits to device capabilities (flutter/engine#39924) --- .../renderer/backend/gles/context_gles.cc | 2 + .../renderer/backend/metal/context_mtl.mm | 1 + .../renderer/backend/vulkan/context_vk.cc | 1 + .../impeller/renderer/device_capabilities.cc | 39 +++++++++++++------ .../impeller/renderer/device_capabilities.h | 19 ++++++--- 5 files changed, 45 insertions(+), 17 deletions(-) diff --git a/engine/src/flutter/impeller/renderer/backend/gles/context_gles.cc b/engine/src/flutter/impeller/renderer/backend/gles/context_gles.cc index a592823e2d8..99922ba7efa 100644 --- a/engine/src/flutter/impeller/renderer/backend/gles/context_gles.cc +++ b/engine/src/flutter/impeller/renderer/backend/gles/context_gles.cc @@ -76,6 +76,8 @@ ContextGLES::ContextGLES(std::unique_ptr gl, .SetHasThreadingRestrictions(true) .SetSupportsOffscreenMSAA(false) .SetSupportsSSBO(false) + .SetSupportsTextureToTextureBlits( + reactor_->GetProcTable().BlitFramebuffer.IsAvailable()) .SetDefaultColorFormat(PixelFormat::kB8G8R8A8UNormInt) .SetDefaultStencilFormat(PixelFormat::kS8UInt) .Build(); diff --git a/engine/src/flutter/impeller/renderer/backend/metal/context_mtl.mm b/engine/src/flutter/impeller/renderer/backend/metal/context_mtl.mm index 5ccf5431693..a601f099fd0 100644 --- a/engine/src/flutter/impeller/renderer/backend/metal/context_mtl.mm +++ b/engine/src/flutter/impeller/renderer/backend/metal/context_mtl.mm @@ -95,6 +95,7 @@ ContextMTL::ContextMTL(id device, .SetHasThreadingRestrictions(false) .SetSupportsOffscreenMSAA(true) .SetSupportsSSBO(true) + .SetSupportsTextureToTextureBlits(true) .SetDefaultColorFormat(PixelFormat::kB8G8R8A8UNormInt) .SetDefaultStencilFormat(PixelFormat::kS8UInt) .Build(); diff --git a/engine/src/flutter/impeller/renderer/backend/vulkan/context_vk.cc b/engine/src/flutter/impeller/renderer/backend/vulkan/context_vk.cc index c8aa9386105..2330f9a78f6 100644 --- a/engine/src/flutter/impeller/renderer/backend/vulkan/context_vk.cc +++ b/engine/src/flutter/impeller/renderer/backend/vulkan/context_vk.cc @@ -504,6 +504,7 @@ ContextVK::ContextVK( .SetHasThreadingRestrictions(false) .SetSupportsOffscreenMSAA(true) .SetSupportsSSBO(false) + .SetSupportsTextureToTextureBlits(true) .SetDefaultColorFormat(PixelFormat::kB8G8R8A8UNormInt) .SetDefaultStencilFormat(PixelFormat::kS8UInt) .Build(); diff --git a/engine/src/flutter/impeller/renderer/device_capabilities.cc b/engine/src/flutter/impeller/renderer/device_capabilities.cc index bddb854e95a..87653bb63be 100644 --- a/engine/src/flutter/impeller/renderer/device_capabilities.cc +++ b/engine/src/flutter/impeller/renderer/device_capabilities.cc @@ -6,31 +6,37 @@ namespace impeller { -IDeviceCapabilities::IDeviceCapabilities(bool threading_restrictions, - bool offscreen_msaa, +IDeviceCapabilities::IDeviceCapabilities(bool has_threading_restrictions, + bool supports_offscreen_msaa, bool supports_ssbo, + bool supports_texture_to_texture_blits, PixelFormat default_color_format, PixelFormat default_stencil_format) - : threading_restrictions_(threading_restrictions), - offscreen_msaa_(offscreen_msaa), + : has_threading_restrictions_(has_threading_restrictions), + supports_offscreen_msaa_(supports_offscreen_msaa), supports_ssbo_(supports_ssbo), + supports_texture_to_texture_blits_(supports_texture_to_texture_blits), default_color_format_(default_color_format), default_stencil_format_(default_stencil_format) {} IDeviceCapabilities::~IDeviceCapabilities() = default; bool IDeviceCapabilities::HasThreadingRestrictions() const { - return threading_restrictions_; + return has_threading_restrictions_; } bool IDeviceCapabilities::SupportsOffscreenMSAA() const { - return offscreen_msaa_; + return supports_offscreen_msaa_; } bool IDeviceCapabilities::SupportsSSBO() const { return supports_ssbo_; } +bool IDeviceCapabilities::SupportsTextureToTextureBlits() const { + return supports_texture_to_texture_blits_; +} + PixelFormat IDeviceCapabilities::GetDefaultColorFormat() const { return default_color_format_; } @@ -45,13 +51,13 @@ DeviceCapabilitiesBuilder::~DeviceCapabilitiesBuilder() = default; DeviceCapabilitiesBuilder& DeviceCapabilitiesBuilder::SetHasThreadingRestrictions(bool value) { - threading_restrictions_ = value; + has_threading_restrictions_ = value; return *this; } DeviceCapabilitiesBuilder& DeviceCapabilitiesBuilder::SetSupportsOffscreenMSAA( bool value) { - offscreen_msaa_ = value; + supports_offscreen_msaa_ = value; return *this; } @@ -61,6 +67,12 @@ DeviceCapabilitiesBuilder& DeviceCapabilitiesBuilder::SetSupportsSSBO( return *this; } +DeviceCapabilitiesBuilder& +DeviceCapabilitiesBuilder::SetSupportsTextureToTextureBlits(bool value) { + supports_texture_to_texture_blits_ = value; + return *this; +} + DeviceCapabilitiesBuilder& DeviceCapabilitiesBuilder::SetDefaultColorFormat( PixelFormat value) { default_color_format_ = value; @@ -79,9 +91,14 @@ std::unique_ptr DeviceCapabilitiesBuilder::Build() { FML_CHECK(default_stencil_format_.has_value()) << "Default stencil format not set"; - IDeviceCapabilities* capabilities = new IDeviceCapabilities( - threading_restrictions_, offscreen_msaa_, supports_ssbo_, - *default_color_format_, *default_stencil_format_); + IDeviceCapabilities* capabilities = new IDeviceCapabilities( // + has_threading_restrictions_, // + supports_offscreen_msaa_, // + supports_ssbo_, // + supports_texture_to_texture_blits_, // + *default_color_format_, // + *default_stencil_format_ // + ); return std::unique_ptr(capabilities); } diff --git a/engine/src/flutter/impeller/renderer/device_capabilities.h b/engine/src/flutter/impeller/renderer/device_capabilities.h index 3224e51939b..010281da37a 100644 --- a/engine/src/flutter/impeller/renderer/device_capabilities.h +++ b/engine/src/flutter/impeller/renderer/device_capabilities.h @@ -21,22 +21,26 @@ class IDeviceCapabilities { bool SupportsSSBO() const; + bool SupportsTextureToTextureBlits() const; + PixelFormat GetDefaultColorFormat() const; PixelFormat GetDefaultStencilFormat() const; private: - IDeviceCapabilities(bool threading_restrictions, - bool offscreen_msaa, + IDeviceCapabilities(bool has_threading_restrictions, + bool supports_offscreen_msaa, bool supports_ssbo, + bool supports_texture_to_texture_blits, PixelFormat default_color_format, PixelFormat default_stencil_format); friend class DeviceCapabilitiesBuilder; - bool threading_restrictions_ = false; - bool offscreen_msaa_ = false; + bool has_threading_restrictions_ = false; + bool supports_offscreen_msaa_ = false; bool supports_ssbo_ = false; + bool supports_texture_to_texture_blits_ = false; PixelFormat default_color_format_; PixelFormat default_stencil_format_; @@ -55,6 +59,8 @@ class DeviceCapabilitiesBuilder { DeviceCapabilitiesBuilder& SetSupportsSSBO(bool value); + DeviceCapabilitiesBuilder& SetSupportsTextureToTextureBlits(bool value); + DeviceCapabilitiesBuilder& SetDefaultColorFormat(PixelFormat value); DeviceCapabilitiesBuilder& SetDefaultStencilFormat(PixelFormat value); @@ -62,9 +68,10 @@ class DeviceCapabilitiesBuilder { std::unique_ptr Build(); private: - bool threading_restrictions_ = false; - bool offscreen_msaa_ = false; + bool has_threading_restrictions_ = false; + bool supports_offscreen_msaa_ = false; bool supports_ssbo_ = false; + bool supports_texture_to_texture_blits_ = false; std::optional default_color_format_ = std::nullopt; std::optional default_stencil_format_ = std::nullopt;