egl: fix _eglQuerySurface in EGL_BUFFER_AGE_EXT case
authorTapani Pälli <tapani.palli@intel.com>
Thu, 8 Jun 2017 09:24:24 +0000 (12:24 +0300)
committerTapani Pälli <tapani.palli@intel.com>
Fri, 9 Jun 2017 04:39:22 +0000 (07:39 +0300)
Specification states that in case of error, value should not be
written, patch changes buffer age queries to return -1 in case of
error so that we can skip changing the value.

In addition, small change to droid_query_buffer_age to return 0
in case buffer does not have a back buffer available.

Fixes:
   dEQP-EGL.functional.negative_partial_update.not_postable_surface

Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Chad Versace <chadversary@chromium.org>
Cc: mesa-stable@lists.freedesktop.org
src/egl/drivers/dri2/platform_android.c
src/egl/drivers/dri2/platform_drm.c
src/egl/drivers/dri2/platform_wayland.c
src/egl/main/eglsurface.c

index 48ecb9fd40b89f8be63bcbb926267ec2441d0aab..4c979351192cd181e55c4357063a3c345ed0b033 100644 (file)
@@ -614,10 +614,10 @@ droid_query_buffer_age(_EGLDriver *drv,
 
    if (update_buffers(dri2_surf) < 0) {
       _eglError(EGL_BAD_ALLOC, "droid_query_buffer_age");
-      return 0;
+      return -1;
    }
 
-   return dri2_surf->back->age;
+   return dri2_surf->back ? dri2_surf->back->age : 0;
 }
 
 static EGLBoolean
index 2f045894265ca99751dd711cf9c2247c7e59bad0..36c89fc832b83eb37c9d7b728c3a5dd2e87f6f39 100644 (file)
@@ -464,7 +464,7 @@ dri2_drm_query_buffer_age(_EGLDriver *drv,
 
    if (get_back_bo(dri2_surf) < 0) {
       _eglError(EGL_BAD_ALLOC, "dri2_query_buffer_age");
-      return 0;
+      return -1;
    }
 
    return dri2_surf->back->age;
index e447aa67290a2bebd62e26abd0ab9ad6be0198d4..15cc597111eabd6d28b78ad62cf07c744e556027 100644 (file)
@@ -810,7 +810,7 @@ dri2_wl_query_buffer_age(_EGLDriver *drv,
 
    if (get_back_bo(dri2_surf) < 0) {
       _eglError(EGL_BAD_ALLOC, "dri2_query_buffer_age");
-      return 0;
+      return -1;
    }
 
    return dri2_surf->back->age;
index e935c8327130af2db791d0b1159ecbd87c64bf51..5b3e83ee92c3df4554f01d8fe3f9757c4a69a2b3 100644 (file)
@@ -409,7 +409,11 @@ _eglQuerySurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface,
          _eglError(EGL_BAD_ATTRIBUTE, "eglQuerySurface");
          return EGL_FALSE;
       }
-      *value = drv->API.QueryBufferAge(drv, dpy, surface);
+      EGLint result = drv->API.QueryBufferAge(drv, dpy, surface);
+      /* error happened */
+      if (result < 0)
+         return EGL_FALSE;
+      *value = result;
       break;
    default:
       _eglError(EGL_BAD_ATTRIBUTE, "eglQuerySurface");