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

[Impeller] Adjust advanced blend construction to avoid moto g4 crash. #47637

Closed
Closed
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
4 changes: 1 addition & 3 deletions impeller/entity/shaders/blending/advanced_blend.frag
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ f16vec4 Sample(f16sampler2D texture_sampler, vec2 texture_coords) {
return IPHalfSampleDecal(texture_sampler, texture_coords);
}

AdvancedBlend(blend_type);

void main() {
f16vec4 dst_sample = Sample(texture_sampler_dst, // sampler
v_dst_texture_coords // texture coordinates
Expand All @@ -51,7 +49,7 @@ void main() {
) *
blend_info.src_input_alpha;

f16vec3 blend_result = Blend(dst.rgb, src.rgb);
f16vec3 blend_result = AdvancedBlend(dst.rgb, src.rgb, blend_type);
f16vec4 blended = mix(src, f16vec4(blend_result, dst.a), dst.a);
frag_color = mix(dst_sample, blended, src.a);
}
82 changes: 47 additions & 35 deletions impeller/entity/shaders/blending/blend_select.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -22,39 +22,51 @@
// kColor,
// kLuminosity,
// Note, this isn't a switch as GLSL ES 1.0 does not support them.
#define AdvancedBlend(blend_type) \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yeah this shader was totally broken for all backends (impellerc runs the preprocessor), but we just don't use this shader on iOS anymore. GL goldens on CI would have caught this.

f16vec3 Blend(f16vec3 dst, f16vec3 src) { \
if (blend_type == 0) { \
return IPBlendScreen(dst, src); \
} else if (blend_type == 1) { \
return IPBlendOverlay(dst, src); \
} else if (blend_type == 2) { \
return IPBlendDarken(dst, src); \
} else if (blend_type == 3) { \
return IPBlendLighten(dst, src); \
} else if (blend_type == 4) { \
return IPBlendColorDodge(dst, src); \
} else if (blend_type == 5) { \
return IPBlendColorBurn(dst, src); \
} else if (blend_type == 6) { \
return IPBlendHardLight(dst, src); \
} else if (blend_type == 7) { \
return IPBlendSoftLight(dst, src); \
} else if (blend_type == 8) { \
return IPBlendDifference(dst, src); \
} else if (blend_type == 9) { \
return IPBlendExclusion(dst, src); \
} else if (blend_type == 10) { \
return IPBlendMultiply(dst, src); \
} else if (blend_type == 11) { \
return IPBlendHue(dst, src); \
} else if (blend_type == 12) { \
return IPBlendSaturation(dst, src); \
} else if (blend_type == 13) { \
return IPBlendColor(dst, src); \
} else if (blend_type == 14) { \
return IPBlendLuminosity(dst, src); \
} else { \
return f16vec3(0.0hf); \
} \
f16vec3 AdvancedBlend(f16vec3 dst, f16vec3 src, int blend_type) {
if (blend_type == 0) {
return IPBlendScreen(dst, src);
}
if (blend_type == 1) {
return IPBlendOverlay(dst, src);
}
if (blend_type == 2) {
return IPBlendDarken(dst, src);
}
if (blend_type == 3) {
return IPBlendLighten(dst, src);
}
if (blend_type == 4) {
return IPBlendColorDodge(dst, src);
}
if (blend_type == 5) {
return IPBlendColorBurn(dst, src);
}
if (blend_type == 6) {
return IPBlendHardLight(dst, src);
}
if (blend_type == 7) {
return IPBlendSoftLight(dst, src);
}
if (blend_type == 8) {
return IPBlendDifference(dst, src);
}
if (blend_type == 9) {
return IPBlendExclusion(dst, src);
}
if (blend_type == 10) {
return IPBlendMultiply(dst, src);
}
if (blend_type == 11) {
return IPBlendHue(dst, src);
}
if (blend_type == 12) {
return IPBlendSaturation(dst, src);
}
if (blend_type == 13) {
return IPBlendColor(dst, src);
}
if (blend_type == 14) {
return IPBlendLuminosity(dst, src);
}
return f16vec3(0.0hf);
}
4 changes: 1 addition & 3 deletions impeller/entity/shaders/blending/framebuffer_blend.frag
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,14 @@ vec4 Sample(sampler2D texture_sampler, vec2 texture_coords) {
return IPSampleDecal(texture_sampler, texture_coords);
}

AdvancedBlend(blend_type);

void main() {
f16vec4 dst = f16vec4(ReadDestination());
f16vec4 src = f16vec4(Sample(texture_sampler_src, // sampler
v_src_texture_coords // texture coordinates
)) *
frag_info.src_input_alpha;

f16vec3 blend_result = Blend(dst.rgb, src.rgb);
f16vec3 blend_result = AdvancedBlend(dst.rgb, src.rgb, blend_type);
f16vec4 blended = mix(src, f16vec4(blend_result, dst.a), dst.a);
frag_color = vec4(mix(dst, blended, src.a));
}