[Mesa-dev] [RFC PATCH] egl/android: Dequeue buffers inside EGL calls
Tomasz Figa
tfiga at chromium.org
Thu Mar 30 11:02:15 UTC 2017
Uhh, last minute rebase without compile re-testing, sorry. <facepalm>
On Thu, Mar 30, 2017 at 7:55 PM, Tomasz Figa <tfiga at chromium.org> wrote:
[snip]
> diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
> index 6db4015cc9..571afa8004 100644
> --- a/src/egl/drivers/dri2/platform_android.c
> +++ b/src/egl/drivers/dri2/platform_android.c
[snip]
> @@ -195,15 +224,36 @@ droid_window_dequeue_buffer(struct dri2_egl_surface *dri2_surf)
> * any value except -1) then the caller is responsible for closing the
> * file descriptor.
> */
> - if (fence_fd >= 0) {
> + if (dri2_surf->acquire_fence_fd >= 0) {
> /* From the SYNC_IOC_WAIT documentation in <linux/sync.h>:
> *
> * Waits indefinitely if timeout < 0.
> */
> int timeout = -1;
> - sync_wait(fence_fd, timeout);
> - close(fence_fd);
> + sync_wait(dri2_surf->acquire_fence_fd, timeout);
> + close(dri2_surf->acquire_fence_fd);
> + dri2_surf->acquire_fence_fd = -1;
> }
> +}
> +
> +static EGLBoolean
> +droid_window_dequeue_buffer(struct dri2_egl_surface *dri2_surf)
Should be:
+droid_window_dequeue_buffer(_EGLDisplay *disp, struct
dri2_egl_surface *dri2_surf)
> +{
> + int err;
> +
> + /* To avoid blocking other EGL calls, release the display mutex before
> + * we enter droid_window_enqueue_buffer() and re-acquire the mutex upon
> + * return.
> + */
> + mtx_unlock(&disp->Mutex);
> +
> + err = dri2_surf->window->dequeueBuffer(dri2_surf->window, &dri2_surf->buffer,
> + &dri2_surf->acquire_fence_fd);
> +
> + mtx_lock(&disp->Mutex);
> +
> + if (err)
> + return EGL_FALSE;
>
> dri2_surf->buffer->common.incRef(&dri2_surf->buffer->common);
>
[snip]
> @@ -336,6 +362,7 @@ droid_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
> _eglError(EGL_BAD_ALLOC, "droid_create_surface");
> return NULL;
> }
> + dri2_surf->acquire_fence_fd = -1;
>
> if (!_eglInitSurface(&dri2_surf->base, disp, type, conf, attrib_list))
> goto cleanup_surface;
> @@ -377,10 +404,18 @@ droid_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
> if (window) {
> window->common.incRef(&window->common);
> dri2_surf->window = window;
> + if (!droid_window_dequeue_buffer(dri2_surf)) {
Should be:
+ if (!droid_window_dequeue_buffer(disp, dri2_surf)) {
> + _eglError(EGL_BAD_SURFACE, "Could not dequeue buffer from native window");
> + goto cleanup_window;
> + }
> }
>
> return &dri2_surf->base;
>
> +cleanup_window:
> + window->common.decRef(&window->common);
> + (*dri2_dpy->core->destroyDrawable)(dri2_surf->dri_drawable);
> +
> cleanup_surface:
> free(dri2_surf);
>
[snip]
> @@ -651,6 +664,12 @@ droid_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
>
> dri2_dpy->flush->invalidate(dri2_surf->dri_drawable);
>
> + /* try to dequeue the next back buffer */
> + if (!droid_window_dequeue_buffer(dri2_surf)) {
Should be:
+ if (!droid_window_dequeue_buffer(disp, dri2_surf)) {
Sorry for the noise. Will resend correct patch anyway.
Best regards,
Tomasz
More information about the mesa-dev
mailing list