diff --git a/impeller/entity/contents/content_context.cc b/impeller/entity/contents/content_context.cc index 2aab84148546e..1a7a8a9b026f0 100644 --- a/impeller/entity/contents/content_context.cc +++ b/impeller/entity/contents/content_context.cc @@ -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(*context_, clip_pipeline_descriptor)); } if (context_->GetCapabilities()->SupportsFramebufferFetch()) { @@ -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); @@ -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( - *context_, clip_pipeline_descriptor)); - is_valid_ = true; InitializeCommonlyUsedShadersIfNeeded(); } @@ -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}) {