summarylogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.SRCINFO23
-rw-r--r--0001-gl-renderer-Add-EGLDevice-enumeration-support.patch49
-rw-r--r--0002-gl-renderer-Add-support-for-EGLDevice-composited-fra.patch290
-rw-r--r--0003-gl-renderer-Add-EGL-client-support-for-EGLStream-fra.patch146
-rw-r--r--0004-backend-drm-Gracefully-handle-vblank-and-flip-invali.patch (renamed from 0004-compositor-drm-Gracefully-handle-vblank-and-flip-inv.patch)23
-rw-r--r--0005-backend-drm-Add-support-for-EGLDevice-EGLOutput.patch707
-rw-r--r--0005-compositor-drm-Add-support-for-EGLDevice-EGLOutput.patch593
-rw-r--r--0006-compositor-Process-stream-attach-requests-with-wl_eg.patch151
-rw-r--r--PKGBUILD27
9 files changed, 1034 insertions, 975 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 0baa1b54c50d..13dbe1e03cc9 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,6 +1,6 @@
pkgbase = weston-eglstream
pkgdesc = Reference implementation of a Wayland compositor with EGLStream support
- pkgver = 6.0.1
+ pkgver = 9.0.0
pkgrel = 1
url = https://wayland.freedesktop.org/
arch = x86_64
@@ -18,23 +18,24 @@ pkgbase = weston-eglstream
depends = libva
depends = libxcursor
depends = colord
+ depends = libpipewire02
depends = egl-wayland
provides = weston
conflicts = weston
- source = https://wayland.freedesktop.org/releases/weston-6.0.1.tar.xz
+ source = https://wayland.freedesktop.org/releases/weston-9.0.0.tar.xz
source = 0001-gl-renderer-Add-EGLDevice-enumeration-support.patch
source = 0002-gl-renderer-Add-support-for-EGLDevice-composited-fra.patch
source = 0003-gl-renderer-Add-EGL-client-support-for-EGLStream-fra.patch
- source = 0004-compositor-drm-Gracefully-handle-vblank-and-flip-inv.patch
- source = 0005-compositor-drm-Add-support-for-EGLDevice-EGLOutput.patch
+ source = 0004-backend-drm-Gracefully-handle-vblank-and-flip-invali.patch
+ source = 0005-backend-drm-Add-support-for-EGLDevice-EGLOutput.patch
source = 0006-compositor-Process-stream-attach-requests-with-wl_eg.patch
- sha256sums = bf2f6d5aae2e11cabb6bd69a76bcf9edb084f8c3e14ca769bea7234a513155b4
- sha256sums = 77f798bbed2dfadfdfc3d47631dc9e315570445b247a905466e5b4970e920ced
- sha256sums = c351c903a09ad2608e853e9b052bef6ad9f99478d1940a217cb9854f275ccf08
- sha256sums = 11b744a32b299bab5ac71e86e087f51f0db0aa3e9093c9ca4c88ab79f2e4ea64
- sha256sums = c2781950d5afeeee7ac35027093291242d7dd81295a34d258f80627f86927da9
- sha256sums = 8bc0b1ce255de1c4901c949d6ecac2101820da678d4de43678c8e04b001814af
- sha256sums = e5ddf3567225470a0a8c358374404f1abdf6f5af05be304afd0376b408027c8d
+ sha256sums = 5cf5d6ce192e0eb15c1fc861a436bf21b5bb3b91dbdabbdebe83e1f83aa098fe
+ sha256sums = 39eb26160b63183f35e5c50bea8cc10248fe194ab96b2cb9417990e5ed45fa1a
+ sha256sums = 55ee7aaed84cdc75cc58919a3ec71c7b2cfdbcf936a5f6c8f07f54376b9cc3a5
+ sha256sums = c971abb2b84d9b2519c08aacbd3a4afc44d31bf0970d3bc71e48cca850a9765f
+ sha256sums = ac1c048f6944b1ddd24c17205a7bd8f55578af5489d2f9ca7121727b0cbacc68
+ sha256sums = 5898de8565d3c449fb276f9e3b1ae1bb9e908e8153e0802989a49baa8d1d134a
+ sha256sums = 5834b4b0068cc0debe5bc20cddafd17f9ca4cb472035716da3942401a130ccc8
pkgname = weston-eglstream
diff --git a/0001-gl-renderer-Add-EGLDevice-enumeration-support.patch b/0001-gl-renderer-Add-EGLDevice-enumeration-support.patch
index bd66c116b69c..6eadeff3a9bc 100644
--- a/0001-gl-renderer-Add-EGLDevice-enumeration-support.patch
+++ b/0001-gl-renderer-Add-EGLDevice-enumeration-support.patch
@@ -1,8 +1,7 @@
-From 368a44faef065d4c45415f13c9b51be0d618b3d5 Mon Sep 17 00:00:00 2001
+From 3cf008cf8b11488e07f3008ab32ce1d43b004914 Mon Sep 17 00:00:00 2001
From: "Miguel A. Vico" <mvicomoya@nvidia.com>
Date: Mon, 2 May 2016 15:56:37 +0200
Subject: [PATCH 1/6] gl-renderer: Add EGLDevice enumeration support
-X-NVConfidentiality: public
EGLDevice provides means to enumerate native devices.
@@ -17,15 +16,15 @@ Reviewed-by: Andy Ritger <aritger@nvidia.com>
Reviewed-by: Adam Cheney <acheney@nvidia.com>
Reviewed-by: James Jones <jajones@nvidia.com>
---
- libweston/gl-renderer.c | 89 ++++++++++++++++++++++++++++++++++++++++-
- libweston/gl-renderer.h | 8 ++++
- 2 files changed, 96 insertions(+), 1 deletion(-)
+ libweston/renderer-gl/gl-renderer.c | 86 +++++++++++++++++++++++++++++
+ libweston/renderer-gl/gl-renderer.h | 8 +++
+ 2 files changed, 94 insertions(+)
-diff --git a/libweston/gl-renderer.c b/libweston/gl-renderer.c
-index a03e45ea..74315347 100644
---- a/libweston/gl-renderer.c
-+++ b/libweston/gl-renderer.c
-@@ -3990,6 +3990,90 @@ gl_renderer_setup(struct weston_compositor *ec, EGLSurface egl_surface)
+diff --git a/libweston/renderer-gl/gl-renderer.c b/libweston/renderer-gl/gl-renderer.c
+index d5bfe830..0c9e197a 100644
+--- a/libweston/renderer-gl/gl-renderer.c
++++ b/libweston/renderer-gl/gl-renderer.c
+@@ -3804,6 +3804,90 @@ gl_renderer_setup(struct weston_compositor *ec, EGLSurface egl_surface)
return 0;
}
@@ -114,23 +113,20 @@ index a03e45ea..74315347 100644
+}
+
WL_EXPORT struct gl_renderer_interface gl_renderer_interface = {
- .opaque_attribs = gl_renderer_opaque_attribs,
- .alpha_attribs = gl_renderer_alpha_attribs,
-@@ -4001,5 +4085,8 @@ WL_EXPORT struct gl_renderer_interface gl_renderer_interface = {
- .output_surface = gl_renderer_output_surface,
+ .display_create = gl_renderer_display_create,
+ .output_window_create = gl_renderer_output_window_create,
+@@ -3811,4 +3895,6 @@ WL_EXPORT struct gl_renderer_interface gl_renderer_interface = {
+ .output_destroy = gl_renderer_output_destroy,
.output_set_border = gl_renderer_output_set_border,
.create_fence_fd = gl_renderer_create_fence_fd,
-- .print_egl_error_state = gl_renderer_print_egl_error_state
-+ .print_egl_error_state = gl_renderer_print_egl_error_state,
-+
+ .get_devices = gl_renderer_get_devices,
+ .get_drm_device_file = gl_renderer_get_drm_device_file
};
-diff --git a/libweston/gl-renderer.h b/libweston/gl-renderer.h
-index 202702b5..151879da 100644
---- a/libweston/gl-renderer.h
-+++ b/libweston/gl-renderer.h
-@@ -38,6 +38,7 @@
+diff --git a/libweston/renderer-gl/gl-renderer.h b/libweston/renderer-gl/gl-renderer.h
+index 1430bb14..80c3379b 100644
+--- a/libweston/renderer-gl/gl-renderer.h
++++ b/libweston/renderer-gl/gl-renderer.h
+@@ -40,6 +40,7 @@
typedef int EGLint;
typedef int EGLenum;
@@ -138,10 +134,10 @@ index 202702b5..151879da 100644
typedef void *EGLDisplay;
typedef void *EGLSurface;
typedef void *EGLConfig;
-@@ -121,5 +122,12 @@ struct gl_renderer_interface {
+@@ -218,4 +219,11 @@ struct gl_renderer_interface {
+ * EGL_ANDROID_native_fence_sync extension.
+ */
int (*create_fence_fd)(struct weston_output *output);
-
- void (*print_egl_error_state)(void);
+
+ int (*get_devices)(EGLint max_devices,
+ EGLDeviceEXT *devices,
@@ -150,7 +146,6 @@ index 202702b5..151879da 100644
+ int (*get_drm_device_file)(EGLDeviceEXT device,
+ const char **drm_device_file);
};
-
--
-2.21.0
+2.25.1
diff --git a/0002-gl-renderer-Add-support-for-EGLDevice-composited-fra.patch b/0002-gl-renderer-Add-support-for-EGLDevice-composited-fra.patch
index 516af4bc3312..1ab6d5cf0900 100644
--- a/0002-gl-renderer-Add-support-for-EGLDevice-composited-fra.patch
+++ b/0002-gl-renderer-Add-support-for-EGLDevice-composited-fra.patch
@@ -1,9 +1,8 @@
-From 75abc9e631667949c2ab8cf46882206d4ed71d0e Mon Sep 17 00:00:00 2001
+From e3914a22b9dfb64705b2bcc8d497ebb464fa2fc7 Mon Sep 17 00:00:00 2001
From: "Miguel A. Vico" <mvicomoya@nvidia.com>
Date: Mon, 2 May 2016 16:34:01 +0200
Subject: [PATCH 2/6] gl-renderer: Add support for EGLDevice composited frame
presentation
-X-NVConfidentiality: public
EGLDevice provides means to enumerate native devices, and then create
an EGL display connection from them.
@@ -42,54 +41,129 @@ Reviewed-by: Andy Ritger <aritger@nvidia.com>
Reviewed-by: Adam Cheney <acheney@nvidia.com>
Reviewed-by: James Jones <jajones@nvidia.com>
---
- libweston/gl-renderer.c | 262 +++++++++++++++++++++++++++++++++++++++-
- libweston/gl-renderer.h | 16 +++
- shared/weston-egl-ext.h | 40 ++++++
- 3 files changed, 315 insertions(+), 3 deletions(-)
+ libweston/renderer-gl/egl-glue.c | 45 +++++
+ libweston/renderer-gl/gl-renderer-internal.h | 22 +++
+ libweston/renderer-gl/gl-renderer.c | 197 ++++++++++++++++++-
+ libweston/renderer-gl/gl-renderer.h | 15 ++
+ shared/weston-egl-ext.h | 40 ++++
+ 5 files changed, 314 insertions(+), 5 deletions(-)
-diff --git a/libweston/gl-renderer.c b/libweston/gl-renderer.c
-index 74315347..f3fb2c65 100644
---- a/libweston/gl-renderer.c
-+++ b/libweston/gl-renderer.c
-@@ -101,6 +101,8 @@ struct gl_output_state {
- struct gl_border_image borders[4];
- enum gl_border_status border_status;
-
-+ EGLStreamKHR egl_stream;
-+
- struct weston_matrix output_matrix;
+diff --git a/libweston/renderer-gl/egl-glue.c b/libweston/renderer-gl/egl-glue.c
+index 28be4ffe..60cebd8f 100644
+--- a/libweston/renderer-gl/egl-glue.c
++++ b/libweston/renderer-gl/egl-glue.c
+@@ -503,6 +503,8 @@ platform_to_extension(EGLenum platform)
+ return "x11";
+ case EGL_PLATFORM_SURFACELESS_MESA:
+ return "surfaceless";
++ case EGL_PLATFORM_DEVICE_EXT:
++ return "device";
+ default:
+ assert(0 && "bad EGL platform enum");
+ }
+@@ -600,6 +602,19 @@ gl_renderer_setup_egl_extensions(struct weston_compositor *ec)
+ (void *) eglGetProcAddress("eglQueryWaylandBufferWL");
+ gr->set_damage_region =
+ (void *) eglGetProcAddress("eglSetDamageRegionKHR");
++ gr->get_output_layers = (void *) eglGetProcAddress("eglGetOutputLayersEXT");
++ gr->query_output_layer_attrib =
++ (void *) eglGetProcAddress("eglQueryOutputLayerAttribEXT");
++ gr->create_stream = (void *) eglGetProcAddress("eglCreateStreamKHR");
++ gr->destroy_stream = (void *) eglGetProcAddress("eglDestroyStreamKHR");
++ gr->create_stream_producer_surface =
++ (void *) eglGetProcAddress("eglCreateStreamProducerSurfaceKHR");
++ gr->stream_consumer_output =
++ (void *) eglGetProcAddress("eglStreamConsumerOutputEXT");
++#ifdef EGL_NV_stream_attrib
++ gr->stream_consumer_acquire_attrib =
++ (void *) eglGetProcAddress("eglStreamConsumerAcquireAttribNV");
++#endif
- EGLSyncKHR begin_render_sync, end_render_sync;
-@@ -238,6 +240,28 @@ struct gl_renderer {
+ extensions =
+ (const char *) eglQueryString(gr->egl_display, EGL_EXTENSIONS);
+@@ -689,5 +704,35 @@ gl_renderer_setup_egl_extensions(struct weston_compositor *ec)
+ "to missing EGL_KHR_wait_sync extension\n");
+ }
- int has_surfaceless_context;
++ if (weston_check_egl_extension(extensions, "EGL_EXT_output_base"))
++ gr->has_egl_output_base = true;
++
++ if (weston_check_egl_extension(extensions, "EGL_EXT_output_drm"))
++ gr->has_egl_output_drm = true;
++
++ if (weston_check_egl_extension(extensions, "EGL_NV_output_drm_flip_event"))
++ gr->has_egl_output_drm_flip_event = true;
++
++ if (weston_check_egl_extension(extensions, "EGL_KHR_stream"))
++ gr->has_egl_stream = true;
++
++ if (weston_check_egl_extension(extensions, "EGL_KHR_stream_producer_eglsurface"))
++ gr->has_egl_stream_producer_eglsurface = true;
++
++ if (weston_check_egl_extension(extensions, "EGL_EXT_stream_consumer_egloutput"))
++ gr->has_egl_stream_consumer_egloutput = true;
++
++ if (weston_check_egl_extension(extensions, "EGL_NV_stream_attrib"))
++ gr->has_egl_stream_attrib = true;
++
++ if (weston_check_egl_extension(extensions, "EGL_EXT_stream_acquire_mode"))
++ gr->has_egl_stream_acquire_mode = true;
++
++ if (weston_check_egl_extension(extensions, "EGL_KHR_stream_consumer_gltexture"))
++ gr->has_egl_stream_consumer_gltexture = true;
++
++ if (weston_check_egl_extension(extensions, "EGL_WL_wayland_eglstream"))
++ gr->has_egl_wayland_eglstream = true;
++
+ return 0;
+ }
+diff --git a/libweston/renderer-gl/gl-renderer-internal.h b/libweston/renderer-gl/gl-renderer-internal.h
+index 529cb2f9..e122f64a 100644
+--- a/libweston/renderer-gl/gl-renderer-internal.h
++++ b/libweston/renderer-gl/gl-renderer-internal.h
+@@ -91,6 +91,28 @@ struct gl_renderer {
+ struct wl_list dmabuf_images;
+ struct wl_list dmabuf_formats;
+ PFNEGLGETOUTPUTLAYERSEXTPROC get_output_layers;
+ PFNEGLQUERYOUTPUTLAYERATTRIBEXTPROC query_output_layer_attrib;
-+ int has_egl_output_base;
-+ int has_egl_output_drm;
-+ int has_egl_output_drm_flip_event;
++ bool has_egl_output_base;
++ bool has_egl_output_drm;
++ bool has_egl_output_drm_flip_event;
+
+ PFNEGLCREATESTREAMKHRPROC create_stream;
+ PFNEGLDESTROYSTREAMKHRPROC destroy_stream;
-+ int has_egl_stream;
++ bool has_egl_stream;
+
+ PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC create_stream_producer_surface;
-+ int has_egl_stream_producer_eglsurface;
++ bool has_egl_stream_producer_eglsurface;
+
+ PFNEGLSTREAMCONSUMEROUTPUTEXTPROC stream_consumer_output;
-+ int has_egl_stream_consumer_egloutput;
++ bool has_egl_stream_consumer_egloutput;
+
+#ifdef EGL_NV_stream_attrib
+ PFNEGLSTREAMCONSUMERACQUIREATTRIBNVPROC stream_consumer_acquire_attrib;
+#endif
-+ int has_egl_stream_attrib;
-+ int has_egl_stream_acquire_mode;
++ bool has_egl_stream_attrib;
++ bool has_egl_stream_acquire_mode;
+
- int has_dmabuf_import;
- struct wl_list dmabuf_images;
+ bool has_gl_texture_rg;
+
+ struct gl_shader texture_shader_rgba;
+diff --git a/libweston/renderer-gl/gl-renderer.c b/libweston/renderer-gl/gl-renderer.c
+index 0c9e197a..6fc469ba 100644
+--- a/libweston/renderer-gl/gl-renderer.c
++++ b/libweston/renderer-gl/gl-renderer.c
+@@ -91,6 +91,8 @@ struct gl_output_state {
+ struct gl_border_image borders[4];
+ enum gl_border_status border_status;
+
++ EGLStreamKHR egl_stream;
++
+ struct weston_matrix output_matrix;
-@@ -1503,6 +1527,38 @@ gl_renderer_repaint_output(struct weston_output *output,
+ EGLSyncKHR begin_render_sync, end_render_sync;
+@@ -1521,6 +1523,38 @@ gl_renderer_repaint_output(struct weston_output *output,
update_buffer_release_fences(compositor, output);
}
@@ -128,7 +202,7 @@ index 74315347..f3fb2c65 100644
static int
gl_renderer_read_pixels(struct weston_output *output,
pixman_format_code_t format, void *pixels,
-@@ -3195,9 +3251,93 @@ gl_renderer_create_window_surface(struct gl_renderer *gr,
+@@ -3238,9 +3272,93 @@ gl_renderer_create_window_surface(struct gl_renderer *gr,
return egl_surface;
}
@@ -223,7 +297,7 @@ index 74315347..f3fb2c65 100644
{
struct gl_output_state *go;
int i;
-@@ -3207,6 +3347,7 @@ gl_renderer_output_create(struct weston_output *output,
+@@ -3250,6 +3368,7 @@ gl_renderer_output_create(struct weston_output *output,
return -1;
go->egl_surface = surface;
@@ -231,7 +305,7 @@ index 74315347..f3fb2c65 100644
for (i = 0; i < BUFFER_DAMAGE_COUNT; i++)
pixman_region32_init(&go->buffer_damage[i]);
-@@ -3244,13 +3385,41 @@ gl_renderer_output_window_create(struct weston_output *output,
+@@ -3283,7 +3402,7 @@ gl_renderer_output_window_create(struct weston_output *output,
return -1;
}
@@ -240,6 +314,15 @@ index 74315347..f3fb2c65 100644
if (ret < 0)
weston_platform_destroy_egl_surface(gr->egl_display, egl_surface);
+@@ -3322,13 +3441,41 @@ gl_renderer_output_pbuffer_create(struct weston_output *output,
+ return -1;
+ }
+
+- ret = gl_renderer_output_create(output, egl_surface);
++ ret = gl_renderer_output_create(output, egl_surface, EGL_NO_STREAM_KHR);
+ if (ret < 0)
+ eglDestroySurface(gr->egl_display, egl_surface);
+
return ret;
}
@@ -274,7 +357,7 @@ index 74315347..f3fb2c65 100644
static void
gl_renderer_output_destroy(struct weston_output *output)
{
-@@ -3280,6 +3449,9 @@ gl_renderer_output_destroy(struct weston_output *output)
+@@ -3358,6 +3505,9 @@ gl_renderer_output_destroy(struct weston_output *output)
if (go->end_render_sync != EGL_NO_SYNC_KHR)
gr->destroy_sync(gr->egl_display, go->end_render_sync);
@@ -284,87 +367,21 @@ index 74315347..f3fb2c65 100644
free(go);
}
-@@ -3393,6 +3565,19 @@ gl_renderer_setup_egl_extensions(struct weston_compositor *ec)
- (void *) eglGetProcAddress("eglUnbindWaylandDisplayWL");
- gr->query_buffer =
- (void *) eglGetProcAddress("eglQueryWaylandBufferWL");
-+ gr->get_output_layers = (void *) eglGetProcAddress("eglGetOutputLayersEXT");
-+ gr->query_output_layer_attrib =
-+ (void *) eglGetProcAddress("eglQueryOutputLayerAttribEXT");
-+ gr->create_stream = (void *) eglGetProcAddress("eglCreateStreamKHR");
-+ gr->destroy_stream = (void *) eglGetProcAddress("eglDestroyStreamKHR");
-+ gr->create_stream_producer_surface =
-+ (void *) eglGetProcAddress("eglCreateStreamProducerSurfaceKHR");
-+ gr->stream_consumer_output =
-+ (void *) eglGetProcAddress("eglStreamConsumerOutputEXT");
-+#ifdef EGL_NV_stream_attrib
-+ gr->stream_consumer_acquire_attrib =
-+ (void *) eglGetProcAddress("eglStreamConsumerAcquireAttribNV");
-+#endif
-
- extensions =
- (const char *) eglQueryString(gr->egl_display, EGL_EXTENSIONS);
-@@ -3467,6 +3652,30 @@ gl_renderer_setup_egl_extensions(struct weston_compositor *ec)
- "to missing EGL_KHR_wait_sync extension\n");
- }
-
-+ if (weston_check_egl_extension(extensions, "EGL_EXT_output_base"))
-+ gr->has_egl_output_base = 1;
-+
-+ if (weston_check_egl_extension(extensions, "EGL_EXT_output_drm"))
-+ gr->has_egl_output_drm = 1;
-+
-+ if (weston_check_egl_extension(extensions, "EGL_NV_output_drm_flip_event"))
-+ gr->has_egl_output_drm_flip_event = 1;
-+
-+ if (weston_check_egl_extension(extensions, "EGL_KHR_stream"))
-+ gr->has_egl_stream = 1;
-+
-+ if (weston_check_egl_extension(extensions, "EGL_KHR_stream_producer_eglsurface"))
-+ gr->has_egl_stream_producer_eglsurface = 1;
-+
-+ if (weston_check_egl_extension(extensions, "EGL_EXT_stream_consumer_egloutput"))
-+ gr->has_egl_stream_consumer_egloutput = 1;
-+
-+ if (weston_check_egl_extension(extensions, "EGL_NV_stream_attrib"))
-+ gr->has_egl_stream_attrib = 1;
-+
-+ if (weston_check_egl_extension(extensions, "EGL_EXT_stream_acquire_mode"))
-+ gr->has_egl_stream_acquire_mode = 1;
-+
- renderer_setup_egl_client_extensions(gr);
-
- return 0;
-@@ -3492,6 +3701,15 @@ static const EGLint gl_renderer_alpha_attribs[] = {
- EGL_NONE
- };
+@@ -3503,7 +3653,8 @@ gl_renderer_display_create(struct weston_compositor *ec,
+ if (gl_renderer_setup_egl_extensions(ec) < 0)
+ goto fail_with_error;
-+static const EGLint gl_renderer_opaque_stream_attribs[] = {
-+ EGL_SURFACE_TYPE, EGL_STREAM_BIT_KHR,
-+ EGL_RED_SIZE, 1,
-+ EGL_GREEN_SIZE, 1,
-+ EGL_BLUE_SIZE, 1,
-+ EGL_ALPHA_SIZE, 0,
-+ EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
-+ EGL_NONE
-+};
+- if (!gr->has_configless_context) {
++ if (!gr->has_configless_context ||
++ options->egl_platform == EGL_PLATFORM_DEVICE_EXT) {
+ EGLint egl_surface_type = options->egl_surface_type;
- /** Checks whether a platform EGL client extension is supported
- *
-@@ -3565,6 +3783,8 @@ platform_to_extension(EGLenum platform)
- return "wayland";
- case EGL_PLATFORM_X11_KHR:
- return "x11";
-+ case EGL_PLATFORM_DEVICE_EXT:
-+ return "device";
- default:
- assert(0 && "bad EGL platform enum");
- }
-@@ -3706,6 +3926,38 @@ gl_renderer_display_create(struct weston_compositor *ec, EGLenum platform,
+ if (!gr->has_surfaceless_context)
+@@ -3526,6 +3677,38 @@ gl_renderer_display_create(struct weston_compositor *ec,
if (gr->has_native_fence_sync && gr->has_wait_sync)
ec->capabilities |= WESTON_CAP_EXPLICIT_SYNC;
-+ if (platform == EGL_PLATFORM_DEVICE_EXT) {
++ if (options->egl_platform == EGL_PLATFORM_DEVICE_EXT) {
+ if (!gr->has_egl_output_base ||
+ !gr->has_egl_output_drm ||
+ !gr->has_egl_stream ||
@@ -399,51 +416,36 @@ index 74315347..f3fb2c65 100644
wl_list_init(&gr->dmabuf_images);
if (gr->has_dmabuf_import) {
gr->base.import_dmabuf = gl_renderer_import_dmabuf;
-@@ -4077,10 +4329,12 @@ gl_renderer_get_drm_device_file(EGLDeviceEXT device,
- WL_EXPORT struct gl_renderer_interface gl_renderer_interface = {
- .opaque_attribs = gl_renderer_opaque_attribs,
- .alpha_attribs = gl_renderer_alpha_attribs,
-+ .opaque_stream_attribs = gl_renderer_opaque_stream_attribs,
-
+@@ -3892,9 +4075,13 @@ WL_EXPORT struct gl_renderer_interface gl_renderer_interface = {
.display_create = gl_renderer_display_create,
- .display = gl_renderer_display,
.output_window_create = gl_renderer_output_window_create,
+ .output_pbuffer_create = gl_renderer_output_pbuffer_create,
+ .output_stream_create = gl_renderer_output_stream_create,
.output_destroy = gl_renderer_output_destroy,
- .output_surface = gl_renderer_output_surface,
.output_set_border = gl_renderer_output_set_border,
-@@ -4088,5 +4342,7 @@ WL_EXPORT struct gl_renderer_interface gl_renderer_interface = {
- .print_egl_error_state = gl_renderer_print_egl_error_state,
-
+ .create_fence_fd = gl_renderer_create_fence_fd,
++
.get_devices = gl_renderer_get_devices,
- .get_drm_device_file = gl_renderer_get_drm_device_file
+ .get_drm_device_file = gl_renderer_get_drm_device_file,
+
+ .output_stream_flip = gl_renderer_output_stream_flip
};
-diff --git a/libweston/gl-renderer.h b/libweston/gl-renderer.h
-index 151879da..973097bf 100644
---- a/libweston/gl-renderer.h
-+++ b/libweston/gl-renderer.h
-@@ -60,6 +60,7 @@ enum gl_renderer_border_side {
- struct gl_renderer_interface {
- const EGLint *opaque_attribs;
- const EGLint *alpha_attribs;
-+ const EGLint *opaque_stream_attribs;
-
- int (*display_create)(struct weston_compositor *ec,
- EGLenum platform,
-@@ -78,6 +79,9 @@ struct gl_renderer_interface {
- const EGLint *visual_id,
- const int n_ids);
+diff --git a/libweston/renderer-gl/gl-renderer.h b/libweston/renderer-gl/gl-renderer.h
+index 80c3379b..f46c21c6 100644
+--- a/libweston/renderer-gl/gl-renderer.h
++++ b/libweston/renderer-gl/gl-renderer.h
+@@ -179,6 +179,9 @@ struct gl_renderer_interface {
+ int (*output_pbuffer_create)(struct weston_output *output,
+ const struct gl_renderer_pbuffer_options *options);
+ int (*output_stream_create)(struct weston_output *output,
+ uint32_t plane_id, uint32_t crtc_id);
+
void (*output_destroy)(struct weston_output *output);
- EGLSurface (*output_surface)(struct weston_output *output);
-@@ -129,5 +133,17 @@ struct gl_renderer_interface {
+ /* Sets the output border.
+@@ -226,4 +229,16 @@ struct gl_renderer_interface {
int (*get_drm_device_file)(EGLDeviceEXT device,
const char **drm_device_file);
@@ -460,12 +462,11 @@ index 151879da..973097bf 100644
+ int (*output_stream_flip)(struct weston_output *output,
+ void *flip_data);
};
-
diff --git a/shared/weston-egl-ext.h b/shared/weston-egl-ext.h
-index 0784ea2d..f39990ed 100644
+index 4a757c8b..dc07c04a 100644
--- a/shared/weston-egl-ext.h
+++ b/shared/weston-egl-ext.h
-@@ -204,12 +204,52 @@ typedef EGLint (EGLAPIENTRYP PFNEGLDUPNATIVEFENCEFDANDROIDPROC) (EGLDisplay dpy,
+@@ -208,6 +208,45 @@ typedef EGLint (EGLAPIENTRYP PFNEGLDUPNATIVEFENCEFDANDROIDPROC) (EGLDisplay dpy,
#define EGL_NO_NATIVE_FENCE_FD_ANDROID -1
#endif
@@ -511,13 +512,14 @@ index 0784ea2d..f39990ed 100644
#else /* ENABLE_EGL */
/* EGL platform definition are keept to allow compositor-xx.c to build */
- #define EGL_PLATFORM_GBM_KHR 0x31D7
+@@ -215,6 +254,7 @@ typedef EGLint (EGLAPIENTRYP PFNEGLDUPNATIVEFENCEFDANDROIDPROC) (EGLDisplay dpy,
#define EGL_PLATFORM_WAYLAND_KHR 0x31D8
#define EGL_PLATFORM_X11_KHR 0x31D5
+ #define EGL_PLATFORM_SURFACELESS_MESA 0x31DD
+#define EGL_PLATFORM_DEVICE_EXT 0x313F
#endif /* ENABLE_EGL */
--
-2.21.0
+2.25.1
diff --git a/0003-gl-renderer-Add-EGL-client-support-for-EGLStream-fra.patch b/0003-gl-renderer-Add-EGL-client-support-for-EGLStream-fra.patch
index 387031d8e989..5f02a285a2c1 100644
--- a/0003-gl-renderer-Add-EGL-client-support-for-EGLStream-fra.patch
+++ b/0003-gl-renderer-Add-EGL-client-support-for-EGLStream-fra.patch
@@ -1,9 +1,8 @@
-From 720e02507651efefe3a4a42077f719dd9f74b07c Mon Sep 17 00:00:00 2001
+From a7fc52ddd8d7f6c212caeb29dc1df5b4b8b74bd3 Mon Sep 17 00:00:00 2001
From: "Miguel A. Vico" <mvicomoya@nvidia.com>
Date: Thu, 29 Mar 2018 00:15:49 -0700
Subject: [PATCH 3/6] gl-renderer: Add EGL client support for EGLStream frame
presentation
-X-NVConfidentiality: public
By attaching a GLTexture consumer to a stream, a producer (wayland EGL
client) could feed frames to a texture, which in turn can be used by a
@@ -28,51 +27,81 @@ Signed-off-by: Erik Kurzinger <ekurzinger@nvidia.com>
Reviewed-by: Adam Cheney <acheney@nvidia.com>
Reviewed-by: James Jones <jajones@nvidia.com>
---
- libweston/gl-renderer.c | 184 ++++++++++++++++++++++++++++++++++++++++
- shared/weston-egl-ext.h | 5 ++
- 2 files changed, 189 insertions(+)
+ libweston/renderer-gl/egl-glue.c | 5 +
+ libweston/renderer-gl/gl-renderer-internal.h | 6 +
+ libweston/renderer-gl/gl-renderer.c | 167 +++++++++++++++++++
+ shared/weston-egl-ext.h | 5 +
+ 4 files changed, 183 insertions(+)
-diff --git a/libweston/gl-renderer.c b/libweston/gl-renderer.c
-index f3fb2c65..4bae6546 100644
---- a/libweston/gl-renderer.c
-+++ b/libweston/gl-renderer.c
-@@ -189,6 +189,9 @@ struct gl_surface_state {
- int hsub[3]; /* horizontal subsampling per plane */
- int vsub[3]; /* vertical subsampling per plane */
-
-+ EGLStreamKHR egl_stream;
-+ bool new_stream;
-+
- struct weston_surface *surface;
+diff --git a/libweston/renderer-gl/egl-glue.c b/libweston/renderer-gl/egl-glue.c
+index 60cebd8f..abe10b46 100644
+--- a/libweston/renderer-gl/egl-glue.c
++++ b/libweston/renderer-gl/egl-glue.c
+@@ -607,14 +607,19 @@ gl_renderer_setup_egl_extensions(struct weston_compositor *ec)
+ (void *) eglGetProcAddress("eglQueryOutputLayerAttribEXT");
+ gr->create_stream = (void *) eglGetProcAddress("eglCreateStreamKHR");
+ gr->destroy_stream = (void *) eglGetProcAddress("eglDestroyStreamKHR");
++ gr->query_stream = (void *) eglGetProcAddress("eglQueryStreamKHR");
+ gr->create_stream_producer_surface =
+ (void *) eglGetProcAddress("eglCreateStreamProducerSurfaceKHR");
+ gr->stream_consumer_output =
+ (void *) eglGetProcAddress("eglStreamConsumerOutputEXT");
+ #ifdef EGL_NV_stream_attrib
++ gr->create_stream_attrib =
++ (void *) eglGetProcAddress("eglCreateStreamAttribNV");
+ gr->stream_consumer_acquire_attrib =
+ (void *) eglGetProcAddress("eglStreamConsumerAcquireAttribNV");
+ #endif
++ gr->stream_consumer_gltexture =
++ (void *) eglGetProcAddress("eglStreamConsumerGLTextureExternalKHR");
- /* Whether this surface was used in the current output repaint.
-@@ -248,6 +251,7 @@ struct gl_renderer {
+ extensions =
+ (const char *) eglQueryString(gr->egl_display, EGL_EXTENSIONS);
+diff --git a/libweston/renderer-gl/gl-renderer-internal.h b/libweston/renderer-gl/gl-renderer-internal.h
+index e122f64a..5b0bd4b5 100644
+--- a/libweston/renderer-gl/gl-renderer-internal.h
++++ b/libweston/renderer-gl/gl-renderer-internal.h
+@@ -99,6 +99,7 @@ struct gl_renderer {
PFNEGLCREATESTREAMKHRPROC create_stream;
PFNEGLDESTROYSTREAMKHRPROC destroy_stream;
+ PFNEGLQUERYSTREAMKHRPROC query_stream;
- int has_egl_stream;
+ bool has_egl_stream;
PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC create_stream_producer_surface;
-@@ -257,11 +261,16 @@ struct gl_renderer {
- int has_egl_stream_consumer_egloutput;
+@@ -108,11 +109,16 @@ struct gl_renderer {
+ bool has_egl_stream_consumer_egloutput;
#ifdef EGL_NV_stream_attrib
+ PFNEGLCREATESTREAMATTRIBNVPROC create_stream_attrib;
PFNEGLSTREAMCONSUMERACQUIREATTRIBNVPROC stream_consumer_acquire_attrib;
#endif
- int has_egl_stream_attrib;
- int has_egl_stream_acquire_mode;
+ bool has_egl_stream_attrib;
+ bool has_egl_stream_acquire_mode;
+ PFNEGLSTREAMCONSUMERGLTEXTUREEXTERNALKHRPROC stream_consumer_gltexture;
-+ int has_egl_stream_consumer_gltexture;
-+ int has_egl_wayland_eglstream;
++ bool has_egl_stream_consumer_gltexture;
++ bool has_egl_wayland_eglstream;
++
+ bool has_gl_texture_rg;
+
+ struct gl_shader texture_shader_rgba;
+diff --git a/libweston/renderer-gl/gl-renderer.c b/libweston/renderer-gl/gl-renderer.c
+index 6fc469ba..f834a7cb 100644
+--- a/libweston/renderer-gl/gl-renderer.c
++++ b/libweston/renderer-gl/gl-renderer.c
+@@ -196,6 +196,9 @@ struct gl_surface_state {
+ int hsub[3]; /* horizontal subsampling per plane */
+ int vsub[3]; /* vertical subsampling per plane */
+
++ EGLStreamKHR egl_stream;
++ bool new_stream;
+
- int has_dmabuf_import;
- struct wl_list dmabuf_images;
+ struct weston_surface *surface;
-@@ -2528,6 +2537,145 @@ gl_renderer_attach_dmabuf(struct weston_surface *surface,
- surface->is_opaque = dmabuf_is_opaque(dmabuf);
+ /* Whether this surface was used in the current output repaint.
+@@ -2636,6 +2639,145 @@ gl_renderer_attach_dmabuf(struct weston_surface *surface,
+ gs->shader = image->shader;
}
+/*
@@ -217,9 +246,9 @@ index f3fb2c65..4bae6546 100644
static void
gl_renderer_attach(struct weston_surface *es, struct weston_buffer *buffer)
{
-@@ -2554,6 +2702,12 @@ gl_renderer_attach(struct weston_surface *es, struct weston_buffer *buffer)
- gs->buffer_type = BUFFER_TYPE_NULL;
- gs->y_inverted = 1;
+@@ -2663,6 +2805,12 @@ gl_renderer_attach(struct weston_surface *es, struct weston_buffer *buffer)
+ gs->y_inverted = true;
+ gs->direct_display = false;
es->is_opaque = false;
+
+ if (gs->egl_stream != EGL_NO_STREAM_KHR) {
@@ -230,17 +259,17 @@ index f3fb2c65..4bae6546 100644
return;
}
-@@ -2561,6 +2715,9 @@ gl_renderer_attach(struct weston_surface *es, struct weston_buffer *buffer)
+@@ -2670,6 +2818,9 @@ gl_renderer_attach(struct weston_surface *es, struct weston_buffer *buffer)
if (shm_buffer)
gl_renderer_attach_shm(es, buffer, shm_buffer);
+ else if (gl_renderer_attach_stream_texture(es, buffer))
-+ /* The stream texture is attached. Nothing else to be done here */
-+ ((void)0);
++ /* The stream texture is attached. Nothing else to be done here */
++ ((void)0);
else if (gr->has_bind_display &&
gr->query_buffer(gr->egl_display, (void *)buffer->resource,
EGL_TEXTURE_FORMAT, &format))
-@@ -2764,6 +2921,10 @@ surface_state_destroy(struct gl_surface_state *gs, struct gl_renderer *gr)
+@@ -2873,6 +3024,10 @@ surface_state_destroy(struct gl_surface_state *gs, struct gl_renderer *gr)
weston_buffer_reference(&gs->buffer_ref, NULL);
weston_buffer_release_reference(&gs->buffer_release_ref, NULL);
pixman_region32_fini(&gs->texture_damage);
@@ -251,7 +280,7 @@ index f3fb2c65..4bae6546 100644
free(gs);
}
-@@ -2814,6 +2975,8 @@ gl_renderer_create_surface(struct weston_surface *surface)
+@@ -2924,6 +3079,8 @@ gl_renderer_create_surface(struct weston_surface *surface)
gs->surface = surface;
@@ -260,40 +289,7 @@ index f3fb2c65..4bae6546 100644
pixman_region32_init(&gs->texture_damage);
surface->renderer_state = gs;
-@@ -3570,14 +3733,19 @@ gl_renderer_setup_egl_extensions(struct weston_compositor *ec)
- (void *) eglGetProcAddress("eglQueryOutputLayerAttribEXT");
- gr->create_stream = (void *) eglGetProcAddress("eglCreateStreamKHR");
- gr->destroy_stream = (void *) eglGetProcAddress("eglDestroyStreamKHR");
-+ gr->query_stream = (void *) eglGetProcAddress("eglQueryStreamKHR");
- gr->create_stream_producer_surface =
- (void *) eglGetProcAddress("eglCreateStreamProducerSurfaceKHR");
- gr->stream_consumer_output =
- (void *) eglGetProcAddress("eglStreamConsumerOutputEXT");
- #ifdef EGL_NV_stream_attrib
-+ gr->create_stream_attrib =
-+ (void *) eglGetProcAddress("eglCreateStreamAttribNV");
- gr->stream_consumer_acquire_attrib =
- (void *) eglGetProcAddress("eglStreamConsumerAcquireAttribNV");
- #endif
-+ gr->stream_consumer_gltexture =
-+ (void *) eglGetProcAddress("eglStreamConsumerGLTextureExternalKHR");
-
- extensions =
- (const char *) eglQueryString(gr->egl_display, EGL_EXTENSIONS);
-@@ -3676,6 +3844,12 @@ gl_renderer_setup_egl_extensions(struct weston_compositor *ec)
- if (weston_check_egl_extension(extensions, "EGL_EXT_stream_acquire_mode"))
- gr->has_egl_stream_acquire_mode = 1;
-
-+ if (weston_check_egl_extension(extensions, "EGL_KHR_stream_consumer_gltexture"))
-+ gr->has_egl_stream_consumer_gltexture = 1;
-+
-+ if (weston_check_egl_extension(extensions, "EGL_WL_wayland_eglstream"))
-+ gr->has_egl_wayland_eglstream = 1;
-+
- renderer_setup_egl_client_extensions(gr);
-
- return 0;
-@@ -3953,6 +4127,16 @@ gl_renderer_display_create(struct weston_compositor *ec, EGLenum platform,
+@@ -3704,6 +3861,16 @@ gl_renderer_display_create(struct weston_compositor *ec,
goto fail_terminate;
}
@@ -311,10 +307,10 @@ index f3fb2c65..4bae6546 100644
weston_log("warning: EGL page flip event notification "
"not supported\n");
diff --git a/shared/weston-egl-ext.h b/shared/weston-egl-ext.h
-index f39990ed..96982e2d 100644
+index dc07c04a..d348a5c0 100644
--- a/shared/weston-egl-ext.h
+++ b/shared/weston-egl-ext.h
-@@ -243,6 +243,11 @@ EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerAcquireAttribEXT (EGLDisplay dpy,
+@@ -247,6 +247,11 @@ EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerAcquireAttribEXT (EGLDisplay dpy,
#define EGL_DRM_FLIP_EVENT_DATA_NV 0x333E
#endif /* EGL_NV_output_drm_flip_event */
@@ -327,5 +323,5 @@ index f39990ed..96982e2d 100644
/* EGL platform definition are keept to allow compositor-xx.c to build */
--
-2.21.0
+2.25.1
diff --git a/0004-compositor-drm-Gracefully-handle-vblank-and-flip-inv.patch b/0004-backend-drm-Gracefully-handle-vblank-and-flip-invali.patch
index 88b5b578c44f..0db21e38460c 100644
--- a/0004-compositor-drm-Gracefully-handle-vblank-and-flip-inv.patch
+++ b/0004-backend-drm-Gracefully-handle-vblank-and-flip-invali.patch
@@ -1,9 +1,8 @@
-From 36ff0ce74aa22e633e0e3821f04cbeea4c25f927 Mon Sep 17 00:00:00 2001
+From b897295ffd88f1046e7150a084d57c41ced4cb9e Mon Sep 17 00:00:00 2001
From: "Miguel A. Vico" <mvicomoya@nvidia.com>
Date: Tue, 1 Mar 2016 22:19:14 +0100
-Subject: [PATCH 4/6] compositor-drm: Gracefully handle vblank and flip invalid
+Subject: [PATCH 4/6] backend-drm: Gracefully handle vblank and flip invalid
timestamps
-X-NVConfidentiality: public
Instant query for vblank timestamp may always fail, resulting in
never scheduling a full repaint in drm_output_start_repaint_loop().
@@ -18,13 +17,13 @@ situations above.
Signed-off-by: Miguel A Vico Moya <mvicomoya@nvidia.com>
Reviewed-by: Andy Ritger <aritger@nvidia.com>
---
- libweston/compositor-drm.c | 28 +++++++++++++++++++++++++---
+ libweston/backend-drm/drm.c | 28 +++++++++++++++++++++++++---
1 file changed, 25 insertions(+), 3 deletions(-)
-diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
-index f1c5d73a..b9eb2883 100644
---- a/libweston/compositor-drm.c
-+++ b/libweston/compositor-drm.c
+diff --git a/libweston/backend-drm/drm.c b/libweston/backend-drm/drm.c
+index 2780f3bd..94a2bf2a 100644
+--- a/libweston/backend-drm/drm.c
++++ b/libweston/backend-drm/drm.c
@@ -4,6 +4,7 @@
* Copyright © 2017, 2018 Collabora, Ltd.
* Copyright © 2017, 2018 General Electric Company
@@ -33,7 +32,7 @@ index f1c5d73a..b9eb2883 100644
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
-@@ -1939,6 +1940,19 @@ drm_output_update_complete(struct drm_output *output, uint32_t flags,
+@@ -319,6 +320,19 @@ drm_output_update_complete(struct drm_output *output, uint32_t flags,
ts.tv_sec = sec;
ts.tv_nsec = usec * 1000;
@@ -53,7 +52,7 @@ index f1c5d73a..b9eb2883 100644
weston_output_finish_frame(&output->base, &ts, flags);
/* We can't call this from frame_notify, because the output's
-@@ -3018,8 +3032,16 @@ drm_output_start_repaint_loop(struct weston_output *output_base)
+@@ -555,8 +569,16 @@ drm_output_start_repaint_loop(struct weston_output *output_base)
vbl.request.type |= drm_waitvblank_pipe(output);
ret = drmWaitVBlank(backend->drm.fd, &vbl);
@@ -72,7 +71,7 @@ index f1c5d73a..b9eb2883 100644
ts.tv_sec = vbl.reply.tval_sec;
ts.tv_nsec = vbl.reply.tval_usec * 1000;
-@@ -3040,7 +3062,7 @@ drm_output_start_repaint_loop(struct weston_output *output_base)
+@@ -577,7 +599,7 @@ drm_output_start_repaint_loop(struct weston_output *output_base)
}
}
@@ -82,5 +81,5 @@ index f1c5d73a..b9eb2883 100644
*/
--
-2.21.0
+2.25.1
diff --git a/0005-backend-drm-Add-support-for-EGLDevice-EGLOutput.patch b/0005-backend-drm-Add-support-for-EGLDevice-EGLOutput.patch
new file mode 100644
index 000000000000..857a9721ffe2
--- /dev/null
+++ b/0005-backend-drm-Add-support-for-EGLDevice-EGLOutput.patch
@@ -0,0 +1,707 @@
+From 8f9701ca16c53caa96edbdf0d0e5fc5cd6f6efbe Mon Sep 17 00:00:00 2001
+From: "Miguel A. Vico" <mvicomoya@nvidia.com>
+Date: Mon, 26 Aug 2019 09:48:49 -0700
+Subject: [PATCH 5/6] backend-drm: Add support for EGLDevice+EGLOutput
+
+As previously stated, EGLDevice and EGLOutput will provide means
+to access native device objects and different portions of display
+control hardware respectively.
+
+Whenever EGL_EXT_device_drm extension is present, EGLDevice can
+be used to enumerate and access DRM KMS devices, and EGLOutputLayer
+to enumerate and access DRM KMS crtcs and planes.
+
+By using EGLStreams and attaching an EGLOutputLayer consumer
+(representing a DRM KMS crtc or plane) to it, backend-drm can
+produce final composition frames and present them on a DRM device.
+
+This change adds required logic to support presentation through
+EGLDevice+EGLOutput+EGLStream. Whether GBM or EGLDevice should be
+used can be controlled by --use-egldevice backend argument.
+
+Signed-off-by: Miguel A Vico Moya <mvicomoya@nvidia.com>
+Reviewed-by: Andy Ritger <aritger@nvidia.com>
+Reviewed-by: Adam Cheney <acheney@nvidia.com>
+Reviewed-by: James Jones <jajones@nvidia.com>
+---
+ compositor/main.c | 4 +-
+ include/libweston/backend-drm.h | 4 +
+ libweston/backend-drm/drm-gbm.c | 262 +++++++++++++------
+ libweston/backend-drm/drm-internal.h | 14 +
+ libweston/backend-drm/drm.c | 15 +-
+ libweston/backend-drm/kms.c | 23 +-
+ libweston/backend-headless/headless.c | 1 +
+ libweston/backend-wayland/wayland.c | 1 +
+ libweston/backend-x11/x11.c | 1 +
+ libweston/renderer-gl/egl-glue.c | 5 +-
+ libweston/renderer-gl/gl-renderer-internal.h | 4 +-
+ libweston/renderer-gl/gl-renderer.c | 4 +-
+ libweston/renderer-gl/gl-renderer.h | 2 +
+ shared/weston-egl-ext.h | 9 +
+ 14 files changed, 259 insertions(+), 90 deletions(-)
+
+diff --git a/compositor/main.c b/compositor/main.c
+index 65da9dbc..2361cc63 100644
+--- a/compositor/main.c
++++ b/compositor/main.c
+@@ -677,7 +677,8 @@ usage(int error_code)
+ " --drm-device=CARD\tThe DRM device to use, e.g. \"card0\".\n"
+ " --use-pixman\t\tUse the pixman (CPU) renderer\n"
+ " --current-mode\tPrefer current KMS mode over EDID preferred mode\n"
+- " --continue-without-input\tAllow the compositor to start without input devices\n\n");
++ " --continue-without-input\tAllow the compositor to start without input devices\n\n"
++ " --use-egldevice\tUse EGLDevice and EGLOutput with the GL renderer\n");
+ #endif
+
+ #if defined(BUILD_FBDEV_COMPOSITOR)
+@@ -2525,6 +2526,7 @@ load_drm_backend(struct weston_compositor *c,
+ { WESTON_OPTION_BOOLEAN, "current-mode", 0, &wet->drm_use_current_mode },
+ { WESTON_OPTION_BOOLEAN, "use-pixman", 0, &config.use_pixman },
+ { WESTON_OPTION_BOOLEAN, "continue-without-input", 0, &config.continue_without_input },
++ { WESTON_OPTION_BOOLEAN, "use-egldevice", 0, &config.use_egldevice },
+ };
+
+ parse_options(options, ARRAY_LENGTH(options), argc, argv);
+diff --git a/include/libweston/backend-drm.h b/include/libweston/backend-drm.h
+index 350eeb0d..8916f98d 100644
+--- a/include/libweston/backend-drm.h
++++ b/include/libweston/backend-drm.h
+@@ -177,6 +177,10 @@ struct weston_drm_backend_config {
+ /** Whether to use the pixman renderer instead of the OpenGL ES renderer. */
+ bool use_pixman;
+
++ /** Whether to use the GL composition based off EGLDevice & friends instead
++ * of GBM. */
++ bool use_egldevice;
++
+ /** The seat to be used for input and output.
+ *
+ * If seat_id is NULL, the seat is taken from XDG_SEAT environment
+diff --git a/libweston/backend-drm/drm-gbm.c b/libweston/backend-drm/drm-gbm.c
+index 30609e3e..04a9f89b 100644
+--- a/libweston/backend-drm/drm-gbm.c
++++ b/libweston/backend-drm/drm-gbm.c
+@@ -51,11 +51,6 @@ create_gbm_device(int fd)
+ {
+ struct gbm_device *gbm;
+
+- gl_renderer = weston_load_module("gl-renderer.so",
+- "gl_renderer_interface");
+- if (!gl_renderer)
+- return NULL;
+-
+ /* GBM will load a dri driver, but even though they need symbols from
+ * libglapi, in some version of Mesa they are not linked to it. Since
+ * only the gl-renderer module links to it, the call above won't make
+@@ -68,6 +63,40 @@ create_gbm_device(int fd)
+ return gbm;
+ }
+
++static EGLDeviceEXT
++find_egldevice(const char *filename)
++{
++ EGLDeviceEXT egldevice = EGL_NO_DEVICE_EXT;
++ EGLDeviceEXT *devices;
++ EGLint num_devices;
++ const char *drm_path;
++ int i;
++
++ if (gl_renderer->get_devices(0, NULL, &num_devices) < 0 ||
++ num_devices < 1)
++ return EGL_NO_DEVICE_EXT;
++
++ devices = zalloc(num_devices * sizeof *devices);
++ if (!devices)
++ return EGL_NO_DEVICE_EXT;
++
++ if (gl_renderer->get_devices(num_devices, devices, &num_devices) < 0) {
++ free(devices);
++ return EGL_NO_DEVICE_EXT;
++ }
++
++ for (i = 0; i < num_devices; i++)
++ if (gl_renderer->get_drm_device_file(devices[i],
++ &drm_path) == 0 &&
++ strcmp(filename, drm_path) == 0) {
++ egldevice = devices[i];
++ break;
++ }
++
++ free(devices);
++ return egldevice;
++}
++
+ /* When initializing EGL, if the preferred buffer format isn't available
+ * we may be able to substitute an ARGB format for an XRGB one.
+ *
+@@ -98,33 +127,57 @@ drm_backend_create_gl_renderer(struct drm_backend *b)
+ fallback_format_for(b->gbm_format),
+ 0,
+ };
+- struct gl_renderer_display_options options = {
+- .egl_platform = EGL_PLATFORM_GBM_KHR,
+- .egl_native_display = b->gbm,
+- .egl_surface_type = EGL_WINDOW_BIT,
+- .drm_formats = format,
+- .drm_formats_count = 2,
++
++ EGLint device_platform_attribs[] = {
++ EGL_DRM_MASTER_FD_EXT, b->drm.fd,
++ EGL_NONE
+ };
+
++ struct gl_renderer_display_options options;
++ if (b->use_egldevice) {
++ options.egl_platform = EGL_PLATFORM_DEVICE_EXT;
++ options.egl_native_display = b->egldevice;
++ options.egl_surface_type = EGL_STREAM_BIT_KHR;
++ options.egl_platform_attribs = device_platform_attribs;
++ options.drm_formats = format;
++ options.drm_formats_count = 2;
++ } else {
++ options.egl_platform = EGL_PLATFORM_GBM_KHR;
++ options.egl_native_display = b->gbm;
++ options.egl_surface_type = EGL_WINDOW_BIT;
++ options.egl_platform_attribs = NULL;
++ options.drm_formats = format;
++ options.drm_formats_count = 2;
++ }
++
+ if (format[1])
+ options.drm_formats_count = 3;
+
+- if (gl_renderer->display_create(b->compositor, &options) < 0)
+- return -1;
+-
+- return 0;
++ return gl_renderer->display_create(b->compositor, &options);
+ }
+
+ int
+ init_egl(struct drm_backend *b)
+ {
+- b->gbm = create_gbm_device(b->drm.fd);
+-
+- if (!b->gbm)
++ gl_renderer = weston_load_module("gl-renderer.so",
++ "gl_renderer_interface");
++ if (!gl_renderer)
+ return -1;
+
++ if (b->use_egldevice) {
++ b->egldevice = find_egldevice(b->drm.filename);
++ if (b->egldevice == EGL_NO_DEVICE_EXT)
++ return -1;
++ } else {
++ b->gbm = create_gbm_device(b->drm.fd);
++
++ if (!b->gbm)
++ return -1;
++ }
++
+ if (drm_backend_create_gl_renderer(b) < 0) {
+- gbm_device_destroy(b->gbm);
++ if (b->gbm)
++ gbm_device_destroy(b->gbm);
+ return -1;
+ }
+
+@@ -181,71 +234,98 @@ err:
+ int
+ drm_output_init_egl(struct drm_output *output, struct drm_backend *b)
+ {
+- uint32_t format[2] = {
++ if (b->use_egldevice) {
++ int w = output->base.current_mode->width;
++ int h = output->base.current_mode->height;
++
++ /* Create a black dumb fb for modesetting */
++ output->dumb[0] = drm_fb_create_dumb(b, w, h,
++ DRM_FORMAT_XRGB8888);
++ if (!output->dumb[0]) {
++ weston_log("failed to create dumb framebuffer\n");
++ return -1;
++ }
++ memset(output->dumb[0]->map, 0, output->dumb[0]->size);
++
++ if (gl_renderer->output_stream_create(&output->base, ~0u,
++ output->crtc_id) < 0) {
++ weston_log("failed to create gl renderer output stream "
++ "state\n");
++ drm_fb_unref(output->dumb[0]);
++ output->dumb[0] = NULL;
++ return -1;
++ }
++
++ /* FIXME: Add hw planes and cursors for EGL device when supported */
++ b->sprites_are_broken = 1;
++ b->cursors_are_broken = 1;
++ } else {
++ uint32_t format[2] = {
+ output->gbm_format,
+ fallback_format_for(output->gbm_format),
+- };
+- struct gl_renderer_output_options options = {
++ };
++ struct gl_renderer_output_options options = {
+ .drm_formats = format,
+ .drm_formats_count = 1,
+- };
+- struct weston_mode *mode = output->base.current_mode;
+- struct drm_plane *plane = output->scanout_plane;
+- unsigned int i;
++ };
++ struct weston_mode *mode = output->base.current_mode;
++ struct drm_plane *plane = output->scanout_plane;
++ unsigned int i;
+
+- assert(output->gbm_surface == NULL);
++ assert(output->gbm_surface == NULL);
+
+- for (i = 0; i < plane->count_formats; i++) {
++ for (i = 0; i < plane->count_formats; i++) {
+ if (plane->formats[i].format == output->gbm_format)
+- break;
+- }
++ break;
++ }
+
+- if (i == plane->count_formats) {
++ if (i == plane->count_formats) {
+ weston_log("format 0x%x not supported by output %s\n",
+ output->gbm_format, output->base.name);
+ return -1;
+- }
++ }
+
+ #ifdef HAVE_GBM_MODIFIERS
+- if (plane->formats[i].count_modifiers > 0) {
++ if (plane->formats[i].count_modifiers > 0) {
+ output->gbm_surface =
+- gbm_surface_create_with_modifiers(b->gbm,
+- mode->width,
+- mode->height,
+- output->gbm_format,
+- plane->formats[i].modifiers,
+- plane->formats[i].count_modifiers);
+- }
+-
+- /* If allocating with modifiers fails, try again without. This can
+- * happen when the KMS display device supports modifiers but the
+- * GBM driver does not, e.g. the old i915 Mesa driver. */
+- if (!output->gbm_surface)
++ gbm_surface_create_with_modifiers(b->gbm,
++ mode->width,
++ mode->height,
++ output->gbm_format,
++ plane->formats[i].modifiers,
++ plane->formats[i].count_modifiers);
++ }
++
++ /* If allocating with modifiers fails, try again without. This can
++ * happen when the KMS display device supports modifiers but the
++ * GBM driver does not, e.g. the old i915 Mesa driver. */
++ if (!output->gbm_surface)
+ #endif
+- {
++ {
+ output->gbm_surface =
+ gbm_surface_create(b->gbm, mode->width, mode->height,
+ output->gbm_format,
+ output->gbm_bo_flags);
+- }
++ }
+
+- if (!output->gbm_surface) {
++ if (!output->gbm_surface) {
+ weston_log("failed to create gbm surface\n");
+ return -1;
+- }
++ }
+
+- if (options.drm_formats[1])
++ if (options.drm_formats[1])
+ options.drm_formats_count = 2;
+- options.window_for_legacy = (EGLNativeWindowType) output->gbm_surface;
+- options.window_for_platform = output->gbm_surface;
+- if (gl_renderer->output_window_create(&output->base, &options) < 0) {
++ options.window_for_legacy = (EGLNativeWindowType) output->gbm_surface;
++ options.window_for_platform = output->gbm_surface;
++ if (gl_renderer->output_window_create(&output->base, &options) < 0) {
+ weston_log("failed to create gl renderer output state\n");
+ gbm_surface_destroy(output->gbm_surface);
+ output->gbm_surface = NULL;
+ return -1;
+- }
++ }
+
+- drm_output_init_cursor_egl(output, b);
++ drm_output_init_cursor_egl(output, b);
++ }
+
+ return 0;
+ }
+@@ -258,14 +338,23 @@ drm_output_fini_egl(struct drm_output *output)
+ /* Destroying the GBM surface will destroy all our GBM buffers,
+ * regardless of refcount. Ensure we destroy them here. */
+ if (!b->shutting_down &&
+- output->scanout_plane->state_cur->fb &&
+- output->scanout_plane->state_cur->fb->type == BUFFER_GBM_SURFACE) {
++ ((output->scanout_plane->state_cur->fb &&
++ output->scanout_plane->state_cur->fb->type == BUFFER_GBM_SURFACE) ||
++ b->use_egldevice)) {
+ drm_plane_reset_state(output->scanout_plane);
+ }
+
+ gl_renderer->output_destroy(&output->base);
+- gbm_surface_destroy(output->gbm_surface);
+- output->gbm_surface = NULL;
++
++ if (output->dumb[0]) {
++ drm_fb_unref(output->dumb[0]);
++ output->dumb[0] = NULL;
++ }
++
++ if (output->gbm_surface) {
++ gbm_surface_destroy(output->gbm_surface);
++ output->gbm_surface = NULL;
++ }
+ drm_output_fini_cursor_egl(output);
+ }
+
+@@ -279,22 +368,25 @@ drm_output_render_gl(struct drm_output_state *state, pixman_region32_t *damage)
+
+ output->base.compositor->renderer->repaint_output(&output->base,
+ damage);
+-
+- bo = gbm_surface_lock_front_buffer(output->gbm_surface);
+- if (!bo) {
+- weston_log("failed to lock front buffer: %s\n",
+- strerror(errno));
+- return NULL;
+- }
+-
+- /* The renderer always produces an opaque image. */
+- ret = drm_fb_get_from_bo(bo, b, true, BUFFER_GBM_SURFACE);
+- if (!ret) {
+- weston_log("failed to get drm_fb for bo\n");
+- gbm_surface_release_buffer(output->gbm_surface, bo);
+- return NULL;
++ if (b->use_egldevice)
++ ret = drm_fb_ref(output->dumb[0]);
++ else {
++ bo = gbm_surface_lock_front_buffer(output->gbm_surface);
++ if (!bo) {
++ weston_log("failed to lock front buffer: %s\n",
++ strerror(errno));
++ return NULL;
++ }
++
++ /* The renderer always produces an opaque image. */
++ ret = drm_fb_get_from_bo(bo, b, true, BUFFER_GBM_SURFACE);
++ if (!ret) {
++ weston_log("failed to get drm_fb for bo\n");
++ gbm_surface_release_buffer(output->gbm_surface, bo);
++ return NULL;
++ }
++ ret->gbm_surface = output->gbm_surface;
+ }
+- ret->gbm_surface = output->gbm_surface;
+
+ return ret;
+ }
+@@ -315,11 +407,20 @@ switch_to_gl_renderer(struct drm_backend *b)
+
+ weston_log("Switching to GL renderer\n");
+
+- b->gbm = create_gbm_device(b->drm.fd);
+- if (!b->gbm) {
+- weston_log("Failed to create gbm device. "
+- "Aborting renderer switch\n");
+- return;
++ if (b->use_egldevice) {
++ b->egldevice = find_egldevice(b->drm.filename);
++ if (b->egldevice == EGL_NO_DEVICE_EXT) {
++ weston_log("Failed to create EGL device. "
++ "Aborting renderer switch\n");
++ return;
++ }
++ } else {
++ b->gbm = create_gbm_device(b->drm.fd);
++ if (!b->gbm) {
++ weston_log("Failed to create gbm device. "
++ "Aborting renderer switch\n");
++ return;
++ }
+ }
+
+ wl_list_for_each(output, &b->compositor->output_list, base.link)
+@@ -328,7 +429,8 @@ switch_to_gl_renderer(struct drm_backend *b)
+ b->compositor->renderer->destroy(b->compositor);
+
+ if (drm_backend_create_gl_renderer(b) < 0) {
+- gbm_device_destroy(b->gbm);
++ if (b->gbm)
++ gbm_device_destroy(b->gbm);
+ weston_log("Failed to create GL renderer. Quitting.\n");
+ /* FIXME: we need a function to shutdown cleanly */
+ assert(0);
+diff --git a/libweston/backend-drm/drm-internal.h b/libweston/backend-drm/drm-internal.h
+index 06f952f2..8bc9c92b 100644
+--- a/libweston/backend-drm/drm-internal.h
++++ b/libweston/backend-drm/drm-internal.h
+@@ -60,6 +60,17 @@
+ #include "backend.h"
+ #include "libweston-internal.h"
+
++#ifdef ENABLE_EGL
++
++#include <EGL/egl.h>
++#include <EGL/eglext.h>
++
++#else
++
++typedef void *EGLDeviceEXT;
++
++#endif
++
+ #ifndef DRM_CLIENT_CAP_ASPECT_RATIO
+ #define DRM_CLIENT_CAP_ASPECT_RATIO 4
+ #endif
+@@ -262,6 +273,9 @@ struct drm_backend {
+ struct wl_listener session_listener;
+ uint32_t gbm_format;
+
++ EGLDeviceEXT egldevice;
++ bool use_egldevice;
++
+ /* we need these parameters in order to not fail drmModeAddFB2()
+ * due to out of bounds dimensions, and then mistakenly set
+ * sprites_are_broken:
+diff --git a/libweston/backend-drm/drm.c b/libweston/backend-drm/drm.c
+index 94a2bf2a..94246bb2 100644
+--- a/libweston/backend-drm/drm.c
++++ b/libweston/backend-drm/drm.c
+@@ -390,7 +390,8 @@ drm_output_render(struct drm_output_state *state, pixman_region32_t *damage)
+ * the damaged region into the renderer to re-render the affected
+ * area.
+ */
+- if (!pixman_region32_not_empty(damage) &&
++ if (!b->use_egldevice &&
++ !pixman_region32_not_empty(damage) &&
+ scanout_plane->state_cur->fb &&
+ (scanout_plane->state_cur->fb->type == BUFFER_GBM_SURFACE ||
+ scanout_plane->state_cur->fb->type == BUFFER_PIXMAN_DUMB)) {
+@@ -2798,6 +2799,11 @@ recorder_binding(struct weston_keyboard *keyboard, const struct timespec *time,
+ struct drm_output *output;
+ int width, height;
+
++ if (b->use_egldevice) {
++ weston_log("recorder not supported with EGL device\n");
++ return;
++ }
++
+ output = container_of(b->compositor->output_list.next,
+ struct drm_output, base.link);
+
+@@ -2879,6 +2885,13 @@ drm_backend_create(struct weston_compositor *compositor,
+ b->use_pixman = config->use_pixman;
+ b->pageflip_timeout = config->pageflip_timeout;
+ b->use_pixman_shadow = config->use_pixman_shadow;
++ b->use_egldevice = config->use_egldevice;
++ if (b->use_egldevice) {
++#if !BUILD_DRM_GBM
++ weston_log("fatal: drm backend with EGLDevice requires GL renderer.\n");
++ goto err_compositor;
++#endif
++ }
+
+ b->debug = weston_compositor_add_log_scope(compositor, "drm-backend",
+ "Debug messages from DRM/KMS backend\n",
+diff --git a/libweston/backend-drm/kms.c b/libweston/backend-drm/kms.c
+index c91e3810..0033dba2 100644
+--- a/libweston/backend-drm/kms.c
++++ b/libweston/backend-drm/kms.c
+@@ -42,6 +42,11 @@
+ #include "pixel-formats.h"
+ #include "presentation-time-server-protocol.h"
+
++#if BUILD_DRM_GBM
++#include "renderer-gl/gl-renderer.h"
++extern struct gl_renderer_interface *gl_renderer;
++#endif
++
+ #ifndef DRM_FORMAT_MOD_LINEAR
+ #define DRM_FORMAT_MOD_LINEAR 0
+ #endif
+@@ -752,9 +757,19 @@ drm_output_apply_state_legacy(struct drm_output_state *state)
+ output->crtc_id, scanout_state->plane->plane_id,
+ pinfo ? pinfo->drm_format_name : "UNKNOWN");
+
+- if (drmModePageFlip(backend->drm.fd, output->crtc_id,
+- scanout_state->fb->fb_id,
+- DRM_MODE_PAGE_FLIP_EVENT, output) < 0) {
++ if (backend->use_egldevice) {
++#if BUILD_DRM_GBM
++ ret = gl_renderer->output_stream_flip(&output->base, output);
++#else
++ assert(!"Can't flip output EGLStream without GL renderer.\n");
++ ret = -1;
++#endif
++ } else
++ ret = drmModePageFlip(backend->drm.fd, output->crtc_id,
++ scanout_state->fb->fb_id,
++ DRM_MODE_PAGE_FLIP_EVENT, output);
++
++ if (ret < 0) {
+ weston_log("queueing pageflip failed: %s\n", strerror(errno));
+ goto err;
+ }
+@@ -1468,7 +1483,7 @@ init_kms_caps(struct drm_backend *b)
+ b->universal_planes = (ret == 0);
+ }
+
+- if (b->universal_planes && !getenv("WESTON_DISABLE_ATOMIC")) {
++ if (b->universal_planes && !getenv("WESTON_DISABLE_ATOMIC") && !b->use_egldevice) {
+ ret = drmGetCap(b->drm.fd, DRM_CAP_CRTC_IN_VBLANK_EVENT, &cap);
+ if (ret != 0)
+ cap = 0;
+diff --git a/libweston/backend-headless/headless.c b/libweston/backend-headless/headless.c
+index c312a0f2..94f4e998 100644
+--- a/libweston/backend-headless/headless.c
++++ b/libweston/backend-headless/headless.c
+@@ -396,6 +396,7 @@ headless_gl_renderer_init(struct headless_backend *b)
+ .egl_platform = EGL_PLATFORM_SURFACELESS_MESA,
+ .egl_native_display = EGL_DEFAULT_DISPLAY,
+ .egl_surface_type = EGL_PBUFFER_BIT,
++ .egl_platform_attribs = NULL,
+ .drm_formats = headless_formats,
+ .drm_formats_count = ARRAY_LENGTH(headless_formats),
+ };
+diff --git a/libweston/backend-wayland/wayland.c b/libweston/backend-wayland/wayland.c
+index 60d42bf3..a8bca921 100644
+--- a/libweston/backend-wayland/wayland.c
++++ b/libweston/backend-wayland/wayland.c
+@@ -2781,6 +2781,7 @@ wayland_backend_create(struct weston_compositor *compositor,
+ .egl_platform = EGL_PLATFORM_WAYLAND_KHR,
+ .egl_native_display = b->parent.wl_display,
+ .egl_surface_type = EGL_WINDOW_BIT,
++ .egl_platform_attribs = NULL,
+ .drm_formats = wayland_formats,
+ .drm_formats_count = ARRAY_LENGTH(wayland_formats),
+ };
+diff --git a/libweston/backend-x11/x11.c b/libweston/backend-x11/x11.c
+index 387e97a4..46af8f02 100644
+--- a/libweston/backend-x11/x11.c
++++ b/libweston/backend-x11/x11.c
+@@ -1806,6 +1806,7 @@ init_gl_renderer(struct x11_backend *b)
+ .egl_platform = EGL_PLATFORM_X11_KHR,
+ .egl_native_display = b->dpy,
+ .egl_surface_type = EGL_WINDOW_BIT,
++ .egl_platform_attribs = NULL,
+ .drm_formats = x11_formats,
+ .drm_formats_count = ARRAY_LENGTH(x11_formats),
+ };
+diff --git a/libweston/renderer-gl/egl-glue.c b/libweston/renderer-gl/egl-glue.c
+index abe10b46..c1fa17d8 100644
+--- a/libweston/renderer-gl/egl-glue.c
++++ b/libweston/renderer-gl/egl-glue.c
+@@ -457,7 +457,8 @@ gl_renderer_get_egl_config(struct gl_renderer *gr,
+
+ int
+ gl_renderer_setup_egl_display(struct gl_renderer *gr,
+- void *native_display)
++ void *native_display,
++ const EGLint *attribs)
+ {
+ gr->egl_display = NULL;
+
+@@ -465,7 +466,7 @@ gl_renderer_setup_egl_display(struct gl_renderer *gr,
+ if (gr->has_platform_base)
+ gr->egl_display = gr->get_platform_display(gr->platform,
+ native_display,
+- NULL);
++ attribs);
+
+ if (!gr->egl_display) {
+ weston_log("warning: either no EGL_EXT_platform_base "
+diff --git a/libweston/renderer-gl/gl-renderer-internal.h b/libweston/renderer-gl/gl-renderer-internal.h
+index 5b0bd4b5..ae76a81e 100644
+--- a/libweston/renderer-gl/gl-renderer-internal.h
++++ b/libweston/renderer-gl/gl-renderer-internal.h
+@@ -171,7 +171,9 @@ gl_renderer_get_egl_config(struct gl_renderer *gr,
+ unsigned drm_formats_count);
+
+ int
+-gl_renderer_setup_egl_display(struct gl_renderer *gr, void *native_display);
++gl_renderer_setup_egl_display(struct gl_renderer *gr,
++ void *native_display,
++ const EGLint *attribs);
+
+ int
+ gl_renderer_setup_egl_client_extensions(struct gl_renderer *gr);
+diff --git a/libweston/renderer-gl/gl-renderer.c b/libweston/renderer-gl/gl-renderer.c
+index f834a7cb..19a2e730 100644
+--- a/libweston/renderer-gl/gl-renderer.c
++++ b/libweston/renderer-gl/gl-renderer.c
+@@ -3800,7 +3800,9 @@ gl_renderer_display_create(struct weston_compositor *ec,
+ gl_renderer_surface_get_content_size;
+ gr->base.surface_copy_content = gl_renderer_surface_copy_content;
+
+- if (gl_renderer_setup_egl_display(gr, options->egl_native_display) < 0)
++ if (gl_renderer_setup_egl_display(gr,
++ options->egl_native_display,
++ options->egl_platform_attribs) < 0)
+ goto fail;
+
+ log_egl_info(gr->egl_display);
+diff --git a/libweston/renderer-gl/gl-renderer.h b/libweston/renderer-gl/gl-renderer.h
+index f46c21c6..8ad069d9 100644
+--- a/libweston/renderer-gl/gl-renderer.h
++++ b/libweston/renderer-gl/gl-renderer.h
+@@ -49,6 +49,7 @@ typedef intptr_t EGLNativeWindowType;
+ #define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0)
+ #define EGL_PBUFFER_BIT 0x0001
+ #define EGL_WINDOW_BIT 0x0004
++#define EGL_NO_DEVICE_EXT ((EGLDeviceEXT)0)
+
+ #endif /* ENABLE_EGL */
+
+@@ -71,6 +72,7 @@ struct gl_renderer_display_options {
+ void *egl_native_display;
+ /** EGL_SURFACE_TYPE bits for the base EGLConfig */
+ EGLint egl_surface_type;
++ const EGLint *egl_platform_attribs;
+ /** Array of DRM pixel formats acceptable for the base EGLConfig */
+ const uint32_t *drm_formats;
+ /** The \c drm_formats array length */
+diff --git a/shared/weston-egl-ext.h b/shared/weston-egl-ext.h
+index d348a5c0..30e4eaba 100644
+--- a/shared/weston-egl-ext.h
++++ b/shared/weston-egl-ext.h
+@@ -212,6 +212,10 @@ typedef EGLint (EGLAPIENTRYP PFNEGLDUPNATIVEFENCEFDANDROIDPROC) (EGLDisplay dpy,
+ #define EGL_PLATFORM_DEVICE_EXT 0x313F
+ #endif
+
++#ifndef EGL_DRM_MASTER_FD_EXT
++#define EGL_DRM_MASTER_FD_EXT 0x333C
++#endif
++
+ /*
+ * FIXME: Remove both EGL_EXT_stream_acquire_mode and
+ * EGL_NV_output_drm_flip_event definitions below once both extensions
+@@ -261,6 +265,11 @@ EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerAcquireAttribEXT (EGLDisplay dpy,
+ #define EGL_PLATFORM_SURFACELESS_MESA 0x31DD
+ #define EGL_PLATFORM_DEVICE_EXT 0x313F
+
++/* EGL_DRM_MASTER_FD_EXT and EGL_NONE enum values are also kept to allow
++ * backend-drm/drm.c to build with EGLDevice and EGLStream support */
++#define EGL_DRM_MASTER_FD_EXT 0x333C
++#define EGL_NONE 0x3038
++
+ #endif /* ENABLE_EGL */
+
+ #endif
+--
+2.25.1
+
diff --git a/0005-compositor-drm-Add-support-for-EGLDevice-EGLOutput.patch b/0005-compositor-drm-Add-support-for-EGLDevice-EGLOutput.patch
deleted file mode 100644
index 65341e0f75f9..000000000000
--- a/0005-compositor-drm-Add-support-for-EGLDevice-EGLOutput.patch
+++ /dev/null
@@ -1,593 +0,0 @@
-From 2543533568a4ea2b4b86d4eada1a87f8fad49c0d Mon Sep 17 00:00:00 2001
-From: "Miguel A. Vico" <mvicomoya@nvidia.com>
-Date: Thu, 28 Jan 2016 19:37:10 +0100
-Subject: [PATCH 5/6] compositor-drm: Add support for EGLDevice+EGLOutput
-X-NVConfidentiality: public
-
-As previously stated, EGLDevice and EGLOutput will provide means
-to access native device objects and different portions of display
-control hardware respectively.
-
-Whenever EGL_EXT_device_drm extension is present, EGLDevice can
-be used to enumerate and access DRM KMS devices, and EGLOutputLayer
-to enumerate and access DRM KMS crtcs and planes.
-
-By using EGLStreams and attaching an EGLOutputLayer consumer
-(representing a DRM KMS crtc or plane) to it, compositor-drm can
-produce final composition frames and present them on a DRM device.
-
-This change adds required logic to support presentation through
-EGLDevice+EGLOutput+EGLStream. Whether GBM or EGLDevice should be
-used can be controlled by --use-egldevice backend argument.
-
-Signed-off-by: Miguel A Vico Moya <mvicomoya@nvidia.com>
-Reviewed-by: Andy Ritger <aritger@nvidia.com>
-Reviewed-by: Adam Cheney <acheney@nvidia.com>
-Reviewed-by: James Jones <jajones@nvidia.com>
----
- compositor/main.c | 2 +
- libweston/compositor-drm.c | 343 +++++++++++++++++++++++++------------
- libweston/compositor-drm.h | 4 +
- libweston/gl-renderer.h | 1 +
- shared/weston-egl-ext.h | 9 +
- 5 files changed, 249 insertions(+), 110 deletions(-)
-
-diff --git a/compositor/main.c b/compositor/main.c
-index b6ac6ea3..f101e3d9 100644
---- a/compositor/main.c
-+++ b/compositor/main.c
-@@ -665,6 +665,7 @@ usage(int error_code)
- " --tty=TTY\t\tThe tty to use\n"
- " --drm-device=CARD\tThe DRM device to use, e.g. \"card0\".\n"
- " --use-pixman\t\tUse the pixman (CPU) renderer\n"
-+ " --use-egldevice\tUse EGLDevice and EGLOutput with the GL renderer\n"
- " --current-mode\tPrefer current KMS mode over EDID preferred mode\n\n");
- #endif
-
-@@ -2345,6 +2346,7 @@ load_drm_backend(struct weston_compositor *c,
- { WESTON_OPTION_STRING, "drm-device", 0, &config.specific_device },
- { WESTON_OPTION_BOOLEAN, "current-mode", 0, &drm_use_current_mode },
- { WESTON_OPTION_BOOLEAN, "use-pixman", 0, &use_pixman_ },
-+ { WESTON_OPTION_BOOLEAN, "use-egldevice", 0, &config.use_egldevice },
- };
-
- parse_options(options, ARRAY_LENGTH(options), argc, argv);
-diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
-index b9eb2883..6b0b8be7 100644
---- a/libweston/compositor-drm.c
-+++ b/libweston/compositor-drm.c
-@@ -310,7 +310,10 @@ struct drm_backend {
- int fd;
- char *filename;
- } drm;
-+
-+ EGLDeviceEXT egldevice;
- struct gbm_device *gbm;
-+
- struct wl_listener session_listener;
- uint32_t gbm_format;
-
-@@ -340,6 +343,8 @@ struct drm_backend {
- bool use_pixman;
- bool use_pixman_shadow;
-
-+ int use_egldevice;
-+
- struct udev_input input;
-
- int32_t cursor_width;
-@@ -2111,21 +2116,25 @@ drm_output_render_gl(struct drm_output_state *state, pixman_region32_t *damage)
- output->base.compositor->renderer->repaint_output(&output->base,
- damage);
-
-- bo = gbm_surface_lock_front_buffer(output->gbm_surface);
-- if (!bo) {
-- weston_log("failed to lock front buffer: %s\n",
-- strerror(errno));
-- return NULL;
-- }
-+ if (b->use_egldevice)
-+ ret = drm_fb_ref(output->dumb[0]);
-+ else {
-+ bo = gbm_surface_lock_front_buffer(output->gbm_surface);
-+ if (!bo) {
-+ weston_log("failed to lock front buffer: %s\n",
-+ strerror(errno));
-+ return NULL;
-+ }
-
-- /* The renderer always produces an opaque image. */
-- ret = drm_fb_get_from_bo(bo, b, true, BUFFER_GBM_SURFACE);
-- if (!ret) {
-- weston_log("failed to get drm_fb for bo\n");
-- gbm_surface_release_buffer(output->gbm_surface, bo);
-- return NULL;
-+ /* The renderer always produces an opaque image. */
-+ ret = drm_fb_get_from_bo(bo, b, true, BUFFER_GBM_SURFACE);
-+ if (!ret) {
-+ weston_log("failed to get drm_fb for bo\n");
-+ gbm_surface_release_buffer(output->gbm_surface, bo);
-+ return NULL;
-+ }
-+ ret->gbm_surface = output->gbm_surface;
- }
-- ret->gbm_surface = output->gbm_surface;
-
- return ret;
- }
-@@ -2168,7 +2177,9 @@ drm_output_render(struct drm_output_state *state, pixman_region32_t *damage)
- if (scanout_state->fb)
- return;
-
-- if (!pixman_region32_not_empty(damage) &&
-+ /* XXX: Assume full damage when using streams */
-+ if (!b->use_egldevice &&
-+ !pixman_region32_not_empty(damage) &&
- scanout_plane->state_cur->fb &&
- (scanout_plane->state_cur->fb->type == BUFFER_GBM_SURFACE ||
- scanout_plane->state_cur->fb->type == BUFFER_PIXMAN_DUMB) &&
-@@ -2364,9 +2375,14 @@ drm_output_apply_state_legacy(struct drm_output_state *state)
- output->crtc_id, scanout_state->plane->plane_id,
- pinfo ? pinfo->drm_format_name : "UNKNOWN");
-
-- if (drmModePageFlip(backend->drm.fd, output->crtc_id,
-- scanout_state->fb->fb_id,
-- DRM_MODE_PAGE_FLIP_EVENT, output) < 0) {
-+ if (backend->use_egldevice)
-+ ret = gl_renderer->output_stream_flip(&output->base, output);
-+ else
-+ ret = drmModePageFlip(backend->drm.fd, output->crtc_id,
-+ scanout_state->fb->fb_id,
-+ DRM_MODE_PAGE_FLIP_EVENT, output);
-+
-+ if (ret < 0) {
- weston_log("queueing pageflip failed: %s\n", strerror(errno));
- goto err;
- }
-@@ -4184,7 +4200,8 @@ init_kms_caps(struct drm_backend *b)
- b->universal_planes ? "supports" : "does not support");
-
- #ifdef HAVE_DRM_ATOMIC
-- if (b->universal_planes && !getenv("WESTON_DISABLE_ATOMIC")) {
-+ /* FIXME: Atomic modeset is not yet fully supported with streams */
-+ if (b->universal_planes && !getenv("WESTON_DISABLE_ATOMIC") && !b->use_egldevice) {
- ret = drmGetCap(b->drm.fd, DRM_CAP_CRTC_IN_VBLANK_EVENT, &cap);
- if (ret != 0)
- cap = 0;
-@@ -4227,11 +4244,6 @@ create_gbm_device(int fd)
- {
- struct gbm_device *gbm;
-
-- gl_renderer = weston_load_module("gl-renderer.so",
-- "gl_renderer_interface");
-- if (!gl_renderer)
-- return NULL;
--
- /* GBM will load a dri driver, but even though they need symbols from
- * libglapi, in some version of Mesa they are not linked to it. Since
- * only the gl-renderer module links to it, the call above won't make
-@@ -4244,6 +4256,40 @@ create_gbm_device(int fd)
- return gbm;
- }
-
-+static EGLDeviceEXT
-+find_egldevice(const char *filename)
-+{
-+ EGLDeviceEXT egldevice = EGL_NO_DEVICE_EXT;
-+ EGLDeviceEXT *devices;
-+ EGLint num_devices;
-+ const char *drm_path;
-+ int i;
-+
-+ if (gl_renderer->get_devices(0, NULL, &num_devices) < 0 ||
-+ num_devices < 1)
-+ return EGL_NO_DEVICE_EXT;
-+
-+ devices = zalloc(num_devices * sizeof *devices);
-+ if (!devices)
-+ return EGL_NO_DEVICE_EXT;
-+
-+ if (gl_renderer->get_devices(num_devices, devices, &num_devices) < 0) {
-+ free(devices);
-+ return EGL_NO_DEVICE_EXT;
-+ }
-+
-+ for (i = 0; i < num_devices; i++)
-+ if (gl_renderer->get_drm_device_file(devices[i],
-+ &drm_path) == 0 &&
-+ strcmp(filename, drm_path) == 0) {
-+ egldevice = devices[i];
-+ break;
-+ }
-+
-+ free(devices);
-+ return egldevice;
-+}
-+
- /* When initializing EGL, if the preferred buffer format isn't available
- * we may be able to substitute an ARGB format for an XRGB one.
- *
-@@ -4270,38 +4316,62 @@ fallback_format_for(uint32_t format)
- static int
- drm_backend_create_gl_renderer(struct drm_backend *b)
- {
-- EGLint format[3] = {
-- b->gbm_format,
-- fallback_format_for(b->gbm_format),
-- 0,
-- };
-- int n_formats = 2;
-+ if (b->use_egldevice) {
-+ EGLint device_platform_attribs[] = {
-+ EGL_DRM_MASTER_FD_EXT, b->drm.fd,
-+ EGL_NONE
-+ };
-
-- if (format[1])
-- n_formats = 3;
-- if (gl_renderer->display_create(b->compositor,
-- EGL_PLATFORM_GBM_KHR,
-- (void *)b->gbm,
-+ return gl_renderer->display_create(
-+ b->compositor,
-+ EGL_PLATFORM_DEVICE_EXT,
-+ (void *)b->egldevice,
-+ device_platform_attribs,
-+ gl_renderer->opaque_stream_attribs,
- NULL,
-- gl_renderer->opaque_attribs,
-- format,
-- n_formats) < 0) {
-- return -1;
-- }
-+ 0);
-+ } else {
-+ EGLint format[3] = {
-+ b->gbm_format,
-+ fallback_format_for(b->gbm_format),
-+ 0,
-+ };
-+ int n_formats = 2;
-
-- return 0;
-+ if (format[1])
-+ n_formats = 3;
-+
-+ return gl_renderer->display_create(b->compositor,
-+ EGL_PLATFORM_GBM_KHR,
-+ (void *)b->gbm,
-+ NULL,
-+ gl_renderer->opaque_attribs,
-+ format,
-+ n_formats);
-+ }
- }
-
- static int
- init_egl(struct drm_backend *b)
- {
-- b->gbm = create_gbm_device(b->drm.fd);
--
-- if (!b->gbm)
-+ gl_renderer = weston_load_module("gl-renderer.so",
-+ "gl_renderer_interface");
-+ if (!gl_renderer)
- return -1;
-
-+ if (b->use_egldevice) {
-+ b->egldevice = find_egldevice(b->drm.filename);
-+ if (b->egldevice == EGL_NO_DEVICE_EXT)
-+ return -1;
-+ } else {
-+ b->gbm = create_gbm_device(b->drm.fd);
-+ if (!b->gbm)
-+ return -1;
-+ }
-+
- if (drm_backend_create_gl_renderer(b) < 0) {
-- gbm_device_destroy(b->gbm);
-+ if (b->gbm)
-+ gbm_device_destroy(b->gbm);
- return -1;
- }
-
-@@ -5068,71 +5138,98 @@ err:
- static int
- drm_output_init_egl(struct drm_output *output, struct drm_backend *b)
- {
-- EGLint format[2] = {
-- output->gbm_format,
-- fallback_format_for(output->gbm_format),
-- };
-- int n_formats = 1;
-- struct weston_mode *mode = output->base.current_mode;
-- struct drm_plane *plane = output->scanout_plane;
-- unsigned int i;
-+ if (b->use_egldevice) {
-+ int w = output->base.current_mode->width;
-+ int h = output->base.current_mode->height;
-
-- assert(output->gbm_surface == NULL);
-+ /* Create a black dumb fb for modesetting */
-+ output->dumb[0] = drm_fb_create_dumb(b, w, h,
-+ DRM_FORMAT_XRGB8888);
-+ if (!output->dumb[0]) {
-+ weston_log("failed to create dumb framebuffer\n");
-+ return -1;
-+ }
-+ memset(output->dumb[0]->map, 0, output->dumb[0]->size);
-+
-+ if (gl_renderer->output_stream_create(&output->base, ~0u,
-+ output->crtc_id) < 0) {
-+ weston_log("failed to create gl renderer output stream "
-+ "state\n");
-+ drm_fb_destroy_dumb(output->dumb[0]);
-+ output->dumb[0] = NULL;
-+ return -1;
-+ }
-
-- for (i = 0; i < plane->count_formats; i++) {
-- if (plane->formats[i].format == output->gbm_format)
-- break;
-- }
-+ /* FIXME: Add hw planes and cursors for EGL device when supported */
-+ b->sprites_are_broken = 1;
-+ b->cursors_are_broken = 1;
-+ } else {
-+ EGLint format[2] = {
-+ output->gbm_format,
-+ fallback_format_for(output->gbm_format),
-+ };
-+ int n_formats = 1;
-+ struct weston_mode *mode = output->base.current_mode;
-+ struct drm_plane *plane = output->scanout_plane;
-+ unsigned int i;
-
-- if (i == plane->count_formats) {
-- weston_log("format 0x%x not supported by output %s\n",
-- output->gbm_format, output->base.name);
-- return -1;
-- }
-+ assert(output->gbm_surface == NULL);
-+
-+ for (i = 0; i < plane->count_formats; i++) {
-+ if (plane->formats[i].format == output->gbm_format)
-+ break;
-+ }
-+
-+ if (i == plane->count_formats) {
-+ weston_log("format 0x%x not supported by output %s\n",
-+ output->gbm_format, output->base.name);
-+ return -1;
-+ }
-
- #ifdef HAVE_GBM_MODIFIERS
-- if (plane->formats[i].count_modifiers > 0) {
-- output->gbm_surface =
-- gbm_surface_create_with_modifiers(b->gbm,
-- mode->width,
-- mode->height,
-- output->gbm_format,
-- plane->formats[i].modifiers,
-- plane->formats[i].count_modifiers);
-- }
--
-- /* If allocating with modifiers fails, try again without. This can
-- * happen when the KMS display device supports modifiers but the
-- * GBM driver does not, e.g. the old i915 Mesa driver. */
-- if (!output->gbm_surface)
-+ if (plane->formats[i].count_modifiers > 0) {
-+ output->gbm_surface =
-+ gbm_surface_create_with_modifiers(b->gbm,
-+ mode->width,
-+ mode->height,
-+ output->gbm_format,
-+ plane->formats[i].modifiers,
-+ plane->formats[i].count_modifiers);
-+ }
-+
-+ /* If allocating with modifiers fails, try again without. This can
-+ * happen when the KMS display device supports modifiers but the
-+ * GBM driver does not, e.g. the old i915 Mesa driver. */
-+ if (!output->gbm_surface)
- #endif
-- {
-- output->gbm_surface =
-- gbm_surface_create(b->gbm, mode->width, mode->height,
-- output->gbm_format,
-- output->gbm_bo_flags);
-- }
-+ {
-+ output->gbm_surface =
-+ gbm_surface_create(b->gbm, mode->width, mode->height,
-+ output->gbm_format,
-+ output->gbm_bo_flags);
-+ }
-
-- if (!output->gbm_surface) {
-- weston_log("failed to create gbm surface\n");
-- return -1;
-- }
-+ if (!output->gbm_surface) {
-+ weston_log("failed to create gbm surface\n");
-+ return -1;
-+ }
-
-- if (format[1])
-- n_formats = 2;
-- if (gl_renderer->output_window_create(&output->base,
-- (EGLNativeWindowType)output->gbm_surface,
-- output->gbm_surface,
-- gl_renderer->opaque_attribs,
-- format,
-- n_formats) < 0) {
-- weston_log("failed to create gl renderer output state\n");
-- gbm_surface_destroy(output->gbm_surface);
-- output->gbm_surface = NULL;
-- return -1;
-- }
-+ if (format[1])
-+ n_formats = 2;
-+ if (gl_renderer->output_window_create(&output->base,
-+ (EGLNativeWindowType)output->gbm_surface,
-+ output->gbm_surface,
-+ gl_renderer->opaque_attribs,
-+ format,
-+ n_formats) < 0) {
-+ weston_log("failed to create gl renderer output state\n");
-+ gbm_surface_destroy(output->gbm_surface);
-+ output->gbm_surface = NULL;
-+ return -1;
-+ }
-
-- drm_output_init_cursor_egl(output, b);
-+ drm_output_init_cursor_egl(output, b);
-+ }
-
- return 0;
- }
-@@ -5145,8 +5242,9 @@ drm_output_fini_egl(struct drm_output *output)
- /* Destroying the GBM surface will destroy all our GBM buffers,
- * regardless of refcount. Ensure we destroy them here. */
- if (!b->shutting_down &&
-- output->scanout_plane->state_cur->fb &&
-- output->scanout_plane->state_cur->fb->type == BUFFER_GBM_SURFACE) {
-+ ((output->scanout_plane->state_cur->fb &&
-+ output->scanout_plane->state_cur->fb->type == BUFFER_GBM_SURFACE) ||
-+ b->use_egldevice)) {
- drm_plane_state_free(output->scanout_plane->state_cur, true);
- output->scanout_plane->state_cur =
- drm_plane_state_alloc(NULL, output->scanout_plane);
-@@ -5154,8 +5252,17 @@ drm_output_fini_egl(struct drm_output *output)
- }
-
- gl_renderer->output_destroy(&output->base);
-- gbm_surface_destroy(output->gbm_surface);
-- output->gbm_surface = NULL;
-+
-+ if (output->dumb[0]) {
-+ drm_fb_unref(output->dumb[0]);
-+ output->dumb[0] = NULL;
-+ }
-+
-+ if (output->gbm_surface) {
-+ gbm_surface_destroy(output->gbm_surface);
-+ output->gbm_surface = NULL;
-+ }
-+
- drm_output_fini_cursor_egl(output);
- }
-
-@@ -7060,6 +7167,11 @@ recorder_binding(struct weston_keyboard *keyboard, const struct timespec *time,
- struct drm_output *output;
- int width, height;
-
-+ if (b->use_egldevice) {
-+ weston_log("recorder not supported with EGL device\n");
-+ return;
-+ }
-+
- output = container_of(b->compositor->output_list.next,
- struct drm_output, base.link);
-
-@@ -7118,11 +7230,20 @@ switch_to_gl_renderer(struct drm_backend *b)
-
- weston_log("Switching to GL renderer\n");
-
-- b->gbm = create_gbm_device(b->drm.fd);
-- if (!b->gbm) {
-- weston_log("Failed to create gbm device. "
-- "Aborting renderer switch\n");
-- return;
-+ if (b->use_egldevice) {
-+ b->egldevice = find_egldevice(b->drm.filename);
-+ if (b->egldevice == EGL_NO_DEVICE_EXT) {
-+ weston_log("Failed to create EGL device. "
-+ "Aborting renderer switch\n");
-+ return;
-+ }
-+ } else {
-+ b->gbm = create_gbm_device(b->drm.fd);
-+ if (!b->gbm) {
-+ weston_log("Failed to create gbm device. "
-+ "Aborting renderer switch\n");
-+ return;
-+ }
- }
-
- wl_list_for_each(output, &b->compositor->output_list, base.link)
-@@ -7131,7 +7252,8 @@ switch_to_gl_renderer(struct drm_backend *b)
- b->compositor->renderer->destroy(b->compositor);
-
- if (drm_backend_create_gl_renderer(b) < 0) {
-- gbm_device_destroy(b->gbm);
-+ if (b->gbm)
-+ gbm_device_destroy(b->gbm);
- weston_log("Failed to create GL renderer. Quitting.\n");
- /* FIXME: we need a function to shutdown cleanly */
- assert(0);
-@@ -7461,6 +7583,7 @@ drm_backend_create(struct weston_compositor *compositor,
- b->use_pixman = config->use_pixman;
- b->pageflip_timeout = config->pageflip_timeout;
- b->use_pixman_shadow = config->use_pixman_shadow;
-+ b->use_egldevice = config->use_egldevice;
-
- b->debug = weston_compositor_add_debug_scope(compositor, "drm-backend",
- "Debug messages from DRM/KMS backend\n",
-diff --git a/libweston/compositor-drm.h b/libweston/compositor-drm.h
-index 71a306fd..435581d9 100644
---- a/libweston/compositor-drm.h
-+++ b/libweston/compositor-drm.h
-@@ -177,6 +177,10 @@ struct weston_drm_backend_config {
- /** Whether to use the pixman renderer instead of the OpenGL ES renderer. */
- bool use_pixman;
-
-+ /** Whether to use the GL composition based off EGLDevice & friends instead
-+ * of GBM. */
-+ bool use_egldevice;
-+
- /** The seat to be used for input and output.
- *
- * If seat_id is NULL, the seat is taken from XDG_SEAT environment
-diff --git a/libweston/gl-renderer.h b/libweston/gl-renderer.h
-index 973097bf..233c9282 100644
---- a/libweston/gl-renderer.h
-+++ b/libweston/gl-renderer.h
-@@ -45,6 +45,7 @@ typedef void *EGLConfig;
- typedef intptr_t EGLNativeDisplayType;
- typedef intptr_t EGLNativeWindowType;
- #define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0)
-+#define EGL_NO_DEVICE_EXT ((EGLDeviceEXT)0)
-
- #endif /* ENABLE_EGL */
-
-diff --git a/shared/weston-egl-ext.h b/shared/weston-egl-ext.h
-index 96982e2d..e4e10ef9 100644
---- a/shared/weston-egl-ext.h
-+++ b/shared/weston-egl-ext.h
-@@ -208,6 +208,10 @@ typedef EGLint (EGLAPIENTRYP PFNEGLDUPNATIVEFENCEFDANDROIDPROC) (EGLDisplay dpy,
- #define EGL_PLATFORM_DEVICE_EXT 0x313F
- #endif
-
-+#ifndef EGL_DRM_MASTER_FD_EXT
-+#define EGL_DRM_MASTER_FD_EXT 0x333C
-+#endif
-+
- /*
- * FIXME: Remove both EGL_EXT_stream_acquire_mode and
- * EGL_NV_output_drm_flip_event definitions below once both extensions
-@@ -256,6 +260,11 @@ EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerAcquireAttribEXT (EGLDisplay dpy,
- #define EGL_PLATFORM_X11_KHR 0x31D5
- #define EGL_PLATFORM_DEVICE_EXT 0x313F
-
-+/* EGL_DRM_MASTER_FD_EXT and EGL_NONE enum values are also kept to allow
-+ * compositor-drm.c to build with EGLDevice and EGLStream support */
-+#define EGL_DRM_MASTER_FD_EXT 0x333C
-+#define EGL_NONE 0x3038
-+
- #endif /* ENABLE_EGL */
-
- #endif
---
-2.21.0
-
diff --git a/0006-compositor-Process-stream-attach-requests-with-wl_eg.patch b/0006-compositor-Process-stream-attach-requests-with-wl_eg.patch
index ac73e3238faf..c157188ec6f9 100644
--- a/0006-compositor-Process-stream-attach-requests-with-wl_eg.patch
+++ b/0006-compositor-Process-stream-attach-requests-with-wl_eg.patch
@@ -1,9 +1,8 @@
-From b2d91b7d969be5b7c42274fbf81093006d2edfef Mon Sep 17 00:00:00 2001
+From 0e3bba550aa51972f92a78ae9b9cbfd0a7adc126 Mon Sep 17 00:00:00 2001
From: "Miguel A. Vico" <mvicomoya@nvidia.com>
Date: Thu, 18 May 2017 14:35:36 -0700
Subject: [PATCH 6/6] compositor: Process stream attach requests with
wl_eglstream_controller
-X-NVConfidentiality: public
So far, the EGLStream implementation of the Wayland client-side driver
has been using wl_surface_attach + commit in order to make the server
@@ -32,52 +31,18 @@ requests.
Signed-off-by: Ashutosh Agarwal <asagarwal@nvidia.com>
Signed-off-by: Miguel A Vico Moya <mvicomoya@nvidia.com>
---
- Makefile.am | 14 ++++
- compositor/meson.build | 1 +
- configure.ac | 4 ++
- libweston/compositor.c | 78 +++++++++++++++++++++
- libweston/compositor.h | 4 ++
- libweston/gl-renderer.c | 147 +++++++++++++++++++++++++---------------
- protocol/meson.build | 7 ++
- 7 files changed, 201 insertions(+), 54 deletions(-)
+ compositor/meson.build | 1 +
+ include/libweston/libweston.h | 4 +
+ libweston/compositor.c | 80 ++++++++++++++-
+ libweston/renderer-gl/gl-renderer.c | 146 ++++++++++++++++++----------
+ protocol/meson.build | 7 ++
+ 5 files changed, 183 insertions(+), 55 deletions(-)
-diff --git a/Makefile.am b/Makefile.am
-index 5407b593..0bad6976 100644
---- a/Makefile.am
-+++ b/Makefile.am
-@@ -192,6 +192,11 @@ nodist_libweston_@LIBWESTON_MAJOR@_la_SOURCES = \
-
- BUILT_SOURCES += $(nodist_libweston_@LIBWESTON_MAJOR@_la_SOURCES)
-
-+nodist_libweston_eglstreams_@LIBWESTON_MAJOR@_la_SOURCES = \
-+ protocol/wayland-eglstream-controller-server-protocol.h
-+
-+BUILT_SOURCES += $(nodist_libweston_eglstreams_@LIBWESTON_MAJOR@_la_SOURCES)
-+
- bin_PROGRAMS += weston
-
- weston_LDFLAGS = -export-dynamic
-@@ -1736,6 +1741,15 @@ protocol/%-server-protocol.h : $(WAYLAND_PROTOCOLS_DATADIR)/$$(call protostabili
- protocol/%-client-protocol.h : $(WAYLAND_PROTOCOLS_DATADIR)/$$(call protostability,$$*)/$$(call protoname,$$*)/$$*.xml
- $(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(wayland_scanner) client-header < $< > $@
-
-+protocol/%-protocol.c : $(WAYLAND_EGLSTREAM_PROTOCOLS_DATADIR)/%.xml
-+ $(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(wayland_scanner) code < $< > $@
-+
-+protocol/%-server-protocol.h : $(WAYLAND_EGLSTREAM_PROTOCOLS_DATADIR)/%.xml
-+ $(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(wayland_scanner) server-header < $< > $@
-+
-+protocol/%-client-protocol.h : $(WAYLAND_EGLSTREAM_PROTOCOLS_DATADIR)/%.xml
-+ $(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(wayland_scanner) client-header < $< > $@
-+
- protocol/%-protocol.c : $(top_srcdir)/protocol/%.xml
- $(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(wayland_scanner) code < $< > $@
-
diff --git a/compositor/meson.build b/compositor/meson.build
-index 3824d6ff..075b0bcd 100644
+index 9dc95f3f..0d35aa53 100644
--- a/compositor/meson.build
+++ b/compositor/meson.build
-@@ -9,6 +9,7 @@ srcs_weston = [
+@@ -10,6 +10,7 @@ srcs_weston = [
input_method_unstable_v1_protocol_c,
weston_screenshooter_server_protocol_h,
weston_screenshooter_protocol_c,
@@ -85,23 +50,23 @@ index 3824d6ff..075b0bcd 100644
]
deps_weston = [
dep_libshared,
-diff --git a/configure.ac b/configure.ac
-index 68cdc86c..53b64bea 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -261,6 +261,10 @@ PKG_CHECK_MODULES(WAYLAND_PROTOCOLS, [wayland-protocols >= 1.17],
- [ac_wayland_protocols_pkgdatadir=`$PKG_CONFIG --variable=pkgdatadir wayland-protocols`])
- AC_SUBST(WAYLAND_PROTOCOLS_DATADIR, $ac_wayland_protocols_pkgdatadir)
-
-+PKG_CHECK_MODULES(WAYLAND_EGLSTREAM_PROTOCOLS, [wayland-eglstream-protocols],
-+ [ac_wayland_eglstream_protocols_pkgdatadir=`$PKG_CONFIG --variable=pkgdatadir wayland-eglstream-protocols`])
-+AC_SUBST(WAYLAND_EGLSTREAM_PROTOCOLS_DATADIR, $ac_wayland_eglstream_protocols_pkgdatadir)
+diff --git a/include/libweston/libweston.h b/include/libweston/libweston.h
+index d036c5bb..b83c04f5 100644
+--- a/include/libweston/libweston.h
++++ b/include/libweston/libweston.h
+@@ -919,6 +919,10 @@ struct weston_renderer {
+ void (*query_dmabuf_modifiers)(struct weston_compositor *ec,
+ int format, uint64_t **modifiers,
+ int *num_modifiers);
+
- AC_ARG_ENABLE(wayland-compositor, [ --enable-wayland-compositor],,
- enable_wayland_compositor=yes)
- AM_CONDITIONAL(ENABLE_WAYLAND_COMPOSITOR,
++ /** Create weston endpoint of an EGLStream & attach a consumer to it */
++ bool (*attach_eglstream_consumer)(struct weston_surface *es,
++ struct wl_resource *wl_eglstream);
+ };
+
+ enum weston_capability {
diff --git a/libweston/compositor.c b/libweston/compositor.c
-index e117479c..3a7b4cec 100644
+index 7fd4cc1e..e1cf4338 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -3,6 +3,7 @@
@@ -112,15 +77,15 @@ index e117479c..3a7b4cec 100644
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
-@@ -71,6 +72,7 @@
- #include "version.h"
- #include "plugin-registry.h"
+@@ -74,6 +75,7 @@
#include "pixel-formats.h"
+ #include "backend.h"
+ #include "libweston-internal.h"
+#include "wayland-eglstream-controller-server-protocol.h"
- #define DEFAULT_REPAINT_WINDOW 7 /* milliseconds */
+ #include "weston-log-internal.h"
-@@ -6473,6 +6475,80 @@ bind_presentation(struct wl_client *client,
+@@ -7042,6 +7044,80 @@ bind_presentation(struct wl_client *client,
wp_presentation_send_clock_id(resource, compositor->presentation_clock);
}
@@ -201,45 +166,32 @@ index e117479c..3a7b4cec 100644
static void
compositor_bind(struct wl_client *client,
void *data, uint32_t version, uint32_t id)
-@@ -6840,6 +6916,8 @@ weston_compositor_create(struct wl_display *display, void *user_data)
+@@ -7392,7 +7468,9 @@ weston_compositor_create(struct wl_display *display,
ec, bind_presentation))
goto fail;
+- if (weston_input_init(ec) != 0)
+ init_eglstream_controller(ec->wl_display);
+
- if (weston_debug_compositor_create(ec) < 0)
++ if (weston_input_init(ec) != 0)
goto fail;
-diff --git a/libweston/compositor.h b/libweston/compositor.h
-index 3af1443a..d7ed3ff2 100644
---- a/libweston/compositor.h
-+++ b/libweston/compositor.h
-@@ -926,6 +926,10 @@ struct weston_renderer {
- void (*query_dmabuf_modifiers)(struct weston_compositor *ec,
- int format, uint64_t **modifiers,
- int *num_modifiers);
-+
-+ /** Create weston endpoint of an EGLStream & attach a consumer to it */
-+ bool (*attach_eglstream_consumer)(struct weston_surface *es,
-+ struct wl_resource *wl_eglstream);
- };
-
- enum weston_capability {
-diff --git a/libweston/gl-renderer.c b/libweston/gl-renderer.c
-index 4bae6546..e66bbd4c 100644
---- a/libweston/gl-renderer.c
-+++ b/libweston/gl-renderer.c
+ wl_list_init(&ec->view_list);
+diff --git a/libweston/renderer-gl/gl-renderer.c b/libweston/renderer-gl/gl-renderer.c
+index 19a2e730..56a6c052 100644
+--- a/libweston/renderer-gl/gl-renderer.c
++++ b/libweston/renderer-gl/gl-renderer.c
@@ -1,7 +1,7 @@
/*
* Copyright © 2012 Intel Corporation
- * Copyright © 2015 Collabora, Ltd.
+ * Copyright © 2015,2019 Collabora, Ltd.
- * Copyright © 2016 NVIDIA Corporation
-+ * Copyright © 2016-2017 NVIDIA Corporation
++ * Copyright © 2016,2017 NVIDIA Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
-@@ -2537,18 +2537,9 @@ gl_renderer_attach_dmabuf(struct weston_surface *surface,
- surface->is_opaque = dmabuf_is_opaque(dmabuf);
+@@ -2639,18 +2639,9 @@ gl_renderer_attach_dmabuf(struct weston_surface *surface,
+ gs->shader = image->shader;
}
-/*
@@ -260,7 +212,7 @@ index 4bae6546..e66bbd4c 100644
{
#ifdef EGL_NV_stream_attrib
struct weston_compositor *ec = es->compositor;
-@@ -2557,65 +2548,111 @@ gl_renderer_attach_stream_texture(struct weston_surface *es,
+@@ -2659,65 +2650,110 @@ gl_renderer_attach_stream_texture(struct weston_surface *es,
EGLStreamKHR stream = EGL_NO_STREAM_KHR;
EGLAttrib stream_attribs[] = {
#ifdef EGL_WL_wayland_eglstream
@@ -310,8 +262,7 @@ index 4bae6546..e66bbd4c 100644
- * does not corresponds to a stream */
- return false;
+ weston_log("failed to set stream consumer\n");
-+ weston_log("EGL error state: %s (0x%04lx)\n",
-+ egl_error_string(err), (long)err);
++ weston_log("EGL error: 0x%04lx\n", (long)err);
- case EGL_BAD_STREAM_KHR:
- /* EGL_BAD_STREAM_KHR is generated whenever
@@ -413,21 +364,21 @@ index 4bae6546..e66bbd4c 100644
}
/* At this point we should have a valid stream handle */
-@@ -4044,6 +4081,8 @@ gl_renderer_display_create(struct weston_compositor *ec, EGLenum platform,
+@@ -3799,6 +3835,8 @@ gl_renderer_display_create(struct weston_compositor *ec,
gr->base.surface_get_content_size =
gl_renderer_surface_get_content_size;
gr->base.surface_copy_content = gl_renderer_surface_copy_content;
+ gr->base.attach_eglstream_consumer =
-+ gl_renderer_attach_eglstream_consumer;
- gr->egl_display = NULL;
++ gl_renderer_attach_eglstream_consumer;
- /* extension_suffix is supported */
+ if (gl_renderer_setup_egl_display(gr,
+ options->egl_native_display,
diff --git a/protocol/meson.build b/protocol/meson.build
-index 34026ff9..37642298 100644
+index 25cea5a8..1a42ee64 100644
--- a/protocol/meson.build
+++ b/protocol/meson.build
-@@ -7,6 +7,9 @@ prog_scanner = find_program(dep_scanner.get_pkgconfig_variable('wayland_scanner'
- dep_wp = dependency('wayland-protocols', version: '>= 1.17')
+@@ -4,6 +4,9 @@ prog_scanner = find_program(dep_scanner.get_pkgconfig_variable('wayland_scanner'
+ dep_wp = dependency('wayland-protocols', version: '>= 1.18')
dir_wp_base = dep_wp.get_pkgconfig_variable('pkgdatadir')
+dep_wep = dependency('wayland-eglstream-protocols')
@@ -455,5 +406,5 @@ index 34026ff9..37642298 100644
base_file = proto_name
xml_path = '@0@/stable/@1@/@1@.xml'.format(dir_wp_base, base_file)
--
-2.21.0
+2.25.1
diff --git a/PKGBUILD b/PKGBUILD
index 5e88a76e24f5..2a9b6e05acde 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -6,14 +6,15 @@
# Contributor: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
pkgname=weston-eglstream
-pkgver=6.0.1
+pkgver=9.0.0
pkgrel=1
pkgdesc='Reference implementation of a Wayland compositor with EGLStream support'
arch=('x86_64')
url='https://wayland.freedesktop.org/'
license=('MIT')
depends=('wayland' 'libxkbcommon' 'libinput' 'libjpeg-turbo' 'libwebp'
- 'libegl' 'libgles' 'pango' 'libva' 'libxcursor' 'colord' 'egl-wayland')
+ 'libegl' 'libgles' 'pango' 'libva' 'libxcursor' 'colord' 'libpipewire02'
+ 'egl-wayland')
makedepends=('meson' 'wayland-protocols')
provides=('weston')
conflicts=('weston')
@@ -21,24 +22,24 @@ source=("https://wayland.freedesktop.org/releases/weston-$pkgver.tar.xz"
'0001-gl-renderer-Add-EGLDevice-enumeration-support.patch'
'0002-gl-renderer-Add-support-for-EGLDevice-composited-fra.patch'
'0003-gl-renderer-Add-EGL-client-support-for-EGLStream-fra.patch'
- '0004-compositor-drm-Gracefully-handle-vblank-and-flip-inv.patch'
- '0005-compositor-drm-Add-support-for-EGLDevice-EGLOutput.patch'
+ '0004-backend-drm-Gracefully-handle-vblank-and-flip-invali.patch'
+ '0005-backend-drm-Add-support-for-EGLDevice-EGLOutput.patch'
'0006-compositor-Process-stream-attach-requests-with-wl_eg.patch')
-sha256sums=('bf2f6d5aae2e11cabb6bd69a76bcf9edb084f8c3e14ca769bea7234a513155b4'
- '77f798bbed2dfadfdfc3d47631dc9e315570445b247a905466e5b4970e920ced'
- 'c351c903a09ad2608e853e9b052bef6ad9f99478d1940a217cb9854f275ccf08'
- '11b744a32b299bab5ac71e86e087f51f0db0aa3e9093c9ca4c88ab79f2e4ea64'
- 'c2781950d5afeeee7ac35027093291242d7dd81295a34d258f80627f86927da9'
- '8bc0b1ce255de1c4901c949d6ecac2101820da678d4de43678c8e04b001814af'
- 'e5ddf3567225470a0a8c358374404f1abdf6f5af05be304afd0376b408027c8d')
+sha256sums=('5cf5d6ce192e0eb15c1fc861a436bf21b5bb3b91dbdabbdebe83e1f83aa098fe'
+ '39eb26160b63183f35e5c50bea8cc10248fe194ab96b2cb9417990e5ed45fa1a'
+ '55ee7aaed84cdc75cc58919a3ec71c7b2cfdbcf936a5f6c8f07f54376b9cc3a5'
+ 'c971abb2b84d9b2519c08aacbd3a4afc44d31bf0970d3bc71e48cca850a9765f'
+ 'ac1c048f6944b1ddd24c17205a7bd8f55578af5489d2f9ca7121727b0cbacc68'
+ '5898de8565d3c449fb276f9e3b1ae1bb9e908e8153e0802989a49baa8d1d134a'
+ '5834b4b0068cc0debe5bc20cddafd17f9ca4cb472035716da3942401a130ccc8')
prepare() {
cd weston-$pkgver
patch -Np1 -i "${srcdir}/0001-gl-renderer-Add-EGLDevice-enumeration-support.patch"
patch -Np1 -i "${srcdir}/0002-gl-renderer-Add-support-for-EGLDevice-composited-fra.patch"
patch -Np1 -i "${srcdir}/0003-gl-renderer-Add-EGL-client-support-for-EGLStream-fra.patch"
- patch -Np1 -i "${srcdir}/0004-compositor-drm-Gracefully-handle-vblank-and-flip-inv.patch"
- patch -Np1 -i "${srcdir}/0005-compositor-drm-Add-support-for-EGLDevice-EGLOutput.patch"
+ patch -Np1 -i "${srcdir}/0004-backend-drm-Gracefully-handle-vblank-and-flip-invali.patch"
+ patch -Np1 -i "${srcdir}/0005-backend-drm-Add-support-for-EGLDevice-EGLOutput.patch"
patch -Np1 -i "${srcdir}/0006-compositor-Process-stream-attach-requests-with-wl_eg.patch"
}