Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion impeller/entity/contents/content_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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_,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 13 additions & 0 deletions impeller/entity/entity_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 3 additions & 5 deletions impeller/entity/shaders/morphology_filter.frag
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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);
Expand Down
19 changes: 10 additions & 9 deletions impeller/tools/malioc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down Expand Up @@ -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
}
}
},
Expand Down Expand Up @@ -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
}
}
}
Expand Down