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

Tapani Pälli tapani.palli at intel.com
Tue Feb 3 22:20:39 PST 2015



On 02/03/2015 07:32 PM, Emil Velikov wrote:
> 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) ?

I put it in separate header so that wcore_platform.h would not need to 
include whole "waffle.h" but if that feels ok then typedef can be moved 
here.

> 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);

This means that callback would be window specific. I think this is ok, 
although then user needs to register callback for each window separately 
and window argument could be removed from the actual callback.

> 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 :)

I'm now sure what would be the abuse case?

>> +    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
> _______________________________________________
> waffle mailing list
> waffle at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/waffle
>


More information about the waffle mailing list