[PATCH] compositor: fix uniform handling for fade_output()

Kristian Høgsberg krh at bitplanet.net
Tue Dec 20 08:09:48 PST 2011


On Tue, Dec 20, 2011 at 9:38 AM, Pekka Paalanen <ppaalanen at gmail.com> wrote:
> fade_output() is strange in that it manufactures a wlsc_surface object
> by hand, and then calls wlsc_surface_draw() on it.
>
> Valgrind complained, that wlsc_surface_draw() accesses uninitialised
> data: wlsc_surface::alpha. fade_output() forgets to set it.
>
> Initialise surface.alpha in fade_output(). Specifically, set it to
> compositor->current_alpha to deliberatly avoid the gluniform1f() call in
> wlsc_surface_draw().
>
> fade_output() binds a different GL shader program than
> wlsc_surface_draw() expects. This program does not have a uniform called
> "alpha", and the uniform location given in glUniform1f() is not for
> this program anyway. A hint of that is the runtime error:
> Mesa: User error: GL_INVALID_OPERATION in glUniform(type mismatch)
>
> Fixing this seems to get rid of half a thousand of Valgrind errors, and
> of course the Mesa user error.

Ah, yup, thanks, applied. I think we want some kind of higher-level
abstraction though.  Maybe a new struct wlsc_visual or wlsc_material
that can incorporate the wlsc_shader and the blend state, with a vfunc
to do the setup.  That will then replace the WLSC_ARGB_VISUAL enums
and the switching.  And the fade surface could be a regular surface
and have it's own solid color visual.

Kristian



> Signed-off-by: Pekka Paalanen <ppaalanen at gmail.com>
> ---
>  compositor/compositor.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/compositor/compositor.c b/compositor/compositor.c
> index 19af47d..4dc99cb 100644
> --- a/compositor/compositor.c
> +++ b/compositor/compositor.c
> @@ -664,6 +664,7 @@ fade_output(struct wlsc_output *output,
>        surface.height = output->current->height;
>        surface.texture = GL_NONE;
>        surface.transform = NULL;
> +       surface.alpha = compositor->current_alpha;
>
>        if (tint <= 1.0)
>                surface.visual = WLSC_PREMUL_ARGB_VISUAL;
> --
> 1.7.3.4
>


More information about the wayland-devel mailing list