[waffle] [RFC] waffle: support for swap completion callback

Emil Velikov emil.l.velikov at gmail.com
Tue Feb 3 09:32:14 PST 2015


On 2 February 2015 at 13:08, Tapani Pälli <tapani.palli at intel.com> wrote:
> Patch introduces a new API that enables application to register
> a callback to be called when swapbuffers has finished. This can be
> used to throttle rendering loop.
>
[...]
> @@ -173,6 +174,9 @@ bool
>  waffle_is_extension_in_string(const char *extension_string,
>                                const char *extension_name);
>
> +bool
> +waffle_register_swap_callback(waffle_swapbuffers_cb func);
> +
Perhaps inlining the typedef in there, and wrapping it in
WAFFLE_API_VERSION (alongside the function prototype) ?

Fwiw changing the func prototype to something like the following will
be more consistent, and less likely to abuse.

bool
waffle_window_register_swap_callback(struct waffle_window *window,
waffle_swapbuffers_cb func);

On the topic of the OML triple (ust, msc, sbc), I cannot really
comment as I've never had the pleasure.

> diff --git a/src/waffle/api/waffle_gl_misc.c b/src/waffle/api/waffle_gl_misc.c
> index 138974d..ac155c0 100644
> --- a/src/waffle/api/waffle_gl_misc.c
> +++ b/src/waffle/api/waffle_gl_misc.c
> @@ -108,3 +108,20 @@ waffle_get_proc_address(const char *name)
>
>      return api_platform->vtbl->get_proc_address(api_platform, name);
>  }
> +
> +WAFFLE_API bool
> +waffle_register_swap_callback(waffle_swapbuffers_cb func)
> +{
> +    const struct api_object *obj_list[] = {
> +        (void*) func,
> +    };
> +
> +    if (!api_check_entry(obj_list, 1))
> +        return false;
> +
With the "struct waffle_window *" in you can use it so that one does
not abuse the API too much :)

> +    if (api_platform->vtbl->register_swap_callback)
> +        return api_platform->vtbl->register_swap_callback(api_platform, func);
> +
> +    wcore_error(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM);
I'm not sure if we should error in here, considering that one of all
platforms is likely to have a callback func.

Cheers,
Emil


More information about the waffle mailing list