|
|
4c4b8b |
From c7853c6de126f6794946c592deed205c0ddad2d9 Mon Sep 17 00:00:00 2001
|
|
|
4c4b8b |
From: Olivier Fourdan <ofourdan@redhat.com>
|
|
|
4c4b8b |
Date: Wed, 3 Mar 2021 09:55:12 +0100
|
|
|
4c4b8b |
Subject: [PATCH xserver 01/27] xwayland: Move dmabuf interface to common
|
|
|
4c4b8b |
glamor code
|
|
|
4c4b8b |
|
|
|
4c4b8b |
This is preliminary work for hardware accelerated rendering with the
|
|
|
4c4b8b |
NVIDIA driver.
|
|
|
4c4b8b |
|
|
|
4c4b8b |
The EGLStream backend can possibly also use the dmabuf interface, so
|
|
|
4c4b8b |
move the relevant code from the GBM specific source to the common bits.
|
|
|
4c4b8b |
|
|
|
4c4b8b |
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
|
|
|
4c4b8b |
(cherry picked from commit ae225417c0a0828ffb24e11eb4b968c34692e25a)
|
|
|
4c4b8b |
---
|
|
|
4c4b8b |
hw/xwayland/xwayland-glamor-gbm.c | 73 ++---------------------------
|
|
|
4c4b8b |
hw/xwayland/xwayland-glamor.c | 76 +++++++++++++++++++++++++++++--
|
|
|
4c4b8b |
hw/xwayland/xwayland-screen.h | 1 +
|
|
|
4c4b8b |
3 files changed, 76 insertions(+), 74 deletions(-)
|
|
|
4c4b8b |
|
|
|
4c4b8b |
diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c
|
|
|
4c4b8b |
index 221bf268a..73c69727e 100644
|
|
|
4c4b8b |
--- a/hw/xwayland/xwayland-glamor-gbm.c
|
|
|
4c4b8b |
+++ b/hw/xwayland/xwayland-glamor-gbm.c
|
|
|
4c4b8b |
@@ -56,7 +56,6 @@ struct xwl_gbm_private {
|
|
|
4c4b8b |
char *device_name;
|
|
|
4c4b8b |
struct gbm_device *gbm;
|
|
|
4c4b8b |
struct wl_drm *drm;
|
|
|
4c4b8b |
- struct zwp_linux_dmabuf_v1 *dmabuf;
|
|
|
4c4b8b |
int drm_fd;
|
|
|
4c4b8b |
int fd_render_node;
|
|
|
4c4b8b |
Bool drm_authenticated;
|
|
|
4c4b8b |
@@ -334,10 +333,10 @@ xwl_glamor_gbm_get_wl_buffer_for_pixmap(PixmapPtr pixmap)
|
|
|
4c4b8b |
}
|
|
|
4c4b8b |
}
|
|
|
4c4b8b |
|
|
|
4c4b8b |
- if (xwl_gbm->dmabuf && modifier_supported) {
|
|
|
4c4b8b |
+ if (xwl_screen->dmabuf && modifier_supported) {
|
|
|
4c4b8b |
struct zwp_linux_buffer_params_v1 *params;
|
|
|
4c4b8b |
|
|
|
4c4b8b |
- params = zwp_linux_dmabuf_v1_create_params(xwl_gbm->dmabuf);
|
|
|
4c4b8b |
+ params = zwp_linux_dmabuf_v1_create_params(xwl_screen->dmabuf);
|
|
|
4c4b8b |
for (i = 0; i < num_planes; i++) {
|
|
|
4c4b8b |
zwp_linux_buffer_params_v1_add(params, prime_fd, i,
|
|
|
4c4b8b |
offsets[i], strides[i],
|
|
|
4c4b8b |
@@ -604,7 +603,7 @@ glamor_get_formats(ScreenPtr screen,
|
|
|
4c4b8b |
/* Explicitly zero the count as the caller may ignore the return value */
|
|
|
4c4b8b |
*num_formats = 0;
|
|
|
4c4b8b |
|
|
|
4c4b8b |
- if (!xwl_gbm->dmabuf_capable || !xwl_gbm->dmabuf)
|
|
|
4c4b8b |
+ if (!xwl_gbm->dmabuf_capable || !xwl_screen->dmabuf)
|
|
|
4c4b8b |
return FALSE;
|
|
|
4c4b8b |
|
|
|
4c4b8b |
if (xwl_screen->num_formats == 0)
|
|
|
4c4b8b |
@@ -633,7 +632,7 @@ glamor_get_modifiers(ScreenPtr screen, uint32_t format,
|
|
|
4c4b8b |
/* Explicitly zero the count as the caller may ignore the return value */
|
|
|
4c4b8b |
*num_modifiers = 0;
|
|
|
4c4b8b |
|
|
|
4c4b8b |
- if (!xwl_gbm->dmabuf_capable || !xwl_gbm->dmabuf)
|
|
|
4c4b8b |
+ if (!xwl_gbm->dmabuf_capable || !xwl_screen->dmabuf)
|
|
|
4c4b8b |
return FALSE;
|
|
|
4c4b8b |
|
|
|
4c4b8b |
if (xwl_screen->num_formats == 0)
|
|
|
4c4b8b |
@@ -797,54 +796,6 @@ static const struct wl_drm_listener xwl_drm_listener = {
|
|
|
4c4b8b |
xwl_drm_handle_capabilities
|
|
|
4c4b8b |
};
|
|
|
4c4b8b |
|
|
|
4c4b8b |
-static void
|
|
|
4c4b8b |
-xwl_dmabuf_handle_format(void *data, struct zwp_linux_dmabuf_v1 *dmabuf,
|
|
|
4c4b8b |
- uint32_t format)
|
|
|
4c4b8b |
-{
|
|
|
4c4b8b |
-}
|
|
|
4c4b8b |
-
|
|
|
4c4b8b |
-static void
|
|
|
4c4b8b |
-xwl_dmabuf_handle_modifier(void *data, struct zwp_linux_dmabuf_v1 *dmabuf,
|
|
|
4c4b8b |
- uint32_t format, uint32_t modifier_hi,
|
|
|
4c4b8b |
- uint32_t modifier_lo)
|
|
|
4c4b8b |
-{
|
|
|
4c4b8b |
- struct xwl_screen *xwl_screen = data;
|
|
|
4c4b8b |
- struct xwl_format *xwl_format = NULL;
|
|
|
4c4b8b |
- int i;
|
|
|
4c4b8b |
-
|
|
|
4c4b8b |
- for (i = 0; i < xwl_screen->num_formats; i++) {
|
|
|
4c4b8b |
- if (xwl_screen->formats[i].format == format) {
|
|
|
4c4b8b |
- xwl_format = &xwl_screen->formats[i];
|
|
|
4c4b8b |
- break;
|
|
|
4c4b8b |
- }
|
|
|
4c4b8b |
- }
|
|
|
4c4b8b |
-
|
|
|
4c4b8b |
- if (xwl_format == NULL) {
|
|
|
4c4b8b |
- xwl_screen->num_formats++;
|
|
|
4c4b8b |
- xwl_screen->formats = realloc(xwl_screen->formats,
|
|
|
4c4b8b |
- xwl_screen->num_formats * sizeof(*xwl_format));
|
|
|
4c4b8b |
- if (!xwl_screen->formats)
|
|
|
4c4b8b |
- return;
|
|
|
4c4b8b |
- xwl_format = &xwl_screen->formats[xwl_screen->num_formats - 1];
|
|
|
4c4b8b |
- xwl_format->format = format;
|
|
|
4c4b8b |
- xwl_format->num_modifiers = 0;
|
|
|
4c4b8b |
- xwl_format->modifiers = NULL;
|
|
|
4c4b8b |
- }
|
|
|
4c4b8b |
-
|
|
|
4c4b8b |
- xwl_format->num_modifiers++;
|
|
|
4c4b8b |
- xwl_format->modifiers = realloc(xwl_format->modifiers,
|
|
|
4c4b8b |
- xwl_format->num_modifiers * sizeof(uint64_t));
|
|
|
4c4b8b |
- if (!xwl_format->modifiers)
|
|
|
4c4b8b |
- return;
|
|
|
4c4b8b |
- xwl_format->modifiers[xwl_format->num_modifiers - 1] = (uint64_t) modifier_lo;
|
|
|
4c4b8b |
- xwl_format->modifiers[xwl_format->num_modifiers - 1] |= (uint64_t) modifier_hi << 32;
|
|
|
4c4b8b |
-}
|
|
|
4c4b8b |
-
|
|
|
4c4b8b |
-static const struct zwp_linux_dmabuf_v1_listener xwl_dmabuf_listener = {
|
|
|
4c4b8b |
- .format = xwl_dmabuf_handle_format,
|
|
|
4c4b8b |
- .modifier = xwl_dmabuf_handle_modifier
|
|
|
4c4b8b |
-};
|
|
|
4c4b8b |
-
|
|
|
4c4b8b |
Bool
|
|
|
4c4b8b |
xwl_screen_set_drm_interface(struct xwl_screen *xwl_screen,
|
|
|
4c4b8b |
uint32_t id, uint32_t version)
|
|
|
4c4b8b |
@@ -862,22 +813,6 @@ xwl_screen_set_drm_interface(struct xwl_screen *xwl_screen,
|
|
|
4c4b8b |
return TRUE;
|
|
|
4c4b8b |
}
|
|
|
4c4b8b |
|
|
|
4c4b8b |
-Bool
|
|
|
4c4b8b |
-xwl_screen_set_dmabuf_interface(struct xwl_screen *xwl_screen,
|
|
|
4c4b8b |
- uint32_t id, uint32_t version)
|
|
|
4c4b8b |
-{
|
|
|
4c4b8b |
- struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen);
|
|
|
4c4b8b |
-
|
|
|
4c4b8b |
- if (version < 3)
|
|
|
4c4b8b |
- return FALSE;
|
|
|
4c4b8b |
-
|
|
|
4c4b8b |
- xwl_gbm->dmabuf =
|
|
|
4c4b8b |
- wl_registry_bind(xwl_screen->registry, id, &zwp_linux_dmabuf_v1_interface, 3);
|
|
|
4c4b8b |
- zwp_linux_dmabuf_v1_add_listener(xwl_gbm->dmabuf, &xwl_dmabuf_listener, xwl_screen);
|
|
|
4c4b8b |
-
|
|
|
4c4b8b |
- return TRUE;
|
|
|
4c4b8b |
-}
|
|
|
4c4b8b |
-
|
|
|
4c4b8b |
static Bool
|
|
|
4c4b8b |
xwl_glamor_gbm_init_wl_registry(struct xwl_screen *xwl_screen,
|
|
|
4c4b8b |
struct wl_registry *wl_registry,
|
|
|
4c4b8b |
diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
|
|
|
4c4b8b |
index bcd07a1a5..cce0c911e 100644
|
|
|
4c4b8b |
--- a/hw/xwayland/xwayland-glamor.c
|
|
|
4c4b8b |
+++ b/hw/xwayland/xwayland-glamor.c
|
|
|
4c4b8b |
@@ -35,6 +35,10 @@
|
|
|
4c4b8b |
#include "glx_extinit.h"
|
|
|
4c4b8b |
#endif
|
|
|
4c4b8b |
|
|
|
4c4b8b |
+#include "linux-dmabuf-unstable-v1-client-protocol.h"
|
|
|
4c4b8b |
+#include "drm-client-protocol.h"
|
|
|
4c4b8b |
+#include <drm_fourcc.h>
|
|
|
4c4b8b |
+
|
|
|
4c4b8b |
#include "xwayland-glamor.h"
|
|
|
4c4b8b |
#include "xwayland-glx.h"
|
|
|
4c4b8b |
#include "xwayland-screen.h"
|
|
|
4c4b8b |
@@ -75,6 +79,68 @@ glamor_egl_screen_init(ScreenPtr screen, struct glamor_context *glamor_ctx)
|
|
|
4c4b8b |
xwl_screen->glamor_ctx = glamor_ctx;
|
|
|
4c4b8b |
}
|
|
|
4c4b8b |
|
|
|
4c4b8b |
+static void
|
|
|
4c4b8b |
+xwl_dmabuf_handle_format(void *data, struct zwp_linux_dmabuf_v1 *dmabuf,
|
|
|
4c4b8b |
+ uint32_t format)
|
|
|
4c4b8b |
+{
|
|
|
4c4b8b |
+}
|
|
|
4c4b8b |
+
|
|
|
4c4b8b |
+static void
|
|
|
4c4b8b |
+xwl_dmabuf_handle_modifier(void *data, struct zwp_linux_dmabuf_v1 *dmabuf,
|
|
|
4c4b8b |
+ uint32_t format, uint32_t modifier_hi,
|
|
|
4c4b8b |
+ uint32_t modifier_lo)
|
|
|
4c4b8b |
+{
|
|
|
4c4b8b |
+ struct xwl_screen *xwl_screen = data;
|
|
|
4c4b8b |
+ struct xwl_format *xwl_format = NULL;
|
|
|
4c4b8b |
+ int i;
|
|
|
4c4b8b |
+
|
|
|
4c4b8b |
+ for (i = 0; i < xwl_screen->num_formats; i++) {
|
|
|
4c4b8b |
+ if (xwl_screen->formats[i].format == format) {
|
|
|
4c4b8b |
+ xwl_format = &xwl_screen->formats[i];
|
|
|
4c4b8b |
+ break;
|
|
|
4c4b8b |
+ }
|
|
|
4c4b8b |
+ }
|
|
|
4c4b8b |
+
|
|
|
4c4b8b |
+ if (xwl_format == NULL) {
|
|
|
4c4b8b |
+ xwl_screen->num_formats++;
|
|
|
4c4b8b |
+ xwl_screen->formats = realloc(xwl_screen->formats,
|
|
|
4c4b8b |
+ xwl_screen->num_formats * sizeof(*xwl_format));
|
|
|
4c4b8b |
+ if (!xwl_screen->formats)
|
|
|
4c4b8b |
+ return;
|
|
|
4c4b8b |
+ xwl_format = &xwl_screen->formats[xwl_screen->num_formats - 1];
|
|
|
4c4b8b |
+ xwl_format->format = format;
|
|
|
4c4b8b |
+ xwl_format->num_modifiers = 0;
|
|
|
4c4b8b |
+ xwl_format->modifiers = NULL;
|
|
|
4c4b8b |
+ }
|
|
|
4c4b8b |
+
|
|
|
4c4b8b |
+ xwl_format->num_modifiers++;
|
|
|
4c4b8b |
+ xwl_format->modifiers = realloc(xwl_format->modifiers,
|
|
|
4c4b8b |
+ xwl_format->num_modifiers * sizeof(uint64_t));
|
|
|
4c4b8b |
+ if (!xwl_format->modifiers)
|
|
|
4c4b8b |
+ return;
|
|
|
4c4b8b |
+ xwl_format->modifiers[xwl_format->num_modifiers - 1] = (uint64_t) modifier_lo;
|
|
|
4c4b8b |
+ xwl_format->modifiers[xwl_format->num_modifiers - 1] |= (uint64_t) modifier_hi << 32;
|
|
|
4c4b8b |
+}
|
|
|
4c4b8b |
+
|
|
|
4c4b8b |
+static const struct zwp_linux_dmabuf_v1_listener xwl_dmabuf_listener = {
|
|
|
4c4b8b |
+ .format = xwl_dmabuf_handle_format,
|
|
|
4c4b8b |
+ .modifier = xwl_dmabuf_handle_modifier
|
|
|
4c4b8b |
+};
|
|
|
4c4b8b |
+
|
|
|
4c4b8b |
+Bool
|
|
|
4c4b8b |
+xwl_screen_set_dmabuf_interface(struct xwl_screen *xwl_screen,
|
|
|
4c4b8b |
+ uint32_t id, uint32_t version)
|
|
|
4c4b8b |
+{
|
|
|
4c4b8b |
+ if (version < 3)
|
|
|
4c4b8b |
+ return FALSE;
|
|
|
4c4b8b |
+
|
|
|
4c4b8b |
+ xwl_screen->dmabuf =
|
|
|
4c4b8b |
+ wl_registry_bind(xwl_screen->registry, id, &zwp_linux_dmabuf_v1_interface, 3);
|
|
|
4c4b8b |
+ zwp_linux_dmabuf_v1_add_listener(xwl_screen->dmabuf, &xwl_dmabuf_listener, xwl_screen);
|
|
|
4c4b8b |
+
|
|
|
4c4b8b |
+ return TRUE;
|
|
|
4c4b8b |
+}
|
|
|
4c4b8b |
+
|
|
|
4c4b8b |
void
|
|
|
4c4b8b |
xwl_glamor_init_wl_registry(struct xwl_screen *xwl_screen,
|
|
|
4c4b8b |
struct wl_registry *registry,
|
|
|
4c4b8b |
@@ -89,11 +155,11 @@ xwl_glamor_init_wl_registry(struct xwl_screen *xwl_screen,
|
|
|
4c4b8b |
version)) {
|
|
|
4c4b8b |
/* no-op */
|
|
|
4c4b8b |
} else if (xwl_screen->eglstream_backend.is_available &&
|
|
|
4c4b8b |
- xwl_screen->eglstream_backend.init_wl_registry(xwl_screen,
|
|
|
4c4b8b |
- registry,
|
|
|
4c4b8b |
- id,
|
|
|
4c4b8b |
- interface,
|
|
|
4c4b8b |
- version)) {
|
|
|
4c4b8b |
+ xwl_screen->eglstream_backend.init_wl_registry(xwl_screen,
|
|
|
4c4b8b |
+ registry,
|
|
|
4c4b8b |
+ id,
|
|
|
4c4b8b |
+ interface,
|
|
|
4c4b8b |
+ version)) {
|
|
|
4c4b8b |
/* no-op */
|
|
|
4c4b8b |
}
|
|
|
4c4b8b |
}
|
|
|
4c4b8b |
diff --git a/hw/xwayland/xwayland-screen.h b/hw/xwayland/xwayland-screen.h
|
|
|
4c4b8b |
index 8d0b12705..5fe4712bd 100644
|
|
|
4c4b8b |
--- a/hw/xwayland/xwayland-screen.h
|
|
|
4c4b8b |
+++ b/hw/xwayland/xwayland-screen.h
|
|
|
4c4b8b |
@@ -83,6 +83,7 @@ struct xwl_screen {
|
|
|
4c4b8b |
struct zwp_relative_pointer_manager_v1 *relative_pointer_manager;
|
|
|
4c4b8b |
struct zwp_pointer_constraints_v1 *pointer_constraints;
|
|
|
4c4b8b |
struct zwp_xwayland_keyboard_grab_manager_v1 *wp_grab;
|
|
|
4c4b8b |
+ struct zwp_linux_dmabuf_v1 *dmabuf;
|
|
|
4c4b8b |
struct zxdg_output_manager_v1 *xdg_output_manager;
|
|
|
4c4b8b |
struct wp_viewporter *viewporter;
|
|
|
4c4b8b |
uint32_t serial;
|
|
|
4c4b8b |
--
|
|
|
4c4b8b |
2.31.1
|
|
|
4c4b8b |
|