All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [RFC 0/2] Use SDL to create an OpenGL ES context for virglrenderer.
@ 2018-01-17 14:50 Elie Tournier
  2018-01-17 14:50 ` [Qemu-devel] [RFC 1/2] sdl2: Add gles options Elie Tournier
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Elie Tournier @ 2018-01-17 14:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, kraxel, Elie Tournier

Hello everyone,

At Collabora, we are working on adding an OpenGL ES backend on virglrenderer [1].
I submit these patches as an RFC because our work didn't land in virglrenderer yet.
Currently, we support OpenGL ES 2.0 on the guest side and OpenGL ES 3.0 on the host side.
Our plan is to increase the guest support to OpenGL ES 3.0.
Thanks to this work, we are able to run QEMU on system that only support OpenGL ES.

In order to use this feature, we need to create a gles context.
This series add an option (`-display sdl,gles=on`) in the SDL display to create that context.

The source code is available on our gitlab instance.
For virglrenderer [2] and qemu [3].

Feel free to review/comment the series.

Have a nice day,
Elie

[1] https://cgit.freedesktop.org/virglrenderer
[2] https://gitlab.collabora.com/jakob/virglrenderer-gles/tree/hacks
[3] https://gitlab.collabora.com/elie/qemu/tree/gles-option

Elie Tournier (2):
  sdl2: Add gles options
  sdl2: gles option will create a gles context

 include/sysemu/sysemu.h |  1 +
 include/ui/sdl2.h       |  1 +
 qemu-options.hx         |  5 ++++-
 ui/sdl2-gl.c            |  8 ++++++--
 ui/sdl2.c               |  8 ++++++++
 vl.c                    | 12 +++++++++++-
 6 files changed, 31 insertions(+), 4 deletions(-)

-- 
2.15.1

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

* [Qemu-devel] [RFC 1/2] sdl2: Add gles options
  2018-01-17 14:50 [Qemu-devel] [RFC 0/2] Use SDL to create an OpenGL ES context for virglrenderer Elie Tournier
@ 2018-01-17 14:50 ` Elie Tournier
  2018-01-17 14:50 ` [Qemu-devel] [RFC 2/2] sdl2: gles option will create a gles context Elie Tournier
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Elie Tournier @ 2018-01-17 14:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, kraxel, Elie Tournier, Elie Tournier

This commit add an option to the sdl display: `-display sdl,gles=on`
This will allow the user to create an OpenGL ES context.

Signed-off-by: Elie Tournier <elie.tournier@collabora.com>
---
 qemu-options.hx |  5 ++++-
 ui/sdl2.c       |  1 +
 vl.c            | 11 ++++++++++-
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/qemu-options.hx b/qemu-options.hx
index 678181c599..18a616e339 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1257,7 +1257,7 @@ ETEXI
 
 DEF("display", HAS_ARG, QEMU_OPTION_display,
     "-display sdl[,frame=on|off][,alt_grab=on|off][,ctrl_grab=on|off]\n"
-    "            [,window_close=on|off][,gl=on|off]\n"
+    "            [,window_close=on|off][,gl=on|off][,gles=on|off]\n"
     "-display gtk[,grab_on_hover=on|off][,gl=on|off]|\n"
     "-display vnc=<display>[,<optargs>]\n"
     "-display curses\n"
@@ -1492,6 +1492,9 @@ Enable/disable spice seamless migration. Default is off.
 @item gl=[on|off]
 Enable/disable OpenGL context. Default is off.
 
+@item gles=[on|off]
+Enable/disable OpenGL ES context. Default is off.
+
 @item rendernode=<file>
 DRM render node for OpenGL rendering. If not specified, it will pick
 the first available. (Since 2.9)
diff --git a/ui/sdl2.c b/ui/sdl2.c
index 89c6a2633c..e78cff1a6f 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -762,6 +762,7 @@ void sdl_display_early_init(int opengl)
     case 0:  /* off */
         break;
     case 1: /* on */
+    case 2: /* gles = on */
 #ifdef CONFIG_OPENGL
         display_opengl = 1;
 #endif
diff --git a/vl.c b/vl.c
index 2586f25952..3fe325222e 100644
--- a/vl.c
+++ b/vl.c
@@ -2154,6 +2154,15 @@ static DisplayType select_display(const char *p)
                 } else {
                     goto invalid_sdl_args;
                 }
+            } else if (strstart(opts, ",gles=", &nextopt)) {
+                opts = nextopt;
+                if (strstart(opts, "on", &nextopt)) {
+                    request_opengl = 2;
+                } else if (strstart(opts, "off", &nextopt)) {
+                    request_opengl = 0;
+                } else {
+                    goto invalid_sdl_args;
+                }
             } else if (strstart(opts, ",gl=", &nextopt)) {
                 opts = nextopt;
                 if (strstart(opts, "on", &nextopt)) {
@@ -4364,7 +4373,7 @@ int main(int argc, char **argv, char **envp)
 
     qemu_console_early_init();
 
-    if (request_opengl == 1 && display_opengl == 0) {
+    if ((request_opengl == 1 || request_opengl == 2) && display_opengl == 0) {
 #if defined(CONFIG_OPENGL)
         error_report("OpenGL is not supported by the display");
 #else
-- 
2.15.1

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

* [Qemu-devel] [RFC 2/2] sdl2: gles option will create a gles context
  2018-01-17 14:50 [Qemu-devel] [RFC 0/2] Use SDL to create an OpenGL ES context for virglrenderer Elie Tournier
  2018-01-17 14:50 ` [Qemu-devel] [RFC 1/2] sdl2: Add gles options Elie Tournier
