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: ee107cd491 ("glamor: support GLES3 shaders")
Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1750>
This commit is contained in:
Icenowy Zheng 2024-12-14 01:07:31 +08:00 committed by Enrico Weigelt, metux IT consult
parent 3079488484
commit 3e1c2d5456

View File

@ -185,6 +185,24 @@ glamor_glyph_add(struct glamor_glyph_atlas *atlas, DrawablePtr glyph_draw)
return TRUE; 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 = { static const glamor_facet glamor_facet_composite_glyphs_130 = {
.name = "composite_glyphs", .name = "composite_glyphs",
.version = 130, .version = 130,
@ -464,7 +482,9 @@ glamor_composite_glyphs(CARD8 op,
if (glamor_glsl_has_ints(glamor_priv)) if (glamor_glsl_has_ints(glamor_priv))
prog = glamor_setup_program_render(op, src, glyph_pict, dst, prog = glamor_setup_program_render(op, src, glyph_pict, dst,
glyphs_program, 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); glamor_priv->glyph_defines);
else else
prog = glamor_setup_program_render(op, src, glyph_pict, dst, prog = glamor_setup_program_render(op, src, glyph_pict, dst,