[Impeller] use spec constant for gaussian shader, rename, and reuse vertex sources. (flutter/engine#52361)

Reduces shader count slightly, and reduces duplication of source code for vertex stages that are identical.

Part of https://github.com/flutter/flutter/issues/143540
This commit is contained in:
Jonah Williams
2024-04-24 12:31:46 -07:00
committed by GitHub
parent 6dca56fb0e
commit 5360ab3084
17 changed files with 529 additions and 1645 deletions

View File

@@ -40378,24 +40378,19 @@ ORIGIN: ../../../flutter/impeller/entity/shaders/blending/framebuffer_blend.vert
ORIGIN: ../../../flutter/impeller/entity/shaders/blending/porter_duff_blend.frag + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/entity/shaders/blending/porter_duff_blend.vert + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/entity/shaders/blending/vertices_uber.frag + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/entity/shaders/blending/vertices_uber.vert + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/entity/shaders/border_mask_blur.frag + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/entity/shaders/border_mask_blur.vert + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/entity/shaders/clip.frag + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/entity/shaders/clip.vert + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/entity/shaders/debug/checkerboard.frag + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/entity/shaders/debug/checkerboard.vert + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/entity/shaders/filters/border_mask_blur.frag + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/entity/shaders/filters/color_matrix_color_filter.frag + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/entity/shaders/filters/filter.vert + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/entity/shaders/filters/filter_position.vert + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/entity/shaders/filters/filter_position_uv.vert + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/entity/shaders/filters/gaussian.frag + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/entity/shaders/filters/linear_to_srgb_filter.frag + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/entity/shaders/filters/morphology_filter.frag + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/entity/shaders/filters/morphology_filter.vert + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/entity/shaders/filters/srgb_to_linear_filter.frag + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/entity/shaders/filters/yuv_to_rgb_filter.frag + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/entity/shaders/gaussian_blur/kernel.glsl + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/entity/shaders/gaussian_blur/kernel.vert + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/entity/shaders/gaussian_blur/kernel_decal.frag + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/entity/shaders/gaussian_blur/kernel_nodecal.frag + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/entity/shaders/glyph_atlas.frag + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/entity/shaders/glyph_atlas.vert + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/entity/shaders/glyph_atlas_color.frag + ../../../flutter/LICENSE
@@ -43259,24 +43254,19 @@ FILE: ../../../flutter/impeller/entity/shaders/blending/framebuffer_blend.vert
FILE: ../../../flutter/impeller/entity/shaders/blending/porter_duff_blend.frag
FILE: ../../../flutter/impeller/entity/shaders/blending/porter_duff_blend.vert
FILE: ../../../flutter/impeller/entity/shaders/blending/vertices_uber.frag
FILE: ../../../flutter/impeller/entity/shaders/blending/vertices_uber.vert
FILE: ../../../flutter/impeller/entity/shaders/border_mask_blur.frag
FILE: ../../../flutter/impeller/entity/shaders/border_mask_blur.vert
FILE: ../../../flutter/impeller/entity/shaders/clip.frag
FILE: ../../../flutter/impeller/entity/shaders/clip.vert
FILE: ../../../flutter/impeller/entity/shaders/debug/checkerboard.frag
FILE: ../../../flutter/impeller/entity/shaders/debug/checkerboard.vert
FILE: ../../../flutter/impeller/entity/shaders/filters/border_mask_blur.frag
FILE: ../../../flutter/impeller/entity/shaders/filters/color_matrix_color_filter.frag
FILE: ../../../flutter/impeller/entity/shaders/filters/filter.vert
FILE: ../../../flutter/impeller/entity/shaders/filters/filter_position.vert
FILE: ../../../flutter/impeller/entity/shaders/filters/filter_position_uv.vert
FILE: ../../../flutter/impeller/entity/shaders/filters/gaussian.frag
FILE: ../../../flutter/impeller/entity/shaders/filters/linear_to_srgb_filter.frag
FILE: ../../../flutter/impeller/entity/shaders/filters/morphology_filter.frag
FILE: ../../../flutter/impeller/entity/shaders/filters/morphology_filter.vert
FILE: ../../../flutter/impeller/entity/shaders/filters/srgb_to_linear_filter.frag
FILE: ../../../flutter/impeller/entity/shaders/filters/yuv_to_rgb_filter.frag
FILE: ../../../flutter/impeller/entity/shaders/gaussian_blur/kernel.glsl
FILE: ../../../flutter/impeller/entity/shaders/gaussian_blur/kernel.vert
FILE: ../../../flutter/impeller/entity/shaders/gaussian_blur/kernel_decal.frag
FILE: ../../../flutter/impeller/entity/shaders/gaussian_blur/kernel_nodecal.frag
FILE: ../../../flutter/impeller/entity/shaders/glyph_atlas.frag
FILE: ../../../flutter/impeller/entity/shaders/glyph_atlas.vert
FILE: ../../../flutter/impeller/entity/shaders/glyph_atlas_color.frag

View File

@@ -16,14 +16,9 @@ impeller_shaders("entity_shaders") {
shaders = [
"shaders/blending/advanced_blend.vert",
"shaders/blending/advanced_blend.frag",
"shaders/border_mask_blur.frag",
"shaders/border_mask_blur.vert",
"shaders/clip.frag",
"shaders/clip.vert",
"shaders/gradients/conical_gradient_fill.frag",
"shaders/gaussian_blur/kernel_decal.frag",
"shaders/gaussian_blur/kernel_nodecal.frag",
"shaders/gaussian_blur/kernel.vert",
"shaders/glyph_atlas.frag",
"shaders/glyph_atlas_color.frag",
"shaders/glyph_atlas.vert",
@@ -46,15 +41,16 @@ impeller_shaders("entity_shaders") {
"shaders/vertices.frag",
"shaders/blending/porter_duff_blend.frag",
"shaders/blending/porter_duff_blend.vert",
"shaders/filters/border_mask_blur.frag",
"shaders/filters/color_matrix_color_filter.frag",
"shaders/filters/filter.vert",
"shaders/filters/filter_position.vert",
"shaders/filters/filter_position_uv.vert",
"shaders/filters/gaussian.frag",
"shaders/filters/yuv_to_rgb_filter.frag",
"shaders/filters/srgb_to_linear_filter.frag",
"shaders/filters/linear_to_srgb_filter.frag",
"shaders/filters/morphology_filter.frag",
"shaders/filters/morphology_filter.vert",
"shaders/blending/vertices_uber.frag",
"shaders/blending/vertices_uber.vert",
]
if (impeller_debug) {

View File

@@ -422,8 +422,8 @@ ContentContext::ContentContext(
rrect_blur_pipelines_.CreateDefault(*context_, options_trianglestrip);
texture_strict_src_pipelines_.CreateDefault(*context_, options);
tiled_texture_pipelines_.CreateDefault(*context_, options, {supports_decal});
kernel_decal_pipelines_.CreateDefault(*context_, options_trianglestrip);
kernel_nodecal_pipelines_.CreateDefault(*context_, options_trianglestrip);
gaussian_blur_pipelines_.CreateDefault(*context_, options_trianglestrip,
{supports_decal});
border_mask_blur_pipelines_.CreateDefault(*context_, options_trianglestrip);
morphology_filter_pipelines_.CreateDefault(*context_, options_trianglestrip,
{supports_decal});

View File

@@ -30,12 +30,13 @@
#endif // IMPELLER_DEBUG
#include "impeller/entity/border_mask_blur.frag.h"
#include "impeller/entity/border_mask_blur.vert.h"
#include "impeller/entity/clip.frag.h"
#include "impeller/entity/clip.vert.h"
#include "impeller/entity/color_matrix_color_filter.frag.h"
#include "impeller/entity/conical_gradient_fill.frag.h"
#include "impeller/entity/filter.vert.h"
#include "impeller/entity/filter_position.vert.h"
#include "impeller/entity/filter_position_uv.vert.h"
#include "impeller/entity/gaussian.frag.h"
#include "impeller/entity/glyph_atlas.frag.h"
#include "impeller/entity/glyph_atlas.vert.h"
#include "impeller/entity/glyph_atlas_color.frag.h"
@@ -43,9 +44,9 @@
#include "impeller/entity/linear_gradient_fill.frag.h"
#include "impeller/entity/linear_to_srgb_filter.frag.h"
#include "impeller/entity/morphology_filter.frag.h"
#include "impeller/entity/morphology_filter.vert.h"
#include "impeller/entity/porter_duff_blend.frag.h"
#include "impeller/entity/porter_duff_blend.vert.h"
#include "impeller/entity/position_color.vert.h"
#include "impeller/entity/radial_gradient_fill.frag.h"
#include "impeller/entity/rrect_blur.frag.h"
#include "impeller/entity/rrect_blur.vert.h"
@@ -61,12 +62,6 @@
#include "impeller/entity/vertices.frag.h"
#include "impeller/entity/yuv_to_rgb_filter.frag.h"
#include "impeller/entity/kernel.vert.h"
#include "impeller/entity/kernel_decal.frag.h"
#include "impeller/entity/kernel_nodecal.frag.h"
#include "impeller/entity/position_color.vert.h"
#include "impeller/typographer/glyph_atlas.h"
#include "impeller/entity/conical_gradient_ssbo_fill.frag.h"
@@ -81,7 +76,6 @@
#include "impeller/entity/framebuffer_blend.vert.h"
#include "impeller/entity/vertices_uber.frag.h"
#include "impeller/entity/vertices_uber.vert.h"
#ifdef IMPELLER_ENABLE_OPENGLES
#include "impeller/entity/tiled_texture_fill_external.frag.h"
@@ -134,23 +128,27 @@ using TextureStrictSrcPipeline =
using TiledTexturePipeline =
RenderPipelineHandle<TextureUvFillVertexShader,
TiledTextureFillFragmentShader>;
using KernelDecalPipeline =
RenderPipelineHandle<KernelVertexShader, KernelDecalFragmentShader>;
using KernelPipeline =
RenderPipelineHandle<KernelVertexShader, KernelNodecalFragmentShader>;
using GaussianBlurPipeline =
RenderPipelineHandle<FilterPositionUvVertexShader, GaussianFragmentShader>;
using BorderMaskBlurPipeline =
RenderPipelineHandle<BorderMaskBlurVertexShader,
RenderPipelineHandle<FilterPositionUvVertexShader,
BorderMaskBlurFragmentShader>;
using MorphologyFilterPipeline =
RenderPipelineHandle<MorphologyFilterVertexShader,
RenderPipelineHandle<FilterPositionUvVertexShader,
MorphologyFilterFragmentShader>;
using ColorMatrixColorFilterPipeline =
RenderPipelineHandle<FilterVertexShader,
RenderPipelineHandle<FilterPositionVertexShader,
ColorMatrixColorFilterFragmentShader>;
using LinearToSrgbFilterPipeline =
RenderPipelineHandle<FilterVertexShader, LinearToSrgbFilterFragmentShader>;
RenderPipelineHandle<FilterPositionVertexShader,
LinearToSrgbFilterFragmentShader>;
using SrgbToLinearFilterPipeline =
RenderPipelineHandle<FilterVertexShader, SrgbToLinearFilterFragmentShader>;
RenderPipelineHandle<FilterPositionVertexShader,
SrgbToLinearFilterFragmentShader>;
using YUVToRGBFilterPipeline =
RenderPipelineHandle<FilterPositionVertexShader,
YuvToRgbFilterFragmentShader>;
using GlyphAtlasPipeline =
RenderPipelineHandle<GlyphAtlasVertexShader, GlyphAtlasFragmentShader>;
using GlyphAtlasColorPipeline =
@@ -162,8 +160,6 @@ using ClipPipeline = RenderPipelineHandle<ClipVertexShader, ClipFragmentShader>;
using GeometryColorPipeline =
RenderPipelineHandle<PositionColorVertexShader, VerticesFragmentShader>;
using YUVToRGBFilterPipeline =
RenderPipelineHandle<FilterVertexShader, YuvToRgbFilterFragmentShader>;
// Advanced blends
using BlendColorPipeline = RenderPipelineHandle<AdvancedBlendVertexShader,
@@ -252,8 +248,8 @@ using FramebufferBlendSoftLightPipeline =
FramebufferBlendFragmentShader>;
/// Draw Vertices/Atlas Uber Shader
using VerticesUberShader =
RenderPipelineHandle<VerticesUberVertexShader, VerticesUberFragmentShader>;
using VerticesUberShader = RenderPipelineHandle<PorterDuffBlendVertexShader,
VerticesUberFragmentShader>;
#ifdef IMPELLER_ENABLE_OPENGLES
using TiledTextureExternalPipeline =
@@ -477,14 +473,9 @@ class ContentContext {
return GetPipeline(tiled_texture_pipelines_, opts);
}
std::shared_ptr<Pipeline<PipelineDescriptor>> GetKernelDecalPipeline(
std::shared_ptr<Pipeline<PipelineDescriptor>> GetGaussianBlurPipeline(
ContentContextOptions opts) const {
return GetPipeline(kernel_decal_pipelines_, opts);
}
std::shared_ptr<Pipeline<PipelineDescriptor>> GetKernelPipeline(
ContentContextOptions opts) const {
return GetPipeline(kernel_nodecal_pipelines_, opts);
return GetPipeline(gaussian_blur_pipelines_, opts);
}
std::shared_ptr<Pipeline<PipelineDescriptor>> GetBorderMaskBlurPipeline(
@@ -915,8 +906,7 @@ class ContentContext {
tiled_texture_external_pipelines_;
#endif // IMPELLER_ENABLE_OPENGLES
mutable Variants<TiledTexturePipeline> tiled_texture_pipelines_;
mutable Variants<KernelDecalPipeline> kernel_decal_pipelines_;
mutable Variants<KernelPipeline> kernel_nodecal_pipelines_;
mutable Variants<GaussianBlurPipeline> gaussian_blur_pipelines_;
mutable Variants<BorderMaskBlurPipeline> border_mask_blur_pipelines_;
mutable Variants<MorphologyFilterPipeline> morphology_filter_pipelines_;
mutable Variants<ColorMatrixColorFilterPipeline>

View File

@@ -8,25 +8,22 @@
#include "flutter/fml/make_copyable.h"
#include "impeller/entity/contents/clip_contents.h"
#include "impeller/entity/contents/color_source_contents.h"
#include "impeller/entity/contents/content_context.h"
#include "impeller/entity/texture_fill.frag.h"
#include "impeller/entity/texture_fill.vert.h"
#include "impeller/renderer/command.h"
#include "impeller/renderer/render_pass.h"
#include "impeller/renderer/texture_mipmap.h"
#include "impeller/renderer/vertex_buffer_builder.h"
namespace impeller {
using GaussianBlurVertexShader = KernelPipeline::VertexShader;
using GaussianBlurFragmentShader = KernelPipeline::FragmentShader;
using GaussianBlurVertexShader = GaussianBlurPipeline::VertexShader;
using GaussianBlurFragmentShader = GaussianBlurPipeline::FragmentShader;
const int32_t GaussianBlurFilterContents::kBlurFilterRequiredMipCount = 4;
namespace {
// 48 comes from kernel.glsl.
// 48 comes from gaussian.frag.
const int32_t kMaxKernelSize = 48;
SamplerDescriptor MakeSamplerDescriptor(MinMagFilter filter,
@@ -155,14 +152,7 @@ fml::StatusOr<RenderTarget> MakeBlurSubpass(
ContentContextOptions options = OptionsFromPass(pass);
options.primitive_type = PrimitiveType::kTriangleStrip;
if (tile_mode == Entity::TileMode::kDecal &&
!renderer.GetDeviceCapabilities()
.SupportsDecalSamplerAddressMode()) {
pass.SetPipeline(renderer.GetKernelDecalPipeline(options));
} else {
pass.SetPipeline(renderer.GetKernelPipeline(options));
}
pass.SetPipeline(renderer.GetGaussianBlurPipeline(options));
BindVertices<GaussianBlurVertexShader>(pass, host_buffer,
{
@@ -181,7 +171,7 @@ fml::StatusOr<RenderTarget> MakeBlurSubpass(
linear_sampler_descriptor));
GaussianBlurVertexShader::BindFrameInfo(
pass, host_buffer.EmplaceUniform(frame_info));
KernelPipeline::FragmentShader::KernelSamples kernel_samples =
GaussianBlurPipeline::FragmentShader::KernelSamples kernel_samples =
LerpHackKernelSamples(GenerateBlurInfo(blur_info));
FML_CHECK(kernel_samples.sample_count < kMaxKernelSize);
GaussianBlurFragmentShader::BindKernelSamples(
@@ -600,9 +590,9 @@ Scalar GaussianBlurFilterContents::ScaleSigma(Scalar sigma) {
return clamped * scalar;
}
KernelPipeline::FragmentShader::KernelSamples GenerateBlurInfo(
GaussianBlurPipeline::FragmentShader::KernelSamples GenerateBlurInfo(
BlurParameters parameters) {
KernelPipeline::FragmentShader::KernelSamples result;
GaussianBlurPipeline::FragmentShader::KernelSamples result;
result.sample_count =
((2 * parameters.blur_radius) / parameters.step_size) + 1;
@@ -617,7 +607,7 @@ KernelPipeline::FragmentShader::KernelSamples GenerateBlurInfo(
Scalar tally = 0.0f;
for (int i = 0; i < result.sample_count; ++i) {
int x = x_offset + (i * parameters.step_size) - parameters.blur_radius;
result.samples[i] = KernelPipeline::FragmentShader::KernelSample{
result.samples[i] = GaussianBlurPipeline::FragmentShader::KernelSample{
.uv_offset = parameters.blur_uv_offset * x,
.coefficient = expf(-0.5f * (x * x) /
(parameters.blur_sigma * parameters.blur_sigma)) /
@@ -636,9 +626,9 @@ KernelPipeline::FragmentShader::KernelSamples GenerateBlurInfo(
// This works by shrinking the kernel size by 2 and relying on lerp to read
// between the samples.
KernelPipeline::FragmentShader::KernelSamples LerpHackKernelSamples(
KernelPipeline::FragmentShader::KernelSamples parameters) {
KernelPipeline::FragmentShader::KernelSamples result;
GaussianBlurPipeline::FragmentShader::KernelSamples LerpHackKernelSamples(
GaussianBlurPipeline::FragmentShader::KernelSamples parameters) {
GaussianBlurPipeline::FragmentShader::KernelSamples result;
result.sample_count = ((parameters.sample_count - 1) / 2) + 1;
int32_t middle = result.sample_count / 2;
int32_t j = 0;
@@ -646,10 +636,11 @@ KernelPipeline::FragmentShader::KernelSamples LerpHackKernelSamples(
if (i == middle) {
result.samples[i] = parameters.samples[j++];
} else {
KernelPipeline::FragmentShader::KernelSample left = parameters.samples[j];
KernelPipeline::FragmentShader::KernelSample right =
GaussianBlurPipeline::FragmentShader::KernelSample left =
parameters.samples[j];
GaussianBlurPipeline::FragmentShader::KernelSample right =
parameters.samples[j + 1];
result.samples[i] = KernelPipeline::FragmentShader::KernelSample{
result.samples[i] = GaussianBlurPipeline::FragmentShader::KernelSample{
.uv_offset = (left.uv_offset * left.coefficient +
right.uv_offset * right.coefficient) /
(left.coefficient + right.coefficient),

View File

@@ -19,13 +19,13 @@ struct BlurParameters {
int step_size;
};
KernelPipeline::FragmentShader::KernelSamples GenerateBlurInfo(
GaussianBlurPipeline::FragmentShader::KernelSamples GenerateBlurInfo(
BlurParameters parameters);
/// This will shrink the size of a kernel by roughly half by sampling between
/// samples and relying on linear interpolation between the samples.
KernelPipeline::FragmentShader::KernelSamples LerpHackKernelSamples(
KernelPipeline::FragmentShader::KernelSamples samples);
GaussianBlurPipeline::FragmentShader::KernelSamples LerpHackKernelSamples(
GaussianBlurPipeline::FragmentShader::KernelSamples samples);
/// Performs a bidirectional Gaussian blur.
///

View File

@@ -5,6 +5,7 @@
#include "flutter/testing/testing.h"
#include "fml/status_or.h"
#include "gmock/gmock.h"
#include "impeller/entity/contents/content_context.h"
#include "impeller/entity/contents/filters/gaussian_blur_filter_contents.h"
#include "impeller/entity/contents/texture_contents.h"
#include "impeller/entity/entity_playground.h"
@@ -456,7 +457,7 @@ TEST(GaussianBlurFilterContentsTest, Coefficients) {
.blur_sigma = 1,
.blur_radius = 5,
.step_size = 1};
KernelPipeline::FragmentShader::KernelSamples samples =
GaussianBlurPipeline::FragmentShader::KernelSamples samples =
GenerateBlurInfo(parameters);
EXPECT_EQ(samples.sample_count, 9);
@@ -477,7 +478,7 @@ TEST(GaussianBlurFilterContentsTest, Coefficients) {
}
TEST(GaussianBlurFilterContentsTest, LerpHackKernelSamplesSimple) {
KernelPipeline::FragmentShader::KernelSamples kernel_samples = {
GaussianBlurPipeline::FragmentShader::KernelSamples kernel_samples = {
.sample_count = 5,
.samples =
{
@@ -504,13 +505,13 @@ TEST(GaussianBlurFilterContentsTest, LerpHackKernelSamplesSimple) {
},
};
KernelPipeline::FragmentShader::KernelSamples fast_kernel_samples =
GaussianBlurPipeline::FragmentShader::KernelSamples fast_kernel_samples =
LerpHackKernelSamples(kernel_samples);
EXPECT_EQ(fast_kernel_samples.sample_count, 3);
KernelPipeline::FragmentShader::KernelSample* samples =
GaussianBlurPipeline::FragmentShader::KernelSample* samples =
kernel_samples.samples;
KernelPipeline::FragmentShader::KernelSample* fast_samples =
GaussianBlurPipeline::FragmentShader::KernelSample* fast_samples =
fast_kernel_samples.samples;
//////////////////////////////////////////////////////////////////////////////
@@ -562,10 +563,10 @@ TEST(GaussianBlurFilterContentsTest, LerpHackKernelSamplesComplex) {
.blur_sigma = sigma,
.blur_radius = blur_radius,
.step_size = 1};
KernelPipeline::FragmentShader::KernelSamples kernel_samples =
GaussianBlurPipeline::FragmentShader::KernelSamples kernel_samples =
GenerateBlurInfo(parameters);
EXPECT_EQ(kernel_samples.sample_count, 33);
KernelPipeline::FragmentShader::KernelSamples fast_kernel_samples =
GaussianBlurPipeline::FragmentShader::KernelSamples fast_kernel_samples =
LerpHackKernelSamples(kernel_samples);
EXPECT_EQ(fast_kernel_samples.sample_count, 17);
float data[33];

View File

@@ -1,26 +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;
in vec4 color;
out vec2 v_texture_coords;
out mediump f16vec4 v_color;
void main() {
gl_Position = frame_info.mvp * vec4(vertices, 0.0, 1.0);
v_color = f16vec4(color);
v_texture_coords =
IPRemapCoords(texture_coords, frame_info.texture_sampler_y_coord_scale);
}

View File

@@ -9,6 +9,8 @@
uniform f16sampler2D texture_sampler;
layout(constant_id = 0) const float supports_decal = 1.0;
struct KernelSample {
vec2 uv_offset;
float coefficient;
@@ -21,11 +23,10 @@ uniform KernelSamples {
blur_info;
f16vec4 Sample(f16sampler2D tex, vec2 coords) {
#if ENABLE_DECAL_SPECIALIZATION
if (supports_decal == 1.0) {
return texture(tex, coords);
}
return IPHalfSampleDecal(tex, coords);
#else
return texture(tex, coords);
#endif
}
in vec2 v_texture_coords;

View File

@@ -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 position;
in vec2 texture_coords;
out vec2 v_texture_coords;
void main() {
gl_Position = frame_info.mvp * vec4(position, 0.0, 1.0);
v_texture_coords =
IPRemapCoords(texture_coords, frame_info.texture_sampler_y_coord_scale);
}

View File

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

View File

@@ -1,9 +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;
#define ENABLE_DECAL_SPECIALIZATION 1
#include "kernel.glsl"

View File

@@ -1,9 +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;
#define ENABLE_DECAL_SPECIALIZATION 0
#include "kernel.glsl"

File diff suppressed because it is too large Load Diff