From nobody Wed Nov 5 17:25:26 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496747227657996.6628083493974; Tue, 6 Jun 2017 04:07:07 -0700 (PDT) Received: from localhost ([::1]:37536 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dICKG-00066Y-1L for importer@patchew.org; Tue, 06 Jun 2017 07:07:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38192) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dICIV-00050n-2K for qemu-devel@nongnu.org; Tue, 06 Jun 2017 07:05:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dICIT-0002iw-Bt for qemu-devel@nongnu.org; Tue, 06 Jun 2017 07:05:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44310) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dICIT-0002ie-42 for qemu-devel@nongnu.org; Tue, 06 Jun 2017 07:05:13 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 318EABDD4 for ; Tue, 6 Jun 2017 11:05:12 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-106.ams2.redhat.com [10.36.116.106]) by smtp.corp.redhat.com (Postfix) with ESMTP id EF05F17D63; Tue, 6 Jun 2017 11:05:03 +0000 (UTC) Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 146AB80FFC; Tue, 6 Jun 2017 13:05:02 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 318EABDD4 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 318EABDD4 From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 6 Jun 2017 13:04:58 +0200 Message-Id: <20170606110459.9771-4-kraxel@redhat.com> In-Reply-To: <20170606110459.9771-1-kraxel@redhat.com> References: <20170606110459.9771-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 06 Jun 2017 11:05:12 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 3/4] sdl2: use framebuffer helper functions. 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: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Gerd Hoffmann --- include/ui/sdl2.h | 8 ++++++-- ui/sdl2-gl.c | 38 ++++++++------------------------------ 2 files changed, 14 insertions(+), 32 deletions(-) diff --git a/include/ui/sdl2.h b/include/ui/sdl2.h index aaf226c2c0..454367ac84 100644 --- a/include/ui/sdl2.h +++ b/include/ui/sdl2.h @@ -7,6 +7,10 @@ #include #include =20 +#ifdef CONFIG_OPENGL +# include "ui/egl-helpers.h" +#endif + struct sdl2_console { DisplayChangeListener dcl; DisplaySurface *surface; @@ -23,8 +27,8 @@ struct sdl2_console { SDL_GLContext winctx; #ifdef CONFIG_OPENGL ConsoleGLState *gls; - GLuint tex_id; - GLuint fbo_id; + egl_fb guest_fb; + egl_fb win_fb; bool y0_top; bool scanout_mode; #endif diff --git a/ui/sdl2-gl.c b/ui/sdl2-gl.c index 1cd77e2c16..6640d0a9c8 100644 --- a/ui/sdl2-gl.c +++ b/ui/sdl2-gl.c @@ -42,14 +42,7 @@ static void sdl2_set_scanout_mode(struct sdl2_console *s= con, bool scanout) =20 scon->scanout_mode =3D scanout; if (!scon->scanout_mode) { - if (scon->fbo_id) { - glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, - GL_COLOR_ATTACHMENT0_EXT, - GL_TEXTURE_2D, 0, 0); - glDeleteFramebuffers(1, &scon->fbo_id); - glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0); - scon->fbo_id =3D 0; - } + egl_fb_destroy(&scon->guest_fb); if (scon->surface) { surface_gl_destroy_texture(scon->gls, scon->surface); surface_gl_create_texture(scon->gls, scon->surface); @@ -191,7 +184,6 @@ void sdl2_gl_scanout_disable(DisplayChangeListener *dcl) assert(scon->opengl); scon->w =3D 0; scon->h =3D 0; - scon->tex_id =3D 0; sdl2_set_scanout_mode(scon, false); } =20 @@ -210,48 +202,34 @@ void sdl2_gl_scanout_texture(DisplayChangeListener *d= cl, scon->y =3D y; scon->w =3D w; scon->h =3D h; - scon->tex_id =3D backing_id; scon->y0_top =3D backing_y_0_top; =20 SDL_GL_MakeCurrent(scon->real_window, scon->winctx); =20 sdl2_set_scanout_mode(scon, true); - if (!scon->fbo_id) { - glGenFramebuffers(1, &scon->fbo_id); - } - - glBindFramebuffer(GL_FRAMEBUFFER_EXT, scon->fbo_id); - glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, - GL_TEXTURE_2D, scon->tex_id, 0); + egl_fb_create_for_tex(&scon->guest_fb, backing_width, backing_height, + backing_id); } =20 void sdl2_gl_scanout_flush(DisplayChangeListener *dcl, uint32_t x, uint32_t y, uint32_t w, uint32_t h) { struct sdl2_console *scon =3D container_of(dcl, struct sdl2_console, d= cl); - int ww, wh, y1, y2; =20 assert(scon->opengl); if (!scon->scanout_mode) { return; } - if (!scon->fbo_id) { + if (!scon->guest_fb.framebuffer) { return; } =20 SDL_GL_MakeCurrent(scon->real_window, scon->winctx); =20 - glBindFramebuffer(GL_READ_FRAMEBUFFER, scon->fbo_id); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); - - SDL_GetWindowSize(scon->real_window, &ww, &wh); - glViewport(0, 0, ww, wh); - y1 =3D scon->y0_top ? 0 : scon->h; - y2 =3D scon->y0_top ? scon->h : 0; - glBlitFramebuffer(0, y1, scon->w, y2, - 0, 0, ww, wh, - GL_COLOR_BUFFER_BIT, GL_NEAREST); - glBindFramebuffer(GL_FRAMEBUFFER_EXT, scon->fbo_id); + SDL_GetWindowSize(scon->real_window, + &scon->win_fb.width, + &scon->win_fb.height); + egl_fb_blit(&scon->win_fb, &scon->guest_fb, !scon->y0_top); =20 SDL_GL_SwapWindow(scon->real_window); } --=20 2.9.3