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

Commit 10c0ba2

Browse files
author
Jonah Williams
authored
[Impeller] use spec constant for decal support in morph filter. (#48288)
Don't branch on uniform for decal support in GLES backend.
1 parent 2185cf4 commit 10c0ba2

File tree

5 files changed

+28
-17
lines changed

5 files changed

+28
-17
lines changed

impeller/entity/contents/content_context.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,8 @@ ContentContext::ContentContext(
322322
gaussian_blur_noalpha_nodecal_pipelines_.CreateDefault(*context_,
323323
options_trianglestrip);
324324
border_mask_blur_pipelines_.CreateDefault(*context_, options_trianglestrip);
325-
morphology_filter_pipelines_.CreateDefault(*context_, options_trianglestrip);
325+
morphology_filter_pipelines_.CreateDefault(*context_, options_trianglestrip,
326+
{supports_decal});
326327
color_matrix_color_filter_pipelines_.CreateDefault(*context_,
327328
options_trianglestrip);
328329
linear_to_srgb_filter_pipelines_.CreateDefault(*context_,

impeller/entity/contents/filters/morphology_filter_contents.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,6 @@ std::optional<Entity> DirectionalMorphologyFilterContents::RenderFilter(
127127
sampler_descriptor.width_address_mode = SamplerAddressMode::kDecal;
128128
sampler_descriptor.height_address_mode = SamplerAddressMode::kDecal;
129129
}
130-
frag_info.supports_decal_sampler_address_mode =
131-
renderer.GetDeviceCapabilities().SupportsDecalSamplerAddressMode();
132130

133131
FS::BindTextureSampler(
134132
cmd, input_snapshot->texture,

impeller/entity/entity_unittests.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2514,6 +2514,19 @@ TEST_P(EntityTest, SpecializationConstantsAreAppliedToVariants) {
25142514
expected_constants);
25152515
}
25162516

2517+
TEST_P(EntityTest, DecalSpecializationAppliedToMorphologyFilter) {
2518+
auto content_context =
2519+
ContentContext(GetContext(), TypographerContextSkia::Make());
2520+
2521+
auto default_color_burn = content_context.GetMorphologyFilterPipeline({});
2522+
2523+
auto decal_supported = static_cast<int32_t>(
2524+
GetContext()->GetCapabilities()->SupportsDecalSamplerAddressMode());
2525+
std::vector<int32_t> expected_constants = {decal_supported};
2526+
ASSERT_EQ(default_color_burn->GetDescriptor().GetSpecializationConstants(),
2527+
expected_constants);
2528+
}
2529+
25172530
} // namespace testing
25182531
} // namespace impeller
25192532

impeller/entity/shaders/morphology_filter.frag

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
precision mediump float;
66

7+
layout(constant_id = 0) const int supports_decal = 1;
8+
79
#include <impeller/constants.glsl>
810
#include <impeller/texture.glsl>
911
#include <impeller/types.glsl>
@@ -34,15 +36,11 @@ void main() {
3436
vec2 texture_coords = v_texture_coords + frag_info.uv_offset * i;
3537

3638
f16vec4 color;
37-
#ifdef IMPELLER_TARGET_OPENGLES
38-
if (frag_info.supports_decal_sampler_address_mode > 0.0) {
39+
if (supports_decal == 1) {
3940
color = texture(texture_sampler, texture_coords);
4041
} else {
4142
color = IPHalfSampleDecal(texture_sampler, texture_coords);
4243
}
43-
#else
44-
color = texture(texture_sampler, texture_coords);
45-
#endif
4644

4745
if (frag_info.morph_type == kMorphTypeDilate) {
4846
result = max(color, result);

impeller/tools/malioc.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4437,7 +4437,7 @@
44374437
"uses_late_zs_update": false,
44384438
"variants": {
44394439
"Main": {
4440-
"fp16_arithmetic": 57,
4440+
"fp16_arithmetic": 80,
44414441
"has_stack_spilling": false,
44424442
"performance": {
44434443
"longest_path_bound_pipelines": [
@@ -4475,22 +4475,23 @@
44754475
0.0
44764476
],
44774477
"total_bound_pipelines": [
4478+
"varying",
44784479
"texture"
44794480
],
44804481
"total_cycles": [
4481-
0.390625,
4482+
0.234375,
44824483
0.078125,
4483-
0.390625,
4484-
0.0625,
4484+
0.234375,
4485+
0.0,
44854486
0.0,
44864487
0.25,
4487-
0.5
4488+
0.25
44884489
]
44894490
},
44904491
"stack_spill_bytes": 0,
44914492
"thread_occupancy": 100,
44924493
"uniform_registers_used": 8,
4493-
"work_registers_used": 20
4494+
"work_registers_used": 21
44944495
}
44954496
}
44964497
},
@@ -4529,14 +4530,14 @@
45294530
"arithmetic"
45304531
],
45314532
"total_cycles": [
4532-
4.666666507720947,
4533+
2.6666667461395264,
45334534
1.0,
4534-
2.0
4535+
1.0
45354536
]
45364537
},
45374538
"thread_occupancy": 100,
45384539
"uniform_registers_used": 1,
4539-
"work_registers_used": 3
4540+
"work_registers_used": 4
45404541
}
45414542
}
45424543
}

0 commit comments

Comments
 (0)