From patchwork Tue Dec 13 11:50:17 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Ordinas i Llopis X-Patchwork-Id: 5630 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 291D223E16 for ; Tue, 13 Dec 2011 11:50:20 +0000 (UTC) Received: from mail-bw0-f52.google.com (mail-bw0-f52.google.com [209.85.214.52]) by fiordland.canonical.com (Postfix) with ESMTP id 00940A18069 for ; Tue, 13 Dec 2011 11:50:19 +0000 (UTC) Received: by bke17 with SMTP id 17so9039146bke.11 for ; Tue, 13 Dec 2011 03:50:19 -0800 (PST) Received: by 10.204.152.138 with SMTP id g10mr10618699bkw.36.1323777019651; Tue, 13 Dec 2011 03:50:19 -0800 (PST) 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.205.129.2 with SMTP id hg2cs78109bkc; Tue, 13 Dec 2011 03:50:19 -0800 (PST) Received: by 10.204.156.135 with SMTP id x7mr5173731bkw.138.1323777018319; Tue, 13 Dec 2011 03:50:18 -0800 (PST) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id y43si11473658eea.205.2011.12.13.03.50.18 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 13 Dec 2011 03:50:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) client-ip=91.189.90.7; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) smtp.mail=bounces@canonical.com Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1RaQsD-0008Tk-Sb for ; Tue, 13 Dec 2011 11:50:17 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id CBD82E0436 for ; Tue, 13 Dec 2011 11:50:17 +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: 69 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~glcompbench-dev/glcompbench/trunk] Rev 69: glproxy: Added new flavor that uses glproxy to access the selected Message-Id: <20111213115017.29337.37216.launchpad@ackee.canonical.com> Date: Tue, 13 Dec 2011 11:50:17 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="14487"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: e83655640746cf2c63fc7eb335bb3bc395a76fc3 Merge authors: Marc Ordinas i Llopis (marcoil) Related merge proposals: https://code.launchpad.net/~marcoil/glcompbench/glproxy-flavor/+merge/85158 proposed by: Marc Ordinas i Llopis (marcoil) review: Approve - Alexandros Frantzis (afrantzis) ------------------------------------------------------------ revno: 69 [merge] committer: Marc Ordinas i Llopis branch nick: trunk timestamp: Tue 2011-12-13 12:42:28 +0100 message: glproxy: Added new flavor that uses glproxy to access the selected backend. Options: Added a --backend option to select which backend (glx, egl-gl, egl-es2) to use. The available values depend on the executable's flavor. modified: src/composite-canvas-egl.cc src/composite-canvas-egl.h src/composite-canvas-glx.cc src/composite-canvas-glx.h src/composite-window-eglimage.cc src/composite-window-eglimage.h src/composite-window-glxpixmap.cc src/composite-window-glxpixmap.h src/gl-headers.h src/glcompbench.cc src/options.cc src/options.h src/wscript_build wscript --- 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-egl.cc' --- src/composite-canvas-egl.cc 2011-07-15 13:01:34 +0000 +++ src/composite-canvas-egl.cc 2011-12-12 13:16:47 +0000 @@ -19,6 +19,7 @@ * Authors: * Alexandros Frantzis * Jesse Barker + * Marc Ordinas i Llopis, Collabora Ltd */ #include @@ -26,9 +27,13 @@ #include "gl-headers.h" +#ifdef USE_GLPROXY +#include +#include +#else #include #include - +#endif #include "composite-canvas-egl.h" #include "composite-window-eglimage.h" #include "composite-window-ximage.h" @@ -37,6 +42,9 @@ PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR_; PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR_; +#ifdef USE_GLPROXY +typedef PFNPROXYEGLIMAGETARGETTEXTURE2DOESPROC PFNGLEGLIMAGETARGETTEXTURE2DOESPROC; +#endif PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES_; bool @@ -119,11 +127,7 @@ EGL_BLUE_SIZE, 1, EGL_ALPHA_SIZE, 1, EGL_DEPTH_SIZE, 1, -#ifdef USE_GLES2 - EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, -#elif USE_GL - EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT, -#endif + EGL_RENDERABLE_TYPE, Options::backend == Options::BACKEND_EGL_GL? EGL_OPENGL_BIT : EGL_OPENGL_ES2_BIT, EGL_NONE }; EGLint num_configs; @@ -161,12 +165,14 @@ bool CompositeCanvasEGL::ensure_egl_surface() { - static const EGLint ctx_attribs[] = { -#ifdef USE_GLES2 - EGL_CONTEXT_CLIENT_VERSION, 2, -#endif - EGL_NONE - }; + EGLint ctx_attribs[3]; + if (Options::backend == Options::BACKEND_EGL_ES2) { + ctx_attribs[0] = EGL_CONTEXT_CLIENT_VERSION; + ctx_attribs[1] = 2; + ctx_attribs[2] = EGL_NONE; + } else { + ctx_attribs[0] = EGL_NONE; + } if (egl_surface_) return true; @@ -174,11 +180,10 @@ if (!ensure_egl_display()) return false; -#ifdef USE_GLES2 - eglBindAPI(EGL_OPENGL_ES_API); -#elif USE_GL - eglBindAPI(EGL_OPENGL_API); -#endif + if (Options::backend == Options::BACKEND_EGL_GL) + eglBindAPI(EGL_OPENGL_API); + else + eglBindAPI(EGL_OPENGL_ES_API); egl_context_ = eglCreateContext(egl_display_, egl_config_, EGL_NO_CONTEXT, ctx_attribs); === modified file 'src/composite-canvas-egl.h' --- src/composite-canvas-egl.h 2011-07-15 13:01:34 +0000 +++ src/composite-canvas-egl.h 2011-12-09 16:09:11 +0000 @@ -19,12 +19,17 @@ * Authors: * Alexandros Frantzis * Jesse Barker + * Marc Ordinas i Llopis, Collabora Ltd */ #ifndef COMPOSITE_CANVAS_EGL_H_ #define COMPOSITE_CANVAS_EGL_H_ +#ifdef USE_GLPROXY +#include +#else #include +#endif #include "composite-canvas.h" class CompositeCanvasEGL: public CompositeCanvas === modified file 'src/composite-canvas-glx.cc' --- src/composite-canvas-glx.cc 2011-07-19 21:34:08 +0000 +++ src/composite-canvas-glx.cc 2011-12-09 16:09:11 +0000 @@ -19,13 +19,19 @@ * Authors: * Alexandros Frantzis * Jesse Barker + * Marc Ordinas i Llopis, Collabora Ltd */ #include #include -#include +#include "gl-headers.h" +#ifdef USE_GLPROXY +#include +#include +#else #include +#endif #include "composite-canvas-glx.h" #include "composite-window-glxpixmap.h" @@ -33,11 +39,19 @@ #include "options.h" #include "log.h" +#ifdef USE_GLPROXY +// NOTE: This is necessary because glproxy names these typedefs differently. +typedef PFNPROXYBINDTEXIMAGEEXTPROC PFNGLXBINDTEXIMAGEEXTPROC; +typedef PFNPROXYRELEASETEXIMAGEEXTPROC PFNGLXRELEASETEXIMAGEEXTPROC; +typedef PFNPROXYSWAPINTERVALEXTPROC PFNGLXSWAPINTERVALEXTPROC; +typedef PFNPROXYSWAPINTERVALMESAPROC PFNGLXSWAPINTERVALMESAPROC; +#endif PFNGLXBINDTEXIMAGEEXTPROC glXBindTexImageEXT_; PFNGLXRELEASETEXIMAGEEXTPROC glXReleaseTexImageEXT_; PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT_; PFNGLXSWAPINTERVALMESAPROC glXSwapIntervalMESA_; + bool CompositeCanvasGLX::check_glx_version() { === modified file 'src/composite-canvas-glx.h' --- src/composite-canvas-glx.h 2011-07-15 13:01:34 +0000 +++ src/composite-canvas-glx.h 2011-12-09 16:09:11 +0000 @@ -19,12 +19,17 @@ * Authors: * Alexandros Frantzis * Jesse Barker + * Marc Ordinas i Llopis, Collabora Ltd */ #ifndef COMPOSITE_CANVAS_GLX_H_ #define COMPOSITE_CANVAS_GLX_H_ +#ifdef USE_GLPROXY +#include +#else #include +#endif #include "composite-canvas.h" class CompositeCanvasGLX: public CompositeCanvas === modified file 'src/composite-window-eglimage.cc' --- src/composite-window-eglimage.cc 2011-08-03 14:34:10 +0000 +++ src/composite-window-eglimage.cc 2011-12-09 16:09:11 +0000 @@ -19,21 +19,31 @@ * Authors: * Alexandros Frantzis * Jesse Barker + * Marc Ordinas i Llopis, Collabora Ltd */ #include #include "gl-headers.h" +#ifdef USE_GLPROXY +#include +#include +#else #include #include +#endif #include "composite-window-eglimage.h" #include "log.h" extern PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR_; extern PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR_; +#ifdef USE_GLPROXY +extern PFNPROXYEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES_; +#else extern PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES_; +#endif CompositeWindowEGLImage::~CompositeWindowEGLImage() { === modified file 'src/composite-window-eglimage.h' --- src/composite-window-eglimage.h 2011-08-03 14:34:10 +0000 +++ src/composite-window-eglimage.h 2011-12-09 16:09:11 +0000 @@ -19,6 +19,7 @@ * Authors: * Alexandros Frantzis * Jesse Barker + * Marc Ordinas i Llopis, Collabora Ltd */ #ifndef COMPOSITE_WINDOW_EGLIMAGE_H_ @@ -26,8 +27,13 @@ #include #include "gl-headers.h" +#ifdef USE_GLPROXY +#include +#include +#else #include #include +#endif #include "composite-window-gl.h" class CompositeWindowEGLImage : public CompositeWindowGL === modified file 'src/composite-window-glxpixmap.cc' --- src/composite-window-glxpixmap.cc 2011-08-03 14:34:10 +0000 +++ src/composite-window-glxpixmap.cc 2011-12-09 16:09:11 +0000 @@ -19,20 +19,32 @@ * Authors: * Alexandros Frantzis * Jesse Barker + * Marc Ordinas i Llopis, Collabora Ltd */ #include +#include "gl-headers.h" + +#ifdef USE_GLPROXY +#include +#include +#else #define GLX_GLXEXT_PROTOTYPES -#include #include #include +#endif #include "composite-window-glxpixmap.h" #include "log.h" +#ifdef USE_GLPROXY +extern PFNPROXYBINDTEXIMAGEEXTPROC glXBindTexImageEXT_; +extern PFNPROXYRELEASETEXIMAGEEXTPROC glXReleaseTexImageEXT_; +#else extern PFNGLXBINDTEXIMAGEEXTPROC glXBindTexImageEXT_; extern PFNGLXRELEASETEXIMAGEEXTPROC glXReleaseTexImageEXT_; +#endif void CompositeWindowGLXPixmap::release_tfp() === modified file 'src/composite-window-glxpixmap.h' --- src/composite-window-glxpixmap.h 2011-08-03 14:34:10 +0000 +++ src/composite-window-glxpixmap.h 2011-12-09 16:09:11 +0000 @@ -19,13 +19,18 @@ * Authors: * Alexandros Frantzis * Jesse Barker + * Marc Ordinas i Llopis, Collabora Ltd */ #ifndef COMPOSITE_WINDOW_GLXPIXMAP_H_ #define COMPOSITE_WINDOW_GLXPIXMAP_H_ #include +#ifdef USE_GLPROXY +#include +#else #include +#endif #include "composite-window-gl.h" class CompositeWindowGLXPixmap : public CompositeWindowGL === modified file 'src/gl-headers.h' --- src/gl-headers.h 2011-02-07 18:35:50 +0000 +++ src/gl-headers.h 2011-12-09 16:09:11 +0000 @@ -19,11 +19,17 @@ * Authors: * Alexandros Frantzis * Jesse Barker + * Marc Ordinas i Llopis, Collabora Ltd */ #ifndef GL_HEADERS_H_ #define GL_HEADERS_H_ +#ifdef USE_GLPROXY +#include +#include +#else + #ifdef USE_GL #define GL_GLEXT_PROTOTYPES #include @@ -33,4 +39,6 @@ #include #endif +#endif // USE_GLPROXY + #endif /* GL_HEADERS_H_ */ === modified file 'src/glcompbench.cc' --- src/glcompbench.cc 2011-10-13 22:48:52 +0000 +++ src/glcompbench.cc 2011-12-12 13:16:47 +0000 @@ -19,13 +19,18 @@ * Authors: * Alexandros Frantzis * Jesse Barker + * Marc Ordinas i Llopis, Collabora Ltd */ #include +#ifdef USE_GLPROXY +#include +#endif #ifdef USE_EGL #include "composite-canvas-egl.h" -#elif USE_GLX +#endif +#if USE_GLX #include "composite-canvas-glx.h" #endif #include "composite-canvas-pixman.h" @@ -140,22 +145,42 @@ canvas_list.push_back(new CompositeCanvasPixman()); canvas_list.push_back(new CompositeCanvasXRender()); + if (!Options::parse_args(argc, argv)) + return 1; + + if (Options::show_help || + Options::backend == Options::BACKEND_NONE) { + Options::print_help(); + return 0; + } + +#ifdef USE_GLPROXY + // Initialize the proxy library and create the correct GL canvas + PROXY_BACKEND_OPTION backend = UNKNOWN_BACKEND; + if (Options::backend == Options::BACKEND_GLX) { + backend = OPENGL_BACKEND; + glProxyInit(&backend); + + canvas_list.push_back(new CompositeCanvasGLX()); + } else if (Options::backend == Options::BACKEND_EGL_ES2) { + backend = OPENGL_ES20_BACKEND; + glProxyInit(&backend); + + canvas_list.push_back(new CompositeCanvasEGL()); + } else { + Options::print_help(); + return 0; + } +#else // USE_GLPROXY #ifdef USE_EGL canvas_list.push_back(new CompositeCanvasEGL()); #elif USE_GLX canvas_list.push_back(new CompositeCanvasGLX()); #endif +#endif // USE_GLPROXY std::list benchmarks; - if (!Options::parse_args(argc, argv)) - return 1; - - if (Options::show_help) { - Options::print_help(); - return 0; - } - Benchmark::register_test(*new CompositeTestDefaultOptions()); Benchmark::register_test(*new CompositeTestSimpleDefault()); Benchmark::register_test(*new CompositeTestSimpleFade()); === modified file 'src/options.cc' --- src/options.cc 2011-06-24 13:44:02 +0000 +++ src/options.cc 2011-12-12 13:16:47 +0000 @@ -19,6 +19,7 @@ * Authors: * Alexandros Frantzis * Jesse Barker + * Marc Ordinas i Llopis, Collabora Ltd */ #include @@ -42,6 +43,15 @@ bool Options::show_help = false; bool Options::list_tests = false; bool Options::swap_buffers = true; +#ifdef USE_GLPROXY +Options::Backends Options::backend = BACKEND_EGL_ES2; +#elif defined(USE_GLX) +Options::Backends Options::backend = BACKEND_GLX; +#elif defined(USE_EGL) && defined(USE_GL) +Options::Backends Options::backend = BACKEND_EGL_GL; +#elif defined(USE_EGL) && defined(USE_GLES2) +Options::Backends Options::backend = BACKEND_EGL_ES2; +#endif static struct option long_options[] = { {"ids", 1, 0, 0}, @@ -57,9 +67,22 @@ {"no-swap-buffers", 0, 0, 0}, {"debug", 0, 0, 0}, {"help", 0, 0, 0}, + {"backend", 1, 0, 0}, {0, 0, 0, 0} }; +#ifdef USE_GLPROXY +static const char *available_backends = "glx, egl-es2"; +#elif defined(USE_GLX) +static const char *available_backends = "glx"; +#elif defined(USE_EGL) && defined(USE_GL) +static const char *available_backends = "egl-gl"; +#elif defined(USE_EGL) && defined(USE_GLES2) +static const char *available_backends = "egl-es2"; +#else +static const char *available_backends = ""; +#endif + static void parse_window_ids(const char *str, std::list &list) { @@ -74,6 +97,22 @@ } } +static Options::Backends +parse_backend(const char *str) +{ + if (!strstr(available_backends, str)) + return Options::BACKEND_NONE; + + if (!strcmp("glx", str)) + return Options::BACKEND_GLX; + else if (!strcmp("egl-gl", str)) + return Options::BACKEND_EGL_GL; + else if (!strcmp("egl-es2", str)) + return Options::BACKEND_EGL_ES2; + + return Options::BACKEND_NONE; +} + void Options::print_help() { @@ -95,8 +134,10 @@ " -l, --list-tests List the avalaible tests and their options\n" " --no-swap-buffers Don't update the screen by swapping the front and\n" " back buffer, use glFinish() instead\n" + " --backend The OpenGL backend to use (%s)\n" " -d, --debug Display debug messages\n" - " -h, --help Display help\n"); + " -h, --help Display help\n", + available_backends); } bool @@ -143,6 +184,8 @@ Options::show_debug = true; else if (c == 'h' || !strcmp(optname, "help")) Options::show_help = true; + else if (!strcmp(optname, "backend")) + Options::backend = parse_backend(optarg); } return true; === modified file 'src/options.h' --- src/options.h 2011-06-23 13:32:36 +0000 +++ src/options.h 2011-12-12 13:16:47 +0000 @@ -19,6 +19,7 @@ * Authors: * Alexandros Frantzis * Jesse Barker + * Marc Ordinas i Llopis, Collabora Ltd */ #ifndef OPTIONS_H_ @@ -45,6 +46,14 @@ static bool show_help; static bool list_tests; static bool swap_buffers; + + typedef enum { + BACKEND_NONE, + BACKEND_GLX, + BACKEND_EGL_GL, + BACKEND_EGL_ES2 + } Backends; + static Backends backend; }; #endif /* OPTIONS_H_ */ === modified file 'src/wscript_build' --- src/wscript_build 2011-08-03 17:03:48 +0000 +++ src/wscript_build 2011-12-12 13:18:23 +0000 @@ -8,6 +8,7 @@ common_libs = ['x11', 'xdamage', 'xcomposite', 'pixman', 'xext', 'xrender'] +# libmatrix if bld.env.BUILD_EGL_GL or bld.env.BUILD_GLX: bld( features = ['cxx', 'cxxstlib'], @@ -30,6 +31,18 @@ export_includes = 'libmatrix' ) +if bld.env.BUILD_GLPROXY: + bld( + features = ['cxx', 'cxxstlib'], + source = bld.path.ant_glob('libmatrix/*.cc'), + target = 'matrix-glproxy', + lib = ['m'], + includes = ['.'], + defines = ['USE_GLPROXY'], + export_includes = 'libmatrix' + ) + +# glcompbench if bld.env.BUILD_EGL_GL: bld( features = ['cxx', 'cprogram'], @@ -63,4 +76,15 @@ defines = ['USE_GLX', 'USE_GL'] ) +if bld.env.BUILD_GLPROXY: + bld( + features = ['cxx', 'cprogram'], + source = common_sources + egl_sources + glx_sources, + target = 'glcompbench', + uselib = ['glproxy'] + common_libs, + use = ['matrix-glproxy'], + lib = ['m'], + defines = ['USE_EGL', 'USE_GLES2', 'USE_GLX', 'USE_GL', 'USE_GLPROXY'] + ) + bld.install_files('${PREFIX}/bin', ['gl-composite-benchmark'], chmod=0755) === modified file 'wscript' --- wscript 2011-10-17 14:15:32 +0000 +++ wscript 2011-12-09 16:09:11 +0000 @@ -22,7 +22,7 @@ opt.add_option('--with-flavors', type = 'string', action='callback', callback=option_list_cb, dest = 'flavors', - help = "a list of flavors to build (glx, egl-gl, egl-es2, all)") + help = "a list of flavors to build (glx, egl-gl, egl-es2, glproxy, all)") opt.parser.set_default('flavors', ['egl-es2']) def configure(ctx): @@ -33,16 +33,17 @@ # Special 'all' flavor if 'all' in Options.options.flavors: Options.options.flavors.remove('all') - Options.options.flavors |= set(['glx', 'egl-gl', 'egl-es2']) + Options.options.flavors |= set(['glx', 'egl-gl', 'egl-es2', 'glproxy']) # Ensure the flavors are valid for flavor in Options.options.flavors: - if flavor not in ('glx', 'egl-es2', 'egl-gl'): - ctx.fatal('Unknown flavor: %s. Supported flavors are glx, egl-gl and egl-es2' % flavor) + if flavor not in ('glx', 'egl-es2', 'egl-gl', 'glproxy'): + ctx.fatal('Unknown flavor: %s. Supported flavors are glx, egl-gl, egl-es2 and glproxy' % flavor) ctx.env.BUILD_GLX = 'glx' in Options.options.flavors ctx.env.BUILD_EGL_ES2 = 'egl-es2' in Options.options.flavors ctx.env.BUILD_EGL_GL = 'egl-gl' in Options.options.flavors + ctx.env.BUILD_GLPROXY = 'glproxy' in Options.options.flavors # Check required headers req_headers = ['inttypes.h', 'stdint.h', 'sys/time.h'] @@ -71,7 +72,8 @@ # Check conditional packages req_pkgs = [('egl', 'egl', ctx.env.BUILD_EGL_ES2 or ctx.env.BUILD_EGL_GL), ('glesv2', 'glesv2', ctx.env.BUILD_EGL_ES2), - ('gl', 'gl', ctx.env.BUILD_GLX or ctx.env.BUILD_EGL_GL)] + ('gl', 'gl', ctx.env.BUILD_GLX or ctx.env.BUILD_EGL_GL), + ('glproxy', 'glproxy', ctx.env.BUILD_GLPROXY)] for (pkg, uselib, check_for) in req_pkgs: if check_for: ctx.check_cfg(package = pkg, uselib_store = uselib, args = '--cflags --libs',