diff --git a/impeller/renderer/backend/gles/texture_gles.cc b/impeller/renderer/backend/gles/texture_gles.cc index 14933adbdbc5f..e315ba6239bc9 100644 --- a/impeller/renderer/backend/gles/texture_gles.cc +++ b/impeller/renderer/backend/gles/texture_gles.cc @@ -124,6 +124,7 @@ struct TexImage2DData { case PixelFormat::kR8G8UNormInt: case PixelFormat::kB10G10R10XRSRGB: case PixelFormat::kB10G10R10XR: + case PixelFormat::kB10G10R10A10XR: return; } is_valid_ = true; @@ -171,6 +172,7 @@ struct TexImage2DData { case PixelFormat::kR8G8UNormInt: case PixelFormat::kB10G10R10XRSRGB: case PixelFormat::kB10G10R10XR: + case PixelFormat::kB10G10R10A10XR: return; } is_valid_ = true; @@ -318,6 +320,7 @@ static std::optional ToRenderBufferFormat(PixelFormat format) { case PixelFormat::kB8G8R8A8UNormIntSRGB: case PixelFormat::kB10G10R10XRSRGB: case PixelFormat::kB10G10R10XR: + case PixelFormat::kB10G10R10A10XR: return std::nullopt; } FML_UNREACHABLE(); diff --git a/impeller/renderer/backend/metal/formats_mtl.h b/impeller/renderer/backend/metal/formats_mtl.h index f03c3aeb9b006..fc323fc212e0b 100644 --- a/impeller/renderer/backend/metal/formats_mtl.h +++ b/impeller/renderer/backend/metal/formats_mtl.h @@ -41,6 +41,8 @@ constexpr PixelFormat FromMTLPixelFormat(MTLPixelFormat format) { return PixelFormat::kB10G10R10XRSRGB; case MTLPixelFormatBGR10_XR: return PixelFormat::kB10G10R10XR; + case MTLPixelFormatBGRA10_XR: + return PixelFormat::kB10G10R10A10XR; default: return PixelFormat::kUnknown; } @@ -56,6 +58,10 @@ MTLPixelFormat SafeMTLPixelFormatBGR10_XR_sRGB(); /// Returns PixelFormat::kUnknown if MTLPixelFormatBGR10_XR isn't supported. MTLPixelFormat SafeMTLPixelFormatBGR10_XR(); +/// Safe accessor for MTLPixelFormatBGRA10_XR. +/// Returns PixelFormat::kUnknown if MTLPixelFormatBGR10_XR isn't supported. +MTLPixelFormat SafeMTLPixelFormatBGRA10_XR(); + constexpr MTLPixelFormat ToMTLPixelFormat(PixelFormat format) { switch (format) { case PixelFormat::kUnknown: @@ -86,6 +92,8 @@ constexpr MTLPixelFormat ToMTLPixelFormat(PixelFormat format) { return SafeMTLPixelFormatBGR10_XR_sRGB(); case PixelFormat::kB10G10R10XR: return SafeMTLPixelFormatBGR10_XR(); + case PixelFormat::kB10G10R10A10XR: + return SafeMTLPixelFormatBGRA10_XR(); } return MTLPixelFormatInvalid; }; diff --git a/impeller/renderer/backend/metal/formats_mtl.mm b/impeller/renderer/backend/metal/formats_mtl.mm index 48d86a279ca90..aece8944aa72d 100644 --- a/impeller/renderer/backend/metal/formats_mtl.mm +++ b/impeller/renderer/backend/metal/formats_mtl.mm @@ -120,4 +120,12 @@ MTLPixelFormat SafeMTLPixelFormatBGR10_XR() { } } +MTLPixelFormat SafeMTLPixelFormatBGRA10_XR() { + if (@available(iOS 10, macOS 11.0, *)) { + return MTLPixelFormatBGRA10_XR; + } else { + return MTLPixelFormatInvalid; + } +} + } // namespace impeller diff --git a/impeller/renderer/backend/vulkan/formats_vk.h b/impeller/renderer/backend/vulkan/formats_vk.h index a9074f661ee1b..3cd5447910dc6 100644 --- a/impeller/renderer/backend/vulkan/formats_vk.h +++ b/impeller/renderer/backend/vulkan/formats_vk.h @@ -138,6 +138,7 @@ constexpr vk::Format ToVKImageFormat(PixelFormat format) { switch (format) { case PixelFormat::kUnknown: case PixelFormat::kB10G10R10XR: + case PixelFormat::kB10G10R10A10XR: case PixelFormat::kB10G10R10XRSRGB: return vk::Format::eUndefined; case PixelFormat::kA8UNormInt: diff --git a/impeller/renderer/formats.h b/impeller/renderer/formats.h index 065d38a9fa900..51a25ac31faf1 100644 --- a/impeller/renderer/formats.h +++ b/impeller/renderer/formats.h @@ -91,6 +91,7 @@ enum class PixelFormat { kR16G16B16A16Float, kB10G10R10XR, kB10G10R10XRSRGB, + kB10G10R10A10XR, // Depth and stencil formats. kS8UInt, kD32FloatS8UInt, @@ -296,6 +297,7 @@ constexpr size_t BytesPerPixelForPixelFormat(PixelFormat format) { case PixelFormat::kD32FloatS8UInt: return 5u; case PixelFormat::kR16G16B16A16Float: + case PixelFormat::kB10G10R10A10XR: return 8u; case PixelFormat::kR32G32B32A32Float: return 16u; diff --git a/impeller/renderer/render_target.cc b/impeller/renderer/render_target.cc index fa87e0cbe36ce..aeca24ab68793 100644 --- a/impeller/renderer/render_target.cc +++ b/impeller/renderer/render_target.cc @@ -202,10 +202,10 @@ RenderTarget RenderTarget::CreateOffscreen( } RenderTarget target; - + PixelFormat pixel_format = context.GetColorAttachmentPixelFormat(); TextureDescriptor color_tex0; color_tex0.storage_mode = color_attachment_config.storage_mode; - color_tex0.format = context.GetColorAttachmentPixelFormat(); + color_tex0.format = pixel_format; color_tex0.size = size; color_tex0.usage = static_cast(TextureUsage::kRenderTarget) | static_cast(TextureUsage::kShaderRead); @@ -260,6 +260,7 @@ RenderTarget RenderTarget::CreateOffscreenMSAA( } RenderTarget target; + PixelFormat pixel_format = context.GetColorAttachmentPixelFormat(); // Create MSAA color texture. @@ -267,7 +268,7 @@ RenderTarget RenderTarget::CreateOffscreenMSAA( color0_tex_desc.storage_mode = color_attachment_config.storage_mode; color0_tex_desc.type = TextureType::kTexture2DMultisample; color0_tex_desc.sample_count = SampleCount::kCount4; - color0_tex_desc.format = context.GetColorAttachmentPixelFormat(); + color0_tex_desc.format = pixel_format; color0_tex_desc.size = size; color0_tex_desc.usage = static_cast(TextureUsage::kRenderTarget); @@ -285,7 +286,7 @@ RenderTarget RenderTarget::CreateOffscreenMSAA( TextureDescriptor color0_resolve_tex_desc; color0_resolve_tex_desc.storage_mode = color_attachment_config.resolve_storage_mode; - color0_resolve_tex_desc.format = context.GetColorAttachmentPixelFormat(); + color0_resolve_tex_desc.format = pixel_format; color0_resolve_tex_desc.size = size; color0_resolve_tex_desc.usage = static_cast(TextureUsage::kRenderTarget) | diff --git a/shell/platform/darwin/ios/framework/Source/FlutterView.mm b/shell/platform/darwin/ios/framework/Source/FlutterView.mm index d0377d0033ff3..f365e87ff800c 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterView.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterView.mm @@ -87,7 +87,9 @@ - (void)layoutSubviews { layer.colorspace = srgb; CFRelease(srgb); if (self.opaque) { - layer.pixelFormat = MTLPixelFormatBGR10_XR; + // TODO(https://github.com/flutter/flutter/issues/120641): Switch to + // MTLPixelFormatBGR10_XR to save memory. + layer.pixelFormat = MTLPixelFormatBGRA10_XR; } else { layer.pixelFormat = MTLPixelFormatBGRA10_XR; }