Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[Impeller] Use specialization constant for blur pipelines decal feature. #47617

Merged
merged 3 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -3153,10 +3153,8 @@ ORIGIN: ../../../flutter/impeller/entity/shaders/conical_gradient_fill.frag + ..
ORIGIN: ../../../flutter/impeller/entity/shaders/conical_gradient_ssbo_fill.frag + ../../../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/gaussian_blur/gaussian_blur.glsl + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/entity/shaders/gaussian_blur/gaussian_blur.frag + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/entity/shaders/gaussian_blur/gaussian_blur.vert + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/entity/shaders/gaussian_blur/gaussian_blur_noalpha_decal.frag + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/entity/shaders/gaussian_blur/gaussian_blur_noalpha_nodecal.frag + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/entity/shaders/geometry/points.comp + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/entity/shaders/geometry/uv.comp + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/entity/shaders/glyph_atlas.frag + ../../../flutter/LICENSE
Expand Down Expand Up @@ -5907,10 +5905,8 @@ FILE: ../../../flutter/impeller/entity/shaders/conical_gradient_fill.frag
FILE: ../../../flutter/impeller/entity/shaders/conical_gradient_ssbo_fill.frag
FILE: ../../../flutter/impeller/entity/shaders/debug/checkerboard.frag
FILE: ../../../flutter/impeller/entity/shaders/debug/checkerboard.vert
FILE: ../../../flutter/impeller/entity/shaders/gaussian_blur/gaussian_blur.glsl
FILE: ../../../flutter/impeller/entity/shaders/gaussian_blur/gaussian_blur.frag
FILE: ../../../flutter/impeller/entity/shaders/gaussian_blur/gaussian_blur.vert
FILE: ../../../flutter/impeller/entity/shaders/gaussian_blur/gaussian_blur_noalpha_decal.frag
FILE: ../../../flutter/impeller/entity/shaders/gaussian_blur/gaussian_blur_noalpha_nodecal.frag
FILE: ../../../flutter/impeller/entity/shaders/geometry/points.comp
FILE: ../../../flutter/impeller/entity/shaders/geometry/uv.comp
FILE: ../../../flutter/impeller/entity/shaders/glyph_atlas.frag
Expand Down
3 changes: 1 addition & 2 deletions impeller/entity/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ impeller_shaders("entity_shaders") {
"shaders/color_matrix_color_filter.vert",
"shaders/conical_gradient_fill.frag",
"shaders/gaussian_blur/gaussian_blur.vert",
"shaders/gaussian_blur/gaussian_blur_noalpha_decal.frag",
"shaders/gaussian_blur/gaussian_blur_noalpha_nodecal.frag",
"shaders/gaussian_blur/gaussian_blur.frag",
"shaders/glyph_atlas.frag",
"shaders/glyph_atlas_color.frag",
"shaders/glyph_atlas.vert",
Expand Down
8 changes: 4 additions & 4 deletions impeller/entity/contents/content_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,10 @@ ContentContext::ContentContext(
texture_pipelines_.CreateDefault(*context_, options);
position_uv_pipelines_.CreateDefault(*context_, options);
tiled_texture_pipelines_.CreateDefault(*context_, options);
gaussian_blur_noalpha_decal_pipelines_.CreateDefault(*context_,
options_trianglestrip);
gaussian_blur_noalpha_nodecal_pipelines_.CreateDefault(*context_,
options_trianglestrip);
gaussian_blur_noalpha_decal_pipelines_.CreateDefault(
*context_, options_trianglestrip, {/*decal_specialization=*/1});
gaussian_blur_noalpha_nodecal_pipelines_.CreateDefault(
*context_, options_trianglestrip, {/*decal_specialization=*/0});
border_mask_blur_pipelines_.CreateDefault(*context_, options_trianglestrip);
morphology_filter_pipelines_.CreateDefault(*context_, options_trianglestrip);
color_matrix_color_filter_pipelines_.CreateDefault(*context_,
Expand Down
9 changes: 3 additions & 6 deletions impeller/entity/contents/content_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,8 @@
#include "impeller/entity/yuv_to_rgb_filter.frag.h"
#include "impeller/entity/yuv_to_rgb_filter.vert.h"

#include "impeller/entity/gaussian_blur.frag.h"
#include "impeller/entity/gaussian_blur.vert.h"
#include "impeller/entity/gaussian_blur_noalpha_decal.frag.h"
#include "impeller/entity/gaussian_blur_noalpha_nodecal.frag.h"

#include "impeller/entity/position_color.vert.h"

Expand Down Expand Up @@ -130,11 +129,9 @@ using PositionUVPipeline =
using TiledTexturePipeline =
RenderPipelineT<TextureFillVertexShader, TiledTextureFillFragmentShader>;
using GaussianBlurDecalPipeline =
RenderPipelineT<GaussianBlurVertexShader,
GaussianBlurNoalphaDecalFragmentShader>;
RenderPipelineT<GaussianBlurVertexShader, GaussianBlurFragmentShader>;
using GaussianBlurPipeline =
RenderPipelineT<GaussianBlurVertexShader,
GaussianBlurNoalphaNodecalFragmentShader>;
RenderPipelineT<GaussianBlurVertexShader, GaussianBlurFragmentShader>;
using BorderMaskBlurPipeline =
RenderPipelineT<BorderMaskBlurVertexShader, BorderMaskBlurFragmentShader>;
using MorphologyFilterPipeline =
Expand Down
13 changes: 13 additions & 0 deletions impeller/entity/entity_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2556,6 +2556,19 @@ TEST_P(EntityTest, SpecializationConstantsAreAppliedToVariants) {
expected_constants);
}

TEST_P(EntityTest, BlurSpecializationConstantValuesAreExpected) {
auto content_context =
ContentContext(GetContext(), TypographerContextSkia::Make());

auto decal_pipeline = content_context.GetGaussianBlurDecalPipeline({});
auto nodecal_pipeline = content_context.GetGaussianBlurPipeline({});

ASSERT_EQ(decal_pipeline->GetDescriptor().GetSpecializationConstants()[0],
/*decal_specialization*/ 1);
ASSERT_EQ(nodecal_pipeline->GetDescriptor().GetSpecializationConstants()[0],
/*decal_specialization*/ 0);
}

} // namespace testing
} // namespace impeller

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include <impeller/texture.glsl>
#include <impeller/types.glsl>

layout(constant_id = 0) const int decal_specialization = 0;

uniform f16sampler2D texture_sampler;

uniform BlurInfo {
Expand All @@ -33,11 +35,10 @@ uniform BlurInfo {
blur_info;

f16vec4 Sample(f16sampler2D tex, vec2 coords) {
#if ENABLE_DECAL_SPECIALIZATION
return IPHalfSampleDecal(tex, coords);
#else
if (decal_specialization == 1) {
return IPHalfSampleDecal(tex, coords);
}
return texture(tex, coords);
#endif
}

in vec2 v_texture_coords;
Expand Down

This file was deleted.

This file was deleted.

Loading