From patchwork Thu Jun 23 14:23:15 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: 2218 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 ED2D823F7C for ; Thu, 23 Jun 2011 14:23:22 +0000 (UTC) Received: from mail-qy0-f180.google.com (mail-qy0-f180.google.com [209.85.216.180]) by fiordland.canonical.com (Postfix) with ESMTP id BE433A189B3 for ; Thu, 23 Jun 2011 14:23:22 +0000 (UTC) Received: by mail-qy0-f180.google.com with SMTP id 30so1372729qyk.11 for ; Thu, 23 Jun 2011 07:23:22 -0700 (PDT) Received: by 10.229.117.95 with SMTP id p31mr1608105qcq.97.1308839001573; Thu, 23 Jun 2011 07:23:21 -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 jm11cs19230qcb; Thu, 23 Jun 2011 07:23:21 -0700 (PDT) Received: by 10.216.231.165 with SMTP id l37mr1901190weq.78.1308838996895; Thu, 23 Jun 2011 07:23:16 -0700 (PDT) Received: from adelie.canonical.com (adelie.canonical.com [91.189.90.139]) by mx.google.com with ESMTP id i13si3952389wed.45.2011.06.23.07.23.16; Thu, 23 Jun 2011 07:23:16 -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 1QZkoO-0003mQ-0B for ; Thu, 23 Jun 2011 14:23:16 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id 001902E8027 for ; Thu, 23 Jun 2011 14:23:16 +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: 88 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~afrantzis/glmark2/trunk] Rev 88: Add special SceneDefaultOptions class, used for setting default options for all other scenes. Message-Id: <20110623142315.3922.73263.launchpad@loganberry.canonical.com> Date: Thu, 23 Jun 2011 14:23:15 -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: a52599a0225891bb9c9398d3bfce4cdfacf06af8 ------------------------------------------------------------ revno: 88 committer: Alexandros Frantzis branch nick: trunk timestamp: Thu 2011-06-23 15:32:34 +0300 message: Add special SceneDefaultOptions class, used for setting default options for all other scenes. added: src/scenedefaultoptions.cpp modified: src/main.cpp src/scene.cpp src/scene.h --- 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 'src/main.cpp' --- src/main.cpp 2011-06-15 11:36:32 +0000 +++ src/main.cpp 2011-06-23 12:32:34 +0000 @@ -100,6 +100,8 @@ scene_iter++) { Scene *scene = scene_iter->second; + if (scene->name().empty()) + continue; Log::info("[Scene] %s\n", scene->name().c_str()); const map &options = scene->options(); @@ -131,23 +133,26 @@ bool keep_running = true; Benchmark *bench = *bench_iter; Scene &scene = bench->setup_scene(); - Log::info("%s", scene.info_string().c_str()); - Log::flush(); - - while (scene.is_running() && - (keep_running = should_keep_running())) - { - screen.clear(); - - scene.draw(); - scene.update(); - - screen.update(); + + if (!scene.name().empty()) { + Log::info("%s", scene.info_string().c_str()); + Log::flush(); + + while (scene.is_running() && + (keep_running = should_keep_running())) + { + screen.clear(); + + scene.draw(); + scene.update(); + + screen.update(); + } + + Log::info(" FPS: %u\n", scene.average_fps()); + score += scene.average_fps(); } - Log::info(" FPS: %u\n", scene.average_fps()); - score += scene.average_fps(); - bench->teardown_scene(); if (!keep_running) @@ -169,30 +174,33 @@ { Benchmark *bench = *bench_iter; Scene &scene = bench->setup_scene(); - Log::info("%s", scene.info_string().c_str()); - Log::flush(); - - screen.clear(); - scene.draw(); - screen.update(); - - string result; - switch(scene.validate()) { - case Scene::ValidationSuccess: - result = "Success"; - break; - case Scene::ValidationFailure: - result = "Failure"; - break; - case Scene::ValidationUnknown: - result = "Unknown"; - break; - default: - break; + + if (!scene.name().empty()) { + Log::info("%s", scene.info_string().c_str()); + Log::flush(); + + screen.clear(); + scene.draw(); + screen.update(); + + string result; + switch(scene.validate()) { + case Scene::ValidationSuccess: + result = "Success"; + break; + case Scene::ValidationFailure: + result = "Failure"; + break; + case Scene::ValidationUnknown: + result = "Unknown"; + break; + default: + break; + } + + Log::info(" Validation: %s\n", result.c_str()); } - Log::info(" Validation: %s\n", result.c_str()); - bench->teardown_scene(); } } @@ -221,6 +229,7 @@ } // Register the scenes, so they can be looked-up by name + Benchmark::register_scene(*new SceneDefaultOptions(screen)); Benchmark::register_scene(*new SceneBuild(screen)); Benchmark::register_scene(*new SceneTexture(screen)); Benchmark::register_scene(*new SceneShading(screen)); === modified file 'src/scene.cpp' --- src/scene.cpp 2011-06-17 13:16:16 +0000 +++ src/scene.cpp 2011-06-23 12:32:34 +0000 @@ -117,6 +117,19 @@ } } +bool +Scene::set_option_default(const string &opt, const string &val) +{ + map::iterator iter = mOptions.find(opt); + + if (iter == mOptions.end()) + return false; + + iter->second.default_value = val; + + return true; +} + string Scene::construct_title(const string &title) === modified file 'src/scene.h' --- src/scene.h 2011-06-17 13:16:16 +0000 +++ src/scene.h 2011-06-23 12:32:34 +0000 @@ -36,6 +36,7 @@ #include #include +#include class Scene { @@ -79,8 +80,9 @@ bool is_running(); const std::string &name() { return mName; } - bool set_option(const std::string &opt, const std::string &val); + virtual bool set_option(const std::string &opt, const std::string &val); void reset_options(); + bool set_option_default(const std::string &opt, const std::string &val); const std::map &options() { return mOptions; } static Scene &dummy() @@ -114,6 +116,20 @@ double mDuration; // Duration of run in seconds }; +/* + * Special Scene used for setting the default options + */ +class SceneDefaultOptions : public Scene +{ +public: + SceneDefaultOptions(Screen &pScreen) : Scene(pScreen, "") {} + bool set_option(const std::string &opt, const std::string &val); + void setup(); + +private: + std::list > mDefaultOptions; +}; + class SceneBuild : public Scene { public: === added file 'src/scenedefaultoptions.cpp' --- src/scenedefaultoptions.cpp 1970-01-01 00:00:00 +0000 +++ src/scenedefaultoptions.cpp 2011-06-23 12:32:34 +0000 @@ -0,0 +1,47 @@ +/* + * 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) + */ +#include "scene.h" +#include "benchmark.h" + +void SceneDefaultOptions::setup() +{ + const std::map &scenes = Benchmark::scenes(); + + for (std::list >::const_iterator iter = mDefaultOptions.begin(); + iter != mDefaultOptions.end(); + iter++) + { + for (std::map::const_iterator scene_iter = scenes.begin(); + scene_iter != scenes.end(); + scene_iter++) + { + scene_iter->second->set_option_default(iter->first, iter->second); + } + } +} + +bool +SceneDefaultOptions::set_option(const std::string &opt, const std::string &val) +{ + mDefaultOptions.push_back(std::pair(opt, val)); + return true; +}