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: 2994 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 16A5D23F4D for ; Thu, 21 Jul 2011 12:44:10 +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 D2EB7A18287 for ; Thu, 21 Jul 2011 12:44:09 +0000 (UTC) Received: by mail-qw0-f52.google.com with SMTP id 8so854415qwb.11 for ; Thu, 21 Jul 2011 05:44:09 -0700 (PDT) Received: by 10.224.195.193 with SMTP id ed1mr181558qab.162.1311252249618; Thu, 21 Jul 2011 05:44:09 -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 hl14cs139576qcb; Thu, 21 Jul 2011 05:44:09 -0700 (PDT) Received: by 10.227.39.93 with SMTP id f29mr205886wbe.16.1311251797534; 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 d17si2392201wbh.45.2011.07.21.05.36.36; 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-0000D3-Hl 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 8536B2E84FB 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: 88 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~glmark2-dev/glmark2/trunk] Rev 88: Add special SceneDefaultOptions class, used for setting default options for all other scenes. Message-Id: <20110721123636.17019.24543.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: 819fc38df0fd9367d0a565f511c1a5f8021b97a3 ------------------------------------------------------------ revno: 88 committer: Alexandros Frantzis 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/~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/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; +}