From patchwork Fri Jun 24 11:48:20 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: alexandros.frantzis@linaro.org X-Patchwork-Id: 2294 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 25D2423F42 for ; Fri, 24 Jun 2011 11:48:23 +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 C585DA1850C for ; Fri, 24 Jun 2011 11:48:22 +0000 (UTC) Received: by qyk10 with SMTP id 10so317933qyk.11 for ; Fri, 24 Jun 2011 04:48:22 -0700 (PDT) Received: by 10.229.7.141 with SMTP id d13mr85266qcd.21.1308916102198; Fri, 24 Jun 2011 04:48:22 -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.230.139 with SMTP id jm11cs46504qcb; Fri, 24 Jun 2011 04:48:21 -0700 (PDT) Received: by 10.216.235.33 with SMTP id t33mr2920062weq.6.1308916100650; Fri, 24 Jun 2011 04:48:20 -0700 (PDT) Received: from adelie.canonical.com (adelie.canonical.com [91.189.90.139]) by mx.google.com with ESMTP id o20si5972233weq.26.2011.06.24.04.48.20; Fri, 24 Jun 2011 04:48:20 -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 1Qa4s0-0005Hh-0i for ; Fri, 24 Jun 2011 11:48:20 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id 01C182E8019 for ; Fri, 24 Jun 2011 11:48:20 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: glmark2 X-Launchpad-Branch: ~afrantzis/glmark2/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 94 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~afrantzis/glmark2/trunk] Rev 94: gl: Disable VSync manually (work around an SDL bug). Message-Id: <20110624114819.24281.97733.launchpad@loganberry.canonical.com> Date: Fri, 24 Jun 2011 11:48:20 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="13265"; Instance="initZopeless config overlay" X-Launchpad-Hash: a8f2f78d4ce32195a74b37f331370943757032e5 ------------------------------------------------------------ revno: 94 tags: 2011.06 committer: Alexandros Frantzis branch nick: trunk timestamp: Fri 2011-06-24 14:47:33 +0300 message: gl: Disable VSync manually (work around an SDL bug). added: src/glx-disable-vsync.cpp src/glx-disable-vsync.h modified: NEWS src/screen-sdl-gl.cpp --- lp:glmark2 https://code.launchpad.net/~afrantzis/glmark2/trunk You are subscribed to branch lp:glmark2. To unsubscribe from this branch go to https://code.launchpad.net/~afrantzis/glmark2/trunk/+edit-subscription === modified file 'NEWS' --- NEWS 2011-06-24 09:25:13 +0000 +++ NEWS 2011-06-24 11:47:33 +0000 @@ -10,6 +10,7 @@ * Add basic output validation functionality (--validate). * Add command line option to call glFinish() instead of swapping the front and back buffers (--no-swap-buffers). +* Manually disable VSync for GL/GLX (work around an SDL bug). * Replace custom math and shader infrastructure with functionality provided by LibMatrix (lp:libmatrix). * Improve user documentation (--help and man page). === added file 'src/glx-disable-vsync.cpp' --- src/glx-disable-vsync.cpp 1970-01-01 00:00:00 +0000 +++ src/glx-disable-vsync.cpp 2011-06-24 11:47:33 +0000 @@ -0,0 +1,86 @@ +/* + * Copyright © 2010-2011 Linaro Limited + * + * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark. + * + * glmark2 is free software: you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. + * + * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * glmark2. If not, see . + * + * Authors: + * Alexandros Frantzis (glmark2) + */ + +#if USE_GL + +#include "glx-disable-vsync.h" +#include +#include +#include +#include + +#include +#include "log.h" + +PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT_ = 0; +PFNGLXSWAPINTERVALMESAPROC glXSwapIntervalMESA_ = 0; + +void +glx_disable_vsync() +{ + SDL_SysWMinfo info; + SDL_VERSION(&info.version); + + if (SDL_GetWMInfo(&info) != 1) { + Log::error("Couldn't get windowing system info from SDL.\n"); + return; + } + + Display *display = info.info.x11.gfxdisplay; + Window window = info.info.x11.window; + + std::string extString; + const char* exts = glXQueryExtensionsString(display, 0); + if (exts) { + extString = exts; + } + + /* + * GLX_EXT_swap_control or GL_MESA_swap_control. Note that + * GLX_SGI_swap_control is not enough because it doesn't allow 0 as a valid + * value (i.e. we can't turn off VSync). + */ + if (extString.find("GLX_EXT_swap_control") != std::string::npos) { + glXSwapIntervalEXT_ = + reinterpret_cast( + glXGetProcAddress((const GLubyte *)"glXSwapIntervalEXT")); + } + else if (extString.find("GLX_MESA_swap_control") != std::string::npos) { + glXSwapIntervalMESA_ = + reinterpret_cast( + glXGetProcAddress((const GLubyte *)"glXSwapIntervalMESA")); + } + + + if (!glXSwapIntervalEXT_ && !glXSwapIntervalMESA_) { + Log::info("** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!\n"); + } + + /* Turn off VSync */ + if ((!glXSwapIntervalEXT_ || glXSwapIntervalEXT_(display, window, 0)) && + (!glXSwapIntervalMESA_ || glXSwapIntervalMESA_(0))) + { + Log::info("** Failed to set swap interval. Results may be bounded above by refresh rate.\n"); + } +} + +#endif === added file 'src/glx-disable-vsync.h' --- src/glx-disable-vsync.h 1970-01-01 00:00:00 +0000 +++ src/glx-disable-vsync.h 2011-06-24 11:47:33 +0000 @@ -0,0 +1,28 @@ +/* + * Copyright © 2010-2011 Linaro Limited + * + * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark. + * + * glmark2 is free software: you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. + * + * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * glmark2. If not, see . + * + * Authors: + * Alexandros Frantzis (glmark2) + */ + +#ifndef GLMARK2_GLX_DISABLE_VSYNC_H_ +#define GLMARK2_GLX_DISABLE_VSYNC_H_ + +void glx_disable_vsync(); + +#endif === modified file 'src/screen-sdl-gl.cpp' --- src/screen-sdl-gl.cpp 2011-06-15 10:11:13 +0000 +++ src/screen-sdl-gl.cpp 2011-06-24 11:47:33 +0000 @@ -23,6 +23,7 @@ */ #include "screen-sdl-gl.h" #include "options.h" +#include "glx-disable-vsync.h" #include ScreenSDLGL::ScreenSDLGL(int pWidth, int pHeight, int pBpp, int pFullScreen, int pFlags) @@ -37,6 +38,13 @@ glViewport(0, 0, mWidth, mHeight); + /* + * There is a bug in SDL that prevents us from setting the swap + * interval using the SDL_GL_SWAP_CONTROL attribute. We take care + * of this manually for now. + */ + glx_disable_vsync(); + clear(); }