@ 2018-01-17 14:50 ` Elie Tournier
  2018-01-17 15:04 ` [Qemu-devel] [RFC 0/2] Use SDL to create an OpenGL ES context for virglrenderer no-reply
  2018-01-29 16:11 ` Elie Tournier
  3 siblings, 0 replies; 9+ messages in thread
From: Elie Tournier @ 2018-01-17 14:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, kraxel, Elie Tournier, Elie Tournier

Create an OpenGL ES context if the option `-display sdl,gles=on` is set.

Signed-off-by: Elie Tournier <elie.tournier@collabora.com>
---
 include/sysemu/sysemu.h | 1 +
 include/ui/sdl2.h       | 1 +
 ui/sdl2-gl.c            | 8 ++++++--
 ui/sdl2.c               | 7 +++++++
 vl.c                    | 1 +
 5 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index 31612caf10..32f242c4c5 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -108,6 +108,7 @@ extern int graphic_width;
 extern int graphic_height;
 extern int graphic_depth;
 extern int display_opengl;
+extern bool use_opengl_es;
 extern const char *keyboard_layout;
 extern int win2k_install_hack;
 extern int alt_grab;
diff --git a/include/ui/sdl2.h b/include/ui/sdl2.h
index 51084e6320..2aaa203f51 100644
--- a/include/ui/sdl2.h
+++ b/include/ui/sdl2.h
@@ -26,6 +26,7 @@ struct sdl2_console {
     int idle_counter;
     int ignore_hotkeys;
     SDL_GLContext winctx;
+    bool opengl_es;
 #ifdef CONFIG_OPENGL
     QemuGLShader *gls;
     egl_fb guest_fb;
diff --git a/ui/sdl2-gl.c b/ui/sdl2-gl.c
index 5e1073a084..4e620c5ff7 100644
--- a/ui/sdl2-gl.c
+++ b/ui/sdl2-gl.c
@@ -142,8 +142,12 @@ QEMUGLContext sdl2_gl_create_context(DisplayChangeListener *dcl,
     SDL_GL_MakeCurrent(scon->real_window, scon->winctx);
 
     SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1);
-    SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK,
-                        SDL_GL_CONTEXT_PROFILE_CORE);
+    if (scon->opengl_es)
+        SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK,
+                            SDL_GL_CONTEXT_PROFILE_ES);
+    else
+        SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK,
+                            SDL_GL_CONTEXT_PROFILE_CORE);
     SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, params->major_ver);
     SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, params->minor_ver);
 
diff --git a/ui/sdl2.c b/ui/sdl2.c
index e78cff1a6f..a1250a6902 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -762,9 +762,14 @@ void sdl_display_early_init(int opengl)
     case 0:  /* off */
         break;
     case 1: /* on */
+#ifdef CONFIG_OPENGL
+        display_opengl = 1;
+#endif
+        break;
     case 2: /* gles = on */
 #ifdef CONFIG_OPENGL
         display_opengl = 1;
+        use_opengl_es = true;
 #endif
         break;
     default:
@@ -829,9 +834,11 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
 #ifdef CONFIG_OPENGL
         sdl2_console[i].opengl = display_opengl;
         sdl2_console[i].dcl.ops = display_opengl ? &dcl_gl_ops : &dcl_2d_ops;
+        sdl2_console[i].opengl_es = use_opengl_es;
 #else
         sdl2_console[i].opengl = 0;
         sdl2_console[i].dcl.ops = &dcl_2d_ops;
+        sdl2_console[i].opengl_es = false;
 #endif
         sdl2_console[i].dcl.con = con;
         register_displaychangelistener(&sdl2_console[i].dcl);
diff --git a/vl.c b/vl.c
index 3fe325222e..a7bde1fa1e 100644
--- a/vl.c
+++ b/vl.c
@@ -137,6 +137,7 @@ const char *bios_name = NULL;
 enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
 int request_opengl = -1;
 int display_opengl;
+bool use_opengl_es;
 const char* keyboard_layout = NULL;
 ram_addr_t ram_size;
 const char *mem_path = NULL;
-- 
2.15.1

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

* Re: [Qemu-devel] [RFC 0/2] Use SDL to create an OpenGL ES context for virglrenderer.
  2018-01-17 14:50 [Qemu-devel] [RFC 0/2] Use SDL to create an OpenGL ES context for virglrenderer Elie Tournier
  2018-01-17 14:50 ` [Qemu-devel] [RFC 1/2] sdl2: Add gles options Elie Tournier
  2018-01-17 14:50 ` [Qemu-devel] [RFC 2/2] sdl2: gles option will create a gles context Elie Tournier
@ 2018-01-17 15:04 ` no-reply
  2018-01-29 16:11 ` Elie Tournier
  3 siblings, 0 replies; 9+ messages in thread
From: no-reply @ 2018-01-17 15:04 UTC (permalink / raw)
  To: tournier.elie; +Cc: famz, qemu-devel, pbonzini, kraxel

Hi,

This series seems to have some coding style problems. See output below for
more information:

Type: series
Message-id: 20180117145029.28736-1-tournier.elie@gmail.com
Subject: [Qemu-devel] [RFC 0/2] Use SDL to create an OpenGL ES context for virglrenderer.

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

git config --local diff.renamelimit 0
git config --local diff.renames True

commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
    echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))
done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 * [new tag]               patchew/20180117145029.28736-1-tournier.elie@gmail.com -> patchew/20180117145029.28736-1-tournier.elie@gmail.com
Switched to a new branch 'test'
0e1d36af8a sdl2: gles option will create a gles context
b552b7e807 sdl2: Add gles options

=== OUTPUT BEGIN ===
Checking PATCH 1/2: sdl2: Add gles options...
Checking PATCH 2/2: sdl2: gles option will create a gles context...
ERROR: braces {} are necessary for all arms of this statement
#45: FILE: ui/sdl2-gl.c:145:
+    if (scon->opengl_es)
[...]
+    else
[...]

total: 1 errors, 0 warnings, 60 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

=== OUTPUT END ===

Test command exited with code: 1


---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@freelists.org

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

* Re: [Qemu-devel] [RFC 0/2] Use SDL to create an OpenGL ES context for virglrenderer.
  2018-01-17 14:50 [Qemu-devel] [RFC 0/2] Use SDL to create an OpenGL ES context for virglrenderer Elie Tournier
                   ` (2 preceding siblings ...)
  2018-01-17 15:04 ` [Qemu-devel] [RFC 0/2] Use SDL to create an OpenGL ES context for virglrenderer no-reply
@ 2018-01-29 16:11 ` Elie Tournier
  2018-01-29 18:08   ` Gerd Hoffmann
  3 siblings, 1 reply; 9+ messages in thread
From: Elie Tournier @ 2018-01-29 16:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, kraxel

On Wed, Jan 17, 2018 at 02:50:27PM +0000, Elie Tournier wrote:
> Hello everyone,
> 
> At Collabora, we are working on adding an OpenGL ES backend on virglrenderer [1].
> I submit these patches as an RFC because our work didn't land in virglrenderer yet.
> Currently, we support OpenGL ES 2.0 on the guest side and OpenGL ES 3.0 on the host side.
> Our plan is to increase the guest support to OpenGL ES 3.0.
> Thanks to this work, we are able to run QEMU on system that only support OpenGL ES.
> 
> In order to use this feature, we need to create a gles context.
> This series add an option (`-display sdl,gles=on`) in the SDL display to create that context.
> 
> The source code is available on our gitlab instance.
> For virglrenderer [2] and qemu [3].
> 
> Feel free to review/comment the series.

Hello,

Humble ping.
I didn't get any comment on this series.
Are you interested by running QEMU on systems that only support OpenGL ES?
If yes, did I proceed correctly?

> 
> Have a nice day,
> Elie
> 
> [1] https://cgit.freedesktop.org/virglrenderer
> [2] https://gitlab.collabora.com/jakob/virglrenderer-gles/tree/hacks
> [3] https://gitlab.collabora.com/elie/qemu/tree/gles-option
> 
> Elie Tournier (2):
>   sdl2: Add gles options
>   sdl2: gles option will create a gles context
> 
>  include/sysemu/sysemu.h |  1 +
>  include/ui/sdl2.h       |  1 +
>  qemu-options.hx         |  5 ++++-
>  ui/sdl2-gl.c            |  8 ++++++--
>  ui/sdl2.c               |  8 ++++++++
>  vl.c                    | 12 +++++++++++-
>  6 files changed, 31 insertions(+), 4 deletions(-)
> 
> -- 
> 2.15.1
> 

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

* Re: [Qemu-devel] [RFC 0/2] Use SDL to create an OpenGL ES context for virglrenderer.
  2018-01-29 16:11 ` Elie Tournier
