Use SDL to create an OpenGL ES context for virglrenderer.
cover Use SDL to create an OpenGL ES context for virglrenderer.
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(-)
Signature · 1 line
2.15.1
RFC 1/2 sdl2: Add gles options
This commit add an option to the sdl display: -display sdl,gles=on This will allow the user to create an OpenGL ES context.
--- qemu-options.hx | 5 ++++- ui/sdl2.c | 1 + vl.c | 11 ++++++++++- 3 files changed, 15 insertions(+), 2 deletions(-)
qemu-options.hx +4 -1
@@ -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)
ui/sdl2.c +1 -0
@@ -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
vl.c +10 -1
@@ -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
Signature · 1 line
2.15.1
RFC 2/2 sdl2: gles option will create a gles context
In reply to Elie TournierCreate an OpenGL ES context if the option -display sdl,gles=on is set.
--- 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(-)
include/sysemu/sysemu.h +1 -0
@@ -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;
include/ui/sdl2.h +1 -0
@@ -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;
ui/sdl2-gl.c +6 -2
@@ -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);
ui/sdl2.c +7 -0
@@ -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);
vl.c +1 -0
@@ -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 ;
Signature · 1 line
2.15.1
This series seems to have some coding style problems. See output below for more information:
Hi,
This series seems to have some coding style problems. See output below for more information:
Type: series
Message-id: [email protected]
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/[email protected] -> patchew/[email protected]
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 [email protected]
Quoted 8 lines · 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.
Quoted 7 lines
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?
Quoted 23 lines
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-optionElie Tournier (2):
sdl2: Add gles options
sdl2: gles option will create a gles contextinclude/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(-)Signature · 1 line
2.15.1
Hi,
Quoted 5 lines
Quoted 2 lines
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
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
Quoted 11 lines
Hi,
Quoted 5 lines
Quoted 2 lines
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.
Quoted 5 lines
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.
Quoted 4 lines
cheers,
Gerd
Hi,
Quoted 6 lines
Quoted 3 lines
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
Quoted 6 lines
Quoted 4 lines
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
Quoted 10 lines · Gerd Hoffmann
Hi,
Quoted 6 lines
Quoted 3 lines
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.
Quoted 11 lines
Quoted 7 lines
Quoted 5 lines
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.
Quoted 2 lines
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
Quoted 4 lines
cheers,
Gerd