qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Elie Tournier <tournier.elie@gmail.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, kraxel@redhat.com,
	Elie Tournier <tournier.elie@gmail.com>,
	Elie Tournier <elie.tournier@collabora.com>
Subject: [Qemu-devel] [RFC 2/2] sdl2: gles option will create a gles context
Date: Wed, 17 Jan 2018 14:50:29 +0000	[thread overview]
Message-ID: <20180117145029.28736-3-tournier.elie@gmail.com> (raw)
In-Reply-To: <20180117145029.28736-1-tournier.elie@gmail.com>

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

  parent reply	other threads:[~2018-01-17 14:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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=20180117145029.28736-3-tournier.elie@gmail.com \
    --to=tournier.elie@gmail.com \
    --cc=elie.tournier@collabora.com \
    --cc=kraxel@redhat.com \
    --cc=pbonzini@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).