@ 2018-01-29 18:08   ` Gerd Hoffmann
  2018-01-30 14:43     ` Elie Tournier
  0 siblings, 1 reply; 9+ messages in thread
From: Gerd Hoffmann @ 2018-01-29 18:08 UTC (permalink / raw)
  To: Elie Tournier; +Cc: qemu-devel, pbonzini

  Hi,

> > In order to use this feature, we need to create a gles context.
> > This series add an option (`-display sdl,gles=on`) in the SDL display to create that context.
> 
> Humble ping.
> I didn't get any comment on this series.

Well, display configuration is going to be rewritten, and while that is
in flight adding new config options isn't a good idea b/c things will
conflict ...

Beside that:  Is a new config option actually needed in the first place?

Ideally qemu (or sdl) would figure on its own that a full core context
isn't available and try fallback to gles then.

cheers,
  Gerd

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

* Re: [Qemu-devel] [RFC 0/2] Use SDL to create an OpenGL ES context for virglrenderer.
  2018-01-29 18:08   ` Gerd Hoffmann
@ 2018-01-30 14:43     ` Elie Tournier
  2018-01-30 15:22       ` Gerd Hoffmann
  0 siblings, 1 reply; 9+ messages in thread
From: Elie Tournier @ 2018-01-30 14:43 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel, pbonzini

On Mon, Jan 29, 2018 at 07:08:30PM +0100, Gerd Hoffmann wrote:
Hello,

First, thanks for your reply.
I added some comments and questions below.

Cheers,
Elie

>   Hi,
> 
> > > In order to use this feature, we need to create a gles context.
> > > This series add an option (`-display sdl,gles=on`) in the SDL display to create that context.
> > 
> > Humble ping.
> > I didn't get any comment on this series.
> 
> Well, display configuration is going to be rewritten, and while that is
> in flight adding new config options isn't a good idea b/c things will
> conflict ...
I'm wondering how extensive this rewrite is going to be. Did you plan to modify the qemu interface?
If someone already start working on this task, can you send me the link to the repository?
I will be happy to help if needed.
> 
> Beside that:  Is a new config option actually needed in the first place?
> 
> Ideally qemu (or sdl) would figure on its own that a full core context
> isn't available and try fallback to gles then.
I'm fine with this idea.
However, I think we still need to add a way to the user to choose the backend he want.
> 
> cheers,
>   Gerd
> 

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

* Re: [Qemu-devel] [RFC 0/2] Use SDL to create an OpenGL ES context for virglrenderer.
  2018-01-30 14:43     ` Elie Tournier
