This patch gathers all values to be loaded to shader uniforms into a new struct gl_shader_config along with texture target and filter information. Struct gl_shader becomes opaque outside of gl-shaders.c. Everything that used or open-coded these are converted.
The aim is to make gl-renderer.c easier to read. Previously, uniform
values were loaded up in various places, texture units were set up in one place, textures were bound into units in different places. Stuff was all over the place.
Now, shader requirements and associated uniform data is stored in a single struct. The data is loaded into a shader program in one function only.
That makes it easy for things like maybe_censor_override() to replace the whole config rather than poke only the shader requirements. This may not look like much right now, but when color management adds more uniforms and even hardcoded color need to go through the proper color pipeline, doing things the old way would become intractable.
Similar simplification can be seen in draw_view(), where the RGBA->RGBX override becomes more contained. There is no longer a need to "pre-load" the shader used by triangle fan debug. Triangle fan debug no longer needs to play tricks with saving and restoring the current shader.
The real benefit of this change will probably come when almost all shader operations need to take color spaces into account. That means filling in gl_shader_config parts based on a color transformation.
This is based on an idea Sebastian already used in his Weston color management work.
0f52da62 gl-renderer: rework uniform value assignments
libweston/renderer-gl/gl-renderer-internal.h | 31 +--
libweston/renderer-gl/gl-renderer.c | 306 +++++++++++++--------------
libweston/renderer-gl/gl-shaders.c | 73 ++++++-
3 files changed, 220 insertions(+), 190 deletions(-)