From 3e1c2d545682aee34329f071d9d791b335bdbf95 Mon Sep 17 00:00:00 2001 From: Icenowy Zheng Date: Sat, 14 Dec 2024 01:07:31 +0800 Subject: [PATCH] glamor: Fix dual blend on GLES3 The EXT_blend_func_extended extension on ESSL always requires explicit request to allow two FS out variables because of limitations of the ESSL language, which is mentioned as the No.6 issue of the extension's specification. Fix this by adding the extension request. The original behavior on GLES3 is slightly against the specification of GL_EXT_blend_func_extended extension, however Mesa and older version of PowerVR closed drivers will just ignore this issue. Newest PowerVR closed driver will bail out on this problem, so it deems a fix now. Fixes: ee107cd4911e ("glamor: support GLES3 shaders") Signed-off-by: Icenowy Zheng Part-of: --- glamor/glamor_composite_glyphs.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/glamor/glamor_composite_glyphs.c b/glamor/glamor_composite_glyphs.c index faf8409c3..8e15a349e 100644 --- a/glamor/glamor_composite_glyphs.c +++ b/glamor/glamor_composite_glyphs.c @@ -185,6 +185,24 @@ glamor_glyph_add(struct glamor_glyph_atlas *atlas, DrawablePtr glyph_draw) return TRUE; } +static const glamor_facet glamor_facet_composite_glyphs_es300 = { + .name = "composite_glyphs", + .version = 130, + .fs_extensions = ("#extension GL_EXT_blend_func_extended : enable\n"), + .vs_vars = ("in vec4 primitive;\n" + "in vec2 source;\n" + "out vec2 glyph_pos;\n"), + .vs_exec = (" vec2 pos = primitive.zw * vec2(gl_VertexID&1, (gl_VertexID&2)>>1);\n" + GLAMOR_POS(gl_Position, (primitive.xy + pos)) + " glyph_pos = (source + pos) * ATLAS_DIM_INV;\n"), + .fs_vars = ("in vec2 glyph_pos;\n" + "out vec4 color0;\n" + "out vec4 color1;\n"), + .fs_exec = (" vec4 mask = texture(atlas, glyph_pos);\n"), + .source_name = "source", + .locations = glamor_program_location_atlas, +}; + static const glamor_facet glamor_facet_composite_glyphs_130 = { .name = "composite_glyphs", .version = 130, @@ -464,7 +482,9 @@ glamor_composite_glyphs(CARD8 op, if (glamor_glsl_has_ints(glamor_priv)) prog = glamor_setup_program_render(op, src, glyph_pict, dst, glyphs_program, - &glamor_facet_composite_glyphs_130, + glamor_priv->is_gles ? + &glamor_facet_composite_glyphs_es300 : + &glamor_facet_composite_glyphs_130, glamor_priv->glyph_defines); else prog = glamor_setup_program_render(op, src, glyph_pict, dst,