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 1 commit
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
Prev Previous commit
Next Next commit
make it blend.
  • Loading branch information
jonahwilliams committed Apr 23, 2024
commit 40dce2813b58afb914535dc5b27440aa01eca697
2 changes: 1 addition & 1 deletion impeller/entity/contents/content_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ ContentContext::ContentContext(
yuv_to_rgb_filter_pipelines_.CreateDefault(*context_, options_trianglestrip);
porter_duff_blend_pipelines_.CreateDefault(*context_, options_trianglestrip,
{supports_decal});
vertices_uber_shader_.CreateDefault(*context_, options);
vertices_uber_shader_.CreateDefault(*context_, options, {supports_decal});
// GLES only shader that is unsupported on macOS.
#if defined(IMPELLER_ENABLE_OPENGLES) && !defined(FML_OS_MACOSX)
if (GetContext()->GetBackendType() == Context::BackendType::kOpenGLES) {
Expand Down
3 changes: 2 additions & 1 deletion impeller/entity/contents/vertices_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,8 @@ bool VerticesSimpleBlendContents::Render(const ContentContext& renderer,
frag_info.dst_coeff = blend_coefficients[2];
frag_info.dst_coeff_src_alpha = blend_coefficients[3];
frag_info.dst_coeff_src_color = blend_coefficients[4];
// Only used on devices that do not natively support advanced blends.

// These values are ignored if the platform supports native decal mode.
frag_info.tmx = static_cast<int>(tile_mode_x_);
frag_info.tmy = static_cast<int>(tile_mode_y_);

Expand Down
17 changes: 16 additions & 1 deletion impeller/entity/shaders/blending/vertices_uber.frag
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
#include <impeller/types.glsl>
#include "blend_select.glsl"

layout(constant_id = 0) const float supports_decal = 1.0;

uniform FragInfo {
float16_t alpha;
float16_t blend_mode;
float tmx;
float tmy;
}
frag_info;

Expand All @@ -19,13 +23,24 @@ in mediump f16vec4 v_color;

out f16vec4 frag_color;

f16vec4 Sample(f16sampler2D texture_sampler,
vec2 texture_coords,
float tmx,
float tmy) {
if (supports_decal > 0.0) {
return texture(texture_sampler, texture_coords);
}
return IPHalfSampleWithTileMode(texture_sampler, texture_coords, tmx, tmy);
}

// A shader that implements the required src/dst blending for drawVertices and
// drawAtlas advanced blends without requiring an offscreen render pass. This is
// done in a single shader to reduce the permutations of PSO needed at runtime
// for rarely used features.
void main() {
f16vec4 dst = IPHalfUnpremultiply(v_color);
f16vec4 src = IPHalfUnpremultiply(texture(texture_sampler, v_texture_coords));
f16vec4 src = IPHalfUnpremultiply(
Sample(texture_sampler, v_texture_coords, frag_info.tmx, frag_info.tmy));
f16vec3 blend_result =
AdvancedBlend(dst.rgb, src.rgb, int(frag_info.blend_mode - 14.0));
frag_color = IPApplyBlendedColor(dst, src, blend_result);
Expand Down