From patchwork Wed Oct 26 21:14:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 9398337 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 45AD060231 for ; Wed, 26 Oct 2016 21:14:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1255D28878 for ; Wed, 26 Oct 2016 21:14:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0470629DB9; Wed, 26 Oct 2016 21:14:43 +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=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 88CE028878 for ; Wed, 26 Oct 2016 21:14:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E0E846E936; Wed, 26 Oct 2016 21:14:39 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt0-x236.google.com (mail-qt0-x236.google.com [IPv6:2607:f8b0:400d:c0d::236]) by gabe.freedesktop.org (Postfix) with ESMTPS id C6E926E936 for ; Wed, 26 Oct 2016 21:14:38 +0000 (UTC) Received: by mail-qt0-x236.google.com with SMTP id g32so10355949qta.2 for ; Wed, 26 Oct 2016 14:14:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=Yx1Ua3N9ANFYHICMbq19E/BTwa+fHJeIbWHkEzdY21I=; b=ep/12aetV3yTqSBL73FbssSjiFUwg5ezUdoFtsOYO3sfiywoOhkveZwUTc4xgZhoBx /FUTgALJu998MglGY/5BaHCmHenBgsMqaaHFdPVZtHm2/10aNjHkmVjMIRSr6kayvjAS y/QM1kHwuqMdeiifchaGTx1TOekxbfXsoNhw/Ih2+SqH9P5dPrEqyF69b4EUs/1EnWoD NTMAS5xd3DB73ODQqmAZZXSMBhxgkb1lDuemtm+OXAxl2sIhg+DZ1sdtwydr6mInIRHD +FLShyYyweC88aup6NMLceVcbRyT4hBlKxMdF8LI+NatY74JU52j6jI2cNwzlc0CAlIi NeXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Yx1Ua3N9ANFYHICMbq19E/BTwa+fHJeIbWHkEzdY21I=; b=XkWwzj3J2NoQrZPGhVDtsARAOglVWegyiMXmu9WbywX+0wHWE24CMsQyj9g8d9kqa/ u7HAKyL+IjlAKsjxdJxxm3lguzR84kj0vbkRkRednYRJEf+Y9gxaZ8G99/2JvClRgEx4 mA2nEJ/SbBT/vf6zfybRVkik2DqAkG72jPtDa4NnIVFjUjQgiPQNb5UrB+LIlAYe/NJ9 1qKcSSjGDjl4/EXW/IFWyk3jOPTsIYW1+7cxnR/YVsglK8A1gDDJqmPsIB/f20MT6M+Q 3zs54z5DAlOGEkMywigAvqtS3T4V09KolRV/3xNlMjk6Nezfq0rbve/L6gIutbUa1587 PQJg== X-Gm-Message-State: ABUngvcn/sRT1agrxmwZPV+Jy5BohLDZJBGMRSWEINRAP+kNERTjkYwl3vJmBPaKmWWVtw== X-Received: by 10.200.55.213 with SMTP id e21mr3117173qtc.106.1477516477933; Wed, 26 Oct 2016 14:14:37 -0700 (PDT) Received: from localhost ([2601:184:4002:8340:4bc4:6936:53db:a239]) by smtp.gmail.com with ESMTPSA id v41sm1943786qta.29.2016.10.26.14.14.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Oct 2016 14:14:37 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Subject: [RFC] mesa: drop current draw/read buffer when ctx is released Date: Wed, 26 Oct 2016 17:14:15 -0400 Message-Id: <1477516470-2042-1-git-send-email-robdclark@gmail.com> X-Mailer: git-send-email 2.7.4 Cc: Emil Velikov , Gurchetan Singh , Brian Paul , =?UTF-8?q?Mikl=C3=B3s=20M=C3=A1t=C3=A9?= , Timothy Arceri X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP So, not quite sure if this is the *correct* solution, but it is at least *a* solution to a problem with android wallpaper vs mesa that I've been debugging. Basically, what happens is: EGLSurface tmpSurface = mEgl.eglCreatePbufferSurface(mEglDisplay, mEglConfig, attribs); mEgl.eglMakeCurrent(mEglDisplay, tmpSurface, tmpSurface, mEglContext); int[] maxSize = new int[1]; Rect frame = surfaceHolder.getSurfaceFrame(); glGetIntegerv(GL_MAX_TEXTURE_SIZE, maxSize, 0); mEgl.eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); mEgl.eglDestroySurface(mEglDisplay, tmpSurface); ... check maxSize vs frame size and bail if needed ... mEglSurface = mEgl.eglCreateWindowSurface(mEglDisplay, mEglConfig, surfaceHolder, null); ... error checking ... mEgl.eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface, mEglContext); When the window-surface is created, it ends up with the same ptr address as the recently freed tmpSurface pbuffer surface. Which after many levels of indirection, results in st_framebuffer_validate() ending up with the same/old framebuffer object, and in the end never calling the DRIimageLoaderExtension::getBuffers(). Then in droid_swap_buffers(), the dri2_surf is still the old pbuffer surface (with dri2_surf->buffer being NULL, obviously, so when wallpaper app calls eglSwapBuffers() nothing gets enqueued to the compositor). Maybe instead, eglDestroySurface() should clear any references the ctx has to the surface. Not sure how that would work. Did I mention there are many levels of indirection? --- src/mesa/main/context.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 5e52065..83b8cc1 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1646,6 +1646,10 @@ ALOGE("%s:%d, drawBuffer=%p, readBuffer=%p", __func__, __LINE__, drawBuffer, rea if (!newCtx) { _glapi_set_dispatch(NULL); /* none current */ + if (curCtx) { + _mesa_reference_framebuffer(&curCtx->WinSysDrawBuffer, NULL); + _mesa_reference_framebuffer(&curCtx->WinSysReadBuffer, NULL); + } } else { _glapi_set_dispatch(newCtx->CurrentDispatch);