From nobody Fri May 3 23:56:48 2024 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.zohomail.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 1506513170000935.2609834326773; Wed, 27 Sep 2017 04:52:50 -0700 (PDT) Received: from localhost ([::1]:54189 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxAtQ-0007Qs-30 for importer@patchew.org; Wed, 27 Sep 2017 07:52:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60685) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxArN-0006Mw-M1 for qemu-devel@nongnu.org; Wed, 27 Sep 2017 07:50:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxArM-0000eU-6c for qemu-devel@nongnu.org; Wed, 27 Sep 2017 07:50:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34488) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxArL-0000dv-Po for qemu-devel@nongnu.org; Wed, 27 Sep 2017 07:50:36 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BC24E81E00 for ; Wed, 27 Sep 2017 11:50:34 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-102.ams2.redhat.com [10.36.116.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2EF9A7F499; Wed, 27 Sep 2017 11:50:32 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 5C6506DB; Wed, 27 Sep 2017 13:50:31 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BC24E81E00 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 27 Sep 2017 13:50:31 +0200 Message-Id: <20170927115031.12063-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 27 Sep 2017 11:50:34 +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] egl: misc framebuffer helper improvements. 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" Rename the functions to to say "setup" instead of "create" because they support being called multiple times on the same egl framebuffer. Properly delete unused textures, update function interfaces to support this. Signed-off-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/ui/egl-helpers.h | 5 +++-- ui/egl-headless.c | 6 +++--- ui/egl-helpers.c | 26 ++++++++++++++++++-------- ui/gtk-egl.c | 4 ++-- ui/gtk-gl-area.c | 4 ++-- ui/sdl2-gl.c | 4 ++-- 6 files changed, 30 insertions(+), 19 deletions(-) diff --git a/include/ui/egl-helpers.h b/include/ui/egl-helpers.h index be8908737c..81cb255de0 100644 --- a/include/ui/egl-helpers.h +++ b/include/ui/egl-helpers.h @@ -18,8 +18,9 @@ typedef struct egl_fb { =20 void egl_fb_destroy(egl_fb *fb); void egl_fb_setup_default(egl_fb *fb, int width, int height); -void egl_fb_create_for_tex(egl_fb *fb, int width, int height, GLuint textu= re); -void egl_fb_create_new_tex(egl_fb *fb, int width, int height); +void egl_fb_setup_for_tex(egl_fb *fb, int width, int height, + GLuint texture, bool delete); +void egl_fb_setup_new_tex(egl_fb *fb, int width, int height); void egl_fb_blit(egl_fb *dst, egl_fb *src, bool flip); void egl_fb_read(void *dst, egl_fb *src); =20 diff --git a/ui/egl-headless.c b/ui/egl-headless.c index 809bfde99c..12ad64e995 100644 --- a/ui/egl-headless.c +++ b/ui/egl-headless.c @@ -54,14 +54,14 @@ static void egl_scanout_texture(DisplayChangeListener *= dcl, edpy->y_0_top =3D backing_y_0_top; =20 /* source framebuffer */ - egl_fb_create_for_tex(&edpy->guest_fb, - backing_width, backing_height, backing_id); + egl_fb_setup_for_tex(&edpy->guest_fb, + backing_width, backing_height, backing_id, false); =20 /* dest framebuffer */ if (edpy->blit_fb.width !=3D backing_width || edpy->blit_fb.height !=3D backing_height) { egl_fb_destroy(&edpy->blit_fb); - egl_fb_create_new_tex(&edpy->blit_fb, backing_width, backing_heigh= t); + egl_fb_setup_new_tex(&edpy->blit_fb, backing_width, backing_height= ); } } =20 diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c index bb19a5eeca..cde9965dea 100644 --- a/ui/egl-helpers.c +++ b/ui/egl-helpers.c @@ -26,16 +26,23 @@ EGLConfig qemu_egl_config; =20 /* ------------------------------------------------------------------ */ =20 +static void egl_fb_delete_texture(egl_fb *fb) +{ + if (!fb->delete_texture) { + return; + } + + glDeleteTextures(1, &fb->texture); + fb->delete_texture =3D false; +} + void egl_fb_destroy(egl_fb *fb) { if (!fb->framebuffer) { return; } =20 - if (fb->delete_texture) { - glDeleteTextures(1, &fb->texture); - fb->delete_texture =3D false; - } + egl_fb_delete_texture(fb); glDeleteFramebuffers(1, &fb->framebuffer); =20 fb->width =3D 0; @@ -51,11 +58,15 @@ void egl_fb_setup_default(egl_fb *fb, int width, int he= ight) fb->framebuffer =3D 0; /* default framebuffer */ } =20 -void egl_fb_create_for_tex(egl_fb *fb, int width, int height, GLuint textu= re) +void egl_fb_setup_for_tex(egl_fb *fb, int width, int height, + GLuint texture, bool delete) { + egl_fb_delete_texture(fb); + fb->width =3D width; fb->height =3D height; fb->texture =3D texture; + fb->delete_texture =3D delete; if (!fb->framebuffer) { glGenFramebuffers(1, &fb->framebuffer); } @@ -65,7 +76,7 @@ void egl_fb_create_for_tex(egl_fb *fb, int width, int hei= ght, GLuint texture) GL_TEXTURE_2D, fb->texture, 0); } =20 -void egl_fb_create_new_tex(egl_fb *fb, int width, int height) +void egl_fb_setup_new_tex(egl_fb *fb, int width, int height) { GLuint texture; =20 @@ -74,8 +85,7 @@ void egl_fb_create_new_tex(egl_fb *fb, int width, int hei= ght) glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, 0); =20 - egl_fb_create_for_tex(fb, width, height, texture); - fb->delete_texture =3D true; + egl_fb_setup_for_tex(fb, width, height, texture, true); } =20 void egl_fb_blit(egl_fb *dst, egl_fb *src, bool flip) diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c index 0d5cab2bc8..0f0d35e041 100644 --- a/ui/gtk-egl.c +++ b/ui/gtk-egl.c @@ -190,8 +190,8 @@ void gd_egl_scanout_texture(DisplayChangeListener *dcl, vc->gfx.esurface, vc->gfx.ectx); =20 gtk_egl_set_scanout_mode(vc, true); - egl_fb_create_for_tex(&vc->gfx.guest_fb, backing_width, backing_height, - backing_id); + egl_fb_setup_for_tex(&vc->gfx.guest_fb, backing_width, backing_height, + backing_id, false); } =20 void gd_egl_scanout_flush(DisplayChangeListener *dcl, diff --git a/ui/gtk-gl-area.c b/ui/gtk-gl-area.c index 18b298fc21..01ebf2c7de 100644 --- a/ui/gtk-gl-area.c +++ b/ui/gtk-gl-area.c @@ -185,8 +185,8 @@ void gd_gl_area_scanout_texture(DisplayChangeListener *= dcl, } =20 gtk_gl_area_set_scanout_mode(vc, true); - egl_fb_create_for_tex(&vc->gfx.guest_fb, backing_width, backing_height, - backing_id); + egl_fb_setup_for_tex(&vc->gfx.guest_fb, backing_width, backing_height, + backing_id, false); } =20 void gd_gl_area_scanout_flush(DisplayChangeListener *dcl, diff --git a/ui/sdl2-gl.c b/ui/sdl2-gl.c index dcad3d0d26..9110491ee5 100644 --- a/ui/sdl2-gl.c +++ b/ui/sdl2-gl.c @@ -207,8 +207,8 @@ void sdl2_gl_scanout_texture(DisplayChangeListener *dcl, SDL_GL_MakeCurrent(scon->real_window, scon->winctx); =20 sdl2_set_scanout_mode(scon, true); - egl_fb_create_for_tex(&scon->guest_fb, backing_width, backing_height, - backing_id); + egl_fb_setup_for_tex(&scon->guest_fb, backing_width, backing_height, + backing_id, false); } =20 void sdl2_gl_scanout_flush(DisplayChangeListener *dcl, --=20 2.9.3