summaryrefslogtreecommitdiff
path: root/glamor
diff options
context:
space:
mode:
authorLouis-Francis Ratté-Boulianne <lfrb@collabora.com>2018-02-28 01:19:44 +0000
committerAdam Jackson <ajax@redhat.com>2018-03-05 13:27:55 -0500
commitcef12efc15ca1444d6d8cd839116b318a4668692 (patch)
tree29d81005b1360e9ab029f09822b222f51fca394b /glamor
parentc8c276c9569b3ca1e695682a5443f1b615c606bd (diff)
glamor: Implement GetSupportedModifiers
Implement function added in DRI3 v1.1. A newest version of libepoxy (>= 1.4.4) is required as earlier versions use a problematic version of Khronos EXT_image_dma_buf_import_modifiers spec. v4: Only send scanout-supported modifiers if flipping is possible v5: Fix memory corruption in XWayland (uninitialized pointer) Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com> Reviewed-by: Daniel Stone <daniels@collabora.com> Acked-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
Diffstat (limited to 'glamor')
-rw-r--r--glamor/glamor.c25
-rw-r--r--glamor/glamor.h23
-rw-r--r--glamor/glamor_egl.c92
-rw-r--r--glamor/glamor_priv.h1
-rw-r--r--glamor/meson.build4
5 files changed, 144 insertions, 1 deletions
diff --git a/glamor/glamor.c b/glamor/glamor.c
index c890d0ce0..c7077dd84 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -793,6 +793,31 @@ glamor_supports_pixmap_import_export(ScreenPtr screen)
return glamor_priv->dri3_enabled;
}
+_X_EXPORT void
+glamor_set_drawable_modifiers_func(ScreenPtr screen,
+ GetDrawableModifiersFuncPtr func)
+{
+ glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+
+ glamor_priv->get_drawable_modifiers = func;
+}
+
+_X_EXPORT Bool
+glamor_get_drawable_modifiers(DrawablePtr draw, CARD32 format,
+ CARD32 *num_modifiers, uint64_t **modifiers)
+{
+ struct glamor_screen_private *glamor_priv =
+ glamor_get_screen_private(draw->pScreen);
+
+ if (glamor_priv->get_drawable_modifiers) {
+ return glamor_priv->get_drawable_modifiers(draw, format,
+ num_modifiers, modifiers);
+ }
+ *num_modifiers = 0;
+ *modifiers = NULL;
+ return TRUE;
+}
+
_X_EXPORT int
glamor_fds_from_pixmap(ScreenPtr screen, PixmapPtr pixmap, int *fds,
uint32_t *strides, uint32_t *offsets,
diff --git a/glamor/glamor.h b/glamor/glamor.h
index 8f8c31b45..5475aedbb 100644
--- a/glamor/glamor.h
+++ b/glamor/glamor.h
@@ -60,6 +60,11 @@ typedef enum glamor_pixmap_type {
GLAMOR_TEXTURE_ONLY,
} glamor_pixmap_type_t;
+typedef Bool (*GetDrawableModifiersFuncPtr) (DrawablePtr draw,
+ CARD32 format,
+ CARD32 *num_modifiers,
+ uint64_t **modifiers);
+
#define GLAMOR_EGL_EXTERNAL_BUFFER 3
#define GLAMOR_USE_EGL_SCREEN (1 << 0)
#define GLAMOR_NO_DRI3 (1 << 1)
@@ -272,6 +277,24 @@ extern _X_EXPORT Bool glamor_back_pixmap_from_fd(PixmapPtr pixmap,
CARD16 stride,
CARD8 depth,
CARD8 bpp);
+
+extern _X_EXPORT Bool glamor_get_formats(ScreenPtr screen,
+ CARD32 *num_formats,
+ CARD32 **formats);
+
+extern _X_EXPORT Bool glamor_get_modifiers(ScreenPtr screen,
+ CARD32 format,
+ CARD32 *num_modifiers,
+ uint64_t **modifiers);
+
+extern _X_EXPORT Bool glamor_get_drawable_modifiers(DrawablePtr draw,
+ CARD32 format,
+ CARD32 *num_modifiers,
+ uint64_t **modifiers);
+
+extern _X_EXPORT void glamor_set_drawable_modifiers_func(ScreenPtr screen,
+ GetDrawableModifiersFuncPtr func);
+
#ifdef GLAMOR_FOR_XORG
#define GLAMOR_EGL_MODULE_NAME "glamoregl"
diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index cf2513491..c00fb3c1b 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -505,6 +505,95 @@ glamor_pixmap_from_fds(ScreenPtr screen,
return pixmap;
}
+_X_EXPORT Bool
+glamor_get_formats(ScreenPtr screen,
+ CARD32 *num_formats, CARD32 **formats)
+{
+#ifdef GLAMOR_HAS_EGL_QUERY_DMABUF
+ struct glamor_egl_screen_private *glamor_egl;
+ EGLint num;
+
+ glamor_egl = glamor_egl_get_screen_private(xf86ScreenToScrn(screen));
+
+ if (!glamor_egl->dmabuf_capable)
+ return FALSE;
+
+ if (!eglQueryDmaBufFormatsEXT(glamor_egl->display, 0, NULL, &num)) {
+ *num_formats = 0;
+ return FALSE;
+ }
+
+ if (num == 0) {
+ *num_formats = 0;
+ return TRUE;
+ }
+
+ *formats = calloc(num, sizeof(CARD32));
+ if (*formats == NULL) {
+ *num_formats = 0;
+ return FALSE;
+ }
+
+ if (!eglQueryDmaBufFormatsEXT(glamor_egl->display, num,
+ (EGLint *) *formats, &num)) {
+ *num_formats = 0;
+ free(*formats);
+ return FALSE;
+ }
+
+ *num_formats = num;
+ return TRUE;
+#else
+ *num_formats = 0;
+ return TRUE;
+#endif
+}
+
+_X_EXPORT Bool
+glamor_get_modifiers(ScreenPtr screen, CARD32 format,
+ CARD32 *num_modifiers, uint64_t **modifiers)
+{
+#ifdef GLAMOR_HAS_EGL_QUERY_DMABUF
+ struct glamor_egl_screen_private *glamor_egl;
+ EGLint num;
+
+ glamor_egl = glamor_egl_get_screen_private(xf86ScreenToScrn(screen));
+
+ if (!glamor_egl->dmabuf_capable)
+ return FALSE;
+
+ if (!eglQueryDmaBufModifiersEXT(glamor_egl->display, format, 0, NULL,
+ NULL, &num)) {
+ *num_modifiers = 0;
+ return FALSE;
+ }
+
+ if (num == 0) {
+ *num_modifiers = 0;
+ return TRUE;
+ }
+
+ *modifiers = calloc(num, sizeof(uint64_t));
+ if (*modifiers == NULL) {
+ *num_modifiers = 0;
+ return FALSE;
+ }
+
+ if (!eglQueryDmaBufModifiersEXT(glamor_egl->display, format, num,
+ (EGLuint64KHR *) *modifiers, NULL, &num)) {
+ *num_modifiers = 0;
+ free(*modifiers);
+ return FALSE;
+ }
+
+ *num_modifiers = num;
+ return TRUE;
+#else
+ *num_modifiers = 0;
+ return TRUE;
+#endif
+}
+
static Bool
glamor_egl_destroy_pixmap(PixmapPtr pixmap)
{
@@ -626,6 +715,9 @@ static dri3_screen_info_rec glamor_dri3_info = {
.open_client = glamor_dri3_open_client,
.pixmap_from_fds = glamor_pixmap_from_fds,
.fds_from_pixmap = glamor_egl_fds_from_pixmap,
+ .get_formats = glamor_get_formats,
+ .get_modifiers = glamor_get_modifiers,
+ .get_drawable_modifiers = glamor_get_drawable_modifiers,
};
#endif /* DRI3 */
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index 2344066cb..3fff6396c 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -281,6 +281,7 @@ typedef struct glamor_screen_private {
int radial_max_nstops;
struct glamor_saved_procs saved_procs;
+ GetDrawableModifiersFuncPtr get_drawable_modifiers;
int flags;
ScreenPtr screen;
int dri3_enabled;
diff --git a/glamor/meson.build b/glamor/meson.build
index 0b963275e..268af593e 100644
--- a/glamor/meson.build
+++ b/glamor/meson.build
@@ -38,12 +38,14 @@ if build_xv
srcs_glamor += 'glamor_xv.c'
endif
+epoxy_dep = dependency('epoxy')
+
glamor = static_library('glamor',
srcs_glamor,
include_directories: inc,
dependencies: [
common_dep,
- dependency('epoxy'),
+ epoxy_dep,
],
)