From patchwork Fri Apr 13 13:58:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elie Tournier X-Patchwork-Id: 897952 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="OXKEFTkT"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40N04Z6Bmqz9s06 for ; Sat, 14 Apr 2018 00:08:46 +1000 (AEST) Received: from localhost ([::1]:56046 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f6zNc-0006gl-MT for incoming@patchwork.ozlabs.org; Fri, 13 Apr 2018 10:08:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46991) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f6zJx-0004Cu-He for qemu-devel@nongnu.org; Fri, 13 Apr 2018 10:04:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f6zJu-00019K-AB for qemu-devel@nongnu.org; Fri, 13 Apr 2018 10:04:57 -0400 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:44714) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f6zJu-00019D-3V for qemu-devel@nongnu.org; Fri, 13 Apr 2018 10:04:54 -0400 Received: by mail-wr0-x242.google.com with SMTP id u46so8435221wrc.11 for ; Fri, 13 Apr 2018 07:04:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=YC+X3S69FVKxpqR4XrJofZM+EoqzOm+q44DkurFJYLk=; b=OXKEFTkTWOsfW68dk8EhA6Jk+HBUo7DqofVVu0awGeYUtsvXTHa64bvqu1UKWktD6y NfQ7Fdw4Bz1P+14I2iH7BxNpn5HpufjayzRWX+I4dd/oD7J7g98vXwfLIZpZHzR83URp TFaR/SnZyAHvmxsPRT8xflMIW+nV6yW8+XKW3TUm1O/8fUxBe20T9qGT58vXK7G/fzao EFQ9Z6CvETKvLhCVutY6PBAuhlwsAZQ1ePese8oELUKdxTdDXqcZL/7ER/98vFIc5bmS d69K3nO8GFCf0xfylGV9brNiUZSykV64PuIOxuWGTlfGqnmp4NEWn95IfE93GL6c9LYz p9UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=YC+X3S69FVKxpqR4XrJofZM+EoqzOm+q44DkurFJYLk=; b=nhpQYSyLEMIhlSj+iWEPK7NAz2Zc+5ZEFqwJetjP2+KWns/rB6BuDdmpirOJvGr6FS IXiRkniFWpXtP/F9WHw01FK2r2FkLR2mb6VYy8Wkz2P9wRmICg1ajs2iCLxH8hCoKkcx pYrTmcU3hwQs/jp6Ow6PNOpWwmMcGXYogjnlfVAL3PwYuxGoKxsd1Zel7jSFZeHrUqcT EySy0nZQXmQPzy+rFBGY00phhwCWFPHAd1WqylW8hNM08wf3o4ONzdkHU58OAbwK178x L4bTGSP0S6j1+G+PefqdSL1ayj6cERAzJRjGlZJlC5WLYHrjXgLXe7/FYssHLoVw8Occ YiNQ== X-Gm-Message-State: ALQs6tBNHX5e+wjDEyf7L2S+pBdg4wyDKM0Ca4ulTnZdc77tceM5zfGu 8uW5MPWHMeJdRwcu2kc4TINBog== X-Google-Smtp-Source: AIpwx4916Vm7AzzFoHalsVnn7mxdDLYhsTDwQwXL7IZcpVctxAAWwiyC9Yb2b2qHPHfttU4sGUjRSg== X-Received: by 10.223.195.40 with SMTP id n37mr1069918wrf.91.1523628292920; Fri, 13 Apr 2018 07:04:52 -0700 (PDT) Received: from Nikki.cbg.collabora.co.uk (bakora.collabora.co.uk. [46.17.161.148]) by smtp.googlemail.com with ESMTPSA id y51sm4785330wrc.38.2018.04.13.07.04.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Apr 2018 07:04:52 -0700 (PDT) From: Elie Tournier To: qemu-devel@nongnu.org Date: Fri, 13 Apr 2018 14:58:42 +0100 Message-Id: <20180413135842.21325-4-tournier.elie@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180413135842.21325-1-tournier.elie@gmail.com> References: <20180413135842.21325-1-tournier.elie@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::242 Subject: [Qemu-devel] [PATCH v3 3/3] sdl: Allow OpenGL ES context creation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Elie Tournier , kraxel@redhat.com, Elie Tournier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Elie Tournier --- 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=[,]\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 {