All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Use EGL device extension in display initialization.
@ 2021-08-05 22:07 Eugene Huang
  2021-08-06  7:24 ` Marc-André Lureau
  0 siblings, 1 reply; 5+ messages in thread
From: Eugene Huang @ 2021-08-05 22:07 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 3985 bytes --]

This patch enables running generic EGL devices such as Nvidia's in headless mode. It assumes single device. More work is needed to support multiple devices.



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 7c530c2825..c11610c083 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

@@ -349,11 +351,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);

+            }

         }

     }

@@ -386,6 +403,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;

@@ -411,8 +439,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");

@@ -434,6 +462,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



[-- Attachment #2: Type: text/html, Size: 18532 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Use EGL device extension in display initialization.
  2021-08-05 22:07 [PATCH] Use EGL device extension in display initialization Eugene Huang
@ 2021-08-06  7:24 ` Marc-André Lureau
  2021-08-11  7:58   ` Eugene Huang via
  0 siblings, 1 reply; 5+ messages in thread
From: Marc-André Lureau @ 2021-08-06  7:24 UTC (permalink / raw)
  To: Eugene Huang; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 4715 bytes --]

Hi

On Fri, Aug 6, 2021 at 2:28 AM Eugene Huang <eugeneh@nvidia.com> wrote:

> This patch enables running generic EGL devices such as Nvidia’s in
> headless mode. It assumes single device. More work is needed to support
> multiple devices.
>
>
>
> Signed-off-by: Eugene Huang <eugeneh@nvidia.com>
>

Thanks for the patch. It isn't correctly formatted and git apply fails  (
https://patchew.org/QEMU/BYAPR12MB319275649A1403C254A9EA43D9F29@BYAPR12MB3192.namprd12.prod.outlook.com/).
Please use git send-email.

---
>
> 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 7c530c2825..c11610c083 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
>
> @@ -349,11 +351,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);
>

Given that the function has a lengthy comment to explain it, and this is
quite archaic stuff, I think you should update the comments with your
additions.


> +            } else {
>
> +                dpy = getPlatformDisplayEXT(platform, native, NULL);
>
> +            }
>
>          }
>
>      }
>
> @@ -386,6 +403,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;
>
> @@ -411,8 +439,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");
>
> @@ -434,6 +462,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
>
>
>

thanks

-- 
Marc-André Lureau

[-- Attachment #2: Type: text/html, Size: 19487 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] Use EGL device extension in display initialization.
  2021-08-06  7:24 ` Marc-André Lureau
@ 2021-08-11  7:58   ` Eugene Huang via
  2021-08-11 10:42     ` Marc-André Lureau
  0 siblings, 1 reply; 5+ messages in thread
From: Eugene Huang via @ 2021-08-11  7:58 UTC (permalink / raw)
  To: Marc-André Lureau; +Cc: qemu-devel


[-- Attachment #1.1: Type: text/plain, Size: 5496 bytes --]

Hi,

I have had some hard time to set up git send-email. I am not even sure if it is doable here. I read that attachments can be used a last resort for first timers. Here are the attachments. Hope it works.

Thanks,
Eugene

From: Marc-André Lureau <marcandre.lureau@gmail.com>
Sent: Friday, August 6, 2021 12:25 AM
To: Eugene Huang <eugeneh@nvidia.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH] Use EGL device extension in display initialization.

External email: Use caution opening links or attachments

Hi

On Fri, Aug 6, 2021 at 2:28 AM Eugene Huang <eugeneh@nvidia.com<mailto:eugeneh@nvidia.com>> wrote:

This patch enables running generic EGL devices such as Nvidia's in headless mode. It assumes single device. More work is needed to support multiple devices.



Signed-off-by: Eugene Huang <eugeneh@nvidia.com<mailto:eugeneh@nvidia.com>>

Thanks for the patch. It isn't correctly formatted and git apply fails  (https://patchew.org/QEMU/BYAPR12MB319275649A1403C254A9EA43D9F29@BYAPR12MB3192.namprd12.prod.outlook.com/<https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatchew.org%2FQEMU%2FBYAPR12MB319275649A1403C254A9EA43D9F29%40BYAPR12MB3192.namprd12.prod.outlook.com%2F&data=04%7C01%7Ceugeneh%40nvidia.com%7C2d1240b866904cc7971308d958ab4471%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637638314899347574%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=EsDRdtG01ja1P9NDZG8ScE7SgC8ZILFS6p%2B9mGoklnY%3D&reserved=0>). Please use git send-email.


---

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 7c530c2825..c11610c083 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

@@ -349,11 +351,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);

Given that the function has a lengthy comment to explain it, and this is quite archaic stuff, I think you should update the comments with your additions.


