From patchwork Wed Jul 20 09:35:37 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: alexandros.frantzis@linaro.org X-Patchwork-Id: 2784 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 41DB723F42 for ; Wed, 20 Jul 2011 09:35:41 +0000 (UTC) Received: from mail-qy0-f173.google.com (mail-qy0-f173.google.com [209.85.216.173]) by fiordland.canonical.com (Postfix) with ESMTP id EB3EFA18236 for ; Wed, 20 Jul 2011 09:35:40 +0000 (UTC) Received: by qyk10 with SMTP id 10so3145701qyk.11 for ; Wed, 20 Jul 2011 02:35:40 -0700 (PDT) Received: by 10.229.25.212 with SMTP id a20mr6887289qcc.148.1311154540347; Wed, 20 Jul 2011 02:35:40 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.229.217.78 with SMTP id hl14cs108984qcb; Wed, 20 Jul 2011 02:35:40 -0700 (PDT) Received: by 10.227.208.208 with SMTP id gd16mr3197662wbb.34.1311154539024; Wed, 20 Jul 2011 02:35:39 -0700 (PDT) Received: from adelie.canonical.com (adelie.canonical.com [91.189.90.139]) by mx.google.com with ESMTP id d17si73481wbh.82.2011.07.20.02.35.38; Wed, 20 Jul 2011 02:35:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.139 as permitted sender) client-ip=91.189.90.139; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.139 as permitted sender) smtp.mail=bounces@canonical.com Received: from loganberry.canonical.com ([91.189.90.37]) by adelie.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1QjTBp-0005iQ-SV for ; Wed, 20 Jul 2011 09:35:37 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id D5EE32E8029 for ; Wed, 20 Jul 2011 09:35:37 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: glcompbench X-Launchpad-Branch: ~glcompbench-dev/glcompbench/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 52 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~glcompbench-dev/glcompbench/trunk] Rev 52: Handle GLX TFP in a more spec-conformant manner. Message-Id: <20110720093537.11752.18168.launchpad@loganberry.canonical.com> Date: Wed, 20 Jul 2011 09:35:37 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="13468"; Instance="initZopeless config overlay" X-Launchpad-Hash: 343046b529ab10fc7af1b93d93fd2e22523b0479 Merge authors: Alexandros Frantzis (afrantzis) Jesse Barker (jesse-barker) ------------------------------------------------------------ revno: 52 [merge] committer: Alexandros Frantzis branch nick: trunk timestamp: Wed 2011-07-20 12:17:11 +0300 message: Handle GLX TFP in a more spec-conformant manner. This allows glcompbench to work with nvidia drivers. modified: src/composite-canvas-glx.cc src/composite-window-glxpixmap.cc src/composite-window-glxpixmap.h --- lp:glcompbench https://code.launchpad.net/~glcompbench-dev/glcompbench/trunk You are subscribed to branch lp:glcompbench. To unsubscribe from this branch go to https://code.launchpad.net/~glcompbench-dev/glcompbench/trunk/+edit-subscription === modified file 'src/composite-canvas-glx.cc' --- src/composite-canvas-glx.cc 2011-07-15 13:01:34 +0000 +++ src/composite-canvas-glx.cc 2011-07-19 21:34:08 +0000 @@ -34,6 +34,7 @@ #include "log.h" PFNGLXBINDTEXIMAGEEXTPROC glXBindTexImageEXT_; +PFNGLXRELEASETEXIMAGEEXTPROC glXReleaseTexImageEXT_; PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT_; PFNGLXSWAPINTERVALMESAPROC glXSwapIntervalMESA_; @@ -73,9 +74,12 @@ glXBindTexImageEXT_ = reinterpret_cast( glXGetProcAddress((const GLubyte *)"glXBindTexImageEXT")); + glXReleaseTexImageEXT_ = + reinterpret_cast( + glXGetProcAddress((const GLubyte *)"glXReleaseTexImageEXT")); } - if (!glXBindTexImageEXT_) { + if (!glXBindTexImageEXT_ || !glXReleaseTexImageEXT_) { Log::info("** GLX does not support GLX_EXT_texture_from_pixmap!\n"); } @@ -117,6 +121,8 @@ GLX_ALPHA_SIZE, 1, GLX_DEPTH_SIZE, 1, GLX_DOUBLEBUFFER, True, + GLX_BIND_TO_TEXTURE_RGBA_EXT, True, + GLX_BIND_TO_TEXTURE_TARGETS_EXT, GLX_TEXTURE_2D_BIT_EXT, None }; int num_configs; === modified file 'src/composite-window-glxpixmap.cc' --- src/composite-window-glxpixmap.cc 2011-04-04 12:56:06 +0000 +++ src/composite-window-glxpixmap.cc 2011-07-20 09:17:11 +0000 @@ -32,11 +32,23 @@ #include "log.h" extern PFNGLXBINDTEXIMAGEEXTPROC glXBindTexImageEXT_; +extern PFNGLXRELEASETEXIMAGEEXTPROC glXReleaseTexImageEXT_; -CompositeWindowGLXPixmap::~CompositeWindowGLXPixmap() +void +CompositeWindowGLXPixmap::release_tfp() { if (glx_pixmap_) + { + glXReleaseTexImageEXT_(xdpy_, glx_pixmap_, GLX_FRONT_LEFT_EXT); glXDestroyPixmap(xdpy_, glx_pixmap_); + glx_pixmap_ = 0; + glx_pixmap_bound_ = false; + } +} + +CompositeWindowGLXPixmap::~CompositeWindowGLXPixmap() +{ + release_tfp(); } void @@ -51,10 +63,7 @@ Profiler::ScopedSamples scoped_tfp(CompositeWindow::get_profiler_tfp_pair()); if (recreate) { - if (glx_pixmap_) { - glXDestroyPixmap(xdpy_, glx_pixmap_); - glx_pixmap_ = 0; - } + release_tfp(); glx_pixmap_ = glXCreatePixmap(xdpy_, glx_fbconfig_, pix_, pixmap_attribs); @@ -64,7 +73,40 @@ /* Update texture with new data */ glXWaitX(); + /* + * According to the spec, proper TFP usage is: + * + * while(1) { + * glXWaitX(); + * glXBindTexImageEXT(); + * + * glXReleaseTexImageEXT(); + * } + * + * we are using: + * + * while(1) { + * glXWaitX(); + * if (bound) glXReleaseTexImageEXT(); + * glxBindTexImageEXT(); + * + * } + * + * The only potential problem here is that rendering to a pixmap bound to a + * texture leaves the contents of the texture in an undefined state + * (according to the spec). We are not performing any explicit pixmap + * rendering, but we do get implicit pixmap changes due to window + * redirection. It is not clear if these changes should affect the texture. + * + * In any case, both compiz and cogl/clutter handle TFP this + * way, so it seems to be safe for now for all drivers. + */ glBindTexture(GL_TEXTURE_2D, tex_); + if (glx_pixmap_bound_) + glXReleaseTexImageEXT_(xdpy_, glx_pixmap_, GLX_FRONT_LEFT_EXT); + glXBindTexImageEXT_(xdpy_, glx_pixmap_, GLX_FRONT_LEFT_EXT, NULL); + + glx_pixmap_bound_ = true; } === modified file 'src/composite-window-glxpixmap.h' --- src/composite-window-glxpixmap.h 2011-07-15 08:16:54 +0000 +++ src/composite-window-glxpixmap.h 2011-07-20 08:23:33 +0000 @@ -34,14 +34,16 @@ CompositeWindowGLXPixmap(Display *xdpy, Window win, GLXFBConfig glx_fbconfig) : CompositeWindowGL(xdpy, win), glx_pixmap_(0), - glx_fbconfig_ (glx_fbconfig) {} + glx_fbconfig_ (glx_fbconfig), glx_pixmap_bound_(false) {} ~CompositeWindowGLXPixmap(); void update_texture_from_pixmap(bool recreate); private: + void release_tfp(); GLXPixmap glx_pixmap_; GLXFBConfig glx_fbconfig_; + bool glx_pixmap_bound_; }; #endif /* COMPOSITE_WINDOW_GLXPIXMAP_H */