[Impeller] fix validation warning on iOS/macOS when compiling external texture shader. (flutter/engine#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 https://github.com/flutter/flutter/issues/133286
Fixes https://github.com/flutter/flutter/issues/133268
This commit is contained in:
Jonah Williams
2023-08-25 08:59:15 -07:00
committed by GitHub
parent ee26f237c7
commit c94e38673c
4 changed files with 29 additions and 7 deletions

View File

@@ -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_] =
@@ -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_);

View File

@@ -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"
@@ -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
@@ -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 =
@@ -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
@@ -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 {
@@ -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>

View File

@@ -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));

View File

@@ -112,7 +112,8 @@ PipelineFuture<PipelineDescriptor> PipelineLibraryMTL::GetPipeline(
^(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;