From nobody Sat Apr 11 23:02:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1772500449; cv=none; d=zohomail.com; s=zohoarc; b=W6tJDCXZnbG97ek3lRzzWxxDOoLGcgIgE44FkPJJx5snys+SKurGSJmOYV0c01HWIC06R7YTqiSvraYfJ9GcsDht2EgTf5eujpRMd+GZ6Cv/IHUGfQ1H1kMKeOoGkAAXg8lm7k+DBuEpq9hjFBN25oTGPAsaWc7bIyQx7REZ2Kc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772500449; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=aUzSY0ntyX3F3QpsHToNRvh0M/XbB6EnT2yStyo21Qo=; b=b55v1NYc0It6nfyTap/8CaLsyX7o7NdfmNFLICt5wywMRn9NauzT+Xx+0YiKQzvihmBlwRyJJP4UJPPIVO/GCdBr8rOCasTeJQ6ZY2OJfMzAYi3a+jIU/cpOPg2ACEIxFTTyqtgthd2WW0FgF1UvG1a/IASSFDXocpojJ/IBcwc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772500448144893.037188699629; Mon, 2 Mar 2026 17:14:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxEKh-000491-6F; Mon, 02 Mar 2026 20:13:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vxEKf-00048n-AP for qemu-devel@nongnu.org; Mon, 02 Mar 2026 20:13:53 -0500 Received: from mgamail.intel.com ([198.175.65.17]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vxEKd-0007kv-Fx for qemu-devel@nongnu.org; Mon, 02 Mar 2026 20:13:53 -0500 Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Mar 2026 17:13:48 -0800 Received: from dongwonk-z390-aorus-ultra.fm.intel.com ([10.105.205.222]) by orviesa004.jf.intel.com with ESMTP; 02 Mar 2026 17:13:48 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1772500432; x=1804036432; h=from:to:subject:date:message-id:mime-version: content-transfer-encoding; bh=dOnnmunbtpt+uAUydZNtyQGOdFuOjFUoe8XXROAhMwE=; b=meCPj2RMRMb61isqKbC37lQuTh9dL3SqJfkEBwUPpQToF5XDrayu9DPa p4Cq00ULkjOHMwILOLtBFD+nlXIs9RZ4PC/yZV0KuVmuSEbJRJeyaq4wT WW/FZRKD6Ia5G+GWVllakGyB3Oy9rp1Fqbx60s8Kcl5B1cgZawjCCz5wr npuKr1XFarrITRkK0SKbgGsxbgJ6SzOK5UGVPMLd1WrLEwqeFORw84Iot u+LrvttD+SnCUGaxRgRkwCJRCzlXomxUGrqSuRz+ChW3psL+d/zNDi1uW oGiuaIqzgqBnDOpnqldW4YZnFtKfw1AMw91Vl3q4b8iKgGp/xAcjX1WKS A==; X-CSE-ConnectionGUID: DhGdmoU9TMWuTGVq3asgyQ== X-CSE-MsgGUID: hYPwU8TlTZSW1YcjRUhi2Q== X-IronPort-AV: E=McAfee;i="6800,10657,11717"; a="73489064" X-IronPort-AV: E=Sophos;i="6.21,321,1763452800"; d="scan'208";a="73489064" X-CSE-ConnectionGUID: FFeYGz28Rp2qaxRW82NjZA== X-CSE-MsgGUID: EWTkv8XPSP6gr8uPSpFwuw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,321,1763452800"; d="scan'208";a="222330570" From: dongwon.kim@intel.com To: qemu-devel@nongnu.org Subject: [PATCH] ui/egl-helpers: Fix FBO recreation and prevent texture accidental deletion Date: Mon, 2 Mar 2026 17:08:44 -0800 Message-Id: <20260303010844.1925737-1-dongwon.kim@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.17; envelope-from=dongwon.kim@intel.com; helo=mgamail.intel.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.968, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.495, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1772500458962139100 From: Dongwon Kim When egl_fb_setup_for_tex is called, we must handle cases where the texture ID is reused across different GL contexts. Texture Preservation - If the new texture ID matches the cached ID, we must skip egl_fb_delete_texture to avoid destroying the texture we are about to use. FBO Recreation - Because FBOs are context-local and not shared, a cached FBO ID from a previous context is invalid. We must generate a new FBO handle if we are re-validating the same texture ID in a potentially new context. This prevents stale FBO usage and unintended texture deletion during context transitions. Cc: Gerd Hoffmann Cc: Marc-Andr=C3=A9 Lureau Signed-off-by: Vivek Kasireddy Signed-off-by: Dongwon Kim --- ui/egl-helpers.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c index e3f2872cc1..7ac64f3ba8 100644 --- a/ui/egl-helpers.c +++ b/ui/egl-helpers.c @@ -111,15 +111,23 @@ void egl_fb_setup_default(egl_fb *fb, int width, int = height, int x, int y) void egl_fb_setup_for_tex(egl_fb *fb, int width, int height, GLuint texture, bool delete) { - egl_fb_delete_texture(fb); + if (fb->texture !=3D texture) { + egl_fb_delete_texture(fb); + } + + /* + * If fb->texture =3D=3D texture, the existing fb->framebuffer is tied= to + * a previous GL context. Since FBOs are not shared across contexts, + * we must create a new FBO for the current context. + */ + if (!fb->framebuffer || (fb->texture =3D=3D texture)) { + glGenFramebuffers(1, &fb->framebuffer); + } =20 fb->width =3D width; fb->height =3D height; fb->texture =3D texture; fb->delete_texture =3D delete; - if (!fb->framebuffer) { - glGenFramebuffers(1, &fb->framebuffer); - } =20 glBindFramebuffer(GL_FRAMEBUFFER_EXT, fb->framebuffer); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, --=20 2.43.0