diff --git a/impeller/entity/contents/content_context.cc b/impeller/entity/contents/content_context.cc index 9a2e66039b5f8..3081469c4511e 100644 --- a/impeller/entity/contents/content_context.cc +++ b/impeller/entity/contents/content_context.cc @@ -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_, diff --git a/impeller/entity/contents/filters/morphology_filter_contents.cc b/impeller/entity/contents/filters/morphology_filter_contents.cc index d9c871dbbfc11..0fb2760e6aa23 100644 --- a/impeller/entity/contents/filters/morphology_filter_contents.cc +++ b/impeller/entity/contents/filters/morphology_filter_contents.cc @@ -127,8 +127,6 @@ std::optional 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, diff --git a/impeller/entity/entity_unittests.cc b/impeller/entity/entity_unittests.cc index 15fa315807954..60aae37ddf693 100644 --- a/impeller/entity/entity_unittests.cc +++ b/impeller/entity/entity_unittests.cc @@ -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( + GetContext()->GetCapabilities()->SupportsDecalSamplerAddressMode()); + std::vector expected_constants = {decal_supported}; + ASSERT_EQ(default_color_burn->GetDescriptor().GetSpecializationConstants(), + expected_constants); +} + } // namespace testing } // namespace impeller diff --git a/impeller/entity/shaders/morphology_filter.frag b/impeller/entity/shaders/morphology_filter.frag index 29428d0774b7f..ec9fb0e369e42 100644 --- a/impeller/entity/shaders/morphology_filter.frag +++ b/impeller/entity/shaders/morphology_filter.frag @@ -4,6 +4,8 @@ precision mediump float; +layout(constant_id = 0) const int supports_decal = 1; + #include #include #include @@ -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); diff --git a/impeller/tools/malioc.json b/impeller/tools/malioc.json index 12f9d54e6eced..90bee3952a2d3 100644 --- a/impeller/tools/malioc.json +++ b/impeller/tools/malioc.json @@ -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 } } }