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

Commit 79461cd

Browse files
[Impeller] Use specialization constant for blur pipelines decal feature. (#47617)
Minor specialization constant cleanup
1 parent dff6692 commit 79461cd

File tree

9 files changed

+209
-412
lines changed

9 files changed

+209
-412
lines changed

ci/licenses_golden/licenses_flutter

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3153,10 +3153,8 @@ ORIGIN: ../../../flutter/impeller/entity/shaders/conical_gradient_fill.frag + ..
31533153
ORIGIN: ../../../flutter/impeller/entity/shaders/conical_gradient_ssbo_fill.frag + ../../../flutter/LICENSE
31543154
ORIGIN: ../../../flutter/impeller/entity/shaders/debug/checkerboard.frag + ../../../flutter/LICENSE
31553155
ORIGIN: ../../../flutter/impeller/entity/shaders/debug/checkerboard.vert + ../../../flutter/LICENSE
3156-
ORIGIN: ../../../flutter/impeller/entity/shaders/gaussian_blur/gaussian_blur.glsl + ../../../flutter/LICENSE
3156+
ORIGIN: ../../../flutter/impeller/entity/shaders/gaussian_blur/gaussian_blur.frag + ../../../flutter/LICENSE
31573157
ORIGIN: ../../../flutter/impeller/entity/shaders/gaussian_blur/gaussian_blur.vert + ../../../flutter/LICENSE
3158-
ORIGIN: ../../../flutter/impeller/entity/shaders/gaussian_blur/gaussian_blur_noalpha_decal.frag + ../../../flutter/LICENSE
3159-
ORIGIN: ../../../flutter/impeller/entity/shaders/gaussian_blur/gaussian_blur_noalpha_nodecal.frag + ../../../flutter/LICENSE
31603158
ORIGIN: ../../../flutter/impeller/entity/shaders/geometry/points.comp + ../../../flutter/LICENSE
31613159
ORIGIN: ../../../flutter/impeller/entity/shaders/geometry/uv.comp + ../../../flutter/LICENSE
31623160
ORIGIN: ../../../flutter/impeller/entity/shaders/glyph_atlas.frag + ../../../flutter/LICENSE
@@ -5907,10 +5905,8 @@ FILE: ../../../flutter/impeller/entity/shaders/conical_gradient_fill.frag
59075905
FILE: ../../../flutter/impeller/entity/shaders/conical_gradient_ssbo_fill.frag
59085906
FILE: ../../../flutter/impeller/entity/shaders/debug/checkerboard.frag
59095907
FILE: ../../../flutter/impeller/entity/shaders/debug/checkerboard.vert
5910-
FILE: ../../../flutter/impeller/entity/shaders/gaussian_blur/gaussian_blur.glsl
5908+
FILE: ../../../flutter/impeller/entity/shaders/gaussian_blur/gaussian_blur.frag
59115909
FILE: ../../../flutter/impeller/entity/shaders/gaussian_blur/gaussian_blur.vert
5912-
FILE: ../../../flutter/impeller/entity/shaders/gaussian_blur/gaussian_blur_noalpha_decal.frag
5913-
FILE: ../../../flutter/impeller/entity/shaders/gaussian_blur/gaussian_blur_noalpha_nodecal.frag
59145910
FILE: ../../../flutter/impeller/entity/shaders/geometry/points.comp
59155911
FILE: ../../../flutter/impeller/entity/shaders/geometry/uv.comp
59165912
FILE: ../../../flutter/impeller/entity/shaders/glyph_atlas.frag

impeller/entity/BUILD.gn

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ impeller_shaders("entity_shaders") {
2626
"shaders/color_matrix_color_filter.vert",
2727
"shaders/conical_gradient_fill.frag",
2828
"shaders/gaussian_blur/gaussian_blur.vert",
29-
"shaders/gaussian_blur/gaussian_blur_noalpha_decal.frag",
30-
"shaders/gaussian_blur/gaussian_blur_noalpha_nodecal.frag",
29+
"shaders/gaussian_blur/gaussian_blur.frag",
3130
"shaders/glyph_atlas.frag",
3231
"shaders/glyph_atlas_color.frag",
3332
"shaders/glyph_atlas.vert",

impeller/entity/contents/content_context.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,10 @@ ContentContext::ContentContext(
317317
texture_pipelines_.CreateDefault(*context_, options);
318318
position_uv_pipelines_.CreateDefault(*context_, options);
319319
tiled_texture_pipelines_.CreateDefault(*context_, options);
320-
gaussian_blur_noalpha_decal_pipelines_.CreateDefault(*context_,
321-
options_trianglestrip);
322-
gaussian_blur_noalpha_nodecal_pipelines_.CreateDefault(*context_,
323-
options_trianglestrip);
320+
gaussian_blur_noalpha_decal_pipelines_.CreateDefault(
321+
*context_, options_trianglestrip, {/*decal_specialization=*/1});
322+
gaussian_blur_noalpha_nodecal_pipelines_.CreateDefault(
323+
*context_, options_trianglestrip, {/*decal_specialization=*/0});
324324
border_mask_blur_pipelines_.CreateDefault(*context_, options_trianglestrip);
325325
morphology_filter_pipelines_.CreateDefault(*context_, options_trianglestrip);
326326
color_matrix_color_filter_pipelines_.CreateDefault(*context_,

impeller/entity/contents/content_context.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,8 @@
6363
#include "impeller/entity/yuv_to_rgb_filter.frag.h"
6464
#include "impeller/entity/yuv_to_rgb_filter.vert.h"
6565

66+
#include "impeller/entity/gaussian_blur.frag.h"
6667
#include "impeller/entity/gaussian_blur.vert.h"
67-
#include "impeller/entity/gaussian_blur_noalpha_decal.frag.h"
68-
#include "impeller/entity/gaussian_blur_noalpha_nodecal.frag.h"
6968

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

@@ -130,11 +129,9 @@ using PositionUVPipeline =
130129
using TiledTexturePipeline =
131130
RenderPipelineT<TextureFillVertexShader, TiledTextureFillFragmentShader>;
132131
using GaussianBlurDecalPipeline =
133-
RenderPipelineT<GaussianBlurVertexShader,
134-
GaussianBlurNoalphaDecalFragmentShader>;
132+
RenderPipelineT<GaussianBlurVertexShader, GaussianBlurFragmentShader>;
135133
using GaussianBlurPipeline =
136-
RenderPipelineT<GaussianBlurVertexShader,
137-
GaussianBlurNoalphaNodecalFragmentShader>;
134+
RenderPipelineT<GaussianBlurVertexShader, GaussianBlurFragmentShader>;
138135
using BorderMaskBlurPipeline =
139136
RenderPipelineT<BorderMaskBlurVertexShader, BorderMaskBlurFragmentShader>;
140137
using MorphologyFilterPipeline =

impeller/entity/entity_unittests.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2556,6 +2556,19 @@ TEST_P(EntityTest, SpecializationConstantsAreAppliedToVariants) {
25562556
expected_constants);
25572557
}
25582558

2559+
TEST_P(EntityTest, BlurSpecializationConstantValuesAreExpected) {
2560+
auto content_context =
2561+
ContentContext(GetContext(), TypographerContextSkia::Make());
2562+
2563+
auto decal_pipeline = content_context.GetGaussianBlurDecalPipeline({});
2564+
auto nodecal_pipeline = content_context.GetGaussianBlurPipeline({});
2565+
2566+
ASSERT_EQ(decal_pipeline->GetDescriptor().GetSpecializationConstants()[0],
2567+
/*decal_specialization*/ 1);
2568+
ASSERT_EQ(nodecal_pipeline->GetDescriptor().GetSpecializationConstants()[0],
2569+
/*decal_specialization*/ 0);
2570+
}
2571+
25592572
} // namespace testing
25602573
} // namespace impeller
25612574

impeller/entity/shaders/gaussian_blur/gaussian_blur.glsl renamed to impeller/entity/shaders/gaussian_blur/gaussian_blur.frag

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#include <impeller/texture.glsl>
1919
#include <impeller/types.glsl>
2020

21+
layout(constant_id = 0) const int decal_specialization = 0;
22+
2123
uniform f16sampler2D texture_sampler;
2224

2325
uniform BlurInfo {
@@ -33,11 +35,10 @@ uniform BlurInfo {
3335
blur_info;
3436

3537
f16vec4 Sample(f16sampler2D tex, vec2 coords) {
36-
#if ENABLE_DECAL_SPECIALIZATION
37-
return IPHalfSampleDecal(tex, coords);
38-
#else
38+
if (decal_specialization == 1) {
39+
return IPHalfSampleDecal(tex, coords);
40+
}
3941
return texture(tex, coords);
40-
#endif
4142
}
4243

4344
in vec2 v_texture_coords;

impeller/entity/shaders/gaussian_blur/gaussian_blur_noalpha_decal.frag

Lines changed: 0 additions & 9 deletions
This file was deleted.

impeller/entity/shaders/gaussian_blur/gaussian_blur_noalpha_nodecal.frag

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)