[weston,v2,1/3] gl-renderer: Add EGLDevice enumeration support

Submitted by Miguel Angel Vico on May 18, 2016, 3:51 p.m.

Details

Message ID 1463586696-28942-1-git-send-email-mvicomoya@nvidia.com
State New
Delegated to: Pekka Paalanen
Headers show
Series "Series without cover letter" ( rev: 13 ) in Wayland

Not browsing as part of any series.

Commit Message

Miguel Angel Vico May 18, 2016, 3:51 p.m.
EGLDevice provides means to enumerate native devices.

In preparation for follow-on changes to support frame presentation
through EGLDevice+EGLOutput, this change adds both
gl_renderer_get_devices() and gl_renderer_get_drm_device_file()
functions which will help to enumerate EGLDevices and match them to DRM
devices.

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>
---
 src/gl-renderer.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 src/gl-renderer.h |  7 +++++
 2 files changed, 95 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/src/gl-renderer.c b/src/gl-renderer.c
index db5f53d..e11db9e 100644
--- a/src/gl-renderer.c
+++ b/src/gl-renderer.c
@@ -3175,6 +3175,90 @@  gl_renderer_setup(struct weston_compositor *ec, EGLSurface egl_surface)
 	return 0;
 }
 
+static int
+gl_renderer_get_devices(EGLint max_devices, EGLDeviceEXT *devices,
+			EGLint *num_devices)
+{
+	const char *extensions;
+	PFNEGLQUERYDEVICESEXTPROC query_devices;
+
+	extensions = (const char *)eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
+	if (!extensions) {
+		weston_log("Retrieving EGL extension string failed.\n");
+		return -1;
+	}
+
+	if (!check_extension(extensions, "EGL_EXT_device_base") &&
+	    (!check_extension(extensions, "EGL_EXT_device_query") ||
+	     !check_extension(extensions, "EGL_EXT_device_enumeration"))) {
+		weston_log("EGL_EXT_device_base not supported\n");
+		return -1;
+	}
+
+	query_devices = (void *) eglGetProcAddress("eglQueryDevicesEXT");
+	if (!query_devices) {
+		weston_log("Failed to get eglQueryDevicesEXT function\n");
+		return -1;
+	}
+
+	if (query_devices(max_devices, devices, num_devices) != EGL_TRUE) {
+		weston_log("Failed to query EGL Devices\n");
+		gl_renderer_print_egl_error_state();
+		return -1;
+	}
+
+	return 0;
+}
+
+static int
+gl_renderer_get_drm_device_file(EGLDeviceEXT device,
+				const char **drm_device_file)
+{
+	const char *exts;
+	PFNEGLQUERYDEVICESTRINGEXTPROC query_device_string;
+
+	exts = (const char *)eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
+	if (!exts) {
+		weston_log("Retrieving EGL extension string failed.\n");
+		return -1;
+	}
+
+	if (!check_extension(exts, "EGL_EXT_device_base") &&
+	    (!check_extension(exts, "EGL_EXT_device_query") ||
+	     !check_extension(exts, "EGL_EXT_device_enumeration"))) {
+		weston_log("EGL_EXT_device_base not supported.\n");
+		return -1;
+	}
+
+	query_device_string =
+		(void *) eglGetProcAddress("eglQueryDeviceStringEXT");
+	if (!query_device_string) {
+		weston_log("Failed to get eglQueryDeviceStringEXT function\n");
+		return -1;
+	}
+
+	exts = query_device_string(device, EGL_EXTENSIONS);
+	if (!exts) {
+		weston_log("Retrieving EGL extension string failed.\n");
+		return -1;
+	}
+
+	if (!check_extension(exts, "EGL_EXT_device_drm")) {
+		weston_log("EGL_EXT_device_drm not supported.\n");
+		return -1;
+	}
+
+	(*drm_device_file) = query_device_string(device,
+						 EGL_DRM_DEVICE_FILE_EXT);
+	if (*drm_device_file == NULL) {
+		weston_log("Failed to query DRM device name.\n");
+		gl_renderer_print_egl_error_state();
+		return -1;
+	}
+
+	return 0;
+}
+
 WL_EXPORT struct gl_renderer_interface gl_renderer_interface = {
 	.opaque_attribs = gl_renderer_opaque_attribs,
 	.alpha_attribs = gl_renderer_alpha_attribs,
@@ -3185,5 +3269,8 @@  WL_EXPORT struct gl_renderer_interface gl_renderer_interface = {
 	.output_destroy = gl_renderer_output_destroy,
 	.output_surface = gl_renderer_output_surface,
 	.output_set_border = gl_renderer_output_set_border,
-	.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/src/gl-renderer.h b/src/gl-renderer.h
index ecd2168..4d8a98e 100644
--- a/src/gl-renderer.h
+++ b/src/gl-renderer.h
@@ -129,5 +129,12 @@  struct gl_renderer_interface {
 				  int32_t tex_width, unsigned char *data);
 
 	void (*print_egl_error_state)(void);
+
+	int (*get_devices)(EGLint max_devices,
+			   EGLDeviceEXT *devices,
+			   EGLint *num_devices);
+
+	int (*get_drm_device_file)(EGLDeviceEXT device,
+				   const char **drm_device_file);
 };
 

Comments

On Wed, 18 May 2016 17:51:36 +0200
"Miguel A. Vico" <mvicomoya@nvidia.com> wrote:

> EGLDevice provides means to enumerate native devices.
> 
> In preparation for follow-on changes to support frame presentation
> through EGLDevice+EGLOutput, this change adds both
> gl_renderer_get_devices() and gl_renderer_get_drm_device_file()
> functions which will help to enumerate EGLDevices and match them to DRM
> devices.
> 
> 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>
> ---
>  src/gl-renderer.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>  src/gl-renderer.h |  7 +++++
>  2 files changed, 95 insertions(+), 1 deletion(-)

Hi,

I thought we shouldn't leave these patches hanging forever.

I marked this patch as deferred, because it might become useful when we
will be able to use EGLDevice to pick the render device separate from
the KMS device.

The other patches in this series, plus the fourth "[PATCH weston v2
1/1] compositor-drm: Add support for EGLDevice+EGLOutput" I marked as
rejected, because I don't think we are going to have EGLStreams in
Weston. Let's go with the thing started at XDC 2016 instead.


