Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 10f83dc

Browse files
committed
[Impeller] Source the pipeline color attachment pixel format from RenderPass textures
1 parent 3ac3338 commit 10f83dc

5 files changed

Lines changed: 20 additions & 0 deletions

File tree

‎impeller/entity/contents/content_context.cc‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ void ContentContextOptions::ApplyToPipelineDescriptor(
2828
desc.SetSampleCount(sample_count);
2929

3030
ColorAttachmentDescriptor color0 = *desc.GetColorAttachmentDescriptor(0u);
31+
color0.format = color_attachment_pixel_format;
3132
color0.alpha_blend_op = BlendOperation::kAdd;
3233
color0.color_blend_op = BlendOperation::kAdd;
3334

‎impeller/entity/contents/content_context.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,15 @@ struct ContentContextOptions {
195195
CompareFunction stencil_compare = CompareFunction::kEqual;
196196
StencilOperation stencil_operation = StencilOperation::kKeep;
197197
PrimitiveType primitive_type = PrimitiveType::kTriangle;
198+
199+
PixelFormat color_attachment_pixel_format = PixelFormat::kDefaultColor;
198200
bool has_stencil_attachment = true;
199201

200202
struct Hash {
201203
constexpr std::size_t operator()(const ContentContextOptions& o) const {
202204
return fml::HashCombine(o.sample_count, o.blend_mode, o.stencil_compare,
203205
o.stencil_operation, o.primitive_type,
206+
o.color_attachment_pixel_format,
204207
o.has_stencil_attachment);
205208
}
206209
};
@@ -213,6 +216,8 @@ struct ContentContextOptions {
213216
lhs.stencil_compare == rhs.stencil_compare &&
214217
lhs.stencil_operation == rhs.stencil_operation &&
215218
lhs.primitive_type == rhs.primitive_type &&
219+
lhs.color_attachment_pixel_format ==
220+
rhs.color_attachment_pixel_format &&
216221
lhs.has_stencil_attachment == rhs.has_stencil_attachment;
217222
}
218223
};

‎impeller/entity/contents/contents.cc‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ namespace impeller {
1616
ContentContextOptions OptionsFromPass(const RenderPass& pass) {
1717
ContentContextOptions opts;
1818
opts.sample_count = pass.GetRenderTarget().GetSampleCount();
19+
opts.color_attachment_pixel_format =
20+
pass.GetRenderTarget().GetRenderTargetPixelFormat();
1921
opts.has_stencil_attachment =
2022
pass.GetRenderTarget().GetStencilAttachment().has_value();
2123
return opts;
@@ -25,6 +27,8 @@ ContentContextOptions OptionsFromPassAndEntity(const RenderPass& pass,
2527
const Entity& entity) {
2628
ContentContextOptions opts;
2729
opts.sample_count = pass.GetRenderTarget().GetSampleCount();
30+
opts.color_attachment_pixel_format =
31+
pass.GetRenderTarget().GetRenderTargetPixelFormat();
2832
opts.has_stencil_attachment =
2933
pass.GetRenderTarget().GetStencilAttachment().has_value();
3034
opts.blend_mode = entity.GetBlendMode();

‎impeller/renderer/render_target.cc‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,14 @@ std::shared_ptr<Texture> RenderTarget::GetRenderTargetTexture() const {
140140
: found->second.texture;
141141
}
142142

143+
PixelFormat RenderTarget::GetRenderTargetPixelFormat() const {
144+
if (auto texture = GetRenderTargetTexture(); texture != nullptr) {
145+
return texture->GetTextureDescriptor().format;
146+
}
147+
148+
return PixelFormat::kUnknown;
149+
}
150+
143151
RenderTarget& RenderTarget::SetColorAttachment(
144152
const ColorAttachment& attachment,
145153
size_t index) {

‎impeller/renderer/render_target.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ class RenderTarget {
7272

7373
std::shared_ptr<Texture> GetRenderTargetTexture() const;
7474

75+
PixelFormat GetRenderTargetPixelFormat() const;
76+
7577
std::optional<ISize> GetColorAttachmentSize(size_t index) const;
7678

7779
RenderTarget& SetColorAttachment(const ColorAttachment& attachment,

0 commit comments

Comments
 (0)