[Impeller] Add support for external GL textures to TiledTextureContents. (flutter/engine#47586)
This commit is contained in:
@@ -143,6 +143,7 @@
|
||||
../../../flutter/impeller/entity/contents/filters/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
|
||||
|
||||
@@ -2965,11 +2965,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
|
||||
@@ -3193,6 +3195,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
|
||||
@@ -5734,11 +5737,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
|
||||
@@ -5962,6 +5967,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
|
||||
|
||||
@@ -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",
|
||||
]
|
||||
|
||||
@@ -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 <impeller/tile_mode.glsl>
|
||||
|
||||
/// 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);
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <impeller/branching.glsl>
|
||||
#include <impeller/conversions.glsl>
|
||||
#include <impeller/tile_mode.glsl>
|
||||
#include <impeller/types.glsl>
|
||||
|
||||
/// 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
|
||||
|
||||
@@ -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;
|
||||
@@ -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",
|
||||
@@ -259,6 +260,7 @@ impeller_component("entity_unittests") {
|
||||
"contents/filters/directional_gaussian_blur_filter_contents_unittests.cc",
|
||||
"contents/filters/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",
|
||||
|
||||
@@ -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 =
|
||||
|
||||
@@ -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<UvComputeShader>;
|
||||
#ifdef IMPELLER_ENABLE_OPENGLES
|
||||
using TextureExternalPipeline =
|
||||
RenderPipelineT<TextureFillVertexShader, TextureFillExternalFragmentShader>;
|
||||
|
||||
using TiledTextureExternalPipeline =
|
||||
RenderPipelineT<TextureFillVertexShader,
|
||||
TiledTextureFillExternalFragmentShader>;
|
||||
#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<Pipeline<PipelineDescriptor>> 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<Pipeline<PipelineDescriptor>> GetPositionUVPipeline(
|
||||
@@ -768,6 +780,8 @@ class ContentContext {
|
||||
mutable Variants<TexturePipeline> texture_pipelines_;
|
||||
#ifdef IMPELLER_ENABLE_OPENGLES
|
||||
mutable Variants<TextureExternalPipeline> texture_external_pipelines_;
|
||||
mutable Variants<TiledTextureExternalPipeline>
|
||||
tiled_texture_external_pipelines_;
|
||||
#endif // IMPELLER_ENABLE_OPENGLES
|
||||
mutable Variants<PositionUVPipeline> position_uv_pipelines_;
|
||||
mutable Variants<TiledTexturePipeline> tiled_texture_pipelines_;
|
||||
|
||||
@@ -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<Texture> 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<Scalar>(x_tile_mode_);
|
||||
frag_info.y_tile_mode = static_cast<Scalar>(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<Scalar>(x_tile_mode_);
|
||||
frag_info.y_tile_mode = static_cast<Scalar>(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))) {
|
||||
|
||||
@@ -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<Texture> CreateFilterTexture(
|
||||
const ContentContext& renderer) const;
|
||||
|
||||
SamplerDescriptor CreateDescriptor(const Capabilities& capabilities) const;
|
||||
SamplerDescriptor CreateSamplerDescriptor(
|
||||
const Capabilities& capabilities) const;
|
||||
|
||||
bool UsesEmulatedTileMode(const Capabilities& capabilities) const;
|
||||
|
||||
|
||||
@@ -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 <memory>
|
||||
|
||||
#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<Command>& 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<Command>& 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
|
||||
@@ -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 <impeller/external_texture_oes.glsl>
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -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<const Context> 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<const Context> 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<const Sampler>,
|
||||
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
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user