@ 2018-01-30 15:22       ` Gerd Hoffmann
  2018-01-30 17:08         ` Elie Tournier
  0 siblings, 1 reply; 9+ messages in thread
From: Gerd Hoffmann @ 2018-01-30 15:22 UTC (permalink / raw)
  To: Elie Tournier; +Cc: qemu-devel, pbonzini

  Hi,

> > Well, display configuration is going to be rewritten, and while that is
> > in flight adding new config options isn't a good idea b/c things will
> > conflict ...
> I'm wondering how extensive this rewrite is going to be. Did you plan to modify the qemu interface?
> If someone already start working on this task, can you send me the link to the repository?
> I will be happy to help if needed.

https://www.kraxel.org/cgit/qemu/log/?h=sirius/display-cmdline

> > Beside that:  Is a new config option actually needed in the first place?
> > 
> > Ideally qemu (or sdl) would figure on its own that a full core context
> > isn't available and try fallback to gles then.
> I'm fine with this idea.
> However, I think we still need to add a way to the user to choose the backend he want.

Changing gl from bool to multiple choice looks more useful to me then,
i.e. have "gl={on,core,gles,off}", where "on" automatically picks "core"
or "gles" depending on what is available.

What is the status of the virglrenderer patches btw?

cheers,
  Gerd

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

