From patchwork Wed Jun 14 08:41:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 9785797 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DD702602D9 for ; Wed, 14 Jun 2017 08:43:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C1DEC28575 for ; Wed, 14 Jun 2017 08:43:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B6D67285C7; Wed, 14 Jun 2017 08:43:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3D05028575 for ; Wed, 14 Jun 2017 08:43:01 +0000 (UTC) Received: from localhost ([::1]:47221 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dL3tE-0000ca-FF for patchwork-qemu-devel@patchwork.kernel.org; Wed, 14 Jun 2017 04:43:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60231) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dL3sA-0000cE-VR for qemu-devel@nongnu.org; Wed, 14 Jun 2017 04:41:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dL3s7-0007bU-RS for qemu-devel@nongnu.org; Wed, 14 Jun 2017 04:41:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44732) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dL3s7-0007b0-J3 for qemu-devel@nongnu.org; Wed, 14 Jun 2017 04:41:51 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8FE424E4D3; Wed, 14 Jun 2017 08:41:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8FE424E4D3 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 8FE424E4D3 Received: from sirius.home.kraxel.org (ovpn-116-125.ams2.redhat.com [10.36.116.125]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8118878369; Wed, 14 Jun 2017 08:41:47 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id F213216E34; Wed, 14 Jun 2017 10:41:49 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 14 Jun 2017 10:41:48 +0200 Message-Id: <20170614084149.31314-4-kraxel@redhat.com> In-Reply-To: <20170614084149.31314-1-kraxel@redhat.com> References: <20170614084149.31314-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 14 Jun 2017 08:41:50 +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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Gerd Hoffmann --- include/ui/sdl2.h | 8 ++++++-- ui/sdl2-gl.c | 36 +++++++----------------------------- 2 files changed, 13 insertions(+), 31 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 +#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..dcad3d0d26 100644 --- a/ui/sdl2-gl.c +++ b/ui/sdl2-gl.c @@ -42,14 +42,7 @@ static void sdl2_set_scanout_mode(struct sdl2_console *scon, bool scanout) scon->scanout_mode = 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 = 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 = 0; scon->h = 0; - scon->tex_id = 0; sdl2_set_scanout_mode(scon, false); } @@ -210,48 +202,34 @@ void sdl2_gl_scanout_texture(DisplayChangeListener *dcl, scon->y = y; scon->w = w; scon->h = h; - scon->tex_id = backing_id; scon->y0_top = backing_y_0_top; SDL_GL_MakeCurrent(scon->real_window, scon->winctx); 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); } void sdl2_gl_scanout_flush(DisplayChangeListener *dcl, uint32_t x, uint32_t y, uint32_t w, uint32_t h) { struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl); - int ww, wh, y1, y2; + int ww, wh; assert(scon->opengl); if (!scon->scanout_mode) { return; } - if (!scon->fbo_id) { + if (!scon->guest_fb.framebuffer) { return; } SDL_GL_MakeCurrent(scon->real_window, scon->winctx); - 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 = scon->y0_top ? 0 : scon->h; - y2 = 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); + egl_fb_setup_default(&scon->win_fb, ww, wh); + egl_fb_blit(&scon->win_fb, &scon->guest_fb, !scon->y0_top); SDL_GL_SwapWindow(scon->real_window); }