diff --git a/ci/licenses_golden/excluded_files b/ci/licenses_golden/excluded_files index a18607ec38205..c028a4d0e861a 100644 --- a/ci/licenses_golden/excluded_files +++ b/ci/licenses_golden/excluded_files @@ -140,6 +140,7 @@ ../../../flutter/impeller/entity/contents/filters/directional_gaussian_blur_filter_contents_unittests.cc ../../../flutter/impeller/entity/contents/filters/inputs/filter_input_unittests.cc ../../../flutter/impeller/entity/contents/test +../../../flutter/impeller/entity/contents/tiled_texture_contents_unittests.cc ../../../flutter/impeller/entity/contents/vertices_contents_unittests.cc ../../../flutter/impeller/entity/entity_pass_target_unittests.cc ../../../flutter/impeller/entity/entity_unittests.cc diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index 78f1bb857c5b8..b8213b96796d5 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -2963,11 +2963,13 @@ ORIGIN: ../../../flutter/impeller/compiler/shader_lib/impeller/color.glsl + ../. ORIGIN: ../../../flutter/impeller/compiler/shader_lib/impeller/constants.glsl + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/compiler/shader_lib/impeller/conversions.glsl + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/compiler/shader_lib/impeller/dithering.glsl + ../../../flutter/LICENSE +ORIGIN: ../../../flutter/impeller/compiler/shader_lib/impeller/external_texture_oes.glsl + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/compiler/shader_lib/impeller/gaussian.glsl + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/compiler/shader_lib/impeller/gradient.glsl + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/compiler/shader_lib/impeller/path.glsl + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/compiler/shader_lib/impeller/prefix_sum.glsl + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/compiler/shader_lib/impeller/texture.glsl + ../../../flutter/LICENSE +ORIGIN: ../../../flutter/impeller/compiler/shader_lib/impeller/tile_mode.glsl + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/compiler/shader_lib/impeller/transform.glsl + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/compiler/shader_lib/impeller/types.glsl + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/compiler/source_options.cc + ../../../flutter/LICENSE @@ -3189,6 +3191,7 @@ ORIGIN: ../../../flutter/impeller/entity/shaders/texture_fill.frag + ../../../fl ORIGIN: ../../../flutter/impeller/entity/shaders/texture_fill.vert + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/entity/shaders/texture_fill_external.frag + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/entity/shaders/tiled_texture_fill.frag + ../../../flutter/LICENSE +ORIGIN: ../../../flutter/impeller/entity/shaders/tiled_texture_fill_external.frag + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/entity/shaders/vertices.frag + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/entity/shaders/yuv_to_rgb_filter.frag + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/entity/shaders/yuv_to_rgb_filter.vert + ../../../flutter/LICENSE @@ -5725,11 +5728,13 @@ FILE: ../../../flutter/impeller/compiler/shader_lib/impeller/color.glsl FILE: ../../../flutter/impeller/compiler/shader_lib/impeller/constants.glsl FILE: ../../../flutter/impeller/compiler/shader_lib/impeller/conversions.glsl FILE: ../../../flutter/impeller/compiler/shader_lib/impeller/dithering.glsl +FILE: ../../../flutter/impeller/compiler/shader_lib/impeller/external_texture_oes.glsl FILE: ../../../flutter/impeller/compiler/shader_lib/impeller/gaussian.glsl FILE: ../../../flutter/impeller/compiler/shader_lib/impeller/gradient.glsl FILE: ../../../flutter/impeller/compiler/shader_lib/impeller/path.glsl FILE: ../../../flutter/impeller/compiler/shader_lib/impeller/prefix_sum.glsl FILE: ../../../flutter/impeller/compiler/shader_lib/impeller/texture.glsl +FILE: ../../../flutter/impeller/compiler/shader_lib/impeller/tile_mode.glsl FILE: ../../../flutter/impeller/compiler/shader_lib/impeller/transform.glsl FILE: ../../../flutter/impeller/compiler/shader_lib/impeller/types.glsl FILE: ../../../flutter/impeller/compiler/source_options.cc @@ -5951,6 +5956,7 @@ FILE: ../../../flutter/impeller/entity/shaders/texture_fill.frag FILE: ../../../flutter/impeller/entity/shaders/texture_fill.vert FILE: ../../../flutter/impeller/entity/shaders/texture_fill_external.frag FILE: ../../../flutter/impeller/entity/shaders/tiled_texture_fill.frag +FILE: ../../../flutter/impeller/entity/shaders/tiled_texture_fill_external.frag FILE: ../../../flutter/impeller/entity/shaders/vertices.frag FILE: ../../../flutter/impeller/entity/shaders/yuv_to_rgb_filter.frag FILE: ../../../flutter/impeller/entity/shaders/yuv_to_rgb_filter.vert diff --git a/impeller/compiler/shader_lib/impeller/BUILD.gn b/impeller/compiler/shader_lib/impeller/BUILD.gn index 08fd0e8af680b..08b2121ee5448 100644 --- a/impeller/compiler/shader_lib/impeller/BUILD.gn +++ b/impeller/compiler/shader_lib/impeller/BUILD.gn @@ -10,10 +10,12 @@ copy("impeller") { "constants.glsl", "conversions.glsl", "dithering.glsl", + "external_texture_oes.glsl", "gaussian.glsl", "gradient.glsl", "path.glsl", "texture.glsl", + "tile_mode.glsl", "transform.glsl", "types.glsl", ] diff --git a/impeller/compiler/shader_lib/impeller/external_texture_oes.glsl b/impeller/compiler/shader_lib/impeller/external_texture_oes.glsl new file mode 100644 index 0000000000000..ece31ed69aa0e --- /dev/null +++ b/impeller/compiler/shader_lib/impeller/external_texture_oes.glsl @@ -0,0 +1,36 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include + +/// A triangle wave. 0->0, 1->1, 2->0, and so on... works with negative numbers. +float TriangleWave(float x) { + return abs(mod(x + 1, 2) - 1); +} + +/// OES_EGL_image_external states that only CLAMP_TO_EDGE is valid, so we +/// emulate all other tile modes here by remapping the texture coordinates. +vec4 IPSampleWithTileModeOES(sampler2D tex, + vec2 coords, + float x_tile_mode, + float y_tile_mode) { + if (x_tile_mode == kTileModeDecal && (coords.x < 0 || coords.x >= 1) || + y_tile_mode == kTileModeDecal && (coords.y < 0 || coords.y >= 1)) { + return vec4(0); + } + + if (x_tile_mode == kTileModeRepeat) { + coords.x = mod(coords.x, 1); + } else if (x_tile_mode == kTileModeMirror) { + coords.x = TriangleWave(coords.x); + } + + if (y_tile_mode == kTileModeRepeat) { + coords.y = mod(coords.y, 1); + } else if (y_tile_mode == kTileModeMirror) { + coords.y = TriangleWave(coords.y); + } + + return texture(tex, coords); +} diff --git a/impeller/compiler/shader_lib/impeller/texture.glsl b/impeller/compiler/shader_lib/impeller/texture.glsl index c973dd2971699..1a504d16d34c7 100644 --- a/impeller/compiler/shader_lib/impeller/texture.glsl +++ b/impeller/compiler/shader_lib/impeller/texture.glsl @@ -7,6 +7,7 @@ #include #include +#include #include /// Sample from a texture. @@ -35,13 +36,6 @@ vec4 IPSampleLinear(sampler2D texture_sampler, return IPSample(texture_sampler, coords, y_coord_scale); } -// These values must correspond to the order of the items in the -// 'Entity::TileMode' enum class. -const float kTileModeClamp = 0; -const float kTileModeRepeat = 1; -const float kTileModeMirror = 2; -const float kTileModeDecal = 3; - /// Remap a float using a tiling mode. /// /// When `tile_mode` is `kTileModeDecal`, no tiling is applied and `t` is diff --git a/impeller/compiler/shader_lib/impeller/tile_mode.glsl b/impeller/compiler/shader_lib/impeller/tile_mode.glsl new file mode 100644 index 0000000000000..31e2bd576538b --- /dev/null +++ b/impeller/compiler/shader_lib/impeller/tile_mode.glsl @@ -0,0 +1,10 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// These values must correspond to the order of the items in the +// 'Entity::TileMode' enum class. +const float kTileModeClamp = 0; +const float kTileModeRepeat = 1; +const float kTileModeMirror = 2; +const float kTileModeDecal = 3; diff --git a/impeller/entity/BUILD.gn b/impeller/entity/BUILD.gn index 89d3071050b43..73669b65cff52 100644 --- a/impeller/entity/BUILD.gn +++ b/impeller/entity/BUILD.gn @@ -51,6 +51,7 @@ impeller_shaders("entity_shaders") { "shaders/texture_fill.vert", "shaders/texture_fill_external.frag", "shaders/tiled_texture_fill.frag", + "shaders/tiled_texture_fill_external.frag", "shaders/vertices.frag", "shaders/yuv_to_rgb_filter.frag", "shaders/yuv_to_rgb_filter.vert", @@ -256,6 +257,7 @@ impeller_component("entity_unittests") { "contents/checkerboard_contents_unittests.cc", "contents/filters/directional_gaussian_blur_filter_contents_unittests.cc", "contents/filters/inputs/filter_input_unittests.cc", + "contents/tiled_texture_contents_unittests.cc", "contents/vertices_contents_unittests.cc", "entity_pass_target_unittests.cc", "entity_playground.cc", diff --git a/impeller/entity/contents/content_context.cc b/impeller/entity/contents/content_context.cc index ec4725795eb31..51544cd311dc1 100644 --- a/impeller/entity/contents/content_context.cc +++ b/impeller/entity/contents/content_context.cc @@ -340,6 +340,9 @@ ContentContext::ContentContext( if (GetContext()->GetBackendType() == Context::BackendType::kOpenGLES) { texture_external_pipelines_.CreateDefault(*context_, options); } + if (GetContext()->GetBackendType() == Context::BackendType::kOpenGLES) { + tiled_texture_external_pipelines_.CreateDefault(*context_, options); + } #endif // IMPELLER_ENABLE_OPENGLES if (context_->GetCapabilities()->SupportsCompute()) { auto pipeline_desc = diff --git a/impeller/entity/contents/content_context.h b/impeller/entity/contents/content_context.h index 7fdcc6cbc74e8..e262850bb3935 100644 --- a/impeller/entity/contents/content_context.h +++ b/impeller/entity/contents/content_context.h @@ -84,6 +84,7 @@ #ifdef IMPELLER_ENABLE_OPENGLES #include "impeller/entity/texture_fill_external.frag.h" +#include "impeller/entity/tiled_texture_fill_external.frag.h" #endif // IMPELLER_ENABLE_OPENGLES #if IMPELLER_ENABLE_3D @@ -249,6 +250,10 @@ using UvComputeShaderPipeline = ComputePipelineBuilder; #ifdef IMPELLER_ENABLE_OPENGLES using TextureExternalPipeline = RenderPipelineT; + +using TiledTextureExternalPipeline = + RenderPipelineT; #endif // IMPELLER_ENABLE_OPENGLES /// Pipeline state configuration. @@ -398,6 +403,13 @@ class ContentContext { Context::BackendType::kOpenGLES); return GetPipeline(texture_external_pipelines_, opts); } + + std::shared_ptr> GetTiledTextureExternalPipeline( + ContentContextOptions opts) const { + FML_DCHECK(GetContext()->GetBackendType() == + Context::BackendType::kOpenGLES); + return GetPipeline(tiled_texture_external_pipelines_, opts); + } #endif // IMPELLER_ENABLE_OPENGLES std::shared_ptr> GetPositionUVPipeline( @@ -768,6 +780,8 @@ class ContentContext { mutable Variants texture_pipelines_; #ifdef IMPELLER_ENABLE_OPENGLES mutable Variants texture_external_pipelines_; + mutable Variants + tiled_texture_external_pipelines_; #endif // IMPELLER_ENABLE_OPENGLES mutable Variants position_uv_pipelines_; mutable Variants tiled_texture_pipelines_; diff --git a/impeller/entity/contents/tiled_texture_contents.cc b/impeller/entity/contents/tiled_texture_contents.cc index 2d18ad1ffa5a7..a9985d8ebab21 100644 --- a/impeller/entity/contents/tiled_texture_contents.cc +++ b/impeller/entity/contents/tiled_texture_contents.cc @@ -4,12 +4,14 @@ #include "impeller/entity/contents/tiled_texture_contents.h" +#include "fml/logging.h" #include "impeller/entity/contents/clip_contents.h" #include "impeller/entity/contents/content_context.h" #include "impeller/entity/geometry/geometry.h" #include "impeller/entity/texture_fill.frag.h" #include "impeller/entity/texture_fill.vert.h" #include "impeller/entity/tiled_texture_fill.frag.h" +#include "impeller/entity/tiled_texture_fill_external.frag.h" #include "impeller/geometry/path_builder.h" #include "impeller/renderer/render_pass.h" #include "impeller/renderer/sampler_library.h" @@ -78,7 +80,7 @@ std::shared_ptr TiledTextureContents::CreateFilterTexture( return nullptr; } -SamplerDescriptor TiledTextureContents::CreateDescriptor( +SamplerDescriptor TiledTextureContents::CreateSamplerDescriptor( const Capabilities& capabilities) const { SamplerDescriptor descriptor = sampler_descriptor_; auto width_mode = TileModeToAddressMode(x_tile_mode_, capabilities); @@ -119,12 +121,16 @@ bool TiledTextureContents::Render(const ContentContext& renderer, using VS = TextureFillVertexShader; using FS = TiledTextureFillFragmentShader; + using FSExternal = TiledTextureFillExternalFragmentShader; const auto texture_size = texture_->GetSize(); if (texture_size.IsEmpty()) { return true; } + bool is_external_texture = + texture_->GetTextureDescriptor().type == TextureType::kTextureExternalOES; + auto& host_buffer = pass.GetTransientsBuffer(); auto geometry_result = GetGeometry()->GetPositionUVBuffer( @@ -153,34 +159,67 @@ bool TiledTextureContents::Render(const ContentContext& renderer, options.stencil_operation = StencilOperation::kIncrementClamp; } options.primitive_type = geometry_result.type; + +#ifdef IMPELLER_ENABLE_OPENGLES + if (is_external_texture) { + cmd.pipeline = renderer.GetTiledTextureExternalPipeline(options); + } else { + cmd.pipeline = uses_emulated_tile_mode + ? renderer.GetTiledTexturePipeline(options) + : renderer.GetTexturePipeline(options); + } +#else cmd.pipeline = uses_emulated_tile_mode ? renderer.GetTiledTexturePipeline(options) : renderer.GetTexturePipeline(options); +#endif // IMPELLER_ENABLE_OPENGLES cmd.BindVertices(geometry_result.vertex_buffer); VS::BindFrameInfo(cmd, host_buffer.EmplaceUniform(frame_info)); - if (uses_emulated_tile_mode) { + if (is_external_texture) { + FSExternal::FragInfo frag_info; + frag_info.x_tile_mode = static_cast(x_tile_mode_); + frag_info.y_tile_mode = static_cast(y_tile_mode_); + FSExternal::BindFragInfo(cmd, host_buffer.EmplaceUniform(frag_info)); + } else if (uses_emulated_tile_mode) { FS::FragInfo frag_info; frag_info.x_tile_mode = static_cast(x_tile_mode_); frag_info.y_tile_mode = static_cast(y_tile_mode_); FS::BindFragInfo(cmd, host_buffer.EmplaceUniform(frag_info)); } - if (color_filter_) { - auto filtered_texture = CreateFilterTexture(renderer); - if (!filtered_texture) { - return false; - } - FS::BindTextureSampler( - cmd, filtered_texture, - renderer.GetContext()->GetSamplerLibrary()->GetSampler( - CreateDescriptor(renderer.GetDeviceCapabilities()))); - } else { - FS::BindTextureSampler( + if (is_external_texture) { + SamplerDescriptor sampler_desc; + // OES_EGL_image_external states that only CLAMP_TO_EDGE is valid, so we + // emulate all other tile modes here by remapping the texture coordinates. + sampler_desc.width_address_mode = SamplerAddressMode::kClampToEdge; + sampler_desc.height_address_mode = SamplerAddressMode::kClampToEdge; + + // Also, external textures cannot be bound to color filters, so ignore this + // case for now. + FML_DCHECK(!color_filter_) + << "Color filters are not currently supported for external textures."; + + FSExternal::BindSAMPLEREXTERNALOESTextureSampler( cmd, texture_, - renderer.GetContext()->GetSamplerLibrary()->GetSampler( - CreateDescriptor(renderer.GetDeviceCapabilities()))); + renderer.GetContext()->GetSamplerLibrary()->GetSampler(sampler_desc)); + } else { + if (color_filter_) { + auto filtered_texture = CreateFilterTexture(renderer); + if (!filtered_texture) { + return false; + } + FS::BindTextureSampler( + cmd, filtered_texture, + renderer.GetContext()->GetSamplerLibrary()->GetSampler( + CreateSamplerDescriptor(renderer.GetDeviceCapabilities()))); + } else { + FS::BindTextureSampler( + cmd, texture_, + renderer.GetContext()->GetSamplerLibrary()->GetSampler( + CreateSamplerDescriptor(renderer.GetDeviceCapabilities()))); + } } if (!pass.AddCommand(std::move(cmd))) { diff --git a/impeller/entity/contents/tiled_texture_contents.h b/impeller/entity/contents/tiled_texture_contents.h index d98dc819f5bc7..90ee30af73283 100644 --- a/impeller/entity/contents/tiled_texture_contents.h +++ b/impeller/entity/contents/tiled_texture_contents.h @@ -45,7 +45,7 @@ class TiledTextureContents final : public ColorSourceContents { /// @param color_filter /// /// When applying a color filter to a tiled texture, we can reduce the - /// size and number of the subpasses required and the shader workloadby + /// size and number of the subpasses required and the shader workload by /// applying the filter to the untiled image and absorbing the opacity before /// tiling it into the final location. /// @@ -66,7 +66,8 @@ class TiledTextureContents final : public ColorSourceContents { std::shared_ptr CreateFilterTexture( const ContentContext& renderer) const; - SamplerDescriptor CreateDescriptor(const Capabilities& capabilities) const; + SamplerDescriptor CreateSamplerDescriptor( + const Capabilities& capabilities) const; bool UsesEmulatedTileMode(const Capabilities& capabilities) const; diff --git a/impeller/entity/contents/tiled_texture_contents_unittests.cc b/impeller/entity/contents/tiled_texture_contents_unittests.cc new file mode 100644 index 0000000000000..9d12c22287c01 --- /dev/null +++ b/impeller/entity/contents/tiled_texture_contents_unittests.cc @@ -0,0 +1,85 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include + +#include "impeller/core/formats.h" +#include "impeller/core/texture_descriptor.h" +#include "impeller/entity/contents/tiled_texture_contents.h" +#include "impeller/entity/entity_playground.h" +#include "impeller/playground/playground_test.h" +#include "third_party/googletest/googletest/include/gtest/gtest.h" + +namespace impeller { +namespace testing { + +using EntityTest = EntityPlayground; +INSTANTIATE_PLAYGROUND_SUITE(EntityTest); + +TEST_P(EntityTest, TiledTextureContentsRendersWithCorrectPipeline) { + TextureDescriptor texture_desc; + texture_desc.size = {100, 100}; + texture_desc.type = TextureType::kTexture2D; + texture_desc.format = PixelFormat::kR8G8B8A8UNormInt; + texture_desc.storage_mode = StorageMode::kDevicePrivate; + auto texture = + GetContext()->GetResourceAllocator()->CreateTexture(texture_desc); + + TiledTextureContents contents; + contents.SetTexture(texture); + contents.SetGeometry(Geometry::MakeCover()); + + auto content_context = GetContentContext(); + auto buffer = content_context->GetContext()->CreateCommandBuffer(); + auto render_target = RenderTarget::CreateOffscreenMSAA( + *content_context->GetContext(), + *GetContentContext()->GetRenderTargetCache(), {100, 100}); + auto render_pass = buffer->CreateRenderPass(render_target); + + ASSERT_TRUE(contents.Render(*GetContentContext(), {}, *render_pass)); + const std::vector& commands = render_pass->GetCommands(); + + ASSERT_EQ(commands.size(), 1u); + ASSERT_STREQ(commands[0].pipeline->GetDescriptor().GetLabel().c_str(), + "TextureFill Pipeline V#1"); +} + +// GL_OES_EGL_image_external isn't supported on MacOS hosts. +#if !defined(FML_OS_MACOSX) +TEST_P(EntityTest, TiledTextureContentsRendersWithCorrectPipelineExternalOES) { + if (GetParam() != PlaygroundBackend::kOpenGLES) { + GTEST_SKIP_( + "External OES textures are only valid for the OpenGLES backend."); + } + + TextureDescriptor texture_desc; + texture_desc.size = {100, 100}; + texture_desc.type = TextureType::kTextureExternalOES; + texture_desc.format = PixelFormat::kR8G8B8A8UNormInt; + texture_desc.storage_mode = StorageMode::kDevicePrivate; + auto texture = + GetContext()->GetResourceAllocator()->CreateTexture(texture_desc); + + TiledTextureContents contents; + contents.SetTexture(texture); + contents.SetGeometry(Geometry::MakeCover()); + + auto content_context = GetContentContext(); + auto buffer = content_context->GetContext()->CreateCommandBuffer(); + auto render_target = RenderTarget::CreateOffscreenMSAA( + *content_context->GetContext(), + *GetContentContext()->GetRenderTargetCache(), {100, 100}); + auto render_pass = buffer->CreateRenderPass(render_target); + + ASSERT_TRUE(contents.Render(*GetContentContext(), {}, *render_pass)); + const std::vector& commands = render_pass->GetCommands(); + + ASSERT_EQ(commands.size(), 1u); + ASSERT_STREQ(commands[0].pipeline->GetDescriptor().GetLabel().c_str(), + "TextureFill Pipeline V#1"); +} +#endif + +} // namespace testing +} // namespace impeller diff --git a/impeller/entity/shaders/tiled_texture_fill_external.frag b/impeller/entity/shaders/tiled_texture_fill_external.frag new file mode 100644 index 0000000000000..b0ece73193b66 --- /dev/null +++ b/impeller/entity/shaders/tiled_texture_fill_external.frag @@ -0,0 +1,30 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +precision mediump float; + +#include + +uniform sampler2D SAMPLER_EXTERNAL_OES_texture_sampler; + +uniform FragInfo { + float x_tile_mode; + float y_tile_mode; +} +frag_info; + +in vec2 v_texture_coords; +in float v_alpha; + +out vec4 frag_color; + +void main() { + frag_color = + IPSampleWithTileModeOES(SAMPLER_EXTERNAL_OES_texture_sampler, // sampler + v_texture_coords, // texture coordinates + frag_info.x_tile_mode, // x tile mode + frag_info.y_tile_mode // y tile mode + ) * + v_alpha; +} diff --git a/impeller/renderer/testing/mocks.h b/impeller/renderer/testing/mocks.h index 8d50ac115c27b..b2b4ea8582860 100644 --- a/impeller/renderer/testing/mocks.h +++ b/impeller/renderer/testing/mocks.h @@ -6,10 +6,13 @@ #include "gmock/gmock.h" #include "impeller/core/allocator.h" +#include "impeller/core/sampler_descriptor.h" #include "impeller/core/texture.h" #include "impeller/renderer/command_buffer.h" #include "impeller/renderer/context.h" +#include "impeller/renderer/render_pass.h" #include "impeller/renderer/render_target.h" +#include "impeller/renderer/sampler_library.h" namespace impeller { namespace testing { @@ -85,6 +88,19 @@ class MockBlitPass : public BlitPass { (override)); }; +class MockRenderPass : public RenderPass { + public: + MockRenderPass(std::weak_ptr context, + const RenderTarget& target) + : RenderPass(std::move(context), target) {} + MOCK_METHOD(bool, IsValid, (), (const, override)); + MOCK_METHOD(bool, + OnEncodeCommands, + (const Context& context), + (const, override)); + MOCK_METHOD(void, OnSetLabel, (std::string label), (override)); +}; + class MockCommandBuffer : public CommandBuffer { public: MockCommandBuffer(std::weak_ptr context) @@ -164,5 +180,37 @@ class MockTexture : public Texture { (override)); }; +class MockCapabilities : public Capabilities { + public: + MOCK_METHOD(bool, SupportsOffscreenMSAA, (), (const, override)); + MOCK_METHOD(bool, SupportsImplicitResolvingMSAA, (), (const, override)); + MOCK_METHOD(bool, SupportsSSBO, (), (const, override)); + MOCK_METHOD(bool, SupportsBufferToTextureBlits, (), (const, override)); + MOCK_METHOD(bool, SupportsTextureToTextureBlits, (), (const, override)); + MOCK_METHOD(bool, SupportsFramebufferFetch, (), (const, override)); + MOCK_METHOD(bool, SupportsCompute, (), (const, override)); + MOCK_METHOD(bool, SupportsComputeSubgroups, (), (const, override)); + MOCK_METHOD(bool, SupportsReadFromResolve, (), (const, override)); + MOCK_METHOD(bool, SupportsDecalSamplerAddressMode, (), (const, override)); + MOCK_METHOD(bool, SupportsDeviceTransientTextures, (), (const, override)); + MOCK_METHOD(PixelFormat, GetDefaultColorFormat, (), (const, override)); + MOCK_METHOD(PixelFormat, GetDefaultStencilFormat, (), (const, override)); + MOCK_METHOD(PixelFormat, GetDefaultDepthStencilFormat, (), (const, override)); +}; + +class MockSamplerLibrary : public SamplerLibrary { + public: + MOCK_METHOD(std::shared_ptr, + GetSampler, + (SamplerDescriptor descriptor), + (override)); +}; + +class MockSampler : public Sampler { + public: + explicit MockSampler(const SamplerDescriptor& desc) : Sampler(desc) {} + MOCK_METHOD(bool, IsValid, (), (const, override)); +}; + } // namespace testing } // namespace impeller diff --git a/impeller/tools/malioc.json b/impeller/tools/malioc.json index 1aa9b4e8a8242..017ab32d7a22f 100644 --- a/impeller/tools/malioc.json +++ b/impeller/tools/malioc.json @@ -6850,6 +6850,123 @@ } } }, + "flutter/impeller/entity/gles/tiled_texture_fill_external.frag.gles": { + "Mali-G78": { + "core": "Mali-G78", + "filename": "flutter/impeller/entity/gles/tiled_texture_fill_external.frag.gles", + "has_side_effects": false, + "has_uniform_computation": true, + "modifies_coverage": false, + "reads_color_buffer": false, + "type": "Fragment", + "uses_late_zs_test": false, + "uses_late_zs_update": false, + "variants": { + "Main": { + "fp16_arithmetic": 70, + "has_stack_spilling": false, + "performance": { + "longest_path_bound_pipelines": [ + "arith_total", + "arith_cvt" + ], + "longest_path_cycles": [ + 0.421875, + 0.328125, + 0.421875, + 0.0, + 0.0, + 0.25, + 0.25 + ], + "pipelines": [ + "arith_total", + "arith_fma", + "arith_cvt", + "arith_sfu", + "load_store", + "varying", + "texture" + ], + "shortest_path_bound_pipelines": [ + "varying" + ], + "shortest_path_cycles": [ + 0.09375, + 0.03125, + 0.09375, + 0.0, + 0.0, + 0.25, + 0.0 + ], + "total_bound_pipelines": [ + "arith_total", + "arith_cvt" + ], + "total_cycles": [ + 0.515625, + 0.359375, + 0.515625, + 0.0, + 0.0, + 0.25, + 0.25 + ] + }, + "stack_spill_bytes": 0, + "thread_occupancy": 100, + "uniform_registers_used": 20, + "work_registers_used": 22 + } + } + }, + "Mali-T880": { + "core": "Mali-T880", + "filename": "flutter/impeller/entity/gles/tiled_texture_fill_external.frag.gles", + "has_uniform_computation": false, + "type": "Fragment", + "variants": { + "Main": { + "has_stack_spilling": false, + "performance": { + "longest_path_bound_pipelines": [ + "arithmetic" + ], + "longest_path_cycles": [ + 7.920000076293945, + 2.0, + 1.0 + ], + "pipelines": [ + "arithmetic", + "load_store", + "texture" + ], + "shortest_path_bound_pipelines": [ + "load_store" + ], + "shortest_path_cycles": [ + 1.3200000524520874, + 2.0, + 0.0 + ], + "total_bound_pipelines": [ + "arithmetic" + ], + "total_cycles": [ + 9.0, + 2.0, + 1.0 + ] + }, + "thread_occupancy": 100, + "uniform_registers_used": 2, + "work_registers_used": 2 + } + } + } + }, "flutter/impeller/entity/gles/vertices.frag.gles": { "Mali-G78": { "core": "Mali-G78", @@ -9746,6 +9863,78 @@ } } }, + "flutter/impeller/entity/tiled_texture_fill_external.frag.vkspv": { + "Mali-G78": { + "core": "Mali-G78", + "filename": "flutter/impeller/entity/tiled_texture_fill_external.frag.vkspv", + "has_side_effects": false, + "has_uniform_computation": true, + "modifies_coverage": false, + "reads_color_buffer": false, + "type": "Fragment", + "uses_late_zs_test": false, + "uses_late_zs_update": false, + "variants": { + "Main": { + "fp16_arithmetic": 100, + "has_stack_spilling": false, + "performance": { + "longest_path_bound_pipelines": [ + "arith_total", + "arith_cvt" + ], + "longest_path_cycles": [ + 0.328125, + 0.1875, + 0.328125, + 0.0, + 0.0, + 0.25, + 0.25 + ], + "pipelines": [ + "arith_total", + "arith_fma", + "arith_cvt", + "arith_sfu", + "load_store", + "varying", + "texture" + ], + "shortest_path_bound_pipelines": [ + "varying" + ], + "shortest_path_cycles": [ + 0.109375, + 0.03125, + 0.109375, + 0.0, + 0.0, + 0.25, + 0.0 + ], + "total_bound_pipelines": [ + "arith_total", + "arith_cvt" + ], + "total_cycles": [ + 0.390625, + 0.21875, + 0.390625, + 0.0, + 0.0, + 0.25, + 0.25 + ] + }, + "stack_spill_bytes": 0, + "thread_occupancy": 100, + "uniform_registers_used": 6, + "work_registers_used": 7 + } + } + } + }, "flutter/impeller/entity/uv.comp.vkspv": { "Mali-G78": { "core": "Mali-G78",