Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion impeller/entity/contents/content_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -454,8 +456,43 @@ ContentContext::ContentContext(
std::move(clip_color_attachments));
clip_pipelines_.SetDefault(options, std::make_unique<ClipPipeline>(
*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;
Expand Down
5 changes: 5 additions & 0 deletions impeller/entity/contents/content_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Context> GetContext() const;

const Capabilities& GetDeviceCapabilities() const;
Expand Down Expand Up @@ -1029,6 +1033,7 @@ class ContentContext {
return nullptr;
}

FML_LOG(ERROR) << "Create! !";
auto variant_future = pipeline->CreateVariant(
[&opts, variants_count =
container.GetPipelineCount()](PipelineDescriptor& desc) {
Expand Down
1 change: 0 additions & 1 deletion impeller/typographer/typographer_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#include <memory>

#include "flutter/fml/macros.h"
#include "impeller/renderer/context.h"
#include "impeller/typographer/glyph_atlas.h"

Expand Down