mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[Impeller] use spec constant for decal support in morph filter. (flutter/engine#48288)
Don't branch on uniform for decal support in GLES backend.
This commit is contained in:
parent
0ba4edc764
commit
02ba2b7ff2
@ -322,7 +322,8 @@ ContentContext::ContentContext(
|
||||
gaussian_blur_noalpha_nodecal_pipelines_.CreateDefault(*context_,
|
||||
options_trianglestrip);
|
||||
border_mask_blur_pipelines_.CreateDefault(*context_, options_trianglestrip);
|
||||
morphology_filter_pipelines_.CreateDefault(*context_, options_trianglestrip);
|
||||
morphology_filter_pipelines_.CreateDefault(*context_, options_trianglestrip,
|
||||
{supports_decal});
|
||||
color_matrix_color_filter_pipelines_.CreateDefault(*context_,
|
||||
options_trianglestrip);
|
||||
linear_to_srgb_filter_pipelines_.CreateDefault(*context_,
|
||||
|
||||
@ -127,8 +127,6 @@ std::optional<Entity> DirectionalMorphologyFilterContents::RenderFilter(
|
||||
sampler_descriptor.width_address_mode = SamplerAddressMode::kDecal;
|
||||
sampler_descriptor.height_address_mode = SamplerAddressMode::kDecal;
|
||||
}
|
||||
frag_info.supports_decal_sampler_address_mode =
|
||||
renderer.GetDeviceCapabilities().SupportsDecalSamplerAddressMode();
|
||||
|
||||
FS::BindTextureSampler(
|
||||
cmd, input_snapshot->texture,
|
||||
|
||||
@ -2514,6 +2514,19 @@ TEST_P(EntityTest, SpecializationConstantsAreAppliedToVariants) {
|
||||
expected_constants);
|
||||
}
|
||||
|
||||
TEST_P(EntityTest, DecalSpecializationAppliedToMorphologyFilter) {
|
||||
auto content_context =
|
||||
ContentContext(GetContext(), TypographerContextSkia::Make());
|
||||
|
||||
auto default_color_burn = content_context.GetMorphologyFilterPipeline({});
|
||||
|
||||
auto decal_supported = static_cast<int32_t>(
|
||||
GetContext()->GetCapabilities()->SupportsDecalSamplerAddressMode());
|
||||
std::vector<int32_t> expected_constants = {decal_supported};
|
||||
ASSERT_EQ(default_color_burn->GetDescriptor().GetSpecializationConstants(),
|
||||
expected_constants);
|
||||
}
|
||||
|
||||
} // namespace testing
|
||||
} // namespace impeller
|
||||
|
||||
|
||||
@ -4,6 +4,8 @@
|
||||
|
||||
precision mediump float;
|
||||
|
||||
layout(constant_id = 0) const int supports_decal = 1;
|
||||
|
||||
#include <impeller/constants.glsl>
|
||||
#include <impeller/texture.glsl>
|
||||
#include <impeller/types.glsl>
|
||||
@ -34,15 +36,11 @@ void main() {
|
||||
vec2 texture_coords = v_texture_coords + frag_info.uv_offset * i;
|
||||
|
||||
f16vec4 color;
|
||||
#ifdef IMPELLER_TARGET_OPENGLES
|
||||
if (frag_info.supports_decal_sampler_address_mode > 0.0) {
|
||||
if (supports_decal == 1) {
|
||||
color = texture(texture_sampler, texture_coords);
|
||||
} else {
|
||||
color = IPHalfSampleDecal(texture_sampler, texture_coords);
|
||||
}
|
||||
#else
|
||||
color = texture(texture_sampler, texture_coords);
|
||||
#endif
|
||||
|
||||
if (frag_info.morph_type == kMorphTypeDilate) {
|
||||
result = max(color, result);
|
||||
|
||||
@ -4437,7 +4437,7 @@
|
||||
"uses_late_zs_update": false,
|
||||
"variants": {
|
||||
"Main": {
|
||||
"fp16_arithmetic": 57,
|
||||
"fp16_arithmetic": 80,
|
||||
"has_stack_spilling": false,
|
||||
"performance": {
|
||||
"longest_path_bound_pipelines": [
|
||||
@ -4475,22 +4475,23 @@
|
||||
0.0
|
||||
],
|
||||
"total_bound_pipelines": [
|
||||
"varying",
|
||||
"texture"
|
||||
],
|
||||
"total_cycles": [
|
||||
0.390625,
|
||||
0.234375,
|
||||
0.078125,
|
||||
0.390625,
|
||||
0.0625,
|
||||
0.234375,
|
||||
0.0,
|
||||
0.0,
|
||||
0.25,
|
||||
0.5
|
||||
0.25
|
||||
]
|
||||
},
|
||||
"stack_spill_bytes": 0,
|
||||
"thread_occupancy": 100,
|
||||
"uniform_registers_used": 8,
|
||||
"work_registers_used": 20
|
||||
"work_registers_used": 21
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -4529,14 +4530,14 @@
|
||||
"arithmetic"
|
||||
],
|
||||
"total_cycles": [
|
||||
4.666666507720947,
|
||||
2.6666667461395264,
|
||||
1.0,
|
||||
2.0
|
||||
1.0
|
||||
]
|
||||
},
|
||||
"thread_occupancy": 100,
|
||||
"uniform_registers_used": 1,
|
||||
"work_registers_used": 3
|
||||
"work_registers_used": 4
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user