From patchwork Thu Jul 21 12:36:36 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: 2997 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 1A89D23F4D for ; Thu, 21 Jul 2011 12:44:15 +0000 (UTC) Received: from mail-qw0-f52.google.com (mail-qw0-f52.google.com [209.85.216.52]) by fiordland.canonical.com (Postfix) with ESMTP id DD347A18287 for ; Thu, 21 Jul 2011 12:44:14 +0000 (UTC) Received: by mail-qw0-f52.google.com with SMTP id 8so853237qwb.11 for ; Thu, 21 Jul 2011 05:44:14 -0700 (PDT) Received: by 10.229.68.200 with SMTP id w8mr192166qci.114.1311252254673; Thu, 21 Jul 2011 05:44:14 -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 hl14cs139579qcb; Thu, 21 Jul 2011 05:44:14 -0700 (PDT) Received: by 10.227.128.81 with SMTP id j17mr181156wbs.55.1311251797655; Thu, 21 Jul 2011 05:36:37 -0700 (PDT) Received: from adelie.canonical.com (adelie.canonical.com [91.189.90.139]) by mx.google.com with ESMTP id fe3si2397370wbb.27.2011.07.21.05.36.37; Thu, 21 Jul 2011 05:36:37 -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 1QjsUW-0000DH-Tg for ; Thu, 21 Jul 2011 12:36:36 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id DF63D2E84FB for ; Thu, 21 Jul 2011 12:36:36 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: glmark2 X-Launchpad-Branch: ~glmark2-dev/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 ~glmark2-dev/glmark2/trunk] Rev 94: gl: Disable VSync manually (work around an SDL bug). Message-Id: <20110721123636.17019.9080.launchpad@loganberry.canonical.com> Date: Thu, 21 Jul 2011 12:36:36 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="13475"; Instance="initZopeless config overlay" X-Launchpad-Hash: fe653632971cb1ab5ec563ddd8967e5a2cff9d44 ------------------------------------------------------------ revno: 94 committer: Alexandros Frantzis 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/~glmark2-dev/glmark2/trunk You are subscribed to branch lp:glmark2. To unsubscribe from this branch go to https://code.launchpad.net/~glmark2-dev/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(); }