Thanks,
pq
Thanks, Pekka.

Inline.

On Mon, 7 Nov 2016 16:22:49 +0200
Pekka Paalanen <ppaalanen@gmail.com> wrote:

> * PGP Signed by an unknown key
> 
> On Wed, 18 May 2016 17:51:36 +0200
> "Miguel A. Vico" <mvicomoya@nvidia.com> wrote:
> 
> > EGLDevice provides means to enumerate native devices.
> > 
> > In preparation for follow-on changes to support frame presentation
> > through EGLDevice+EGLOutput, this change adds both
> > gl_renderer_get_devices() and gl_renderer_get_drm_device_file()
> > functions which will help to enumerate EGLDevices and match them to
> > DRM devices.
> > 
> > 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>
> > ---
> >  src/gl-renderer.c | 89
> > ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
> > src/gl-renderer.h |  7 +++++ 2 files changed, 95 insertions(+), 1
> > deletion(-)  
> 
> Hi,
> 
> I thought we shouldn't leave these patches hanging forever.
> 
> I marked this patch as deferred, because it might become useful when
> we will be able to use EGLDevice to pick the render device separate
> from the KMS device.

Sounds good.

> 
> The other patches in this series, plus the fourth "[PATCH weston v2
> 1/1] compositor-drm: Add support for EGLDevice+EGLOutput" I marked as
> rejected, because I don't think we are going to have EGLStreams in
> Weston. Let's go with the thing started at XDC 2016 instead.

I was somehow expecting that. We'll keep rebasing them and pushing side
branches with EGLStream support to
https://cgit.freedesktop.org/~jjones/weston/ for anyone that wants to
use weston on top of NVIDIA proprietary drivers until GBM2 comes to
life.

Thanks.

> 
> 
> Thanks,
> pq
> 
> * Unknown Key
> * 0x11AAAAA7
On Mon, 14 Nov 2016 20:38:43 -0800
Miguel Angel Vico <mvicomoya@nvidia.com> wrote:

> Thanks, Pekka.
> 
> Inline.
> 
> On Mon, 7 Nov 2016 16:22:49 +0200
> Pekka Paalanen <ppaalanen@gmail.com> wrote:
> 
> > * PGP Signed by an unknown key
> > 
> > On Wed, 18 May 2016 17:51:36 +0200
> > "Miguel A. Vico" <mvicomoya@nvidia.com> wrote:
> >   
> > > EGLDevice provides means to enumerate native devices.
> > > 
> > > In preparation for follow-on changes to support frame presentation
> > > through EGLDevice+EGLOutput, this change adds both
> > > gl_renderer_get_devices() and gl_renderer_get_drm_device_file()
> > > functions which will help to enumerate EGLDevices and match them to
> > > DRM devices.
> > > 
> > > 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>
> > > ---
> > >  src/gl-renderer.c | 89
> > > ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
> > > src/gl-renderer.h |  7 +++++ 2 files changed, 95 insertions(+), 1
> > > deletion(-)    
> > 
> > Hi,
> > 
> > I thought we shouldn't leave these patches hanging forever.
> > 
> > I marked this patch as deferred, because it might become useful when
> > we will be able to use EGLDevice to pick the render device separate
> > from the KMS device.  
> 
> Sounds good.
> 
> > 
> > The other patches in this series, plus the fourth "[PATCH weston v2
> > 1/1] compositor-drm: Add support for EGLDevice+EGLOutput" I marked as
> > rejected, because I don't think we are going to have EGLStreams in
> > Weston. Let's go with the thing started at XDC 2016 instead.  
> 
> I was somehow expecting that. We'll keep rebasing them and pushing side
> branches with EGLStream support to
> https://cgit.freedesktop.org/~jjones/weston/ for anyone that wants to
> use weston on top of NVIDIA proprietary drivers until GBM2 comes to
> life.

I very much like that plan. Thank you for taking the maintenance effort.


Thanks,
pq