Skip to content

Commit

Permalink
[Impeller] fix validation warning on iOS/macOS when compiling externa…
Browse files Browse the repository at this point in the history
…l texture shader. (flutter#45080)

```
[VERBOSE-2:validation.cc(49)] Break on 'ImpellerValidationBreak' to inspect point of failure: Could not create render pipeline for TextureFillExternal Pipeline :Fragment input(s) `user(locn1)` mismatching vertex shader output type(s) or not written by vertex shader
```

Fixes flutter/flutter#133286
Fixes flutter/flutter#133268
  • Loading branch information
jonahwilliams authored Aug 25, 2023
1 parent 00f532d commit 33fca02
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
10 changes: 7 additions & 3 deletions impeller/entity/contents/content_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,6 @@ ContentContext::ContentContext(
CreateDefaultPipeline<BlendPipeline>(*context_);
texture_pipelines_[default_options_] =
CreateDefaultPipeline<TexturePipeline>(*context_);
texture_external_pipelines_[default_options_] =
CreateDefaultPipeline<TextureExternalPipeline>(*context_);
position_uv_pipelines_[default_options_] =
CreateDefaultPipeline<PositionUVPipeline>(*context_);
tiled_texture_pipelines_[default_options_] =
Expand Down Expand Up @@ -312,7 +310,13 @@ ContentContext::ContentContext(
CreateDefaultPipeline<YUVToRGBFilterPipeline>(*context_);
porter_duff_blend_pipelines_[default_options_] =
CreateDefaultPipeline<PorterDuffBlendPipeline>(*context_);

// GLES only shader.
#ifdef IMPELLER_ENABLE_OPENGLES
if (GetContext()->GetBackendType() == Context::BackendType::kOpenGLES) {
texture_external_pipelines_[default_options_] =
CreateDefaultPipeline<TextureExternalPipeline>(*context_);
}
#endif // IMPELLER_ENABLE_OPENGLES
if (context_->GetCapabilities()->SupportsCompute()) {
auto pipeline_desc =
PointsComputeShaderPipeline::MakeDefaultPipelineDescriptor(*context_);
Expand Down
18 changes: 15 additions & 3 deletions impeller/entity/contents/content_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
#include "impeller/entity/sweep_gradient_fill.frag.h"
#include "impeller/entity/texture_fill.frag.h"
#include "impeller/entity/texture_fill.vert.h"
#include "impeller/entity/texture_fill_external.frag.h"
#include "impeller/entity/tiled_texture_fill.frag.h"
#include "impeller/entity/uv.comp.h"
#include "impeller/entity/vertices.frag.h"
Expand Down Expand Up @@ -112,6 +111,10 @@
#include "impeller/entity/framebuffer_blend_screen.frag.h"
#include "impeller/entity/framebuffer_blend_softlight.frag.h"

#ifdef IMPELLER_ENABLE_OPENGLES
#include "impeller/entity/texture_fill_external.frag.h"
#endif // IMPELLER_ENABLE_OPENGLES

#if IMPELLER_ENABLE_3D
#include "impeller/scene/scene_context.h" // nogncheck
#endif
Expand Down Expand Up @@ -151,8 +154,6 @@ using RRectBlurPipeline =
using BlendPipeline = RenderPipelineT<BlendVertexShader, BlendFragmentShader>;
using TexturePipeline =
RenderPipelineT<TextureFillVertexShader, TextureFillFragmentShader>;
using TextureExternalPipeline =
RenderPipelineT<TextureFillVertexShader, TextureFillExternalFragmentShader>;
using PositionUVPipeline =
RenderPipelineT<TextureFillVertexShader, TiledTextureFillFragmentShader>;
using TiledTexturePipeline =
Expand Down Expand Up @@ -291,6 +292,11 @@ using FramebufferBlendSoftLightPipeline =
using PointsComputeShaderPipeline = ComputePipelineBuilder<PointsComputeShader>;
using UvComputeShaderPipeline = ComputePipelineBuilder<UvComputeShader>;

#ifdef IMPELLER_ENABLE_OPENGLES
using TextureExternalPipeline =
RenderPipelineT<TextureFillVertexShader, TextureFillExternalFragmentShader>;
#endif // IMPELLER_ENABLE_OPENGLES

/// Pipeline state configuration.
///
/// Each unique combination of these options requires a different pipeline state
Expand Down Expand Up @@ -428,10 +434,14 @@ class ContentContext {
return GetPipeline(texture_pipelines_, opts);
}

#ifdef IMPELLER_ENABLE_OPENGLES
std::shared_ptr<Pipeline<PipelineDescriptor>> GetTextureExternalPipeline(
ContentContextOptions opts) const {
FML_DCHECK(GetContext()->GetBackendType() ==
Context::BackendType::kOpenGLES);
return GetPipeline(texture_external_pipelines_, opts);
}
#endif // IMPELLER_ENABLE_OPENGLES

std::shared_ptr<Pipeline<PipelineDescriptor>> GetPositionUVPipeline(
ContentContextOptions opts) const {
Expand Down Expand Up @@ -757,7 +767,9 @@ class ContentContext {
mutable Variants<RRectBlurPipeline> rrect_blur_pipelines_;
mutable Variants<BlendPipeline> texture_blend_pipelines_;
mutable Variants<TexturePipeline> texture_pipelines_;
#ifdef IMPELLER_ENABLE_OPENGLES
mutable Variants<TextureExternalPipeline> texture_external_pipelines_;
#endif // IMPELLER_ENABLE_OPENGLES
mutable Variants<PositionUVPipeline> position_uv_pipelines_;
mutable Variants<TiledTexturePipeline> tiled_texture_pipelines_;
mutable Variants<GaussianBlurAlphaDecalPipeline>
Expand Down
5 changes: 5 additions & 0 deletions impeller/entity/contents/texture_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,16 @@ bool TextureContents::Render(const ContentContext& renderer,
}
pipeline_options.primitive_type = PrimitiveType::kTriangleStrip;

#ifdef IMPELLER_ENABLE_OPENGLES
if (is_external_texture) {
cmd.pipeline = renderer.GetTextureExternalPipeline(pipeline_options);
} else {
cmd.pipeline = renderer.GetTexturePipeline(pipeline_options);
}
#else
cmd.pipeline = renderer.GetTexturePipeline(pipeline_options);
#endif // IMPELLER_ENABLE_OPENGLES

cmd.stencil_reference = entity.GetStencilDepth();
cmd.BindVertices(vertex_builder.CreateVertexBuffer(host_buffer));
VS::BindFrameInfo(cmd, host_buffer.EmplaceUniform(frame_info));
Expand Down
3 changes: 2 additions & 1 deletion impeller/renderer/backend/metal/pipeline_library_mtl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@
^(id<MTLRenderPipelineState> _Nullable render_pipeline_state,
NSError* _Nullable error) {
if (error != nil) {
VALIDATION_LOG << "Could not create render pipeline: "
VALIDATION_LOG << "Could not create render pipeline for "
<< descriptor.GetLabel() << " :"
<< error.localizedDescription.UTF8String;
promise->set_value(nullptr);
return;
Expand Down

0 comments on commit 33fca02

Please sign in to comment.