egl: return correct error for EGL_KHR_image_pixmap
authorEric Engestrom <eric@engestrom.ch>
Fri, 15 Mar 2019 11:58:16 +0000 (11:58 +0000)
committerMarge Bot <emma+marge@anholt.net>
Fri, 16 Jun 2023 18:29:26 +0000 (18:29 +0000)
EGL_KHR_image_pixmap says:
> If <target> is EGL_NATIVE_PIXMAP_KHR, and <ctx> is not EGL_NO_CONTEXT,
> the error EGL_BAD_PARAMETER is generated.

Reported-by: Rohan Garg <rohan@garg.io>
Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/166
Fixes: a1c4a8a3c855d52fbfef "egl: Add support for EGL_KHR_image."
Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/454>

src/egl/main/eglapi.c

index 8830b40..be9e5c5 100644 (file)
@@ -1865,6 +1865,13 @@ _eglCreateImageCommon(_EGLDisplay *disp, EGLContext ctx, EGLenum target,
       RETURN_EGL_EVAL(disp, EGL_NO_IMAGE_KHR);
    if (!context && ctx != EGL_NO_CONTEXT)
       RETURN_EGL_ERROR(disp, EGL_BAD_CONTEXT, EGL_NO_IMAGE_KHR);
+
+   /* "If <target> is EGL_NATIVE_PIXMAP_KHR, and <ctx> is not EGL_NO_CONTEXT,
+    * the error EGL_BAD_PARAMETER is generated."
+    */
+   if (target == EGL_NATIVE_PIXMAP_KHR && ctx != EGL_NO_CONTEXT)
+      RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_NO_IMAGE_KHR);
+
    /* "If <target> is EGL_LINUX_DMA_BUF_EXT, <dpy> must be a valid display,
     *  <ctx> must be EGL_NO_CONTEXT..."
     */