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