From patchwork Thu Sep 29 13:08:12 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: 4433 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 9617823F6F for ; Thu, 29 Sep 2011 13:08:14 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id 82DBCA184D8 for ; Thu, 29 Sep 2011 13:08:14 +0000 (UTC) Received: by fxe23 with SMTP id 23so2478454fxe.11 for ; Thu, 29 Sep 2011 06:08:14 -0700 (PDT) Received: by 10.223.57.17 with SMTP id a17mr1885791fah.65.1317301694344; Thu, 29 Sep 2011 06:08: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.152.3.234 with SMTP id f10cs14162laf; Thu, 29 Sep 2011 06:08:13 -0700 (PDT) Received: by 10.216.169.74 with SMTP id m52mr13562392wel.33.1317301692950; Thu, 29 Sep 2011 06:08:12 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id n47si1204767wed.125.2011.09.29.06.08.12 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 29 Sep 2011 06:08:12 -0700 (PDT) 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 1R9GLU-0007YU-ER for ; Thu, 29 Sep 2011 13:08:12 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 602B1E230E for ; Thu, 29 Sep 2011 13:08:12 +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: 148 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~glmark2-dev/glmark2/trunk] Rev 148: CanvasX11: Check GL version string to ensure that OpenGL(ES) 2.0 is really supported. Message-Id: <20110929130812.5097.48910.launchpad@ackee.canonical.com> Date: Thu, 29 Sep 2011 13:08:12 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="14063"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 4512308ff950fae198ddcc8fb2f52dade62a953a ------------------------------------------------------------ revno: 148 fixes bug: https://launchpad.net/bugs/842279 committer: Alexandros Frantzis branch nick: lp-842279 timestamp: Thu 2011-09-29 16:05:21 +0300 message: CanvasX11: Check GL version string to ensure that OpenGL(ES) 2.0 is really supported. When running glmark2 on older hardware (OpenGL 1.x compatible) leads to a crash. This commit checks that OpenGL(ES) 2.0 is really supported before trying to execute any OpenGL(ES) 2.0 only code and fails gracefully if it's not supported (LP #842279). modified: src/canvas-x11.cpp src/canvas-x11.h --- 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 'src/canvas-x11.cpp' --- src/canvas-x11.cpp 2011-09-09 11:24:17 +0000 +++ src/canvas-x11.cpp 2011-09-29 13:05:21 +0000 @@ -22,6 +22,7 @@ #include "canvas-x11.h" #include "log.h" #include "options.h" +#include "util.h" #include #include @@ -84,6 +85,13 @@ if (!make_current()) return false; + if (!supports_gl2()) { + Log::error("Glmark2 needs OpenGL(ES) version >= 2.0 to run" + " (but version string is: '%s')!\n", + glGetString(GL_VERSION)); + return false; + } + glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glEnable(GL_CULL_FACE); @@ -212,3 +220,28 @@ mProjection = LibMatrix::Mat4::perspective(60.0, mWidth / (float)mHeight, 1.0, 1024.0); } + +bool +CanvasX11::supports_gl2() +{ + std::string gl_version_str(reinterpret_cast(glGetString(GL_VERSION))); + int gl_major(0); + + size_t point_pos(gl_version_str.find('.')); + + if (point_pos != std::string::npos) { + point_pos--; + + size_t start_pos(gl_version_str.rfind(' ', point_pos)); + if (start_pos == std::string::npos) + start_pos = 0; + else + start_pos++; + + std::stringstream ss; + ss << gl_version_str.substr(start_pos, point_pos - start_pos + 1); + ss >> gl_major; + } + + return gl_major >= 2; +} === modified file 'src/canvas-x11.h' --- src/canvas-x11.h 2011-08-09 10:51:03 +0000 +++ src/canvas-x11.h 2011-09-29 13:05:21 +0000 @@ -48,6 +48,7 @@ virtual XVisualInfo *get_xvisualinfo() = 0; virtual bool make_current() = 0; virtual void swap_buffers() = 0; + bool supports_gl2(); Window xwin_; Display *xdpy_;