compositor: fix and simplify shader uniform handling
The uniform location variables should be signed, according to the OpenGL
ES 2 specification. Moreover, GL_NONE, i.e. 0, is not an invalid nor
special location; it is actually used as a valid uniform location.
Change struct weston_shader uniform members to signed.
Stop using 0 for identifying a non-existing uniform, use -1 instead.
Furthermore, as the spec says a) glGetUniformLocation() will return -1
for non-active/existing uniforms, and b) glUniform*() function will
simply ignore all calls with location -1, we can simplify the code. We
don't have to avoid locating uniforms that don't exist, and we don't
need to test for them in weston_surface_draw() either.
Remove the micro-optimisation that avoids setting 'alpha' uniform if it
has not changed, in the name of simplification.
Unify shader creation by dropping init_solid_shader(), and calling
weston_shader_init() instead. The downside is that we compile the vertex
shader twice at startup now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
diff --git a/src/compositor.h b/src/compositor.h
index 4bc4ba2..5d12d43 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -99,11 +99,11 @@
struct weston_shader {
GLuint program;
GLuint vertex_shader, fragment_shader;
- GLuint proj_uniform;
- GLuint tex_uniform;
- GLuint alpha_uniform;
- GLuint color_uniform;
- GLuint texwidth_uniform;
+ GLint proj_uniform;
+ GLint tex_uniform;
+ GLint alpha_uniform;
+ GLint color_uniform;
+ GLint texwidth_uniform;
};
struct weston_animation {
@@ -148,7 +148,6 @@
EGLContext context;
EGLConfig config;
GLuint fbo;
- uint32_t current_alpha;
struct weston_shader texture_shader;
struct weston_shader solid_shader;
struct weston_shader *current_shader;