From: Elie Tournier <tournier.elie@gmail.com>
To: qemu-devel@nongnu.org
Cc: eblake@redhat.com, kraxel@redhat.com,
Elie Tournier <tournier.elie@gmail.com>,
Elie Tournier <elie.tournier@collabora.com>
Subject: [Qemu-devel] [PATCH v3 3/3] sdl: Allow OpenGL ES context creation
Date: Fri, 13 Apr 2018 14:58:42 +0100 [thread overview]
Message-ID: <20180413135842.21325-4-tournier.elie@gmail.com> (raw)
In-Reply-To: <20180413135842.21325-1-tournier.elie@gmail.com>
Signed-off-by: Elie Tournier <elie.tournier@collabora.com>
---
qemu-options.hx | 2 +-
ui/sdl2-gl.c | 19 +++++++++++++++++--
vl.c | 4 ++++
3 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/qemu-options.hx b/qemu-options.hx
index ca4e412f2f..333dd1f1c8 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1240,7 +1240,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|core|es|off]\n"
"-display gtk[,grab_on_hover=on|off][,gl=on|off]|\n"
"-display vnc=<display>[,<optargs>]\n"
"-display curses\n"
diff --git a/ui/sdl2-gl.c b/ui/sdl2-gl.c
index c3683e6b65..a1200bfd20 100644
--- a/ui/sdl2-gl.c
+++ b/ui/sdl2-gl.c
@@ -140,12 +140,27 @@ 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->opts->gl == DISPLAYGL_MODE_ON ||
+ scon->opts->gl == DISPLAYGL_MODE_CORE) {
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK,
+ SDL_GL_CONTEXT_PROFILE_CORE);
+ } else if (scon->opts->gl == DISPLAYGL_MODE_ES) {
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK,
+ SDL_GL_CONTEXT_PROFILE_ES);
+ }
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, params->major_ver);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, params->minor_ver);
ctx = SDL_GL_CreateContext(scon->real_window);
+
+ /* If SDL fail to create a GL context and we use the "on" flag,
+ * then try to fallback to GLES.
+ */
+ if (!ctx && scon->opts->gl == DISPLAYGL_MODE_ON) {
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK,
+ SDL_GL_CONTEXT_PROFILE_ES);
+ ctx = SDL_GL_CreateContext(scon->real_window);
+ }
return (QEMUGLContext)ctx;
}
diff --git a/vl.c b/vl.c
index 99284fd518..3bd3b902a0 100644
--- a/vl.c
+++ b/vl.c
@@ -2143,6 +2143,10 @@ static void parse_display(const char *p)
dpy.has_gl = true;
if (strstart(opts, "on", &nextopt)) {
dpy.gl = DISPLAYGL_MODE_ON;
+ } else if (strstart(opts, "core", &nextopt)) {
+ dpy.gl = DISPLAYGL_MODE_CORE;
+ } else if (strstart(opts, "es", &nextopt)) {
+ dpy.gl = DISPLAYGL_MODE_ES;
} else if (strstart(opts, "off", &nextopt)) {
dpy.gl = DISPLAYGL_MODE_OFF;
} else {
--
2.17.0
next prev parent reply other threads:[~2018-04-13 14:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-13 13:58 [Qemu-devel] [PATCH v3 0/3] Use SDL to create an OpenGL ES context for virglrenderer Elie Tournier
2018-04-13 13:58 ` [Qemu-devel] [PATCH v3 1/3] qapi: Parameter gl of DisplayType now accept an enum Elie Tournier
2018-04-13 13:58 ` [Qemu-devel] [PATCH v3 2/3] sdl: Move DisplayOptions global to sdl2_console Elie Tournier
2018-04-13 13:58 ` Elie Tournier [this message]
2018-04-20 9:32 ` [Qemu-devel] [PATCH v3 0/3] Use SDL to create an OpenGL ES context for virglrenderer Elie Tournier
2018-04-20 10:44 ` Gerd Hoffmann
2018-04-20 10:46 ` Elie Tournier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180413135842.21325-4-tournier.elie@gmail.com \
--to=tournier.elie@gmail.com \
--cc=eblake@redhat.com \
--cc=elie.tournier@collabora.com \
--cc=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).