[Mesa-dev] [PATCH] android: add support for EGL_EXT_buffer_age extension
Tapani Pälli
tapani.palli at intel.com
Wed Nov 30 11:01:45 UTC 2016
On 11/29/2016 04:20 PM, Eric Engestrom wrote:
> On Thursday, 2016-11-24 11:38:07 +0200, Tapani Pälli wrote:
>> From: Kalyan Kondapally <kalyan.kondapally at intel.com>
>>
>> - initialize buffer age as 0 (Tapani)
>>
>> Signed-off-by: Kalyan Kondapally <kalyan.kondapally at intel.com>
>> ---
>> src/egl/drivers/dri2/egl_dri2.h | 2 ++
>> src/egl/drivers/dri2/platform_android.c | 24 +++++++++++++++++++++++-
>> 2 files changed, 25 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
>> index eac58f3..4eda1a2 100644
>> --- a/src/egl/drivers/dri2/egl_dri2.h
>> +++ b/src/egl/drivers/dri2/egl_dri2.h
>> @@ -297,6 +297,8 @@ struct dri2_egl_surface
>> __DRIimage *dri_image_back;
>> __DRIimage *dri_image_front;
>>
>> + int back_buffer_age;
>> +
>> /* EGL-owned buffers */
>> __DRIbuffer *local_buffers[__DRI_BUFFER_COUNT];
>> #endif
>> diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
>> index 373e2c0..b6c6533 100644
>> --- a/src/egl/drivers/dri2/platform_android.c
>> +++ b/src/egl/drivers/dri2/platform_android.c
>> @@ -477,6 +477,8 @@ get_back_bo(struct dri2_egl_surface *dri2_surf)
>> if (!dri2_surf->dri_image_back)
>> return -1;
>>
>> + dri2_surf->back_buffer_age = 0;
>> +
>> return 0;
>> }
>>
>> @@ -573,6 +575,9 @@ droid_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
>> if (dri2_surf->base.Type != EGL_WINDOW_BIT)
>> return EGL_TRUE;
>>
>> + if (dri2_surf->back_buffer_age > 0)
>> + dri2_surf->back_buffer_age++;
>> +
> Am I missing something, or are you only incrementing the age of the
> buffer you just swapped?
>
> age for buffer # 0 1
>
> create buffer #0: 0
> create buffer #1: 0 0
> swap buffer #0: 1 0
> swap buffer #1: 1 1 <- buffer #0 should now have age 2
>
> I don't know the android code much, so I may well be missing something
> that already takes care of this :)
Right, I get what you mean. I'll go through the tests in more detail to
see how they actually use the age information and get back to this.
There is partial rendering, resizing (with preserved and non preserved)
so it seems like it *should* catch if there's something wrong.
>> dri2_flush_drawable_for_swapbuffers(disp, draw);
>>
>> if (dri2_surf->buffer)
>> @@ -580,9 +585,25 @@ droid_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
>>
>> (*dri2_dpy->flush->invalidate)(dri2_surf->dri_drawable);
>>
>> + dri2_surf->back_buffer_age = 1;
>> +
>> return EGL_TRUE;
>> }
>>
>> +static EGLint
>> +droid_query_buffer_age(_EGLDriver *drv,
>> + _EGLDisplay *disp, _EGLSurface *surface)
>> +{
>> + struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surface);
>> +
>> + if (get_back_bo(dri2_surf) < 0) {
>> + _eglError(EGL_BAD_ALLOC, "dri2_query_buffer_age");
>> + return 0;
>> + }
>> +
>> + return dri2_surf->back_buffer_age;
>> +}
>> +
>> static _EGLImage *
>> droid_create_image_from_prime_fd_yuv(_EGLDisplay *disp, _EGLContext *ctx,
>> struct ANativeWindowBuffer *buf, int fd)
>> @@ -1027,7 +1048,7 @@ static struct dri2_egl_display_vtbl droid_display_vtbl = {
>> .swap_buffers_region = dri2_fallback_swap_buffers_region,
>> .post_sub_buffer = dri2_fallback_post_sub_buffer,
>> .copy_buffers = dri2_fallback_copy_buffers,
>> - .query_buffer_age = dri2_fallback_query_buffer_age,
>> + .query_buffer_age = droid_query_buffer_age,
>> .query_surface = droid_query_surface,
>> .create_wayland_buffer_from_image = dri2_fallback_create_wayland_buffer_from_image,
>> .get_sync_values = dri2_fallback_get_sync_values,
>> @@ -1126,6 +1147,7 @@ dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *dpy)
>> dpy->Extensions.ANDROID_framebuffer_target = EGL_TRUE;
>> dpy->Extensions.ANDROID_image_native_buffer = EGL_TRUE;
>> dpy->Extensions.ANDROID_recordable = EGL_TRUE;
>> + dpy->Extensions.EXT_buffer_age = EGL_TRUE;
>>
>> /* Fill vtbl last to prevent accidentally calling virtual function during
>> * initialization.
>> --
>> 2.7.4
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list