<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, May 19, 2017 at 2:37 AM, Daniel Stone <span dir="ltr"><<a href="mailto:daniels@collabora.com" target="_blank">daniels@collabora.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Varad Gautam <<a href="mailto:varad.gautam@collabora.com">varad.gautam@collabora.com</a>><br>
<br>
allow egl clients to query the dmabuf formats supported on this platform.<br>
<br>
v2: return EGLBoolean.<br>
v3: Check DRIimageExtension version before querying (Daniel Stone)<br>
<br>
Signed-off-by: Louis-Francis Ratté-Boulianne <<a href="mailto:lfrb@collabora.com">lfrb@collabora.com</a>><br>
Signed-off-by: Varad Gautam <<a href="mailto:varad.gautam@collabora.com">varad.gautam@collabora.com</a>><br>
Reviewed-by: Daniel Stone <<a href="mailto:daniels@collabora.com">daniels@collabora.com</a>><br>
Signed-off-by: Daniel Stone <<a href="mailto:daniels@collabora.com">daniels@collabora.com</a>><br>
---<br>
src/egl/drivers/dri2/egl_dri2.<wbr>c | 21 +++++++++++++++++++++<br>
src/egl/main/eglapi.c | 18 ++++++++++++++++++<br>
src/egl/main/eglapi.h | 4 ++++<br>
src/egl/main/eglentrypoint.h | 1 +<br>
4 files changed, 44 insertions(+)<br>
<br>
diff --git a/src/egl/drivers/dri2/egl_<wbr>dri2.c b/src/egl/drivers/dri2/egl_<wbr>dri2.c<br>
index f06b5535c7..55b6fcf1fc 100644<br>
--- a/src/egl/drivers/dri2/egl_<wbr>dri2.c<br>
+++ b/src/egl/drivers/dri2/egl_<wbr>dri2.c<br>
@@ -2111,6 +2111,26 @@ dri2_check_dma_buf_format(<wbr>const _EGLImageAttribs *attrs)<br>
return plane_n;<br>
}<br>
<br>
+static EGLBoolean<br>
+dri2_query_dma_buf_formats(_<wbr>EGLDriver *drv, _EGLDisplay *disp,<br>
+ EGLint max, EGLint *formats, EGLint *count)<br>
+{<br>
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);<br>
+ if (max < 0 || (max > 0 && formats == NULL)) {<br>
+ _eglError(EGL_BAD_PARAMETER, "invalid value for max count of formats");<br>
+ return EGL_FALSE;<br>
+ }<br>
+<br>
+ if (dri2_dpy->image->base.version < 16)<br></blockquote><div><br></div><div>I think you need to also check for the existance of the function pointer.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ return EGL_FALSE;<br>
+<br>
+ if (!dri2_dpy->image-><wbr>queryDmaBufFormats(dri2_dpy-><wbr>dri_screen, max,<br>
+ formats, count))<br>
+ return EGL_FALSE;<br>
+<br>
+ return EGL_TRUE;<br>
+}<br>
+<br>
/**<br>
* The spec says:<br>
*<br>
@@ -3043,6 +3063,7 @@ _eglBuiltInDriverDRI2(const char *args)<br>
dri2_drv->base.API.<wbr>ExportDRMImageMESA = dri2_export_drm_image_mesa;<br>
dri2_drv->base.API.<wbr>ExportDMABUFImageQueryMESA = dri2_export_dma_buf_image_<wbr>query_mesa;<br>
dri2_drv->base.API.<wbr>ExportDMABUFImageMESA = dri2_export_dma_buf_image_<wbr>mesa;<br>
+ dri2_drv->base.API.<wbr>QueryDmaBufFormatsEXT = dri2_query_dma_buf_formats;<br>
#endif<br>
#ifdef HAVE_WAYLAND_PLATFORM<br>
dri2_drv->base.API.<wbr>BindWaylandDisplayWL = dri2_bind_wayland_display_wl;<br>
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c<br>
index 9cea2f41ff..e83e3a414e 100644<br>
--- a/src/egl/main/eglapi.c<br>
+++ b/src/egl/main/eglapi.c<br>
@@ -2385,6 +2385,24 @@ _eglFunctionCompare(const void *key, const void *elem)<br>
return strcmp(procname, entrypoint->name);<br>
}<br>
<br>
+static EGLBoolean EGLAPIENTRY<br>
+eglQueryDmaBufFormatsEXT(<wbr>EGLDisplay dpy, EGLint max_formats,<br>
+ EGLint *formats, EGLint *num_formats)<br>
+{<br>
+ _EGLDisplay *disp = _eglLockDisplay(dpy);<br>
+ _EGLDriver *drv;<br>
+ EGLBoolean ret;<br>
+<br>
+ _EGL_FUNC_START(NULL, EGL_NONE, NULL, EGL_FALSE);<br>
+<br>
+ _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv);<br>
+<br>
+ ret = drv->API.<wbr>QueryDmaBufFormatsEXT(drv, disp, max_formats, formats,<br>
+ num_formats);<br>
+<br>
+ RETURN_EGL_EVAL(disp, ret);<br>
+}<br>
+<br>
__<wbr>eglMustCastToProperFunctionPoi<wbr>nterType EGLAPIENTRY<br>
eglGetProcAddress(const char *procname)<br>
{<br>
diff --git a/src/egl/main/eglapi.h b/src/egl/main/eglapi.h<br>
index 710c5d860a..c9f98963db 100644<br>
--- a/src/egl/main/eglapi.h<br>
+++ b/src/egl/main/eglapi.h<br>
@@ -198,6 +198,10 @@ struct _egl_api<br>
int (*GLInteropExportObject)(_<wbr>EGLDisplay *dpy, _EGLContext *ctx,<br>
struct mesa_glinterop_export_in *in,<br>
struct mesa_glinterop_export_out *out);<br>
+<br>
+ EGLBoolean (*QueryDmaBufFormatsEXT)(_<wbr>EGLDriver *drv, _EGLDisplay *dpy,<br>
+ EGLint max_formats, EGLint *formats,<br>
+ EGLint *num_formats);<br>
};<br>
<br>
#ifdef __cplusplus<br>
diff --git a/src/egl/main/eglentrypoint.h b/src/egl/main/eglentrypoint.h<br>
index e6318b9311..91536239e9 100644<br>
--- a/src/egl/main/eglentrypoint.h<br>
+++ b/src/egl/main/eglentrypoint.h<br>
@@ -56,6 +56,7 @@ EGL_ENTRYPOINT(<wbr>eglPostSubBufferNV)<br>
EGL_ENTRYPOINT(eglQueryAPI)<br>
EGL_ENTRYPOINT(<wbr>eglQueryContext)<br>
EGL_ENTRYPOINT(<wbr>eglQueryDebugKHR)<br>
+EGL_ENTRYPOINT(<wbr>eglQueryDmaBufFormatsEXT)<br>
EGL_ENTRYPOINT(eglQueryString)<br>
EGL_ENTRYPOINT(<wbr>eglQuerySurface)<br>
EGL_ENTRYPOINT(<wbr>eglQueryWaylandBufferWL)<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.13.0<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>