summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVarad Gautam <varadgautam@gmail.com>2016-10-20 08:04:14 (GMT)
committerVarad Gautam <varadgautam@gmail.com>2016-10-20 08:06:51 (GMT)
commit59a214fc9f9afd094c6f0284e9abf475009b43a1 (patch)
treeaec61dd6550b3461a3932d8a5ab746b7ff2a1457
parent8ac319d4a0e3eef4a479dbcc2ada53531cef5c7b (diff)
downloadmesa-59a214fc9f9afd094c6f0284e9abf475009b43a1.tar.gz
mesa-59a214fc9f9afd094c6f0284e9abf475009b43a1.tar.xz
egl: implement eglQueryDmaBufModifiersEXT
Signed-off-by: Varad Gautam <varadgautam@gmail.com>
-rw-r--r--include/EGL/eglext.h2
-rw-r--r--include/GL/internal/dri_interface.h10
-rw-r--r--src/egl/drivers/dri2/egl_dri2.c46
-rw-r--r--src/egl/main/eglapi.c20
-rw-r--r--src/egl/main/eglapi.h5
-rw-r--r--src/gallium/include/pipe/p_screen.h7
-rw-r--r--src/gallium/state_trackers/dri/dri2.c15
7 files changed, 104 insertions, 1 deletions
diff --git a/include/EGL/eglext.h b/include/EGL/eglext.h
index fb43f72..6adceb5 100644
--- a/include/EGL/eglext.h
+++ b/include/EGL/eglext.h
@@ -618,9 +618,11 @@ EGLAPI EGLBoolean EGLAPIENTRY eglQueryDisplayAttribEXT (EGLDisplay dpy, EGLint a
#define EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT 0x0BAD0131
#define EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT 0x0BAD0132
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDMABUFFORMATSEXTPROC) (EGLint max_formats, EGLint *formats, EGLint *num_formats);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDMABUFMODIFIERSEXTPROC) (EGLDisplay dpy, EGLint format, EGLint max_modifiers, EGLint *modifiers, EGLBoolean *external_only, EGLint *num_modifiers);
#endif /* EGL_EXT_image_dma_buf_import_modifiers */
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglQueryDmaBufFormatsEXT (EGLDisplay dpy, EGLint max_formats, EGLint *formats, EGLint *num_formats);
+EGLAPI EGLBoolean EGLAPIENTRY eglQueryDmaBufModifiersEXT (EGLDisplay dpy, EGLint format, EGLint max_modifiers, EGLint *modifiers, EGLint *num_modifiers);
#endif
#ifndef EGL_EXT_multiview_window
diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h
index 22375c7..17b487a 100644
--- a/include/GL/internal/dri_interface.h
+++ b/include/GL/internal/dri_interface.h
@@ -1441,6 +1441,16 @@ struct __DRIimageExtensionRec {
enum __DRIChromaSiting vert_siting,
unsigned *error,
void *loaderPrivate);
+
+ /*
+ * Returns modifiers supported by the driver for a given format.
+ *
+ * For EGL_EXT_image_dma_buf_import_modifiers.
+ *
+ * \since 14
+ */
+ void (*queryDmaBufModifiers)(__DRIscreen *screen, int fourcc, int max,
+ int *modifiers, int *count);
};
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 7d6370f..4191757 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -2120,11 +2120,16 @@ dri2_query_dma_buf_formats (_EGLDriver *drv, _EGLDisplay *disp,
{
EGLint i;
- if (max <= 0) {
+ if (max < 0) {
_eglError(EGL_BAD_ATTRIBUTE, "invalid value for max count of formats");
return EGL_FALSE;
}
+ if (max == 0 || formats == NULL) {
+ *count = ARRAY_SIZE(dma_buf_formats);
+ return EGL_TRUE;
+ }
+
for (i = 0; i < ARRAY_SIZE(dma_buf_formats) && i < max; i++) {
formats[i] = dma_buf_formats[i];
}
@@ -2133,6 +2138,44 @@ dri2_query_dma_buf_formats (_EGLDriver *drv, _EGLDisplay *disp,
return EGL_TRUE;
}
+static EGLBoolean
+dri2_query_dma_buf_modifiers(_EGLDriver *drv, _EGLDisplay *disp, EGLint format,
+ EGLint max, EGLint *modifiers,
+ EGLBoolean *external_only, EGLint *count)
+{
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+ EGLint i;
+
+ if (max < 0) {
+ _eglError(EGL_BAD_ATTRIBUTE, "invalid value for max count of formats");
+ return EGL_FALSE;
+ }
+
+ if (max > 0 && modifiers == NULL) {
+ _eglError(EGL_BAD_ATTRIBUTE, "invalid modifiers array");
+ return EGL_FALSE;
+ }
+
+ for (i = 0; i < ARRAY_SIZE(dma_buf_formats); i++) {
+ if (format == dma_buf_formats[i])
+ break;
+ }
+ if (i == ARRAY_SIZE(dma_buf_formats)) {
+ _eglError(EGL_BAD_ATTRIBUTE, "invalid format");
+ return EGL_FALSE;
+ }
+
+ dri2_dpy->image->queryDmaBufModifiers(dri2_dpy->dri_screen, format, max,
+ modifiers, count);
+
+ if (external_only != NULL) {
+ for (i = 0; i < *count && i < max; i++)
+ external_only[i] = EGL_TRUE;
+ }
+
+ return EGL_TRUE;
+}
+
/**
* The spec says:
*
@@ -3007,6 +3050,7 @@ _eglBuiltInDriverDRI2(const char *args)
dri2_drv->base.API.CreateImageKHR = dri2_create_image;
dri2_drv->base.API.DestroyImageKHR = dri2_destroy_image_khr;
dri2_drv->base.API.QueryDmaBufFormatsEXT = dri2_query_dma_buf_formats;
+ dri2_drv->base.API.QueryDmaBufModifiersEXT = dri2_query_dma_buf_modifiers;
dri2_drv->base.API.CreateWaylandBufferFromImageWL = dri2_create_wayland_buffer_from_image;
dri2_drv->base.API.QuerySurface = dri2_query_surface;
#ifdef HAVE_LIBDRM
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index 2556ef8..6e3d064 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -1864,6 +1864,25 @@ eglQueryDmaBufFormatsEXT(EGLDisplay dpy, EGLint max_formats,
RETURN_EGL_EVAL(disp, ret);
}
+static EGLBoolean EGLAPIENTRY
+eglQueryDmaBufModifiersEXT(EGLDisplay dpy, EGLint format, EGLint max_modifiers,
+ EGLint *modifiers, EGLBoolean *external_only,
+ EGLint *num_modifiers)
+{
+ _EGLDisplay *disp = _eglLockDisplay(dpy);
+ _EGLDriver *drv;
+ EGLBoolean ret;
+
+ _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv);
+ assert(disp->Extensions.EXT_image_dma_buf_import_modifiers);
+
+ ret = drv->API.QueryDmaBufModifiersEXT(drv, disp, format, max_modifiers,
+ modifiers, external_only,
+ num_modifiers);
+
+ RETURN_EGL_EVAL(disp, ret);
+}
+
__eglMustCastToProperFunctionPointerType EGLAPIENTRY
eglGetProcAddress(const char *procname)
{
@@ -1922,6 +1941,7 @@ eglGetProcAddress(const char *procname)
{ "eglCreateImageKHR", (_EGLProc) eglCreateImageKHR },
{ "eglDestroyImageKHR", (_EGLProc) eglDestroyImage },
{ "eglQueryDmaBufFormatsEXT", (_EGLProc) eglQueryDmaBufFormatsEXT },
+ { "eglQueryDmaBufModifiersEXT", (_EGLProc) eglQueryDmaBufModifiersEXT },
{ "eglCreateSyncKHR", (_EGLProc) eglCreateSyncKHR },
{ "eglCreateSync64KHR", (_EGLProc) eglCreateSync64KHR },
{ "eglDestroySyncKHR", (_EGLProc) eglDestroySync },
diff --git a/src/egl/main/eglapi.h b/src/egl/main/eglapi.h
index c195e71..a4d5bcb 100644
--- a/src/egl/main/eglapi.h
+++ b/src/egl/main/eglapi.h
@@ -136,6 +136,11 @@ struct _egl_api
EGLBoolean (*QueryDmaBufFormatsEXT)(_EGLDriver *drv, _EGLDisplay *dpy,
EGLint max_formats, EGLint *formats,
EGLint *num_formats);
+ EGLBoolean (*QueryDmaBufModifiersEXT) (_EGLDriver *drv, _EGLDisplay *dpy,
+ EGLint format, EGLint max_modifiers,
+ EGLint *modifiers,
+ EGLBoolean *external_only,
+ EGLint *num_modifiers);
_EGLSync *(*CreateSyncKHR)(_EGLDriver *drv, _EGLDisplay *dpy, EGLenum type,
const EGLint *attrib_list,
diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h
index 255647e..5d5641a 100644
--- a/src/gallium/include/pipe/p_screen.h
+++ b/src/gallium/include/pipe/p_screen.h
@@ -300,6 +300,13 @@ struct pipe_screen {
const void *(*get_compiler_options)(struct pipe_screen *screen,
enum pipe_shader_ir ir,
unsigned shader);
+
+ /**
+ * Get supported modifiers for a format.
+ */
+ void (*get_modifiers_for_format)(struct pipe_screen *screen,
+ enum pipe_format format, int max,
+ int *modifiers, int *count);
};
diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
index 6b1e24c..e117e18 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -1257,6 +1257,20 @@ dri2_from_fds(__DRIscreen *screen, int width, int height, int fourcc,
return img;
}
+static void
+dri2_query_dma_buf_modifiers(__DRIscreen *_screen, int fourcc, int max,
+ int *modifiers, int *count)
+{
+ struct dri_screen *screen = dri_screen(_screen);
+ struct pipe_screen *pscreen = screen->base.screen;
+ int dri_components;
+ enum pipe_format format = dri2_format_to_pipe_format(
+ convert_fourcc(fourcc,&dri_components));
+
+ if (pscreen->get_modifiers_for_format)
+ pscreen->get_modifiers_for_format(pscreen, format, max, modifiers, count);
+}
+
static __DRIimage *
dri2_from_dma_bufs(__DRIscreen *screen,
int width, int height, int fourcc,
@@ -1935,6 +1949,7 @@ dri2_init_screen(__DRIscreen * sPriv)
dri2ImageExtension.createImageFromFds = dri2_from_fds;
dri2ImageExtension.createImageFromDmaBufs = dri2_from_dma_bufs;
dri2ImageExtension.createImageFromDmaBufs2 = dri2_from_dma_bufs2;
+ dri2ImageExtension.queryDmaBufModifiers = dri2_query_dma_buf_modifiers;
}
}