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

Commit 9df2d3a

Browse files
Reverts "[Impeller] adds a plus advanced blend for f16 pixel formats (#51589)" (#51741)
Reverts: #51589 Initiated by: jonahwilliams Reason for reverting: draw vertices devicelab test is crashing due to SIGABRT in blend contents ![image](https://github.com/flutter/engine/assets/8975114/8bfaec63-29e9-43c2-8954-181d0ad1c413) Original PR Author: gaaclarke Reviewed By: {jonahwilliams} This change reverts the following previous change: fixes flutter/flutter#142549 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
1 parent cd4b8cc commit 9df2d3a

30 files changed

Lines changed: 179 additions & 364 deletions

display_list/testing/dl_test_surface_metal.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ sk_sp<DlImage> DlMetalSurfaceProvider::MakeImpellerImage(
115115

116116
void DlMetalSurfaceProvider::InitScreenShotter() const {
117117
if (!snapshotter_) {
118-
snapshotter_.reset(new MetalScreenshotter(/*enable_wide_gamut=*/false));
118+
snapshotter_.reset(new MetalScreenshotter());
119119
auto typographer = impeller::TypographerContextSkia::Make();
120120
aiks_context_.reset(new impeller::AiksContext(
121121
snapshotter_->GetPlayground().GetContext(), typographer));

impeller/aiks/aiks_unittests.cc

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,76 +1102,6 @@ TEST_P(AiksTest, PaintBlendModeIsRespected) {
11021102
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
11031103
}
11041104

1105-
// This makes sure the WideGamut named tests use 16bit float pixel format.
1106-
TEST_P(AiksTest, F16WideGamut) {
1107-
if (GetParam() != PlaygroundBackend::kMetal) {
1108-
GTEST_SKIP_("This backend doesn't yet support wide gamut.");
1109-
}
1110-
EXPECT_EQ(GetContext()->GetCapabilities()->GetDefaultColorFormat(),
1111-
PixelFormat::kR16G16B16A16Float);
1112-
EXPECT_FALSE(IsAlphaClampedToOne(
1113-
GetContext()->GetCapabilities()->GetDefaultColorFormat()));
1114-
}
1115-
1116-
TEST_P(AiksTest, NotF16) {
1117-
EXPECT_TRUE(IsAlphaClampedToOne(
1118-
GetContext()->GetCapabilities()->GetDefaultColorFormat()));
1119-
}
1120-
1121-
// Bug: https://github.com/flutter/flutter/issues/142549
1122-
TEST_P(AiksTest, BlendModePlusAlphaWideGamut) {
1123-
if (GetParam() != PlaygroundBackend::kMetal) {
1124-
GTEST_SKIP_("This backend doesn't yet support wide gamut.");
1125-
}
1126-
EXPECT_EQ(GetContext()->GetCapabilities()->GetDefaultColorFormat(),
1127-
PixelFormat::kR16G16B16A16Float);
1128-
auto texture = CreateTextureForFixture("airplane.jpg",
1129-
/*enable_mipmapping=*/true);
1130-
1131-
Canvas canvas;
1132-
canvas.Scale(GetContentScale());
1133-
canvas.DrawPaint({.color = Color(0.9, 1.0, 0.9, 1.0)});
1134-
canvas.SaveLayer({});
1135-
Paint paint;
1136-
paint.blend_mode = BlendMode::kPlus;
1137-
paint.color = Color::Red();
1138-
canvas.DrawRect(Rect::MakeXYWH(100, 100, 400, 400), paint);
1139-
paint.color = Color::White();
1140-
canvas.DrawImageRect(
1141-
std::make_shared<Image>(texture), Rect::MakeSize(texture->GetSize()),
1142-
Rect::MakeXYWH(100, 100, 400, 400).Expand(-100, -100), paint);
1143-
canvas.Restore();
1144-
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
1145-
}
1146-
1147-
// Bug: https://github.com/flutter/flutter/issues/142549
1148-
TEST_P(AiksTest, BlendModePlusAlphaColorFilterWideGamut) {
1149-
if (GetParam() != PlaygroundBackend::kMetal) {
1150-
GTEST_SKIP_("This backend doesn't yet support wide gamut.");
1151-
}
1152-
EXPECT_EQ(GetContext()->GetCapabilities()->GetDefaultColorFormat(),
1153-
PixelFormat::kR16G16B16A16Float);
1154-
auto texture = CreateTextureForFixture("airplane.jpg",
1155-
/*enable_mipmapping=*/true);
1156-
1157-
Canvas canvas;
1158-
canvas.Scale(GetContentScale());
1159-
canvas.DrawPaint({.color = Color(0.1, 0.2, 0.1, 1.0)});
1160-
canvas.SaveLayer({
1161-
.color_filter =
1162-
ColorFilter::MakeBlend(BlendMode::kPlus, Color(Vector4{1, 0, 0, 1})),
1163-
});
1164-
Paint paint;
1165-
paint.color = Color::Red();
1166-
canvas.DrawRect(Rect::MakeXYWH(100, 100, 400, 400), paint);
1167-
paint.color = Color::White();
1168-
canvas.DrawImageRect(
1169-
std::make_shared<Image>(texture), Rect::MakeSize(texture->GetSize()),
1170-
Rect::MakeXYWH(100, 100, 400, 400).Expand(-100, -100), paint);
1171-
canvas.Restore();
1172-
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
1173-
}
1174-
11751105
TEST_P(AiksTest, ColorWheel) {
11761106
// Compare with https://fiddle.skia.org/c/@BlendModes
11771107

impeller/compiler/shader_lib/impeller/color.glsl

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,4 @@ f16vec4 IPHalfPremultiply(f16vec4 color) {
4646
return f16vec4(color.rgb * color.a, color.a);
4747
}
4848

49-
/// Performs the plus blend on `src` and `dst` which are premultiplied colors.
50-
//`max` determines the values the results are clamped to.
51-
f16vec4 IPHalfPlusBlend(f16vec4 src, f16vec4 dst) {
52-
float16_t min = 0.0hf;
53-
float16_t max = 1.0hf;
54-
return clamp(dst + src, min, max);
55-
}
56-
5749
#endif

impeller/core/formats.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,6 @@ constexpr bool IsStencilWritable(PixelFormat format) {
138138
}
139139
}
140140

141-
/// Returns `true` if the pixel format has an implicit `clamp(x, 0, 1)` in the
142-
/// pixel format. This is important for example when performing the `Plus` blend
143-
/// where we don't want alpha values over 1.0.
144-
constexpr bool IsAlphaClampedToOne(PixelFormat pixel_format) {
145-
return !(pixel_format == PixelFormat::kR32G32B32A32Float ||
146-
pixel_format == PixelFormat::kR16G16B16A16Float);
147-
}
148-
149141
constexpr const char* PixelFormatToString(PixelFormat format) {
150142
switch (format) {
151143
case PixelFormat::kUnknown:

impeller/entity/contents/content_context.cc

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ void ContentContextOptions::ApplyToPipelineDescriptor(
124124
color0.src_color_blend_factor = BlendFactor::kOneMinusDestinationAlpha;
125125
break;
126126
case BlendMode::kPlus:
127-
// The kPlusAdvanced should be used instead.
128-
FML_DCHECK(IsAlphaClampedToOne(color_attachment_pixel_format));
129127
color0.dst_alpha_blend_factor = BlendFactor::kOne;
130128
color0.dst_color_blend_factor = BlendFactor::kOne;
131129
color0.src_alpha_blend_factor = BlendFactor::kOne;
@@ -326,10 +324,6 @@ ContentContext::ContentContext(
326324
framebuffer_blend_lighten_pipelines_.CreateDefault(
327325
*context_, options_trianglestrip,
328326
{static_cast<Scalar>(BlendSelectValues::kLighten), supports_decal});
329-
framebuffer_blend_plus_advanced_pipelines_.CreateDefault(
330-
*context_, options_trianglestrip,
331-
{static_cast<Scalar>(BlendSelectValues::kPlusAdvanced),
332-
supports_decal});
333327
framebuffer_blend_luminosity_pipelines_.CreateDefault(
334328
*context_, options_trianglestrip,
335329
{static_cast<Scalar>(BlendSelectValues::kLuminosity), supports_decal});
@@ -377,9 +371,6 @@ ContentContext::ContentContext(
377371
blend_lighten_pipelines_.CreateDefault(
378372
*context_, options_trianglestrip,
379373
{static_cast<Scalar>(BlendSelectValues::kLighten), supports_decal});
380-
blend_plus_advanced_pipelines_.CreateDefault(
381-
*context_, options_trianglestrip,
382-
{static_cast<Scalar>(BlendSelectValues::kPlusAdvanced), supports_decal});
383374
blend_luminosity_pipelines_.CreateDefault(
384375
*context_, options_trianglestrip,
385376
{static_cast<Scalar>(BlendSelectValues::kLuminosity), supports_decal});

impeller/entity/contents/content_context.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,6 @@ using BlendHuePipeline =
197197
RenderPipelineT<AdvancedBlendVertexShader, AdvancedBlendFragmentShader>;
198198
using BlendLightenPipeline =
199199
RenderPipelineT<AdvancedBlendVertexShader, AdvancedBlendFragmentShader>;
200-
using BlendPlusAdvancedPipeline =
201-
RenderPipelineT<AdvancedBlendVertexShader, AdvancedBlendFragmentShader>;
202200
using BlendLuminosityPipeline =
203201
RenderPipelineT<AdvancedBlendVertexShader, AdvancedBlendFragmentShader>;
204202
using BlendMultiplyPipeline =
@@ -239,9 +237,6 @@ using FramebufferBlendHuePipeline =
239237
using FramebufferBlendLightenPipeline =
240238
RenderPipelineT<FramebufferBlendVertexShader,
241239
FramebufferBlendFragmentShader>;
242-
using FramebufferBlendPlusAdvancedPipeline =
243-
RenderPipelineT<FramebufferBlendVertexShader,
244-
FramebufferBlendFragmentShader>;
245240
using FramebufferBlendLuminosityPipeline =
246241
RenderPipelineT<FramebufferBlendVertexShader,
247242
FramebufferBlendFragmentShader>;
@@ -645,11 +640,6 @@ class ContentContext {
645640
return GetPipeline(blend_lighten_pipelines_, opts);
646641
}
647642

648-
std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendPlusAdvancedPipeline(
649-
ContentContextOptions opts) const {
650-
return GetPipeline(blend_plus_advanced_pipelines_, opts);
651-
}
652-
653643
std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendLuminosityPipeline(
654644
ContentContextOptions opts) const {
655645
return GetPipeline(blend_luminosity_pipelines_, opts);
@@ -735,12 +725,6 @@ class ContentContext {
735725
return GetPipeline(framebuffer_blend_lighten_pipelines_, opts);
736726
}
737727

738-
std::shared_ptr<Pipeline<PipelineDescriptor>>
739-
GetFramebufferBlendPlusAdvancedPipeline(ContentContextOptions opts) const {
740-
FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
741-
return GetPipeline(framebuffer_blend_plus_advanced_pipelines_, opts);
742-
}
743-
744728
std::shared_ptr<Pipeline<PipelineDescriptor>>
745729
GetFramebufferBlendLuminosityPipeline(ContentContextOptions opts) const {
746730
FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
@@ -1005,7 +989,6 @@ class ContentContext {
1005989
mutable Variants<BlendHardLightPipeline> blend_hardlight_pipelines_;
1006990
mutable Variants<BlendHuePipeline> blend_hue_pipelines_;
1007991
mutable Variants<BlendLightenPipeline> blend_lighten_pipelines_;
1008-
mutable Variants<BlendPlusAdvancedPipeline> blend_plus_advanced_pipelines_;
1009992
mutable Variants<BlendLuminosityPipeline> blend_luminosity_pipelines_;
1010993
mutable Variants<BlendMultiplyPipeline> blend_multiply_pipelines_;
1011994
mutable Variants<BlendOverlayPipeline> blend_overlay_pipelines_;
@@ -1031,8 +1014,6 @@ class ContentContext {
10311014
framebuffer_blend_hue_pipelines_;
10321015
mutable Variants<FramebufferBlendLightenPipeline>
10331016
framebuffer_blend_lighten_pipelines_;
1034-
mutable Variants<FramebufferBlendPlusAdvancedPipeline>
1035-
framebuffer_blend_plus_advanced_pipelines_;
10361017
mutable Variants<FramebufferBlendLuminosityPipeline>
10371018
framebuffer_blend_luminosity_pipelines_;
10381019
mutable Variants<FramebufferBlendMultiplyPipeline>

impeller/entity/contents/filters/blend_filter_contents.cc

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,6 @@ std::optional<Entity> BlendFilterContents::CreateForegroundAdvancedBlend(
338338
case BlendMode::kColor:
339339
pass.SetPipeline(renderer.GetBlendColorPipeline(options));
340340
break;
341-
case BlendMode::kPlusAdvanced:
342-
pass.SetPipeline(renderer.GetBlendPlusAdvancedPipeline(options));
343-
break;
344341
case BlendMode::kLuminosity:
345342
pass.SetPipeline(renderer.GetBlendLuminosityPipeline(options));
346343
break;
@@ -586,7 +583,6 @@ void BlendFilterContents::SetBlendMode(BlendMode blend_mode) {
586583
BLEND_CASE(Hue)
587584
BLEND_CASE(Saturation)
588585
BLEND_CASE(Color)
589-
BLEND_CASE(PlusAdvanced)
590586
BLEND_CASE(Luminosity)
591587
default:
592588
FML_UNREACHABLE();
@@ -615,26 +611,19 @@ std::optional<Entity> BlendFilterContents::RenderFilter(
615611
std::nullopt, GetAbsorbOpacity(), GetAlpha());
616612
}
617613

618-
BlendMode blend_mode = blend_mode_;
619-
if (blend_mode == BlendMode::kPlus &&
620-
!IsAlphaClampedToOne(
621-
renderer.GetContext()->GetCapabilities()->GetDefaultColorFormat())) {
622-
blend_mode = BlendMode::kPlusAdvanced;
623-
}
624-
625-
if (blend_mode <= Entity::kLastPipelineBlendMode) {
626-
return PipelineBlend(inputs, renderer, entity, coverage, blend_mode,
614+
if (blend_mode_ <= Entity::kLastPipelineBlendMode) {
615+
return PipelineBlend(inputs, renderer, entity, coverage, blend_mode_,
627616
foreground_color_, GetAbsorbOpacity(), GetAlpha());
628617
}
629618

630-
if (blend_mode <= Entity::kLastAdvancedBlendMode) {
619+
if (blend_mode_ <= Entity::kLastAdvancedBlendMode) {
631620
if (inputs.size() == 1 && foreground_color_.has_value() &&
632621
GetAbsorbOpacity() == ColorFilterContents::AbsorbOpacity::kYes) {
633622
return CreateForegroundAdvancedBlend(
634623
inputs[0], renderer, entity, coverage, foreground_color_.value(),
635-
blend_mode, GetAlpha(), GetAbsorbOpacity());
624+
blend_mode_, GetAlpha(), GetAbsorbOpacity());
636625
}
637-
return advanced_blend_proc_(inputs, renderer, entity, coverage, blend_mode,
626+
return advanced_blend_proc_(inputs, renderer, entity, coverage, blend_mode_,
638627
foreground_color_, GetAbsorbOpacity(),
639628
GetAlpha());
640629
}

impeller/entity/contents/framebuffer_blend_contents.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,6 @@ bool FramebufferBlendContents::Render(const ContentContext& renderer,
118118
case BlendMode::kColor:
119119
pass.SetPipeline(renderer.GetFramebufferBlendColorPipeline(options));
120120
break;
121-
case BlendMode::kPlusAdvanced:
122-
pass.SetPipeline(
123-
renderer.GetFramebufferBlendPlusAdvancedPipeline(options));
124-
break;
125121
case BlendMode::kLuminosity:
126122
pass.SetPipeline(renderer.GetFramebufferBlendLuminosityPipeline(options));
127123
break;

impeller/entity/contents/framebuffer_blend_contents.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ enum class BlendSelectValues {
2727
kHue,
2828
kSaturation,
2929
kColor,
30-
kPlusAdvanced,
3130
kLuminosity,
3231
};
3332

impeller/entity/entity_pass.cc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -970,13 +970,6 @@ bool EntityPass::OnRender(
970970
/// Setup advanced blends.
971971
///
972972

973-
if (result.entity.GetBlendMode() == BlendMode::kPlus &&
974-
!IsAlphaClampedToOne(pass_context.GetPassTarget()
975-
.GetRenderTarget()
976-
.GetRenderTargetPixelFormat())) {
977-
result.entity.SetBlendMode(BlendMode::kPlusAdvanced);
978-
}
979-
980973
if (result.entity.GetBlendMode() > Entity::kLastPipelineBlendMode) {
981974
if (renderer.GetDeviceCapabilities().SupportsFramebufferFetch()) {
982975
auto src_contents = result.entity.GetContents();

0 commit comments

Comments
 (0)