[Impeller] organize texture shaders / delete blend.frag + external_texture_fill (flutter/engine#52137)
* Deletes blend.frag/vert . This was identical to the existing texture_fill shader. * Move alpha to frag info and stop passing as varying. ~~* Deletes strict src rect fragment shader. We should be able to compute the UVs on the CPU, which is trivial since this is only used for rectangular draws.~~ * Deletes external texture fill in favor of tiled texture external fill. The former shader is marginally faster, but we don't use it since we don't correctly check for the right extensions needed for non-emulated sampling modes with external textures on GLES. Easier to just always use emulated tile modes
This commit is contained in:
@@ -40372,8 +40372,6 @@ ORIGIN: ../../../flutter/impeller/entity/render_target_cache.cc + ../../../flutt
|
||||
ORIGIN: ../../../flutter/impeller/entity/render_target_cache.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/blending/advanced_blend.frag + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/blending/advanced_blend.vert + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/blending/blend.frag + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/blending/blend.vert + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/blending/blend_select.glsl + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/blending/framebuffer_blend.frag + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/blending/framebuffer_blend.vert + ../../../flutter/LICENSE
|
||||
@@ -40418,7 +40416,6 @@ ORIGIN: ../../../flutter/impeller/entity/shaders/solid_fill.frag + ../../../flut
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/solid_fill.vert + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/texture_fill.frag + ../../../flutter/LICENSE
|
||||
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/texture_fill_strict_src.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
|
||||
@@ -43255,8 +43252,6 @@ FILE: ../../../flutter/impeller/entity/render_target_cache.cc
|
||||
FILE: ../../../flutter/impeller/entity/render_target_cache.h
|
||||
FILE: ../../../flutter/impeller/entity/shaders/blending/advanced_blend.frag
|
||||
FILE: ../../../flutter/impeller/entity/shaders/blending/advanced_blend.vert
|
||||
FILE: ../../../flutter/impeller/entity/shaders/blending/blend.frag
|
||||
FILE: ../../../flutter/impeller/entity/shaders/blending/blend.vert
|
||||
FILE: ../../../flutter/impeller/entity/shaders/blending/blend_select.glsl
|
||||
FILE: ../../../flutter/impeller/entity/shaders/blending/framebuffer_blend.frag
|
||||
FILE: ../../../flutter/impeller/entity/shaders/blending/framebuffer_blend.vert
|
||||
@@ -43301,7 +43296,6 @@ FILE: ../../../flutter/impeller/entity/shaders/solid_fill.frag
|
||||
FILE: ../../../flutter/impeller/entity/shaders/solid_fill.vert
|
||||
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/texture_fill_strict_src.frag
|
||||
FILE: ../../../flutter/impeller/entity/shaders/tiled_texture_fill.frag
|
||||
FILE: ../../../flutter/impeller/entity/shaders/tiled_texture_fill_external.frag
|
||||
|
||||
@@ -16,8 +16,6 @@ impeller_shaders("entity_shaders") {
|
||||
shaders = [
|
||||
"shaders/blending/advanced_blend.vert",
|
||||
"shaders/blending/advanced_blend.frag",
|
||||
"shaders/blending/blend.frag",
|
||||
"shaders/blending/blend.vert",
|
||||
"shaders/border_mask_blur.frag",
|
||||
"shaders/border_mask_blur.vert",
|
||||
"shaders/clip.frag",
|
||||
@@ -41,10 +39,9 @@ impeller_shaders("entity_shaders") {
|
||||
"shaders/gradients/sweep_gradient_fill.frag",
|
||||
"shaders/texture_fill.frag",
|
||||
"shaders/texture_fill.vert",
|
||||
"shaders/texture_fill_external.frag",
|
||||
"shaders/texture_fill_strict_src.frag",
|
||||
"shaders/tiled_texture_fill.frag",
|
||||
"shaders/tiled_texture_fill_external.frag",
|
||||
"shaders/texture_fill_strict_src.frag",
|
||||
"shaders/vertices.frag",
|
||||
"shaders/blending/porter_duff_blend.frag",
|
||||
"shaders/blending/porter_duff_blend.vert",
|
||||
|
||||
@@ -405,12 +405,16 @@ bool AtlasTextureContents::Render(const ContentContext& renderer,
|
||||
VS::FrameInfo frame_info;
|
||||
frame_info.mvp = entity.GetShaderTransform(pass);
|
||||
frame_info.texture_sampler_y_coord_scale = texture->GetYCoordScale();
|
||||
frame_info.alpha = alpha_;
|
||||
|
||||
auto options = OptionsFromPassAndEntity(pass, entity);
|
||||
pass.SetPipeline(renderer.GetTexturePipeline(options));
|
||||
pass.SetVertexBuffer(vertex_builder.CreateVertexBuffer(host_buffer));
|
||||
VS::BindFrameInfo(pass, host_buffer.EmplaceUniform(frame_info));
|
||||
|
||||
FS::FragInfo frag_info;
|
||||
frag_info.alpha = alpha_;
|
||||
|
||||
FS::BindFragInfo(pass, host_buffer.EmplaceUniform(frag_info));
|
||||
FS::BindTextureSampler(pass, texture,
|
||||
renderer.GetContext()->GetSamplerLibrary()->GetSampler(
|
||||
parent_.GetSamplerDescriptor()));
|
||||
|
||||
@@ -421,7 +421,6 @@ ContentContext::ContentContext(
|
||||
{static_cast<Scalar>(BlendSelectValues::kSoftLight), supports_decal});
|
||||
|
||||
rrect_blur_pipelines_.CreateDefault(*context_, options_trianglestrip);
|
||||
texture_blend_pipelines_.CreateDefault(*context_, options);
|
||||
texture_strict_src_pipelines_.CreateDefault(*context_, options);
|
||||
position_uv_pipelines_.CreateDefault(*context_, options);
|
||||
tiled_texture_pipelines_.CreateDefault(*context_, options);
|
||||
@@ -448,9 +447,6 @@ ContentContext::ContentContext(
|
||||
{supports_decal});
|
||||
// GLES only shader that is unsupported on macOS.
|
||||
#if defined(IMPELLER_ENABLE_OPENGLES) && !defined(FML_OS_MACOSX)
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -29,8 +29,6 @@
|
||||
#include "impeller/entity/checkerboard.vert.h"
|
||||
#endif // IMPELLER_DEBUG
|
||||
|
||||
#include "impeller/entity/blend.frag.h"
|
||||
#include "impeller/entity/blend.vert.h"
|
||||
#include "impeller/entity/border_mask_blur.frag.h"
|
||||
#include "impeller/entity/border_mask_blur.vert.h"
|
||||
#include "impeller/entity/clip.frag.h"
|
||||
@@ -84,7 +82,6 @@
|
||||
#include "impeller/entity/framebuffer_blend.vert.h"
|
||||
|
||||
#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
|
||||
|
||||
@@ -127,8 +124,6 @@ using SweepGradientSSBOFillPipeline =
|
||||
SweepGradientSsboFillFragmentShader>;
|
||||
using RRectBlurPipeline =
|
||||
RenderPipelineHandle<RrectBlurVertexShader, RrectBlurFragmentShader>;
|
||||
using BlendPipeline =
|
||||
RenderPipelineHandle<BlendVertexShader, BlendFragmentShader>;
|
||||
using TexturePipeline =
|
||||
RenderPipelineHandle<TextureFillVertexShader, TextureFillFragmentShader>;
|
||||
using TextureStrictSrcPipeline =
|
||||
@@ -261,10 +256,6 @@ using PointsComputeShaderPipeline = ComputePipelineBuilder<PointsComputeShader>;
|
||||
using UvComputeShaderPipeline = ComputePipelineBuilder<UvComputeShader>;
|
||||
|
||||
#ifdef IMPELLER_ENABLE_OPENGLES
|
||||
using TextureExternalPipeline =
|
||||
RenderPipelineHandle<TextureFillVertexShader,
|
||||
TextureFillExternalFragmentShader>;
|
||||
|
||||
using TiledTextureExternalPipeline =
|
||||
RenderPipelineHandle<TextureFillVertexShader,
|
||||
TiledTextureFillExternalFragmentShader>;
|
||||
@@ -468,11 +459,6 @@ class ContentContext {
|
||||
return GetPipeline(solid_fill_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendPipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(texture_blend_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetTexturePipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(texture_pipelines_, opts);
|
||||
@@ -484,13 +470,6 @@ class ContentContext {
|
||||
}
|
||||
|
||||
#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);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetTiledTextureExternalPipeline(
|
||||
ContentContextOptions opts) const {
|
||||
FML_DCHECK(GetContext()->GetBackendType() ==
|
||||
@@ -947,11 +926,9 @@ class ContentContext {
|
||||
mutable Variants<SweepGradientSSBOFillPipeline>
|
||||
sweep_gradient_ssbo_fill_pipelines_;
|
||||
mutable Variants<RRectBlurPipeline> rrect_blur_pipelines_;
|
||||
mutable Variants<BlendPipeline> texture_blend_pipelines_;
|
||||
mutable Variants<TexturePipeline> texture_pipelines_;
|
||||
mutable Variants<TextureStrictSrcPipeline> texture_strict_src_pipelines_;
|
||||
#ifdef IMPELLER_ENABLE_OPENGLES
|
||||
mutable Variants<TextureExternalPipeline> texture_external_pipelines_;
|
||||
mutable Variants<TiledTextureExternalPipeline>
|
||||
tiled_texture_external_pipelines_;
|
||||
#endif // IMPELLER_ENABLE_OPENGLES
|
||||
|
||||
@@ -505,8 +505,8 @@ static std::optional<Entity> PipelineBlend(
|
||||
std::optional<Color> foreground_color,
|
||||
ColorFilterContents::AbsorbOpacity absorb_opacity,
|
||||
std::optional<Scalar> alpha) {
|
||||
using VS = BlendPipeline::VertexShader;
|
||||
using FS = BlendPipeline::FragmentShader;
|
||||
using VS = TexturePipeline::VertexShader;
|
||||
using FS = TexturePipeline::FragmentShader;
|
||||
|
||||
auto dst_snapshot =
|
||||
inputs[0]->GetSnapshot("PipelineBlend(Dst)", renderer, entity);
|
||||
@@ -552,7 +552,7 @@ static std::optional<Entity> PipelineBlend(
|
||||
const std::unique_ptr<const Sampler>& sampler =
|
||||
renderer.GetContext()->GetSamplerLibrary()->GetSampler(
|
||||
input->sampler_descriptor);
|
||||
FS::BindTextureSamplerSrc(pass, input->texture, sampler);
|
||||
FS::BindTextureSampler(pass, input->texture, sampler);
|
||||
|
||||
auto size = input->texture->GetSize();
|
||||
VertexBufferBuilder<VS::PerVertexData> vtx_builder;
|
||||
@@ -572,7 +572,7 @@ static std::optional<Entity> PipelineBlend(
|
||||
input->texture->GetYCoordScale();
|
||||
|
||||
FS::FragInfo frag_info;
|
||||
frag_info.input_alpha =
|
||||
frag_info.alpha =
|
||||
absorb_opacity == ColorFilterContents::AbsorbOpacity::kYes
|
||||
? input->opacity
|
||||
: 1.0;
|
||||
@@ -584,7 +584,7 @@ static std::optional<Entity> PipelineBlend(
|
||||
|
||||
// Draw the first texture using kSource.
|
||||
options.blend_mode = BlendMode::kSource;
|
||||
pass.SetPipeline(renderer.GetBlendPipeline(options));
|
||||
pass.SetPipeline(renderer.GetTexturePipeline(options));
|
||||
if (!add_blend_command(dst_snapshot)) {
|
||||
return true;
|
||||
}
|
||||
@@ -593,7 +593,7 @@ static std::optional<Entity> PipelineBlend(
|
||||
|
||||
if (inputs.size() >= 2) {
|
||||
options.blend_mode = blend_mode;
|
||||
pass.SetPipeline(renderer.GetBlendPipeline(options));
|
||||
pass.SetPipeline(renderer.GetTexturePipeline(options));
|
||||
|
||||
for (auto texture_i = inputs.begin() + 1; texture_i < inputs.end();
|
||||
texture_i++) {
|
||||
|
||||
@@ -95,7 +95,9 @@ fml::StatusOr<RenderTarget> MakeDownsampleSubpass(
|
||||
TextureFillVertexShader::FrameInfo frame_info;
|
||||
frame_info.mvp = Matrix::MakeOrthographic(ISize(1, 1));
|
||||
frame_info.texture_sampler_y_coord_scale = 1.0;
|
||||
frame_info.alpha = 1.0;
|
||||
|
||||
TextureFillFragmentShader::FragInfo frag_info;
|
||||
frag_info.alpha = 1.0;
|
||||
|
||||
BindVertices<TextureFillVertexShader>(pass, host_buffer,
|
||||
{
|
||||
@@ -111,6 +113,8 @@ fml::StatusOr<RenderTarget> MakeDownsampleSubpass(
|
||||
linear_sampler_descriptor.min_filter = MinMagFilter::kLinear;
|
||||
TextureFillVertexShader::BindFrameInfo(
|
||||
pass, host_buffer.EmplaceUniform(frame_info));
|
||||
TextureFillFragmentShader::BindFragInfo(
|
||||
pass, host_buffer.EmplaceUniform(frag_info));
|
||||
TextureFillFragmentShader::BindTextureSampler(
|
||||
pass, input_texture,
|
||||
renderer.GetContext()->GetSamplerLibrary()->GetSampler(
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
#include "impeller/entity/entity.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/texture_fill_strict_src.frag.h"
|
||||
#include "impeller/entity/tiled_texture_fill_external.frag.h"
|
||||
#include "impeller/geometry/constants.h"
|
||||
#include "impeller/renderer/render_pass.h"
|
||||
#include "impeller/renderer/vertex_buffer_builder.h"
|
||||
@@ -113,8 +114,8 @@ bool TextureContents::Render(const ContentContext& renderer,
|
||||
|
||||
using VS = TextureFillVertexShader;
|
||||
using FS = TextureFillFragmentShader;
|
||||
using FSStrictSrc = TextureFillStrictSrcFragmentShader;
|
||||
using FSExternal = TextureFillExternalFragmentShader;
|
||||
using FSExternal = TiledTextureFillExternalFragmentShader;
|
||||
using FSStrict = TextureFillStrictSrcFragmentShader;
|
||||
|
||||
if (destination_rect_.IsEmpty() || source_rect_.IsEmpty() ||
|
||||
texture_ == nullptr || texture_->GetSize().IsEmpty()) {
|
||||
@@ -129,7 +130,6 @@ bool TextureContents::Render(const ContentContext& renderer,
|
||||
Rect::MakeSize(texture_->GetSize()).Project(source_rect);
|
||||
|
||||
VertexBufferBuilder<VS::PerVertexData> vertex_builder;
|
||||
|
||||
auto destination_rect =
|
||||
capture.AddRect("Destination rect", destination_rect_);
|
||||
vertex_builder.AddVertices({
|
||||
@@ -144,7 +144,6 @@ bool TextureContents::Render(const ContentContext& renderer,
|
||||
VS::FrameInfo frame_info;
|
||||
frame_info.mvp = entity.GetShaderTransform(pass);
|
||||
frame_info.texture_sampler_y_coord_scale = texture_->GetYCoordScale();
|
||||
frame_info.alpha = capture.AddScalar("Alpha", GetOpacity());
|
||||
|
||||
#ifdef IMPELLER_DEBUG
|
||||
if (label_.empty()) {
|
||||
@@ -163,7 +162,7 @@ bool TextureContents::Render(const ContentContext& renderer,
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> pipeline;
|
||||
#ifdef IMPELLER_ENABLE_OPENGLES
|
||||
if (is_external_texture) {
|
||||
pipeline = renderer.GetTextureExternalPipeline(pipeline_options);
|
||||
pipeline = renderer.GetTiledTextureExternalPipeline(pipeline_options);
|
||||
}
|
||||
#endif // IMPELLER_ENABLE_OPENGLES
|
||||
|
||||
@@ -178,11 +177,27 @@ bool TextureContents::Render(const ContentContext& renderer,
|
||||
|
||||
pass.SetVertexBuffer(vertex_builder.CreateVertexBuffer(host_buffer));
|
||||
VS::BindFrameInfo(pass, host_buffer.EmplaceUniform(frame_info));
|
||||
|
||||
if (is_external_texture) {
|
||||
FSExternal::FragInfo frag_info;
|
||||
frag_info.x_tile_mode =
|
||||
static_cast<int>(sampler_descriptor_.width_address_mode);
|
||||
frag_info.y_tile_mode =
|
||||
static_cast<int>(sampler_descriptor_.height_address_mode);
|
||||
frag_info.alpha = capture.AddScalar("Alpha", GetOpacity());
|
||||
|
||||
auto sampler_descriptor = sampler_descriptor_;
|
||||
// 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_descriptor.width_address_mode = SamplerAddressMode::kClampToEdge;
|
||||
sampler_descriptor.height_address_mode = SamplerAddressMode::kClampToEdge;
|
||||
|
||||
FSExternal::BindFragInfo(pass, host_buffer.EmplaceUniform((frag_info)));
|
||||
FSExternal::BindSAMPLEREXTERNALOESTextureSampler(
|
||||
pass, texture_,
|
||||
renderer.GetContext()->GetSamplerLibrary()->GetSampler(
|
||||
sampler_descriptor_));
|
||||
sampler_descriptor));
|
||||
} else if (strict_source_rect_enabled_) {
|
||||
// For a strict source rect, shrink the texture coordinate range by half a
|
||||
// texel to ensure that linear filtering does not sample anything outside
|
||||
@@ -190,14 +205,18 @@ bool TextureContents::Render(const ContentContext& renderer,
|
||||
auto strict_texture_coords =
|
||||
Rect::MakeSize(texture_->GetSize()).Project(source_rect.Expand(-0.5));
|
||||
|
||||
FSStrictSrc::FragInfo frag_info;
|
||||
FSStrict::FragInfo frag_info;
|
||||
frag_info.source_rect = Vector4(strict_texture_coords.GetLTRB());
|
||||
FSStrictSrc::BindFragInfo(pass, host_buffer.EmplaceUniform(frag_info));
|
||||
FSStrictSrc::BindTextureSampler(
|
||||
frag_info.alpha = capture.AddScalar("Alpha", GetOpacity());
|
||||
FSStrict::BindFragInfo(pass, host_buffer.EmplaceUniform((frag_info)));
|
||||
FSStrict::BindTextureSampler(
|
||||
pass, texture_,
|
||||
renderer.GetContext()->GetSamplerLibrary()->GetSampler(
|
||||
sampler_descriptor_));
|
||||
} else {
|
||||
FS::FragInfo frag_info;
|
||||
frag_info.alpha = capture.AddScalar("Alpha", GetOpacity());
|
||||
FS::BindFragInfo(pass, host_buffer.EmplaceUniform((frag_info)));
|
||||
FS::BindTextureSampler(
|
||||
pass, texture_,
|
||||
renderer.GetContext()->GetSamplerLibrary()->GetSampler(
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "fml/logging.h"
|
||||
#include "impeller/entity/contents/content_context.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"
|
||||
@@ -132,7 +133,6 @@ bool TiledTextureContents::Render(const ContentContext& renderer,
|
||||
|
||||
VS::FrameInfo frame_info;
|
||||
frame_info.texture_sampler_y_coord_scale = texture_->GetYCoordScale();
|
||||
frame_info.alpha = GetOpacityFactor();
|
||||
|
||||
PipelineBuilderMethod pipeline_method;
|
||||
|
||||
@@ -170,12 +170,19 @@ bool TiledTextureContents::Render(const ContentContext& renderer,
|
||||
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_);
|
||||
frag_info.alpha = GetOpacityFactor();
|
||||
FSExternal::BindFragInfo(pass, 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_);
|
||||
frag_info.alpha = GetOpacityFactor();
|
||||
FS::BindFragInfo(pass, host_buffer.EmplaceUniform(frag_info));
|
||||
} else {
|
||||
TextureFillFragmentShader::FragInfo frag_info;
|
||||
frag_info.alpha = GetOpacityFactor();
|
||||
TextureFillFragmentShader::BindFragInfo(
|
||||
pass, host_buffer.EmplaceUniform(frag_info));
|
||||
}
|
||||
|
||||
if (is_external_texture) {
|
||||
|
||||
@@ -169,9 +169,11 @@ bool VerticesUVContents::Render(const ContentContext& renderer,
|
||||
frame_info.mvp = geometry_result.transform;
|
||||
frame_info.texture_sampler_y_coord_scale =
|
||||
snapshot->texture->GetYCoordScale();
|
||||
frame_info.alpha = alpha_ * snapshot->opacity;
|
||||
VS::BindFrameInfo(pass, host_buffer.EmplaceUniform(frame_info));
|
||||
|
||||
FS::FragInfo frag_info;
|
||||
frag_info.alpha = alpha_ * snapshot->opacity;
|
||||
FS::BindFragInfo(pass, host_buffer.EmplaceUniform(frag_info));
|
||||
FS::BindTextureSampler(pass, snapshot->texture,
|
||||
renderer.GetContext()->GetSamplerLibrary()->GetSampler(
|
||||
snapshot->sampler_descriptor));
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
// 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/texture.glsl>
|
||||
#include <impeller/types.glsl>
|
||||
|
||||
uniform f16sampler2D texture_sampler_src;
|
||||
|
||||
uniform FragInfo {
|
||||
float16_t input_alpha;
|
||||
}
|
||||
frag_info;
|
||||
|
||||
in vec2 v_texture_coords;
|
||||
|
||||
out f16vec4 frag_color;
|
||||
|
||||
void main() {
|
||||
frag_color =
|
||||
texture(texture_sampler_src, v_texture_coords) * frag_info.input_alpha;
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
// 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/conversions.glsl>
|
||||
#include <impeller/types.glsl>
|
||||
|
||||
uniform FrameInfo {
|
||||
mat4 mvp;
|
||||
float texture_sampler_y_coord_scale;
|
||||
}
|
||||
frame_info;
|
||||
|
||||
in vec2 vertices;
|
||||
in vec2 texture_coords;
|
||||
|
||||
out vec2 v_texture_coords;
|
||||
|
||||
void main() {
|
||||
gl_Position = frame_info.mvp * vec4(vertices, 0.0, 1.0);
|
||||
v_texture_coords =
|
||||
IPRemapCoords(texture_coords, frame_info.texture_sampler_y_coord_scale);
|
||||
}
|
||||
@@ -9,13 +9,17 @@ precision mediump float;
|
||||
|
||||
uniform f16sampler2D texture_sampler;
|
||||
|
||||
uniform FragInfo {
|
||||
float alpha;
|
||||
}
|
||||
frag_info;
|
||||
|
||||
in highp vec2 v_texture_coords;
|
||||
IMPELLER_MAYBE_FLAT in float16_t v_alpha;
|
||||
|
||||
out f16vec4 frag_color;
|
||||
|
||||
void main() {
|
||||
f16vec4 sampled =
|
||||
texture(texture_sampler, v_texture_coords, float16_t(kDefaultMipBias));
|
||||
frag_color = sampled * v_alpha;
|
||||
frag_color = sampled * float16_t(frag_info.alpha);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
uniform FrameInfo {
|
||||
mat4 mvp;
|
||||
float texture_sampler_y_coord_scale;
|
||||
float16_t alpha;
|
||||
}
|
||||
frame_info;
|
||||
|
||||
@@ -16,11 +15,9 @@ in vec2 position;
|
||||
in vec2 texture_coords;
|
||||
|
||||
out vec2 v_texture_coords;
|
||||
IMPELLER_MAYBE_FLAT out mediump float16_t v_alpha;
|
||||
|
||||
void main() {
|
||||
gl_Position = frame_info.mvp * vec4(position, 0.0, 1.0);
|
||||
v_alpha = frame_info.alpha;
|
||||
v_texture_coords =
|
||||
IPRemapCoords(texture_coords, frame_info.texture_sampler_y_coord_scale);
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
// 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.
|
||||
|
||||
uniform sampler2D SAMPLER_EXTERNAL_OES_texture_sampler;
|
||||
|
||||
in vec2 v_texture_coords;
|
||||
in float v_alpha;
|
||||
|
||||
out vec4 frag_color;
|
||||
|
||||
void main() {
|
||||
vec4 sampled =
|
||||
texture(SAMPLER_EXTERNAL_OES_texture_sampler, v_texture_coords);
|
||||
frag_color = sampled * v_alpha;
|
||||
}
|
||||
@@ -11,11 +11,11 @@ uniform f16sampler2D texture_sampler;
|
||||
|
||||
uniform FragInfo {
|
||||
vec4 source_rect;
|
||||
float alpha;
|
||||
}
|
||||
frag_info;
|
||||
|
||||
in highp vec2 v_texture_coords;
|
||||
IMPELLER_MAYBE_FLAT in float16_t v_alpha;
|
||||
|
||||
out f16vec4 frag_color;
|
||||
|
||||
@@ -26,5 +26,5 @@ void main() {
|
||||
frag_info.source_rect.w));
|
||||
f16vec4 sampled =
|
||||
texture(texture_sampler, texture_coords, float16_t(kDefaultMipBias));
|
||||
frag_color = sampled * v_alpha;
|
||||
frag_color = sampled * float16_t(frag_info.alpha);
|
||||
}
|
||||
|
||||
@@ -10,22 +10,22 @@ precision mediump float;
|
||||
uniform f16sampler2D texture_sampler;
|
||||
|
||||
uniform FragInfo {
|
||||
float16_t x_tile_mode;
|
||||
float16_t y_tile_mode;
|
||||
float x_tile_mode;
|
||||
float y_tile_mode;
|
||||
float alpha;
|
||||
}
|
||||
frag_info;
|
||||
|
||||
in highp vec2 v_texture_coords;
|
||||
IMPELLER_MAYBE_FLAT in float16_t v_alpha;
|
||||
|
||||
out f16vec4 frag_color;
|
||||
|
||||
void main() {
|
||||
frag_color =
|
||||
IPHalfSampleWithTileMode(texture_sampler, // sampler
|
||||
v_texture_coords, // texture coordinates
|
||||
frag_info.x_tile_mode, // x tile mode
|
||||
frag_info.y_tile_mode // y tile mode
|
||||
IPHalfSampleWithTileMode(texture_sampler, // sampler
|
||||
v_texture_coords, // texture coordinates
|
||||
float16_t(frag_info.x_tile_mode), // x tile mode
|
||||
float16_t(frag_info.y_tile_mode) // y tile mode
|
||||
) *
|
||||
v_alpha;
|
||||
float16_t(frag_info.alpha);
|
||||
}
|
||||
|
||||
@@ -11,11 +11,11 @@ uniform sampler2D SAMPLER_EXTERNAL_OES_texture_sampler;
|
||||
uniform FragInfo {
|
||||
float x_tile_mode;
|
||||
float y_tile_mode;
|
||||
float alpha;
|
||||
}
|
||||
frag_info;
|
||||
|
||||
in vec2 v_texture_coords;
|
||||
in float v_alpha;
|
||||
|
||||
out vec4 frag_color;
|
||||
|
||||
@@ -26,5 +26,5 @@ void main() {
|
||||
frag_info.x_tile_mode, // x tile mode
|
||||
frag_info.y_tile_mode // y tile mode
|
||||
) *
|
||||
v_alpha;
|
||||
frag_info.alpha;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user