diff --git a/impeller/entity/contents/content_context.cc b/impeller/entity/contents/content_context.cc index 5284c7f79fb46..3f4684148702d 100644 --- a/impeller/entity/contents/content_context.cc +++ b/impeller/entity/contents/content_context.cc @@ -28,6 +28,7 @@ void ContentContextOptions::ApplyToPipelineDescriptor( desc.SetSampleCount(sample_count); ColorAttachmentDescriptor color0 = *desc.GetColorAttachmentDescriptor(0u); + color0.format = color_attachment_pixel_format; color0.alpha_blend_op = BlendOperation::kAdd; color0.color_blend_op = BlendOperation::kAdd; diff --git a/impeller/entity/contents/content_context.h b/impeller/entity/contents/content_context.h index c534afddc1d9d..3ea17010d459d 100644 --- a/impeller/entity/contents/content_context.h +++ b/impeller/entity/contents/content_context.h @@ -195,12 +195,14 @@ struct ContentContextOptions { CompareFunction stencil_compare = CompareFunction::kEqual; StencilOperation stencil_operation = StencilOperation::kKeep; PrimitiveType primitive_type = PrimitiveType::kTriangle; + PixelFormat color_attachment_pixel_format = PixelFormat::kDefaultColor; bool has_stencil_attachment = true; struct Hash { constexpr std::size_t operator()(const ContentContextOptions& o) const { return fml::HashCombine(o.sample_count, o.blend_mode, o.stencil_compare, o.stencil_operation, o.primitive_type, + o.color_attachment_pixel_format, o.has_stencil_attachment); } }; @@ -213,6 +215,8 @@ struct ContentContextOptions { lhs.stencil_compare == rhs.stencil_compare && lhs.stencil_operation == rhs.stencil_operation && lhs.primitive_type == rhs.primitive_type && + lhs.color_attachment_pixel_format == + rhs.color_attachment_pixel_format && lhs.has_stencil_attachment == rhs.has_stencil_attachment; } }; diff --git a/impeller/entity/contents/contents.cc b/impeller/entity/contents/contents.cc index 0105704a1a450..73469966e158d 100644 --- a/impeller/entity/contents/contents.cc +++ b/impeller/entity/contents/contents.cc @@ -16,6 +16,8 @@ namespace impeller { ContentContextOptions OptionsFromPass(const RenderPass& pass) { ContentContextOptions opts; opts.sample_count = pass.GetRenderTarget().GetSampleCount(); + opts.color_attachment_pixel_format = + pass.GetRenderTarget().GetRenderTargetPixelFormat(); opts.has_stencil_attachment = pass.GetRenderTarget().GetStencilAttachment().has_value(); return opts; @@ -25,6 +27,8 @@ ContentContextOptions OptionsFromPassAndEntity(const RenderPass& pass, const Entity& entity) { ContentContextOptions opts; opts.sample_count = pass.GetRenderTarget().GetSampleCount(); + opts.color_attachment_pixel_format = + pass.GetRenderTarget().GetRenderTargetPixelFormat(); opts.has_stencil_attachment = pass.GetRenderTarget().GetStencilAttachment().has_value(); opts.blend_mode = entity.GetBlendMode(); diff --git a/impeller/renderer/render_target.cc b/impeller/renderer/render_target.cc index c4178d6333c4e..fa87e0cbe36ce 100644 --- a/impeller/renderer/render_target.cc +++ b/impeller/renderer/render_target.cc @@ -140,6 +140,14 @@ std::shared_ptr RenderTarget::GetRenderTargetTexture() const { : found->second.texture; } +PixelFormat RenderTarget::GetRenderTargetPixelFormat() const { + if (auto texture = GetRenderTargetTexture(); texture != nullptr) { + return texture->GetTextureDescriptor().format; + } + + return PixelFormat::kUnknown; +} + RenderTarget& RenderTarget::SetColorAttachment( const ColorAttachment& attachment, size_t index) { diff --git a/impeller/renderer/render_target.h b/impeller/renderer/render_target.h index aac8c508938a4..fef7cf30ae651 100644 --- a/impeller/renderer/render_target.h +++ b/impeller/renderer/render_target.h @@ -72,6 +72,8 @@ class RenderTarget { std::shared_ptr GetRenderTargetTexture() const; + PixelFormat GetRenderTargetPixelFormat() const; + std::optional GetColorAttachmentSize(size_t index) const; RenderTarget& SetColorAttachment(const ColorAttachment& attachment,