Skip to content

Commit 78f9dcf

Browse files
authored
[Impeller] Avoid errors due to triangle fans usage on Molten. (flutter#56321)
Added the test case for flutter/flutter#157885 to the corpus but Jonah fixed it in flutter#56310. Fixes flutter/flutter#158024 which is more of an inconvenience on macOS.
1 parent 20ea348 commit 78f9dcf

File tree

4 files changed

+89
-3
lines changed

4 files changed

+89
-3
lines changed

impeller/display_list/aiks_dl_text_unittests.cc

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
#include "display_list/dl_tile_mode.h"
88
#include "display_list/effects/dl_color_source.h"
99
#include "display_list/effects/dl_mask_filter.h"
10-
#include "flutter/impeller/display_list/aiks_unittests.h"
11-
1210
#include "flutter/display_list/dl_builder.h"
1311
#include "flutter/display_list/dl_color.h"
1412
#include "flutter/display_list/dl_paint.h"
13+
#include "flutter/fml/build_config.h"
14+
#include "flutter/impeller/display_list/aiks_unittests.h"
1515
#include "flutter/testing/testing.h"
1616
#include "impeller/geometry/matrix.h"
1717
#include "impeller/typographer/backends/skia/text_frame_skia.h"
@@ -483,5 +483,81 @@ TEST_P(AiksTest, TextForegroundShaderWithTransform) {
483483
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
484484
}
485485

486+
// Regression test for https://github.com/flutter/flutter/issues/157885.
487+
TEST_P(AiksTest, DifferenceClipsMustRenderIdenticallyAcrossBackends) {
488+
DisplayListBuilder builder;
489+
490+
DlPaint paint;
491+
DlColor clear_color(1.0, 0.5, 0.5, 0.5, DlColorSpace::kSRGB);
492+
paint.setColor(clear_color);
493+
builder.DrawPaint(paint);
494+
495+
DlMatrix identity = {
496+
1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0,
497+
0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0,
498+
};
499+
builder.Save();
500+
builder.Transform(identity);
501+
502+
DlRect frame = DlRect::MakeLTRB(1.0, 1.0, 1278.0, 763.0);
503+
DlColor white(1.0, 1.0, 1.0, 1.0, DlColorSpace::kSRGB);
504+
paint.setColor(white);
505+
builder.DrawRect(frame, paint);
506+
507+
builder.Save();
508+
builder.ClipRect(frame, DlCanvas::ClipOp::kIntersect);
509+
510+
DlMatrix rect_xform = {
511+
0.8241262, 0.56640625, 0.0, 0.0, -0.56640625, 0.8241262, 0.0, 0.0,
512+
0.0, 0.0, 1.0, 0.0, 271.1137, 489.4733, 0.0, 1.0,
513+
};
514+
builder.Save();
515+
builder.Transform(rect_xform);
516+
517+
DlRect rect = DlRect::MakeLTRB(0.0, 0.0, 100.0, 100.0);
518+
DlColor bluish(1.0, 0.184, 0.501, 0.929, DlColorSpace::kSRGB);
519+
paint.setColor(bluish);
520+
DlRoundRect rrect = DlRoundRect::MakeRectRadius(rect, 18.0);
521+
builder.DrawRoundRect(rrect, paint);
522+
523+
builder.Save();
524+
builder.ClipRect(rect, DlCanvas::ClipOp::kIntersect);
525+
builder.Restore();
526+
527+
builder.Restore();
528+
529+
DlMatrix path_xform = {
530+
1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0,
531+
0.0, 0.0, 1.0, 0.0, 675.0, 279.5, 0.0, 1.0,
532+
};
533+
builder.Save();
534+
builder.Transform(path_xform);
535+
536+
SkPath path;
537+
path.moveTo(87.5, 349.5);
538+
path.lineTo(25.0, 29.5);
539+
path.lineTo(150.0, 118.0);
540+
path.lineTo(25.0, 118.0);
541+
path.lineTo(150.0, 29.5);
542+
path.close();
543+
544+
DlColor fill_color(1.0, 1.0, 0.0, 0.0, DlColorSpace::kSRGB);
545+
DlColor stroke_color(1.0, 0.0, 0.0, 0.0, DlColorSpace::kSRGB);
546+
paint.setColor(fill_color);
547+
paint.setDrawStyle(DlDrawStyle::kFill);
548+
builder.DrawPath(DlPath(path), paint);
549+
550+
paint.setColor(stroke_color);
551+
paint.setStrokeWidth(2.0);
552+
paint.setDrawStyle(DlDrawStyle::kStroke);
553+
builder.DrawPath(path, paint);
554+
555+
builder.Restore();
556+
builder.Restore();
557+
builder.Restore();
558+
559+
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
560+
}
561+
486562
} // namespace testing
487563
} // namespace impeller

impeller/renderer/backend/vulkan/capabilities_vk.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,12 @@ bool CapabilitiesVK::SetPhysicalDevice(
595595
ISize{device_properties_.limits.maxFramebufferWidth,
596596
device_properties_.limits.maxFramebufferHeight};
597597

598+
// Molten, Vulkan on Metal, cannot support triangle fans because Metal doesn't
599+
// support triangle fans.
600+
// See VUID-VkPipelineInputAssemblyStateCreateInfo-triangleFans-04452.
601+
has_triangle_fans_ =
602+
!HasExtension(OptionalDeviceExtensionVK::kVKKHRPortabilitySubset);
603+
598604
return true;
599605
}
600606

@@ -746,7 +752,7 @@ CapabilitiesVK::GetSupportedFRCRate(CompressionType compression_type,
746752
}
747753

748754
bool CapabilitiesVK::SupportsTriangleFan() const {
749-
return true;
755+
return has_triangle_fans_;
750756
}
751757

752758
ISize CapabilitiesVK::GetMaximumRenderPassAttachmentSize() const {

impeller/renderer/backend/vulkan/capabilities_vk.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ class CapabilitiesVK final : public Capabilities,
297297
bool supports_device_transient_textures_ = false;
298298
bool supports_texture_fixed_rate_compression_ = false;
299299
ISize max_render_pass_attachment_size_ = ISize{0, 0};
300+
bool has_triangle_fans_ = true;
300301
bool is_valid_ = false;
301302

302303
// The embedder.h API is responsible for providing the instance and device

testing/impeller_golden_tests_output.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,9 @@ impeller_Play_AiksTest_CoverageOriginShouldBeAccountedForInSubpasses_Vulkan.png
563563
impeller_Play_AiksTest_DestructiveBlendColorFilterFloodsClip_Metal.png
564564
impeller_Play_AiksTest_DestructiveBlendColorFilterFloodsClip_OpenGLES.png
565565
impeller_Play_AiksTest_DestructiveBlendColorFilterFloodsClip_Vulkan.png
566+
impeller_Play_AiksTest_DifferenceClipsMustRenderIdenticallyAcrossBackends_Metal.png
567+
impeller_Play_AiksTest_DifferenceClipsMustRenderIdenticallyAcrossBackends_OpenGLES.png
568+
impeller_Play_AiksTest_DifferenceClipsMustRenderIdenticallyAcrossBackends_Vulkan.png
566569
impeller_Play_AiksTest_DispatcherDoesNotCullPerspectiveTransformedChildDisplayLists_Metal.png
567570
impeller_Play_AiksTest_DispatcherDoesNotCullPerspectiveTransformedChildDisplayLists_OpenGLES.png
568571
impeller_Play_AiksTest_DispatcherDoesNotCullPerspectiveTransformedChildDisplayLists_Vulkan.png

0 commit comments

Comments
 (0)