+            } else {

+                dpy = getPlatformDisplayEXT(platform, native, NULL);

+            }

         }

     }

@@ -386,6 +403,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;

@@ -411,8 +439,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");

@@ -434,6 +462,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



thanks

--
Marc-André Lureau

[-- Attachment #1.2: Type: text/html, Size: 24300 bytes --]

[-- Attachment #2: 0002-Add-comment-for-qemu_egl_get_display.patch --]
[-- Type: application/octet-stream, Size: 1146 bytes --]

From 05eee1f21b21e76cac6b3922f6971c4de0228961 Mon Sep 17 00:00:00 2001
From: Eugene Huang <eugeneh@nvidia.com>
Date: Wed, 11 Aug 2021 00:23:54 -0700
Subject: [PATCH 2/2] Add comment for qemu_egl_get_display

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


[-- Attachment #3: 0001-Use-EGL-device-extension-in-display-initialization.patch --]
[-- Type: application/octet-stream, Size: 3746 bytes --]

From d01f3c16e116de01d60595c954f42d42e98cfca7 Mon Sep 17 00:00:00 2001
From: Eugene Huang <eugeneh@nvidia.com>
Date: Fri, 6 Aug 2021 11:17:42 -0700
Subject: [PATCH 1/2] Use EGL device extension in display initialization.

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] 5+ messages in thread

* Re: [PATCH] Use EGL device extension in display initialization.
  2021-08-11  7:58   ` Eugene Huang via
@ 2021-08-11 10:42     ` Marc-André Lureau
  2021-08-26 18:00       ` Eugene Huang
  0 siblings, 1 reply; 5+ messages in thread
From: Marc-André Lureau @ 2021-08-11 10:42 UTC (permalink / raw)
  To: Eugene Huang; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 6127 bytes --]

Hi

On Wed, Aug 11, 2021 at 11:58 AM Eugene Huang <eugeneh@nvidia.com> wrote:

> Hi,
>
>
>
> I have had some hard time to set up git send-email. I am not even sure if
> it is doable here. I read that attachments can be used a last resort for
> first timers. Here are the attachments. Hope it works.
>
>
>

Unfortunately, the patches still fail to apply.
https://patchew.org/QEMU/BYAPR12MB3192EC20271BF35444CE2FF3D9F89@BYAPR12MB3192.namprd12.prod.outlook.com/

Thanks,
>
> Eugene
>
>
>
> *From:* Marc-André Lureau <marcandre.lureau@gmail.com>
> *Sent:* Friday, August 6, 2021 12:25 AM
> *To:* Eugene Huang <eugeneh@nvidia.com>
> *Cc:* qemu-devel@nongnu.org
> *Subject:* Re: [PATCH] Use EGL device extension in display initialization.
>
>
>
> *External email: Use caution opening links or attachments*
>
>
>
> Hi
>
>
>
> On Fri, Aug 6, 2021 at 2:28 AM Eugene Huang <eugeneh@nvidia.com> wrote:
>
> This patch enables running generic EGL devices such as Nvidia’s in
> headless mode. It assumes single device. More work is needed to support
> multiple devices.
>
>
>
> Signed-off-by: Eugene Huang <eugeneh@nvidia.com>
>
>
>
> Thanks for the patch. It isn't correctly formatted and git apply fails  (
> https://patchew.org/QEMU/BYAPR12MB319275649A1403C254A9EA43D9F29@BYAPR12MB3192.namprd12.prod.outlook.com/
> <https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatchew.org%2FQEMU%2FBYAPR12MB319275649A1403C254A9EA43D9F29%40BYAPR12MB3192.namprd12.prod.outlook.com%2F&data=04%7C01%7Ceugeneh%40nvidia.com%7C2d1240b866904cc7971308d958ab4471%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637638314899347574%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=EsDRdtG01ja1P9NDZG8ScE7SgC8ZILFS6p%2B9mGoklnY%3D&reserved=0>).
> Please use git send-email.
>
>
>
> ---
>
> 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 7c530c2825..c11610c083 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
>
> @@ -349,11 +351,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);
>
>
>
> Given that the function has a lengthy comment to explain it, and this is
> quite archaic stuff, I think you should update the comments with your
> additions.
>
>
>
> +            } else {
>
> +                dpy = getPlatformDisplayEXT(platform, native, NULL);
>
> +            }
>
>          }
>
>      }
>
> @@ -386,6 +403,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;
>
> @@ -411,8 +439,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");
>
> @@ -434,6 +462,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
>
>
>
>
> thanks
>
>
>
> --
>
> Marc-André Lureau
>


-- 
Marc-André Lureau

[-- Attachment #2: Type: text/html, Size: 24884 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] Use EGL device extension in display initialization.
  2021-08-11 10:42     ` Marc-André Lureau
@ 2021-08-26 18:00       ` Eugene Huang
  0 siblings, 0 replies; 5+ messages in thread
From: Eugene Huang @ 2021-08-26 18:00 UTC (permalink / raw)
  To: Marc-André Lureau; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 6973 bytes --]

Hi,

Sorry for the delay. Finally got git send-email working and resubmitted the patch on Aug. 24:
https://lists.nongnu.org/archive/html/qemu-devel/2021-08/msg04112.html
https://lists.nongnu.org/archive/html/qemu-devel/2021-08/msg04113.html

If anything is still incorrect, please advise.

Regards,
Eugene Huang

From: Marc-André Lureau <marcandre.lureau@gmail.com>
Sent: Wednesday, August 11, 2021 3:43 AM
To: Eugene Huang <eugeneh@nvidia.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH] Use EGL device extension in display initialization.

External email: Use caution opening links or attachments

Hi

On Wed, Aug 11, 2021 at 11:58 AM Eugene Huang <eugeneh@nvidia.com<mailto:eugeneh@nvidia.com>> wrote:
Hi,

I have had some hard time to set up git send-email. I am not even sure if it is doable here. I read that attachments can be used a last resort for first timers. Here are the attachments. Hope it works.


Unfortunately, the patches still fail to apply.
https://patchew.org/QEMU/BYAPR12MB3192EC20271BF35444CE2FF3D9F89@BYAPR12MB3192.namprd12.prod.outlook.com/<https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatchew.org%2FQEMU%2FBYAPR12MB3192EC20271BF35444CE2FF3D9F89%40BYAPR12MB3192.namprd12.prod.outlook.com%2F&data=04%7C01%7Ceugeneh%40nvidia.com%7Cdee6cf4f0f4d412c2fe708d95cb4c69f%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637642753764629442%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=u9cACiyD12DPZ9QVnrnWCElQHCFznFsCq5qssXH1t64%3D&reserved=0>

Thanks,
Eugene

From: Marc-André Lureau <marcandre.lureau@gmail.com<mailto:marcandre.lureau@gmail.com>>
Sent: Friday, August 6, 2021 12:25 AM
To: Eugene Huang <eugeneh@nvidia.com<mailto:eugeneh@nvidia.com>>
Cc: qemu-devel@nongnu.org<mailto:qemu-devel@nongnu.org>
Subject: Re: [PATCH] Use EGL device extension in display initialization.

External email: Use caution opening links or attachments

Hi

On Fri, Aug 6, 2021 at 2:28 AM Eugene Huang <eugeneh@nvidia.com<mailto:eugeneh@nvidia.com>> wrote:

This patch enables running generic EGL devices such as Nvidia's in headless mode. It assumes single device. More work is needed to support multiple devices.



Signed-off-by: Eugene Huang <eugeneh@nvidia.com<mailto:eugeneh@nvidia.com>>

Thanks for the patch. It isn't correctly formatted and git apply fails  (https://patchew.org/QEMU/BYAPR12MB319275649A1403C254A9EA43D9F29@BYAPR12MB3192.namprd12.prod.outlook.com/<https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatchew.org%2FQEMU%2FBYAPR12MB319275649A1403C254A9EA43D9F29%40BYAPR12MB3192.namprd12.prod.outlook.com%2F&data=04%7C01%7Ceugeneh%40nvidia.com%7Cdee6cf4f0f4d412c2fe708d95cb4c69f%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637642753764639436%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=1GyXOJ%2B9xKBDsX3q9Uemj4xMZBjhNTeR0le8Upm843w%3D&reserved=0>). Please use git send-email.


---

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 7c530c2825..c11610c083 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

@@ -349,11 +351,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);

Given that the function has a lengthy comment to explain it, and this is quite archaic stuff, I think you should update the comments with your additions.


+            } else {

+                dpy = getPlatformDisplayEXT(platform, native, NULL);

+            }

         }

     }

@@ -386,6 +403,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;

@@ -411,8 +439,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");

@@ -434,6 +462,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



thanks

--
Marc-André Lureau


--
Marc-André Lureau

[-- Attachment #2: Type: text/html, Size: 32703 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-08-26 18:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-05 22:07 [PATCH] Use EGL device extension in display initialization Eugene Huang
2021-08-06  7:24 ` Marc-André Lureau
2021-08-11  7:58   ` Eugene Huang via
2021-08-11 10:42     ` Marc-André Lureau
2021-08-26 18:00       ` Eugene Huang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.