diff --git a/impeller/entity/contents/content_context.cc b/impeller/entity/contents/content_context.cc index bde5a604b62ce..5f2d0a886eb69 100644 --- a/impeller/entity/contents/content_context.cc +++ b/impeller/entity/contents/content_context.cc @@ -11,12 +11,14 @@ #include "impeller/entity/contents/framebuffer_blend_contents.h" #include "impeller/entity/entity.h" #include "impeller/entity/render_target_cache.h" +#include "impeller/geometry/color.h" #include "impeller/renderer/command_buffer.h" #include "impeller/renderer/pipeline_descriptor.h" #include "impeller/renderer/pipeline_library.h" #include "impeller/renderer/render_target.h" #include "impeller/renderer/texture_mipmap.h" #include "impeller/tessellator/tessellator.h" +#include "impeller/typographer/glyph_atlas.h" #include "impeller/typographer/typographer_context.h" namespace impeller { @@ -454,8 +456,43 @@ ContentContext::ContentContext( std::move(clip_color_attachments)); clip_pipelines_.SetDefault(options, std::make_unique( *context_, clip_pipeline_descriptor)); - is_valid_ = true; + CreateDeferredVariants(); +} + +// Attempt to populate pipeline variants that are very likely to be used +// on or near the first frame of the application. +void ContentContext::CreateDeferredVariants() { + auto options = ContentContextOptions{ + .sample_count = SampleCount::kCount4, + .color_attachment_pixel_format = + context_->GetCapabilities()->GetDefaultColorFormat()}; + + for (const auto mode : {BlendMode::kSource, BlendMode::kSourceOver}) { + for (const auto geometry : + {PrimitiveType::kTriangle, PrimitiveType::kTriangleStrip}) { + options.blend_mode = mode; + options.primitive_type = geometry; + GetSolidFillPipeline(options); + if (context_->GetCapabilities()->SupportsSSBO()) { + GetLinearGradientSSBOFillPipeline(options); + GetRadialGradientSSBOFillPipeline(options); + GetSweepGradientSSBOFillPipeline(options); + GetConicalGradientSSBOFillPipeline(options); + GetTexturePipeline(options); + } + } + } + + options.blend_mode = BlendMode::kDestination; + options.primitive_type = PrimitiveType::kTriangleStrip; + for (const auto stencil_mode : + {ContentContextOptions::StencilMode::kLegacyClipIncrement, + ContentContextOptions::StencilMode::kLegacyClipDecrement, + ContentContextOptions::StencilMode::kLegacyClipRestore}) { + options.stencil_mode = stencil_mode; + GetClipPipeline(options); + } } ContentContext::~ContentContext() = default; diff --git a/impeller/entity/contents/content_context.h b/impeller/entity/contents/content_context.h index 64ad969559a75..eafad75038446 100644 --- a/impeller/entity/contents/content_context.h +++ b/impeller/entity/contents/content_context.h @@ -750,6 +750,10 @@ class ContentContext { return uv_compute_pipelines_; } + /// @brief Populate variants of the initial shader set that are likely to be + /// used on the first few frames of an application. + void CreateDeferredVariants(); + std::shared_ptr GetContext() const; const Capabilities& GetDeviceCapabilities() const; @@ -1029,6 +1033,7 @@ class ContentContext { return nullptr; } + FML_LOG(ERROR) << "Create! !"; auto variant_future = pipeline->CreateVariant( [&opts, variants_count = container.GetPipelineCount()](PipelineDescriptor& desc) { diff --git a/impeller/typographer/typographer_context.h b/impeller/typographer/typographer_context.h index 9d62a6d98009e..efd10bdffa7c6 100644 --- a/impeller/typographer/typographer_context.h +++ b/impeller/typographer/typographer_context.h @@ -7,7 +7,6 @@ #include -#include "flutter/fml/macros.h" #include "impeller/renderer/context.h" #include "impeller/typographer/glyph_atlas.h"