compositor: fix and simplify shader uniform handling
authorPekka Paalanen <ppaalanen@gmail.com>
Thu, 2 Feb 2012 14:49:05 +0000 (16:49 +0200)
committerPekka Paalanen <ppaalanen@gmail.com>
Thu, 2 Feb 2012 14:49:05 +0000 (16:49 +0200)
commitf55f544e4fe1abc5224afda4a96355e6665391cc
tree9f76ef1ba0eb1f22f82f171c938c42dbe2fd9985
parent0e4452e02a1036e7c85059762cd7b5f5aede1eaa
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>
src/compositor.c
src/compositor.h