[Impeller] Use specialization constant for blur pipelines decal feature. (flutter/engine#47617)

Minor specialization constant cleanup
This commit is contained in:
Jonah Williams
2023-11-02 17:56:59 -07:00
committed by GitHub
parent da55f0c57d
commit e914c1d207
9 changed files with 218 additions and 421 deletions

View File

@@ -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
@@ -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

View File

@@ -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",

View File

@@ -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_,

View File

@@ -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"
@@ -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 =

View File

@@ -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

View File

@@ -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 {
@@ -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;

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 "gaussian_blur.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 "gaussian_blur.glsl"

View File

@@ -1153,6 +1153,79 @@
}
}
},
"flutter/impeller/entity/gaussian_blur.frag.vkspv": {
"Mali-G78": {
"core": "Mali-G78",
"filename": "flutter/impeller/entity/gaussian_blur.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": 0,
"has_stack_spilling": false,
"performance": {
"longest_path_bound_pipelines": [
null
],
"longest_path_cycles": [
null,
null,
null,
null,
null,
null,
null
],
"pipelines": [
"arith_total",
"arith_fma",
"arith_cvt",
"arith_sfu",
"load_store",
"varying",
"texture"
],
"shortest_path_bound_pipelines": [
"arith_total",
"arith_cvt"
],
"shortest_path_cycles": [
0.140625,
0.0625,
0.140625,
0.0625,
0.0,
0.0,
0.0
],
"total_bound_pipelines": [
"arith_total",
"arith_fma",
"arith_cvt"
],
"total_cycles": [
0.265625,
0.265625,
0.265625,
0.125,
0.0,
0.25,
0.25
]
},
"stack_spill_bytes": 0,
"thread_occupancy": 100,
"uniform_registers_used": 10,
"work_registers_used": 15
}
}
}
},
"flutter/impeller/entity/gaussian_blur.vert.vkspv": {
"Mali-G78": {
"core": "Mali-G78",
@@ -1265,151 +1338,6 @@
}
}
},
"flutter/impeller/entity/gaussian_blur_noalpha_decal.frag.vkspv": {
"Mali-G78": {
"core": "Mali-G78",
"filename": "flutter/impeller/entity/gaussian_blur_noalpha_decal.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": 42,
"has_stack_spilling": false,
"performance": {
"longest_path_bound_pipelines": [
null
],
"longest_path_cycles": [
null,
null,
null,
null,
null,
null,
null
],
"pipelines": [
"arith_total",
"arith_fma",
"arith_cvt",
"arith_sfu",
"load_store",
"varying",
"texture"
],
"shortest_path_bound_pipelines": [
"arith_total",
"arith_cvt"
],
"shortest_path_cycles": [
0.109375,
0.03125,
0.109375,
0.0625,
0.0,
0.0,
0.0
],
"total_bound_pipelines": [
"arith_total",
"arith_cvt",
"arith_sfu"
],
"total_cycles": [
0.3125,
0.203125,
0.3125,
0.3125,
0.0,
0.25,
0.25
]
},
"stack_spill_bytes": 0,
"thread_occupancy": 100,
"uniform_registers_used": 10,
"work_registers_used": 16
}
}
}
},
"flutter/impeller/entity/gaussian_blur_noalpha_nodecal.frag.vkspv": {
"Mali-G78": {
"core": "Mali-G78",
"filename": "flutter/impeller/entity/gaussian_blur_noalpha_nodecal.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": 35,
"has_stack_spilling": false,
"performance": {
"longest_path_bound_pipelines": [
null
],
"longest_path_cycles": [
null,
null,
null,
null,
null,
null,
null
],
"pipelines": [
"arith_total",
"arith_fma",
"arith_cvt",
"arith_sfu",
"load_store",
"varying",
"texture"
],
"shortest_path_bound_pipelines": [
"arith_total",
"arith_cvt"
],
"shortest_path_cycles": [
0.109375,
0.03125,
0.109375,
0.0625,
0.0,
0.0,
0.0
],
"total_bound_pipelines": [
"varying",
"texture"
],
"total_cycles": [
0.203125,
0.203125,
0.203125,
0.125,
0.0,
0.25,
0.25
]
},
"stack_spill_bytes": 0,
"thread_occupancy": 100,
"uniform_registers_used": 10,
"work_registers_used": 13
}
}
}
},
"flutter/impeller/entity/gles/advanced_blend.frag.gles": {
"Mali-G78": {
"core": "Mali-G78",
@@ -3083,6 +3011,123 @@
}
}
},
"flutter/impeller/entity/gles/gaussian_blur.frag.gles": {
"Mali-G78": {
"core": "Mali-G78",
"filename": "flutter/impeller/entity/gles/gaussian_blur.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": 0,
"has_stack_spilling": false,
"performance": {
"longest_path_bound_pipelines": [
null
],
"longest_path_cycles": [
null,
null,
null,
null,
null,
null,
null
],
"pipelines": [
"arith_total",
"arith_fma",
"arith_cvt",
"arith_sfu",
"load_store",
"varying",
"texture"
],
"shortest_path_bound_pipelines": [
"arith_total",
"arith_cvt"
],
"shortest_path_cycles": [
0.09375,
0.0625,
0.09375,
0.0625,
0.0,
0.0,
0.0
],
"total_bound_pipelines": [
"arith_total",
"arith_fma"
],
"total_cycles": [
0.28125,
0.28125,
0.25,
0.125,
0.0,
0.25,
0.25
]
},
"stack_spill_bytes": 0,
"thread_occupancy": 100,
"uniform_registers_used": 10,
"work_registers_used": 19
}
}
},
"Mali-T880": {
"core": "Mali-T880",
"filename": "flutter/impeller/entity/gles/gaussian_blur.frag.gles",
"has_uniform_computation": false,
"type": "Fragment",
"variants": {
"Main": {
"has_stack_spilling": false,
"performance": {
"longest_path_bound_pipelines": [
null
],
"longest_path_cycles": [
null,
null,
null
],
"pipelines": [
"arithmetic",
"load_store",
"texture"
],
"shortest_path_bound_pipelines": [
"arithmetic"
],
"shortest_path_cycles": [
1.649999976158142,
1.0,
0.0
],
"total_bound_pipelines": [
"arithmetic"
],
"total_cycles": [
3.6666667461395264,
1.0,
1.0
]
},
"thread_occupancy": 100,
"uniform_registers_used": 1,
"work_registers_used": 4
}
}
}
},
"flutter/impeller/entity/gles/gaussian_blur.vert.gles": {
"Mali-G78": {
"core": "Mali-G78",
@@ -3240,242 +3285,6 @@
}
}
},
"flutter/impeller/entity/gles/gaussian_blur_noalpha_decal.frag.gles": {
"Mali-G78": {
"core": "Mali-G78",
"filename": "flutter/impeller/entity/gles/gaussian_blur_noalpha_decal.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": [
null
],
"longest_path_cycles": [
null,
null,
null,
null,
null,
null,
null
],
"pipelines": [
"arith_total",
"arith_fma",
"arith_cvt",
"arith_sfu",
"load_store",
"varying",
"texture"
],
"shortest_path_bound_pipelines": [
"arith_total",
"arith_cvt",
"arith_sfu"
],
"shortest_path_cycles": [
0.0625,
0.03125,
0.0625,
0.0625,
0.0,
0.0,
0.0
],
"total_bound_pipelines": [
"arith_total",
"arith_sfu"
],
"total_cycles": [
0.3125,
0.234375,
0.296875,
0.3125,
0.0,
0.25,
0.25
]
},
"stack_spill_bytes": 0,
"thread_occupancy": 100,
"uniform_registers_used": 8,
"work_registers_used": 19
}
}
},
"Mali-T880": {
"core": "Mali-T880",
"filename": "flutter/impeller/entity/gles/gaussian_blur_noalpha_decal.frag.gles",
"has_uniform_computation": false,
"type": "Fragment",
"variants": {
"Main": {
"has_stack_spilling": false,
"performance": {
"longest_path_bound_pipelines": [
null
],
"longest_path_cycles": [
null,
null,
null
],
"pipelines": [
"arithmetic",
"load_store",
"texture"
],
"shortest_path_bound_pipelines": [
"arithmetic"
],
"shortest_path_cycles": [
1.649999976158142,
1.0,
0.0
],
"total_bound_pipelines": [
"arithmetic"
],
"total_cycles": [
5.0,
1.0,
1.0
]
},
"thread_occupancy": 100,
"uniform_registers_used": 1,
"work_registers_used": 4
}
}
}
},
"flutter/impeller/entity/gles/gaussian_blur_noalpha_nodecal.frag.gles": {
"Mali-G78": {
"core": "Mali-G78",
"filename": "flutter/impeller/entity/gles/gaussian_blur_noalpha_nodecal.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": 66,
"has_stack_spilling": false,
"performance": {
"longest_path_bound_pipelines": [
null
],
"longest_path_cycles": [
null,
null,
null,
null,
null,
null,
null
],
"pipelines": [
"arith_total",
"arith_fma",
"arith_cvt",
"arith_sfu",
"load_store",
"varying",
"texture"
],
"shortest_path_bound_pipelines": [
"arith_total",
"arith_cvt",
"arith_sfu"
],
"shortest_path_cycles": [
0.0625,
0.03125,
0.0625,
0.0625,
0.0,
0.0,
0.0
],
"total_bound_pipelines": [
"varying",
"texture"
],
"total_cycles": [
0.234375,
0.234375,
0.1875,
0.125,
0.0,
0.25,
0.25
]
},
"stack_spill_bytes": 0,
"thread_occupancy": 100,
"uniform_registers_used": 8,
"work_registers_used": 19
}
}
},
"Mali-T880": {
"core": "Mali-T880",
"filename": "flutter/impeller/entity/gles/gaussian_blur_noalpha_nodecal.frag.gles",
"has_uniform_computation": false,
"type": "Fragment",
"variants": {
"Main": {
"has_stack_spilling": false,
"performance": {
"longest_path_bound_pipelines": [
null
],
"longest_path_cycles": [
null,
null,
null
],
"pipelines": [
"arithmetic",
"load_store",
"texture"
],
"shortest_path_bound_pipelines": [
"arithmetic"
],
"shortest_path_cycles": [
1.649999976158142,
1.0,
0.0
],
"total_bound_pipelines": [
"arithmetic"
],
"total_cycles": [
3.6666667461395264,
1.0,
1.0
]
},
"thread_occupancy": 100,
"uniform_registers_used": 1,
"work_registers_used": 2
}
}
}
},
"flutter/impeller/entity/gles/glyph_atlas.frag.gles": {
"Mali-G78": {
"core": "Mali-G78",