gl-renderer: rework uniform value assignments
This is another step towards adding color transformation capabilities to GL-renderer.
More code is moved into gl-shaders.c
. A new struct gl_shader_config
is introduced:
struct gl_shader_config {
struct gl_shader_requirements req;
struct weston_matrix projection;
float view_alpha;
GLfloat unicolor[4];
GLint input_tex_filter; /* GL_NEAREST or GL_LINEAR */
GLuint input_tex[GL_SHADER_INPUT_TEX_MAX];
};
This structure contains the shader requirements which controls what parts of a fragment shader get compiled, and the values for all possible uniforms (not uniform locations). Additionally, input_tex_filter
and input_tex_target
to help with setting up input textures (i.e. client content; other kinds of textures will be added later).
The aim is to simplify code. The idea is that one builds a gl_shader_config
from everything you know. If something like triangle fan debug or HDCP-related censoring needs to replace it with something totally different, it can be done with a single assignment. Then the shader config is loaded in a function that takes care of compiling the shader if needed, setting up textures, and loading uniform values, all in one place together.
I felt that this change is necessary going forward with color management. I need to add more textures and uniforms to fragment shaders, and the old approach looks like it would fall apart quickly.
If you want to see where I'm going with this, see my WIP https://gitlab.freedesktop.org/pq/weston/-/commits/mr/color-arch .
This idea is not my own, it comes from @swick and his Weston color management work that I am using as guidance. Unfortunately I've changed so many things that I can't even rebase Sebastian's patches, so I hope tagging him as co-authored-by is enough.
Cc @vitalyp