render/gles2: unify fragment shader

Instead of having 3 different fragment shaders for textures and 1
more for quads, unify them all and compile different variants via
a SOURCE constant.

In the future, we will have more variant dimensions: pre-multiplied
alpha on/off, color transformation, etc. It will become inpractical
to have one file per combination.

Weston has a similar approach:
https://gitlab.freedesktop.org/wayland/weston/-/blob/main/libweston/renderer-gl/fragment.glsl
This commit is contained in:
Simon Ser 2022-10-26 21:22:47 +02:00
parent 32d00984e1
commit 25d8151870
8 changed files with 91 additions and 77 deletions

View file

@ -112,6 +112,12 @@ struct wlr_gles2_texture {
struct wlr_addon buffer_addon;
};
enum wlr_gles2_shader_source {
WLR_GLES2_SHADER_SOURCE_SINGLE_COLOR = 1,
WLR_GLES2_SHADER_SOURCE_TEXTURE_RGBA = 2,
WLR_GLES2_SHADER_SOURCE_TEXTURE_RGBX = 3,
WLR_GLES2_SHADER_SOURCE_TEXTURE_EXTERNAL = 4,
};
bool is_gles2_pixel_format_supported(const struct wlr_gles2_renderer *renderer,
const struct wlr_gles2_pixel_format *format);