* [PATCH 1/2] Use EGL device extension in display initialization.
@ 2021-08-24 22:22 Eugene Huang
2021-08-24 22:22 ` [PATCH 2/2] Add comment for qemu_egl_get_display Eugene Huang
2021-08-30 14:01 ` [PATCH 1/2] Use EGL device extension in display initialization Marc-André Lureau
0 siblings, 2 replies; 4+ messages in thread
From: Eugene Huang @ 2021-08-24 22:22 UTC (permalink / raw)
To: qemu-devel; +Cc: marcandre.lureau, Eugene Huang
Signed-off-by: Eugene Huang <eugeneh@nvidia.com>
---
ui/egl-helpers.c | 41 +++++++++++++++++++++++++++++++++++++----
1 file changed, 37 insertions(+), 4 deletions(-)
diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c
index 6d0cb2b5cb..ce0971422b 100644
--- a/ui/egl-helpers.c
+++ b/ui/egl-helpers.c
@@ -1,6 +1,8 @@
/*
* Copyright (C) 2015-2016 Gerd Hoffmann <kraxel@redhat.com>
*
+ * Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
@@ -351,11 +353,26 @@ static EGLDisplay qemu_egl_get_display(EGLNativeDisplayType native,
EGLDisplay dpy = EGL_NO_DISPLAY;
/* In practise any EGL 1.5 implementation would support the EXT extension */
- if (epoxy_has_egl_extension(NULL, "EGL_EXT_platform_base")) {
+ if (epoxy_has_egl_extension(NULL, "EGL_EXT_platform_base")
+ && epoxy_has_egl_extension(NULL, "EGL_EXT_platform_device")
+ && (epoxy_has_egl_extension(NULL, "EGL_EXT_device_base")
+ || epoxy_has_egl_extension(NULL, "EGL_EXT_device_enumeration"))) {
PFNEGLGETPLATFORMDISPLAYEXTPROC getPlatformDisplayEXT =
(void *) eglGetProcAddress("eglGetPlatformDisplayEXT");
if (getPlatformDisplayEXT && platform != 0) {
- dpy = getPlatformDisplayEXT(platform, native, NULL);
+ if (platform == EGL_PLATFORM_DEVICE_EXT) {
+ static const int MAX_DEVICES = 4;
+ EGLDeviceEXT eglDevs[MAX_DEVICES];
+ EGLint numDevices;
+
+ PFNEGLQUERYDEVICESEXTPROC eglQueryDevicesEXT =
+ (PFNEGLQUERYDEVICESEXTPROC)
+ eglGetProcAddress("eglQueryDevicesEXT");
+ eglQueryDevicesEXT(MAX_DEVICES, eglDevs, &numDevices);
+ dpy = getPlatformDisplayEXT(platform, eglDevs[0], 0);
+ } else {
+ dpy = getPlatformDisplayEXT(platform, native, NULL);
+ }
}
}
@@ -388,6 +405,17 @@ static int qemu_egl_init_dpy(EGLNativeDisplayType dpy,
EGL_ALPHA_SIZE, 0,
EGL_NONE,
};
+
+ static const EGLint conf_att_pbuffer[] = {
+ EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
+ EGL_RED_SIZE, 8,
+ EGL_GREEN_SIZE, 8,
+ EGL_BLUE_SIZE, 8,
+ EGL_DEPTH_SIZE, 1,
+ EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
+ EGL_NONE
+ };
+
EGLint major, minor;
EGLBoolean b;
EGLint n;
@@ -413,8 +441,8 @@ static int qemu_egl_init_dpy(EGLNativeDisplayType dpy,
}
b = eglChooseConfig(qemu_egl_display,
- gles ? conf_att_gles : conf_att_core,
- &qemu_egl_config, 1, &n);
+ gles ? conf_att_gles : (platform == EGL_PLATFORM_DEVICE_EXT ? conf_att_pbuffer : conf_att_core),
+ &qemu_egl_config, 1, &n);
if (b == EGL_FALSE || n != 1) {
error_report("egl: eglChooseConfig failed (%s mode)",
gles ? "gles" : "core");
@@ -436,6 +464,11 @@ int qemu_egl_init_dpy_x11(EGLNativeDisplayType dpy, DisplayGLMode mode)
int qemu_egl_init_dpy_mesa(EGLNativeDisplayType dpy, DisplayGLMode mode)
{
+ // Try EGL Device Extension
+ if (qemu_egl_init_dpy(dpy, EGL_PLATFORM_DEVICE_EXT, mode) == 0) {
+ return 0;
+ }
+
#ifdef EGL_MESA_platform_gbm
return qemu_egl_init_dpy(dpy, EGL_PLATFORM_GBM_MESA, mode);
#else
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] Add comment for qemu_egl_get_display
2021-08-24 22:22 [PATCH 1/2] Use EGL device extension in display initialization Eugene Huang
@ 2021-08-24 22:22 ` Eugene Huang
2021-08-30 14:01 ` [PATCH 1/2] Use EGL device extension in display initialization Marc-André Lureau
1 sibling, 0 replies; 4+ messages in thread
From: Eugene Huang @ 2021-08-24 22:22 UTC (permalink / raw)
To: qemu-devel; +Cc: marcandre.lureau, Eugene Huang
Signed-off-by: Eugene Huang <eugeneh@nvidia.com>
---
ui/egl-helpers.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c
index ce0971422b..dee31c6fbb 100644
--- a/ui/egl-helpers.c
+++ b/ui/egl-helpers.c
@@ -346,6 +346,10 @@ EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, EGLNativeWindowType win)
* We can workaround this (circular dependency) by probing for the EGL 1.5
* platform extensions (EGL_KHR_platform_gbm and friends) yet it doesn't seem
* like mesa will be able to advertise these (even though it can do EGL 1.5).
+ *
+ * 5. It is worth adding an EGL_EXT_platform_device && (EGL_EXT_device_base ||
+ * EGL_EXT_device_enumeration) extension check with the EGL_EXT_platform_base
+ * check before using the EGLDevice functionality.
*/
static EGLDisplay qemu_egl_get_display(EGLNativeDisplayType native,
EGLenum platform)
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] Use EGL device extension in display initialization.
2021-08-24 22:22 [PATCH 1/2] Use EGL device extension in display initialization Eugene Huang
2021-08-24 22:22 ` [PATCH 2/2] Add comment for qemu_egl_get_display Eugene Huang
@ 2021-08-30 14:01 ` Marc-André Lureau
2021-09-02 3:22 ` Eugene Huang
1 sibling, 1 reply; 4+ messages in thread
From: Marc-André Lureau @ 2021-08-30 14:01 UTC (permalink / raw)
To: Eugene Huang, Gerd Hoffmann; +Cc: QEMU
[-- Attachment #1: Type: text/plain, Size: 4147 bytes --]
On Wed, Aug 25, 2021 at 2:22 AM Eugene Huang <eugeneh@nvidia.com> wrote:
> Signed-off-by: Eugene Huang <eugeneh@nvidia.com>
> ---
> ui/egl-helpers.c | 41 +++++++++++++++++++++++++++++++++++++----
> 1 file changed, 37 insertions(+), 4 deletions(-)
>
> diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c
> index 6d0cb2b5cb..ce0971422b 100644
> --- a/ui/egl-helpers.c
> +++ b/ui/egl-helpers.c
> @@ -1,6 +1,8 @@
> /*
> * Copyright (C) 2015-2016 Gerd Hoffmann <kraxel@redhat.com>
> *
> + * Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights
> reserved.
> + *
> * This library is free software; you can redistribute it and/or
> * modify it under the terms of the GNU Lesser General Public
> * License as published by the Free Software Foundation; either
> @@ -351,11 +353,26 @@ static EGLDisplay
> qemu_egl_get_display(EGLNativeDisplayType native,
> EGLDisplay dpy = EGL_NO_DISPLAY;
>
> /* In practise any EGL 1.5 implementation would support the EXT
> extension */
> - if (epoxy_has_egl_extension(NULL, "EGL_EXT_platform_base")) {
> + if (epoxy_has_egl_extension(NULL, "EGL_EXT_platform_base")
> + && epoxy_has_egl_extension(NULL, "EGL_EXT_platform_device")
> + && (epoxy_has_egl_extension(NULL, "EGL_EXT_device_base")
> + || epoxy_has_egl_extension(NULL, "EGL_EXT_device_enumeration"))) {
> PFNEGLGETPLATFORMDISPLAYEXTPROC getPlatformDisplayEXT =
> (void *) eglGetProcAddress("eglGetPlatformDisplayEXT");
> if (getPlatformDisplayEXT && platform != 0) {
> - dpy = getPlatformDisplayEXT(platform, native, NULL);
> + if (platform == EGL_PLATFORM_DEVICE_EXT) {
> + static const int MAX_DEVICES = 4;
> + EGLDeviceEXT eglDevs[MAX_DEVICES];
> + EGLint numDevices;
> +
> + PFNEGLQUERYDEVICESEXTPROC eglQueryDevicesEXT =
> + (PFNEGLQUERYDEVICESEXTPROC)
> + eglGetProcAddress("eglQueryDevicesEXT");
>
It should handle the case where returned eglQueryDevicesEXT is NULL.
+ eglQueryDevicesEXT(MAX_DEVICES, eglDevs, &numDevices);
>
You need to handle the success return value, as well as the case where
numDevices == 0.
(surprisingly, we don't need to care about memory of eglDevs?)
> + dpy = getPlatformDisplayEXT(platform, eglDevs[0], 0);
> + } else {
> + dpy = getPlatformDisplayEXT(platform, native, NULL);
> + }
> }
> }
>
> @@ -388,6 +405,17 @@ static int qemu_egl_init_dpy(EGLNativeDisplayType dpy,
> EGL_ALPHA_SIZE, 0,
> EGL_NONE,
> };
> +
> + static const EGLint conf_att_pbuffer[] = {
> + EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
> + EGL_RED_SIZE, 8,
> + EGL_GREEN_SIZE, 8,
> + EGL_BLUE_SIZE, 8,
> + EGL_DEPTH_SIZE, 1,
> + EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
> + EGL_NONE
> + };
> +
> EGLint major, minor;
> EGLBoolean b;
> EGLint n;
> @@ -413,8 +441,8 @@ static int qemu_egl_init_dpy(EGLNativeDisplayType dpy,
> }
>
> b = eglChooseConfig(qemu_egl_display,
> - gles ? conf_att_gles : conf_att_core,
> - &qemu_egl_config, 1, &n);
> + gles ? conf_att_gles : (platform == EGL_PLATFORM_DEVICE_EXT ?
> conf_att_pbuffer : conf_att_core),
> + &qemu_egl_config, 1, &n);
> if (b == EGL_FALSE || n != 1) {
> error_report("egl: eglChooseConfig failed (%s mode)",
> gles ? "gles" : "core");
> @@ -436,6 +464,11 @@ int qemu_egl_init_dpy_x11(EGLNativeDisplayType dpy,
> DisplayGLMode mode)
>
> int qemu_egl_init_dpy_mesa(EGLNativeDisplayType dpy, DisplayGLMode mode)
> {
> + // Try EGL Device Extension
> + if (qemu_egl_init_dpy(dpy, EGL_PLATFORM_DEVICE_EXT, mode) == 0) {
> + return 0;
> + }
> +
> #ifdef EGL_MESA_platform_gbm
> return qemu_egl_init_dpy(dpy, EGL_PLATFORM_GBM_MESA, mode);
> #else
> --
> 2.17.1
>
>
--
Marc-André Lureau
[-- Attachment #2: Type: text/html, Size: 5599 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH 1/2] Use EGL device extension in display initialization.
2021-08-30 14:01 ` [PATCH 1/2] Use EGL device extension in display initialization Marc-André Lureau
@ 2021-09-02 3:22 ` Eugene Huang
0 siblings, 0 replies; 4+ messages in thread
From: Eugene Huang @ 2021-09-02 3:22 UTC (permalink / raw)
To: Marc-André Lureau, Gerd Hoffmann; +Cc: QEMU
[-- Attachment #1: Type: text/plain, Size: 4450 bytes --]
Thanks for the comment. I will submit another patch.
Best regards,
Eugene
From: Marc-André Lureau <marcandre.lureau@gmail.com>
Sent: Monday, August 30, 2021 7:01 AM
To: Eugene Huang <eugeneh@nvidia.com>; Gerd Hoffmann <kraxel@redhat.com>
Cc: QEMU <qemu-devel@nongnu.org>
Subject: Re: [PATCH 1/2] Use EGL device extension in display initialization.
External email: Use caution opening links or attachments
On Wed, Aug 25, 2021 at 2:22 AM Eugene Huang <eugeneh@nvidia.com<mailto:eugeneh@nvidia.com>> wrote:
Signed-off-by: Eugene Huang <eugeneh@nvidia.com<mailto:eugeneh@nvidia.com>>
---
ui/egl-helpers.c | 41 +++++++++++++++++++++++++++++++++++++----
1 file changed, 37 insertions(+), 4 deletions(-)
diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c
index 6d0cb2b5cb..ce0971422b 100644
--- a/ui/egl-helpers.c
+++ b/ui/egl-helpers.c
@@ -1,6 +1,8 @@
/*
* Copyright (C) 2015-2016 Gerd Hoffmann <kraxel@redhat.com<mailto:kraxel@redhat.com>>
*
+ * Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
@@ -351,11 +353,26 @@ static EGLDisplay qemu_egl_get_display(EGLNativeDisplayType native,
EGLDisplay dpy = EGL_NO_DISPLAY;
/* In practise any EGL 1.5 implementation would support the EXT extension */
- if (epoxy_has_egl_extension(NULL, "EGL_EXT_platform_base")) {
+ if (epoxy_has_egl_extension(NULL, "EGL_EXT_platform_base")
+ && epoxy_has_egl_extension(NULL, "EGL_EXT_platform_device")
+ && (epoxy_has_egl_extension(NULL, "EGL_EXT_device_base")
+ || epoxy_has_egl_extension(NULL, "EGL_EXT_device_enumeration"))) {
PFNEGLGETPLATFORMDISPLAYEXTPROC getPlatformDisplayEXT =
(void *) eglGetProcAddress("eglGetPlatformDisplayEXT");
if (getPlatformDisplayEXT && platform != 0) {
- dpy = getPlatformDisplayEXT(platform, native, NULL);
+ if (platform == EGL_PLATFORM_DEVICE_EXT) {
+ static const int MAX_DEVICES = 4;
+ EGLDeviceEXT eglDevs[MAX_DEVICES];
+ EGLint numDevices;
+
+ PFNEGLQUERYDEVICESEXTPROC eglQueryDevicesEXT =
+ (PFNEGLQUERYDEVICESEXTPROC)
+ eglGetProcAddress("eglQueryDevicesEXT");
It should handle the case where returned eglQueryDevicesEXT is NULL.
+ eglQueryDevicesEXT(MAX_DEVICES, eglDevs, &numDevices);
You need to handle the success return value, as well as the case where numDevices == 0.
(surprisingly, we don't need to care about memory of eglDevs?)
+ dpy = getPlatformDisplayEXT(platform, eglDevs[0], 0);
+ } else {
+ dpy = getPlatformDisplayEXT(platform, native, NULL);
+ }
}
}
@@ -388,6 +405,17 @@ static int qemu_egl_init_dpy(EGLNativeDisplayType dpy,
EGL_ALPHA_SIZE, 0,
EGL_NONE,
};
+
+ static const EGLint conf_att_pbuffer[] = {
+ EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
+ EGL_RED_SIZE, 8,
+ EGL_GREEN_SIZE, 8,
+ EGL_BLUE_SIZE, 8,
+ EGL_DEPTH_SIZE, 1,
+ EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
+ EGL_NONE
+ };
+
EGLint major, minor;
EGLBoolean b;
EGLint n;
@@ -413,8 +441,8 @@ static int qemu_egl_init_dpy(EGLNativeDisplayType dpy,
}
b = eglChooseConfig(qemu_egl_display,
- gles ? conf_att_gles : conf_att_core,
- &qemu_egl_config, 1, &n);
+ gles ? conf_att_gles : (platform == EGL_PLATFORM_DEVICE_EXT ? conf_att_pbuffer : conf_att_core),
+ &qemu_egl_config, 1, &n);
if (b == EGL_FALSE || n != 1) {
error_report("egl: eglChooseConfig failed (%s mode)",
gles ? "gles" : "core");
@@ -436,6 +464,11 @@ int qemu_egl_init_dpy_x11(EGLNativeDisplayType dpy, DisplayGLMode mode)
int qemu_egl_init_dpy_mesa(EGLNativeDisplayType dpy, DisplayGLMode mode)
{
+ // Try EGL Device Extension
+ if (qemu_egl_init_dpy(dpy, EGL_PLATFORM_DEVICE_EXT, mode) == 0) {
+ return 0;
+ }
+
#ifdef EGL_MESA_platform_gbm
return qemu_egl_init_dpy(dpy, EGL_PLATFORM_GBM_MESA, mode);
#else
--
2.17.1
--
Marc-André Lureau
[-- Attachment #2: Type: text/html, Size: 10344 bytes --]
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-09-02 3:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-24 22:22 [PATCH 1/2] Use EGL device extension in display initialization Eugene Huang
2021-08-24 22:22 ` [PATCH 2/2] Add comment for qemu_egl_get_display Eugene Huang
2021-08-30 14:01 ` [PATCH 1/2] Use EGL device extension in display initialization Marc-André Lureau
2021-09-02 3:22 ` Eugene Huang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).