Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
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
78 changes: 43 additions & 35 deletions impeller/entity/contents/content_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -282,18 +282,48 @@ ContentContext::ContentContext(
checkerboard_pipelines_.CreateDefault(*context_, options);
#endif // IMPELLER_DEBUG

solid_fill_pipelines_.CreateDefault(*context_, options);
// These pipelines are created first since they are immediately used by
// InitializeCommonlyUsedShadersIfNeeded. Their order matches the order in
// InitializeCommonlyUsedShadersIfNeeded.
{
solid_fill_pipelines_.CreateDefault(*context_, options);
texture_pipelines_.CreateDefault(*context_, options);

if (context_->GetCapabilities()->SupportsSSBO()) {
linear_gradient_ssbo_fill_pipelines_.CreateDefault(*context_, options);
radial_gradient_ssbo_fill_pipelines_.CreateDefault(*context_, options);
conical_gradient_ssbo_fill_pipelines_.CreateDefault(*context_, options);
sweep_gradient_ssbo_fill_pipelines_.CreateDefault(*context_, options);
} else {
linear_gradient_fill_pipelines_.CreateDefault(*context_, options);
radial_gradient_fill_pipelines_.CreateDefault(*context_, options);
conical_gradient_fill_pipelines_.CreateDefault(*context_, options);
sweep_gradient_fill_pipelines_.CreateDefault(*context_, options);
}

if (context_->GetCapabilities()->SupportsSSBO()) {
linear_gradient_ssbo_fill_pipelines_.CreateDefault(*context_, options);
radial_gradient_ssbo_fill_pipelines_.CreateDefault(*context_, options);
conical_gradient_ssbo_fill_pipelines_.CreateDefault(*context_, options);
sweep_gradient_ssbo_fill_pipelines_.CreateDefault(*context_, options);
} else {
linear_gradient_fill_pipelines_.CreateDefault(*context_, options);
radial_gradient_fill_pipelines_.CreateDefault(*context_, options);
conical_gradient_fill_pipelines_.CreateDefault(*context_, options);
sweep_gradient_fill_pipelines_.CreateDefault(*context_, options);
/// Setup default clip pipeline.

auto clip_pipeline_descriptor =
ClipPipeline::Builder::MakeDefaultPipelineDescriptor(*context_);
if (!clip_pipeline_descriptor.has_value()) {
return;
}
ContentContextOptions{
.sample_count = SampleCount::kCount4,
.color_attachment_pixel_format =
context_->GetCapabilities()->GetDefaultColorFormat()}
.ApplyToPipelineDescriptor(*clip_pipeline_descriptor);
// Disable write to all color attachments.
auto clip_color_attachments =
clip_pipeline_descriptor->GetColorAttachmentDescriptors();
for (auto& color_attachment : clip_color_attachments) {
color_attachment.second.write_mask = ColorWriteMaskBits::kNone;
}
clip_pipeline_descriptor->SetColorAttachmentDescriptors(
std::move(clip_color_attachments));
clip_pipelines_.SetDefault(
options,
std::make_unique<ClipPipeline>(*context_, clip_pipeline_descriptor));
}

if (context_->GetCapabilities()->SupportsFramebufferFetch()) {
Expand Down Expand Up @@ -392,7 +422,6 @@ ContentContext::ContentContext(

rrect_blur_pipelines_.CreateDefault(*context_, options_trianglestrip);
texture_blend_pipelines_.CreateDefault(*context_, options);
texture_pipelines_.CreateDefault(*context_, options);
texture_strict_src_pipelines_.CreateDefault(*context_, options);
position_uv_pipelines_.CreateDefault(*context_, options);
tiled_texture_pipelines_.CreateDefault(*context_, options);
Expand Down Expand Up @@ -438,29 +467,6 @@ ContentContext::ContentContext(
context_->GetPipelineLibrary()->GetPipeline(uv_pipeline_desc).Get();
}

/// Setup default clip pipeline.

auto clip_pipeline_descriptor =
ClipPipeline::Builder::MakeDefaultPipelineDescriptor(*context_);
if (!clip_pipeline_descriptor.has_value()) {
return;
}
ContentContextOptions{
.sample_count = SampleCount::kCount4,
.color_attachment_pixel_format =
context_->GetCapabilities()->GetDefaultColorFormat()}
.ApplyToPipelineDescriptor(*clip_pipeline_descriptor);
// Disable write to all color attachments.
auto clip_color_attachments =
clip_pipeline_descriptor->GetColorAttachmentDescriptors();
for (auto& color_attachment : clip_color_attachments) {
color_attachment.second.write_mask = ColorWriteMaskBits::kNone;
}
clip_pipeline_descriptor->SetColorAttachmentDescriptors(
std::move(clip_color_attachments));
clip_pipelines_.SetDefault(options, std::make_unique<ClipPipeline>(
*context_, clip_pipeline_descriptor));

is_valid_ = true;
InitializeCommonlyUsedShadersIfNeeded();
}
Expand Down Expand Up @@ -606,6 +612,8 @@ void ContentContext::InitializeCommonlyUsedShadersIfNeeded() const {
.color_attachment_pixel_format =
context_->GetCapabilities()->GetDefaultColorFormat()};

// Note: When editing this, check the order the default pipelines are created.
// These should be first.
for (const auto mode : {BlendMode::kSource, BlendMode::kSourceOver}) {
for (const auto geometry :
{PrimitiveType::kTriangle, PrimitiveType::kTriangleStrip}) {
Expand Down