From d9164fd427f1204956d313108467c63da3971c1b Mon Sep 17 00:00:00 2001 From: Chad Versace Date: Thu, 4 May 2017 17:46:34 -0700 Subject: [PATCH] egl/android: Mark surface as lost when dequeueBuffer fails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This ensures that future calls to eglSwapBuffers and eglMakeCurrent emit an error. This patch is part of a series for fixing android.hardware.camera2.cts.RobustnessTest#testAbandonRepeatingRequestSurface on Chrome OS x86 devices. Cc: mesa-stable@lists.freedesktop.org Cc: Tomasz Figa Cc: Tapani Pälli Reviewed-by: Nicolas Boichat Reviewed-by: Emil Velikov (cherry picked from commit e5eace586848511f4ceaffaa2d45131c31c45ae0) Squashed with commit: egl/android: Set EGLSurface.Lost to EGL_TRUE/EGL_FALSE Lost is an EGLBoolean, so we should assign it to EGL_TRUE/EGL_FALSE, not true/false. Fixes: e5eace58684 ("egl/android: Mark surface as lost when dequeueBuffer fails") Fixes: 0212db35040 ("egl/android: Cancel any outstanding ANativeBuffer in surface destructor") Reviewed-by: Chad Versace (cherry picked from commit 63b12b0c77759a0244416cd1406c2bf50e7c01ec) --- src/egl/drivers/dri2/platform_android.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c index 3ac6098549c..8448427b4db 100644 --- a/src/egl/drivers/dri2/platform_android.c +++ b/src/egl/drivers/dri2/platform_android.c @@ -258,7 +258,7 @@ droid_window_cancel_buffer(struct dri2_egl_surface *dri2_surf) ret = dri2_surf->window->cancelBuffer(dri2_surf->window, dri2_surf->buffer, -1); if (ret < 0) { _eglLog(_EGL_WARNING, "ANativeWindow::cancelBuffer failed"); - dri2_surf->base.Lost = true; + dri2_surf->base.Lost = EGL_TRUE; } } @@ -418,12 +418,16 @@ droid_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf) static int update_buffers(struct dri2_egl_surface *dri2_surf) { + if (dri2_surf->base.Lost) + return -1; + if (dri2_surf->base.Type != EGL_WINDOW_BIT) return 0; /* try to dequeue the next back buffer */ if (!dri2_surf->buffer && !droid_window_dequeue_buffer(dri2_surf)) { _eglLog(_EGL_WARNING, "Could not dequeue buffer from native window"); + dri2_surf->base.Lost = EGL_TRUE; return -1; } @@ -595,6 +599,12 @@ droid_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw) dri2_flush_drawable_for_swapbuffers(disp, draw); + /* dri2_surf->buffer can be null even when no error has occured. For + * example, if the user has called no GL rendering commands since the + * previous eglSwapBuffers, then the driver may have not triggered + * a callback to ANativeWindow::dequeueBuffer, in which case + * dri2_surf->buffer remains null. + */ if (dri2_surf->buffer) droid_window_enqueue_buffer(disp, dri2_surf);