* Re: [Qemu-devel] [RFC 0/2] Use SDL to create an OpenGL ES context for virglrenderer.
  2018-01-30 15:22       ` Gerd Hoffmann
@ 2018-01-30 17:08         ` Elie Tournier
  0 siblings, 0 replies; 9+ messages in thread
From: Elie Tournier @ 2018-01-30 17:08 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel, pbonzini

On Tue, Jan 30, 2018 at 04:22:33PM +0100, Gerd Hoffmann wrote:
>   Hi,
> 
> > > Well, display configuration is going to be rewritten, and while that is
> > > in flight adding new config options isn't a good idea b/c things will
> > > conflict ...
> > I'm wondering how extensive this rewrite is going to be. Did you plan to modify the qemu interface?
> > If someone already start working on this task, can you send me the link to the repository?
> > I will be happy to help if needed.
> 
> https://www.kraxel.org/cgit/qemu/log/?h=sirius/display-cmdline
Awesome, thanks. I will definitely have a look to it.
> 
> > > Beside that:  Is a new config option actually needed in the first place?
> > > 
> > > Ideally qemu (or sdl) would figure on its own that a full core context
> > > isn't available and try fallback to gles then.
> > I'm fine with this idea.
> > However, I think we still need to add a way to the user to choose the backend he want.
> 
> Changing gl from bool to multiple choice looks more useful to me then,
> i.e. have "gl={on,core,gles,off}", where "on" automatically picks "core"
> or "gles" depending on what is available.
I like that solution. ;). I will implement it on top of your work.
> 
> What is the status of the virglrenderer patches btw?
We keep upstreaming no invasive patches.
But with upstream virglrenderer, you will not be able to use a gles backend.
If you want to know more about the current status of the project, you can have a look to our repo [1].

Currently, we are working through bugs, cleaning up the remaing patches.
Our short term goal is to pass the GLES2 CTS [2] in the guest side.

Regards,
Elie

[1] https://gitlab.collabora.com/jakob/virglrenderer-gles/tree/hacks
[2] https://github.com/KhronosGroup/VK-GL-CTS
> 
> cheers,
>   Gerd
> 

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

end of thread, other threads:[~2018-01-30 17:10 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-17 14:50 [Qemu-devel] [RFC 0/2] Use SDL to create an OpenGL ES context for virglrenderer Elie Tournier
2018-01-17 14:50 ` [Qemu-devel] [RFC 1/2] sdl2: Add gles options Elie Tournier
2018-01-17 14:50 ` [Qemu-devel] [RFC 2/2] sdl2: gles option will create a gles context Elie Tournier
2018-01-17 15:04 ` [Qemu-devel] [RFC 0/2] Use SDL to create an OpenGL ES context for virglrenderer no-reply
2018-01-29 16:11 ` Elie Tournier
2018-01-29 18:08   ` Gerd Hoffmann
2018-01-30 14:43     ` Elie Tournier
2018-01-30 15:22       ` Gerd Hoffmann
2018-01-30 17:08         ` Elie Tournier

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.