summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNataraj Deshpande <[email protected]>2019-07-19 08:44:13 -0700
committerJuan A. Suarez Romero <[email protected]>2019-07-23 11:42:30 +0000
commit87efbe488e919ee2833d0872d7bece8dc32ad630 (patch)
treef35065d531922c46e0ad19191fe1546c4f6dc013 /src
parente1800b20f44670829ce4d3ec9c0df2f9f2d87976 (diff)
egl/android: Update color_buffers querying for buffer age
color_buffers[] is currently hard coded to 3 for android which fails in droid_window_dequeue_buffer when ANativeWindow creates color_buffers >3 while querying buffer age during dEQP partial_update tests on chromeOS. The patch removes static color_buffers[], queries for MIN_UNDEQUEUED_BUFFERS, sets native window buffer count and allocates the correct number of color_buffers as per android. Fixes dEQP-EGL.functional.partial_update* tests on chromebooks with enabling EGL_KHR_partial_update. v2: update comment instead of removing (Eric Engestrom) v3: change static array to dynamic allocated color_buffers querying MIN_UNDEQUEUED_BUFFERS (Chia-I Wu [email protected]) Fixes: 2acc69da8ce "EGL/Android: Add EGL_EXT_buffer_age extension" Signed-off-by: Nataraj Deshpande <[email protected]> Acked-by: Eric Engestrom <[email protected]> Reviewed-by: Chia-I Wu <[email protected]> (cherry picked from commit 0661c357c60313905f35ee31a270bd5d5cf555b7)
Diffstat (limited to 'src')
-rw-r--r--src/egl/drivers/dri2/egl_dri2.h7
-rw-r--r--src/egl/drivers/dri2/platform_android.c30
2 files changed, 31 insertions, 6 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index e7ff5c9184b..db63311243d 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -322,13 +322,14 @@ struct dri2_egl_surface
__DRIimage *dri_image_front;
/* Used to record all the buffers created by ANativeWindow and their ages.
- * Usually Android uses at most triple buffers in ANativeWindow
- * so hardcode the number of color_buffers to 3.
+ * Allocate number of color_buffers based on query to android bufferqueue
+ * and save color_buffers_count.
*/
+ int color_buffers_count;
struct {
struct ANativeWindowBuffer *buffer;
int age;
- } color_buffers[3], *back;
+ } *color_buffers, *back;
#endif
#if defined(HAVE_SURFACELESS_PLATFORM)
diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
index 270d342ac6d..44450a47dd6 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -229,7 +229,7 @@ droid_window_dequeue_buffer(struct dri2_egl_surface *dri2_surf)
* for updating buffer's age in swap_buffers.
*/
EGLBoolean updated = EGL_FALSE;
- for (int i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
+ for (int i = 0; i < dri2_surf->color_buffers_count; i++) {
if (!dri2_surf->color_buffers[i].buffer) {
dri2_surf->color_buffers[i].buffer = dri2_surf->buffer;
}
@@ -244,7 +244,7 @@ droid_window_dequeue_buffer(struct dri2_egl_surface *dri2_surf)
/* In case of all the buffers were recreated by ANativeWindow, reset
* the color_buffers
*/
- for (int i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
+ for (int i = 0; i < dri2_surf->color_buffers_count; i++) {
dri2_surf->color_buffers[i].buffer = NULL;
dri2_surf->color_buffers[i].age = 0;
}
@@ -358,6 +358,7 @@ droid_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
if (type == EGL_WINDOW_BIT) {
int format;
+ int buffer_count;
if (window->common.magic != ANDROID_NATIVE_WINDOW_MAGIC) {
_eglError(EGL_BAD_NATIVE_WINDOW, "droid_create_surface");
@@ -368,6 +369,26 @@ droid_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
goto cleanup_surface;
}
+ /* Query ANativeWindow for MIN_UNDEQUEUED_BUFFER, set buffer count
+ * and allocate color_buffers.
+ */
+ if (window->query(window, NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS,
+ &buffer_count)) {
+ _eglError(EGL_BAD_NATIVE_WINDOW, "droid_create_surface");
+ goto cleanup_surface;
+ }
+ if (native_window_set_buffer_count(window, buffer_count+1)) {
+ _eglError(EGL_BAD_NATIVE_WINDOW, "droid_create_surface");
+ goto cleanup_surface;
+ }
+ dri2_surf->color_buffers = calloc(buffer_count+1,
+ sizeof(*dri2_surf->color_buffers));
+ if (!dri2_surf->color_buffers) {
+ _eglError(EGL_BAD_ALLOC, "droid_create_surface");
+ goto cleanup_surface;
+ }
+ dri2_surf->color_buffers_count = buffer_count+1;
+
if (format != dri2_conf->base.NativeVisualID) {
_eglLog(_EGL_WARNING, "Native format mismatch: 0x%x != 0x%x",
format, dri2_conf->base.NativeVisualID);
@@ -395,6 +416,8 @@ droid_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
return &dri2_surf->base;
cleanup_surface:
+ if (dri2_surf->color_buffers_count)
+ free(dri2_surf->color_buffers);
free(dri2_surf);
return NULL;
@@ -447,6 +470,7 @@ droid_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf)
dri2_dpy->core->destroyDrawable(dri2_surf->dri_drawable);
dri2_fini_surface(surf);
+ free(dri2_surf->color_buffers);
free(dri2_surf);
return EGL_TRUE;
@@ -688,7 +712,7 @@ droid_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
return EGL_TRUE;
}
- for (int i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
+ for (int i = 0; i < dri2_surf->color_buffers_count; i++) {
if (dri2_surf->color_buffers[i].age > 0)
dri2_surf->color_buffers[i].age++;
}