Merge lp:~linaro-graphics-wg/glmark2/demo into lp:glmark2/2011.11

Proposed by Alexandros Frantzis
Status: Merged
Merged at revision: 199
Proposed branch: lp:~linaro-graphics-wg/glmark2/demo
Merge into: lp:glmark2/2011.11
Diff against target: 905 lines (+377/-188)
11 files modified
src/android.cpp (+25/-18)
src/benchmark-collection.cpp (+113/-0)
src/benchmark-collection.h (+54/-0)
src/benchmark.cpp (+17/-0)
src/benchmark.h (+5/-0)
src/main-loop.cpp (+96/-120)
src/main-loop.h (+25/-31)
src/main.cpp (+21/-12)
src/options.cpp (+6/-6)
src/options.h (+1/-1)
src/scene.cpp (+14/-0)
To merge this branch: bzr merge lp:~linaro-graphics-wg/glmark2/demo
Reviewer Review Type Date Requested Status
Jesse Barker Approve
Review via email: mp+93257@code.launchpad.net

Description of the change

Demo functionality (missing --annotate option, which I will add tomorrow).

To post a comment you must log in.
Revision history for this message
Jesse Barker (jesse-barker) wrote :

Looks good. I like the new benchmark collection object and the integration of the main loop.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/android.cpp'
--- src/android.cpp 2012-02-14 15:29:48 +0000
+++ src/android.cpp 2012-02-15 17:41:11 +0000
@@ -31,21 +31,22 @@
31#include "options.h"31#include "options.h"
32#include "log.h"32#include "log.h"
33#include "util.h"33#include "util.h"
34#include "default-benchmarks.h"
35#include "main-loop.h"34#include "main-loop.h"
35#include "benchmark-collection.h"
3636
37static Canvas *g_canvas;37static Canvas *g_canvas;
38static MainLoop *g_loop;38static MainLoop *g_loop;
39static BenchmarkCollection *g_benchmark_collection;
3940
40class MainLoopAndroid : public MainLoop41class MainLoopAndroid : public MainLoop
41{42{
42public:43public:
43 MainLoopAndroid(Canvas &canvas) :44 MainLoopAndroid(Canvas &canvas, const std::vector<Benchmark *> &benchmarks) :
44 MainLoop(canvas) {}45 MainLoop(canvas, benchmarks) {}
4546
46 virtual void after_scene_setup() {}47 virtual void log_scene_info() {}
4748
48 virtual void before_scene_teardown()49 virtual void log_scene_result()
49 {50 {
50 Log::info("%s FPS: %u", scene_->info_string().c_str(),51 Log::info("%s FPS: %u", scene_->info_string().c_str(),
51 scene_->average_fps());52 scene_->average_fps());
@@ -55,12 +56,12 @@
55class MainLoopDecorationAndroid : public MainLoopDecoration56class MainLoopDecorationAndroid : public MainLoopDecoration
56{57{
57public:58public:
58 MainLoopDecorationAndroid(Canvas &canvas) :59 MainLoopDecorationAndroid(Canvas &canvas, const std::vector<Benchmark *> &benchmarks) :
59 MainLoopDecoration(canvas) {}60 MainLoopDecoration(canvas, benchmarks) {}
6061
61 virtual void after_scene_setup() {}62 virtual void log_scene_info() {}
6263
63 virtual void before_scene_teardown()64 virtual void log_scene_result()
64 {65 {
65 Log::info("%s FPS: %u", scene_->info_string().c_str(),66 Log::info("%s FPS: %u", scene_->info_string().c_str(),
66 scene_->average_fps());67 scene_->average_fps());
@@ -186,12 +187,17 @@
186 Benchmark::register_scene(*new SceneDesktop(*g_canvas));187 Benchmark::register_scene(*new SceneDesktop(*g_canvas));
187 Benchmark::register_scene(*new SceneBuffer(*g_canvas));188 Benchmark::register_scene(*new SceneBuffer(*g_canvas));
188189
189 if (Options::show_fps)190 g_benchmark_collection = new BenchmarkCollection();
190 g_loop = new MainLoopDecorationAndroid(*g_canvas);191 g_benchmark_collection->populate_from_options();
191 else
192 g_loop = new MainLoopAndroid(*g_canvas);
193192
194 g_loop->add_benchmarks();193 if (g_benchmark_collection->needs_decoration()) {
194 g_loop = new MainLoopDecorationAndroid(*g_canvas,
195 g_benchmark_collection->benchmarks());
196 }
197 else {
198 g_loop = new MainLoopAndroid(*g_canvas,
199 g_benchmark_collection->benchmarks());
200 }
195}201}
196202
197void203void
@@ -213,6 +219,7 @@
213 static_cast<void>(env);219 static_cast<void>(env);
214220
215 delete g_loop;221 delete g_loop;
222 delete g_benchmark_collection;
216 delete g_canvas;223 delete g_canvas;
217}224}
218225
219226
=== added file 'src/benchmark-collection.cpp'
--- src/benchmark-collection.cpp 1970-01-01 00:00:00 +0000
+++ src/benchmark-collection.cpp 2012-02-15 17:41:11 +0000
@@ -0,0 +1,113 @@
1/*
2 * Copyright © 2012 Linaro Limited
3 *
4 * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
5 *
6 * glmark2 is free software: you can redistribute it and/or modify it under the
7 * terms of the GNU General Public License as published by the Free Software
8 * Foundation, either version 3 of the License, or (at your option) any later
9 * version.
10 *
11 * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 * details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * glmark2. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * Authors:
20 * Alexandros Frantzis
21 */
22#include <fstream>
23#include "benchmark-collection.h"
24#include "default-benchmarks.h"
25#include "options.h"
26#include "log.h"
27#include "util.h"
28
29BenchmarkCollection::~BenchmarkCollection()
30{
31 Util::dispose_pointer_vector(benchmarks_);
32}
33
34void
35BenchmarkCollection::add(const std::vector<std::string> &benchmarks)
36{
37 for (std::vector<std::string>::const_iterator iter = benchmarks.begin();
38 iter != benchmarks.end();
39 iter++)
40 {
41 benchmarks_.push_back(new Benchmark(*iter));
42 }
43}
44
45void
46BenchmarkCollection::populate_from_options()
47{
48 if (!Options::benchmarks.empty())
49 add(Options::benchmarks);
50
51 if (!Options::benchmark_files.empty())
52 add_benchmarks_from_files();
53
54 if (!benchmarks_contain_normal_scenes())
55 add(DefaultBenchmarks::get());
56}
57
58bool
59BenchmarkCollection::needs_decoration()
60{
61 for (std::vector<Benchmark *>::const_iterator bench_iter = benchmarks_.begin();
62 bench_iter != benchmarks_.end();
63 bench_iter++)
64 {
65 const Benchmark *bench = *bench_iter;
66 if (bench->needs_decoration())
67 return true;
68 }
69
70 return false;
71}
72
73
74void
75BenchmarkCollection::add_benchmarks_from_files()
76{
77 for (std::vector<std::string>::const_iterator iter = Options::benchmark_files.begin();
78 iter != Options::benchmark_files.end();
79 iter++)
80 {
81 std::ifstream ifs(iter->c_str());
82
83 if (!ifs.fail()) {
84 std::string line;
85
86 while (getline(ifs, line)) {
87 if (!line.empty())
88 benchmarks_.push_back(new Benchmark(line));
89 }
90 }
91 else {
92 Log::error("Cannot open benchmark file %s\n",
93 iter->c_str());
94 }
95
96 }
97}
98
99bool
100BenchmarkCollection::benchmarks_contain_normal_scenes()
101{
102 for (std::vector<Benchmark *>::const_iterator bench_iter = benchmarks_.begin();
103 bench_iter != benchmarks_.end();
104 bench_iter++)
105 {
106 const Benchmark *bench = *bench_iter;
107 if (!bench->scene().name().empty())
108 return true;
109 }
110
111 return false;
112}
113
0114
=== added file 'src/benchmark-collection.h'
--- src/benchmark-collection.h 1970-01-01 00:00:00 +0000
+++ src/benchmark-collection.h 2012-02-15 17:41:11 +0000
@@ -0,0 +1,54 @@
1/*
2 * Copyright © 2012 Linaro Limited
3 *
4 * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
5 *
6 * glmark2 is free software: you can redistribute it and/or modify it under the
7 * terms of the GNU General Public License as published by the Free Software
8 * Foundation, either version 3 of the License, or (at your option) any later
9 * version.
10 *
11 * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 * details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * glmark2. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * Authors:
20 * Alexandros Frantzis
21 */
22#include <vector>
23#include <string>
24#include "benchmark.h"
25
26class BenchmarkCollection
27{
28public:
29 BenchmarkCollection() {}
30 ~BenchmarkCollection();
31
32 /*
33 * Adds benchmarks to the collection.
34 */
35 void add(const std::vector<std::string> &benchmarks);
36
37 /*
38 * Populates the collection guided by the global options.
39 */
40 void populate_from_options();
41
42 /*
43 * Whether the benchmarks in this collection need decoration.
44 */
45 bool needs_decoration();
46
47 const std::vector<Benchmark *>& benchmarks() { return benchmarks_; }
48
49private:
50 void add_benchmarks_from_files();
51 bool benchmarks_contain_normal_scenes();
52
53 std::vector<Benchmark *> benchmarks_;
54};
055
=== modified file 'src/benchmark.cpp'
--- src/benchmark.cpp 2011-10-26 11:12:19 +0000
+++ src/benchmark.cpp 2012-02-15 17:41:11 +0000
@@ -120,6 +120,23 @@
120 scene_.unload();120 scene_.unload();
121}121}
122122
123bool
124Benchmark::needs_decoration() const
125{
126 for (vector<OptionPair>::const_iterator iter = options_.begin();
127 iter != options_.end();
128 iter++)
129 {
130 if ((iter->first == "show-fps" && iter->second == "true") ||
131 (iter->first == "title" && !iter->second.empty()))
132 {
133 return true;
134 }
135 }
136
137 return false;
138}
139
123void140void
124Benchmark::load_options()141Benchmark::load_options()
125{142{
126143
=== modified file 'src/benchmark.h'
--- src/benchmark.h 2012-01-17 15:41:29 +0000
+++ src/benchmark.h 2012-02-15 17:41:11 +0000
@@ -91,6 +91,11 @@
91 void teardown_scene();91 void teardown_scene();
9292
93 /**93 /**
94 * Whether the benchmark needs extra decoration.
95 */
96 bool needs_decoration() const;
97
98 /**
94 * Registers a Scene, so that it becomes accessible by name.99 * Registers a Scene, so that it becomes accessible by name.
95 */100 */
96 static void register_scene(Scene &scene);101 static void register_scene(Scene &scene);
97102
=== modified file 'src/main-loop.cpp'
--- src/main-loop.cpp 2012-02-14 13:08:26 +0000
+++ src/main-loop.cpp 2012-02-15 17:41:11 +0000
@@ -23,26 +23,20 @@
23#include "main-loop.h"23#include "main-loop.h"
24#include "util.h"24#include "util.h"
25#include "log.h"25#include "log.h"
26#include "default-benchmarks.h"
2726
28#include <string>27#include <string>
29#include <sstream>28#include <sstream>
30#include <fstream>
3129
32/************30/************
33 * MainLoop *31 * MainLoop *
34 ************/32 ************/
3533
36MainLoop::MainLoop(Canvas &canvas) :34MainLoop::MainLoop(Canvas &canvas, const std::vector<Benchmark *> &benchmarks) :
37 canvas_(canvas)35 canvas_(canvas), benchmarks_(benchmarks)
38{36{
39 reset();37 reset();
40}38}
4139
42MainLoop::~MainLoop()
43{
44 Util::dispose_pointer_vector(benchmarks_);
45}
4640
47void41void
48MainLoop::reset()42MainLoop::reset()
@@ -53,28 +47,6 @@
53 bench_iter_ = benchmarks_.begin();47 bench_iter_ = benchmarks_.begin();
54}48}
5549
56void
57MainLoop::add_benchmarks()
58{
59 if (!Options::benchmarks.empty())
60 add_custom_benchmarks();
61
62 if (!Options::benchmark_files.empty())
63 add_custom_benchmarks_from_files();
64
65 if (!benchmarks_contain_normal_scenes())
66 add_default_benchmarks();
67
68 bench_iter_ = benchmarks_.begin();
69}
70
71void
72MainLoop::add_benchmarks(const std::vector<Benchmark *> &benchmarks)
73{
74 benchmarks_.insert(benchmarks_.end(), benchmarks.begin(), benchmarks.end());
75 bench_iter_ = benchmarks_.begin();
76}
77
78unsigned int50unsigned int
79MainLoop::score()51MainLoop::score()
80{52{
@@ -102,7 +74,7 @@
102 else74 else
103 break;75 break;
10476
105 bench_iter_++;77 next_benchmark();
106 }78 }
10779
108 /* If we have found a valid scene, set it up */80 /* If we have found a valid scene, set it up */
@@ -112,6 +84,7 @@
112 before_scene_setup();84 before_scene_setup();
113 scene_ = &(*bench_iter_)->setup_scene();85 scene_ = &(*bench_iter_)->setup_scene();
114 after_scene_setup();86 after_scene_setup();
87 log_scene_info();
115 }88 }
116 else {89 else {
117 /* ... otherwise we are done */90 /* ... otherwise we are done */
@@ -130,10 +103,10 @@
130 */103 */
131 if (!scene_->running() || should_quit) {104 if (!scene_->running() || should_quit) {
132 score_ += scene_->average_fps();105 score_ += scene_->average_fps();
133 before_scene_teardown();106 log_scene_result();
134 (*bench_iter_)->teardown_scene();107 (*bench_iter_)->teardown_scene();
135 scene_ = 0;108 scene_ = 0;
136 bench_iter_++;109 next_benchmark();
137 benchmarks_run_++;110 benchmarks_run_++;
138 }111 }
139112
@@ -152,90 +125,34 @@
152}125}
153126
154void127void
155MainLoop::after_scene_setup()128MainLoop::log_scene_info()
156{129{
157 Log::info("%s", scene_->info_string().c_str());130 Log::info("%s", scene_->info_string().c_str());
158 Log::flush();131 Log::flush();
159}132}
160133
161void134void
162MainLoop::before_scene_teardown()135MainLoop::log_scene_result()
163{136{
164 static const std::string format(Log::continuation_prefix + " FPS: %u\n");137 static const std::string format(Log::continuation_prefix + " FPS: %u\n");
165 Log::info(format.c_str(), scene_->average_fps());138 Log::info(format.c_str(), scene_->average_fps());
166}139}
167140
168void141void
169MainLoop::add_default_benchmarks()142MainLoop::next_benchmark()
170{143{
171 const std::vector<std::string> &default_benchmarks = DefaultBenchmarks::get();144 bench_iter_++;
172145 if (bench_iter_ == benchmarks_.end() && Options::run_forever)
173 for (std::vector<std::string>::const_iterator iter = default_benchmarks.begin();146 bench_iter_ = benchmarks_.begin();
174 iter != default_benchmarks.end();147}
175 iter++)
176 {
177 benchmarks_.push_back(new Benchmark(*iter));
178 }
179}
180
181void
182MainLoop::add_custom_benchmarks()
183{
184 for (std::vector<std::string>::const_iterator iter = Options::benchmarks.begin();
185 iter != Options::benchmarks.end();
186 iter++)
187 {
188 benchmarks_.push_back(new Benchmark(*iter));
189 }
190}
191
192void
193MainLoop::add_custom_benchmarks_from_files()
194{
195 for (std::vector<std::string>::const_iterator iter = Options::benchmark_files.begin();
196 iter != Options::benchmark_files.end();
197 iter++)
198 {
199 std::ifstream ifs(iter->c_str());
200
201 if (!ifs.fail()) {
202 std::string line;
203
204 while (getline(ifs, line)) {
205 if (!line.empty())
206 benchmarks_.push_back(new Benchmark(line));
207 }
208 }
209 else {
210 Log::error("Cannot open benchmark file %s\n",
211 iter->c_str());
212 }
213
214 }
215}
216
217bool
218MainLoop::benchmarks_contain_normal_scenes()
219{
220 for (std::vector<Benchmark *>::const_iterator bench_iter = benchmarks_.begin();
221 bench_iter != benchmarks_.end();
222 bench_iter++)
223 {
224 const Benchmark *bench = *bench_iter;
225 if (!bench->scene().name().empty())
226 return true;
227 }
228
229 return false;
230}
231
232148
233/**********************149/**********************
234 * MainLoopDecoration *150 * MainLoopDecoration *
235 **********************/151 **********************/
236152
237MainLoopDecoration::MainLoopDecoration(Canvas &canvas) :153MainLoopDecoration::MainLoopDecoration(Canvas &canvas, const std::vector<Benchmark *> &benchmarks) :
238 MainLoop(canvas), fps_renderer_(0), last_fps_(0)154 MainLoop(canvas, benchmarks), show_fps_(false), show_title_(false),
155 fps_renderer_(0), title_renderer_(0), last_fps_(0)
239{156{
240157
241}158}
@@ -244,36 +161,79 @@
244{161{
245 delete fps_renderer_;162 delete fps_renderer_;
246 fps_renderer_ = 0;163 fps_renderer_ = 0;
164 delete title_renderer_;
165 title_renderer_ = 0;
247}166}
248167
249void168void
250MainLoopDecoration::draw()169MainLoopDecoration::draw()
251{170{
252 static const unsigned int fps_interval = 500000;171 static const unsigned int fps_interval = 500000;
253 uint64_t now = Util::get_timestamp_us();
254172
255 canvas_.clear();173 canvas_.clear();
256174
257 scene_->draw();175 scene_->draw();
258 scene_->update();176 scene_->update();
259177
260 if (now - fps_timestamp_ >= fps_interval) {178 if (show_fps_) {
261 last_fps_ = scene_->average_fps();179 uint64_t now = Util::get_timestamp_us();
180 if (now - fps_timestamp_ >= fps_interval) {
181 last_fps_ = scene_->average_fps();
182 fps_renderer_update_text(last_fps_);
183 fps_timestamp_ = now;
184 }
185 fps_renderer_->render();
186 }
187
188 if (show_title_)
189 title_renderer_->render();
190
191 canvas_.update();
192}
193
194void
195MainLoopDecoration::before_scene_setup()
196{
197 delete fps_renderer_;
198 fps_renderer_ = 0;
199 delete title_renderer_;
200 title_renderer_ = 0;
201}
202
203void
204MainLoopDecoration::after_scene_setup()
205{
206 const Scene::Option &show_fps_option(scene_->options().find("show-fps")->second);
207 const Scene::Option &title_option(scene_->options().find("title")->second);
208 show_fps_ = show_fps_option.value == "true";
209 show_title_ = !title_option.value.empty();
210
211 if (show_fps_) {
212 const Scene::Option &fps_pos_option(scene_->options().find("fps-pos")->second);
213 const Scene::Option &fps_size_option(scene_->options().find("fps-size")->second);
214 fps_renderer_ = new TextRenderer(canvas_);
215 fps_renderer_->position(vec2_from_pos_string(fps_pos_option.value));
216 fps_renderer_->size(Util::fromString<float>(fps_size_option.value));
262 fps_renderer_update_text(last_fps_);217 fps_renderer_update_text(last_fps_);
263 fps_timestamp_ = now;218 fps_timestamp_ = Util::get_timestamp_us();
264 }219 }
265 fps_renderer_->render();220
266221 if (show_title_) {
267 canvas_.update();222 const Scene::Option &title_pos_option(scene_->options().find("title-pos")->second);
268}223 const Scene::Option &title_size_option(scene_->options().find("title-size")->second);
269224 title_renderer_ = new TextRenderer(canvas_);
270void225 title_renderer_->position(vec2_from_pos_string(title_pos_option.value));
271MainLoopDecoration::before_scene_setup()226 title_renderer_->size(Util::fromString<float>(title_size_option.value));
272{227
273 delete fps_renderer_;228 if (title_option.value == "#info#")
274 fps_renderer_ = new TextRenderer(canvas_);229 title_renderer_->text(scene_->info_string());
275 fps_renderer_update_text(last_fps_);230 else if (title_option.value == "#name#")
276 fps_timestamp_ = Util::get_timestamp_us();231 title_renderer_->text(scene_->name());
232 else if (title_option.value == "#r2d2#")
233 title_renderer_->text("Help me, Obi-Wan Kenobi. You're my only hope.");
234 else
235 title_renderer_->text(title_option.value);
236 }
277}237}
278238
279void239void
@@ -284,12 +244,28 @@
284 fps_renderer_->text(ss.str());244 fps_renderer_->text(ss.str());
285}245}
286246
247LibMatrix::vec2
248MainLoopDecoration::vec2_from_pos_string(const std::string &s)
249{
250 LibMatrix::vec2 v(0.0, 0.0);
251 std::vector<std::string> elems;
252 Util::split(s, ',', elems);
253
254 if (elems.size() > 0)
255 v.x(Util::fromString<float>(elems[0]));
256
257 if (elems.size() > 1)
258 v.y(Util::fromString<float>(elems[1]));
259
260 return v;
261}
262
287/**********************263/**********************
288 * MainLoopValidation *264 * MainLoopValidation *
289 **********************/265 **********************/
290266
291MainLoopValidation::MainLoopValidation(Canvas &canvas) :267MainLoopValidation::MainLoopValidation(Canvas &canvas, const std::vector<Benchmark *> &benchmarks) :
292 MainLoop(canvas)268 MainLoop(canvas, benchmarks)
293{269{
294}270}
295271
@@ -307,7 +283,7 @@
307}283}
308284
309void285void
310MainLoopValidation::before_scene_teardown()286MainLoopValidation::log_scene_result()
311{287{
312 static const std::string format(Log::continuation_prefix + " Validation: %s\n");288 static const std::string format(Log::continuation_prefix + " Validation: %s\n");
313 std::string result;289 std::string result;
314290
=== modified file 'src/main-loop.h'
--- src/main-loop.h 2012-02-14 13:08:26 +0000
+++ src/main-loop.h 2012-02-15 17:41:11 +0000
@@ -25,6 +25,7 @@
25#include "canvas.h"25#include "canvas.h"
26#include "benchmark.h"26#include "benchmark.h"
27#include "text-renderer.h"27#include "text-renderer.h"
28#include "vec.h"
28#include <vector>29#include <vector>
2930
30/**31/**
@@ -33,9 +34,9 @@
33class MainLoop34class MainLoop
34{35{
35public:36public:
36 MainLoop(Canvas &canvas);37 MainLoop(Canvas &canvas, const std::vector<Benchmark *> &benchmarks);
3738
38 virtual ~MainLoop();39 virtual ~MainLoop() {}
3940
40 /**41 /**
41 * Resets the main loop.42 * Resets the main loop.
@@ -45,19 +46,6 @@
45 */46 */
46 void reset();47 void reset();
4748
48 /**
49 * Adds benchmarks.
50 *
51 * This method takes into account benchmark related command line options
52 * to decide which benchmarks to add.
53 */
54 void add_benchmarks();
55
56 /**
57 * Adds user defined benchmarks.
58 */
59 void add_benchmarks(const std::vector<Benchmark *> &benchmarks);
60
61 /**49 /**
62 * Gets the current total benchmarking score.50 * Gets the current total benchmarking score.
63 */51 */
@@ -83,27 +71,27 @@
83 /**71 /**
84 * Overridable method for post scene-setup customizations.72 * Overridable method for post scene-setup customizations.
85 */73 */
86 virtual void after_scene_setup();74 virtual void after_scene_setup() {}
8775
88 /**76 /**
89 * Overridable method for pre scene-teardown customizations.77 * Overridable method for logging scene info.
90 */78 */
91 virtual void before_scene_teardown();79 virtual void log_scene_info();
80
81 /**
82 * Overridable method for logging scene result.
83 */
84 virtual void log_scene_result();
9285
93protected:86protected:
87 void next_benchmark();
94 Canvas &canvas_;88 Canvas &canvas_;
95 Scene *scene_;89 Scene *scene_;
96 std::vector<Benchmark *> benchmarks_;90 const std::vector<Benchmark *> &benchmarks_;
97 unsigned int score_;91 unsigned int score_;
98 unsigned int benchmarks_run_;92 unsigned int benchmarks_run_;
9993
100 std::vector<Benchmark *>::const_iterator bench_iter_;94 std::vector<Benchmark *>::const_iterator bench_iter_;
101
102private:
103 void add_default_benchmarks();
104 void add_custom_benchmarks();
105 void add_custom_benchmarks_from_files();
106 bool benchmarks_contain_normal_scenes();
107};95};
10896
109/**97/**
@@ -112,15 +100,21 @@
112class MainLoopDecoration : public MainLoop100class MainLoopDecoration : public MainLoop
113{101{
114public:102public:
115 MainLoopDecoration(Canvas &canvas);103 MainLoopDecoration(Canvas &canvas, const std::vector<Benchmark *> &benchmarks);
116 virtual ~MainLoopDecoration();104 virtual ~MainLoopDecoration();
117105
118 virtual void draw();106 virtual void draw();
119 virtual void before_scene_setup();107 virtual void before_scene_setup();
108 virtual void after_scene_setup();
120109
121protected:110protected:
122 void fps_renderer_update_text(unsigned int fps);111 void fps_renderer_update_text(unsigned int fps);
112 LibMatrix::vec2 vec2_from_pos_string(const std::string &s);
113
114 bool show_fps_;
115 bool show_title_;
123 TextRenderer *fps_renderer_;116 TextRenderer *fps_renderer_;
117 TextRenderer *title_renderer_;
124 unsigned int last_fps_;118 unsigned int last_fps_;
125 uint64_t fps_timestamp_;119 uint64_t fps_timestamp_;
126};120};
@@ -131,10 +125,10 @@
131class MainLoopValidation : public MainLoop125class MainLoopValidation : public MainLoop
132{126{
133public:127public:
134 MainLoopValidation(Canvas &canvas);128 MainLoopValidation(Canvas &canvas, const std::vector<Benchmark *> &benchmarks);
135129
136 virtual void draw();130 virtual void draw();
137 virtual void before_scene_teardown();131 virtual void log_scene_result();
138};132};
139133
140#endif /* GLMARK2_MAIN_LOOP_H_ */134#endif /* GLMARK2_MAIN_LOOP_H_ */
141135
=== modified file 'src/main.cpp'
--- src/main.cpp 2012-02-14 13:08:26 +0000
+++ src/main.cpp 2012-02-15 17:41:11 +0000
@@ -28,9 +28,9 @@
28#include "options.h"28#include "options.h"
29#include "log.h"29#include "log.h"
30#include "util.h"30#include "util.h"
31#include "default-benchmarks.h"
32#include "text-renderer.h"31#include "text-renderer.h"
33#include "main-loop.h"32#include "main-loop.h"
33#include "benchmark-collection.h"
3434
35#include <iostream>35#include <iostream>
36#include <fstream>36#include <fstream>
@@ -111,24 +111,33 @@
111void111void
112do_benchmark(Canvas &canvas)112do_benchmark(Canvas &canvas)
113{113{
114 MainLoop loop_normal(canvas);114 BenchmarkCollection benchmark_collection;
115 MainLoopDecoration loop_decoration(canvas);115 MainLoop *loop;
116116
117 MainLoop &loop(Options::show_fps ? loop_decoration : loop_normal);117 benchmark_collection.populate_from_options();
118 loop.add_benchmarks();
119 118
120 while (loop.step());119 if (benchmark_collection.needs_decoration())
121120 loop = new MainLoopDecoration(canvas, benchmark_collection.benchmarks());
122 Log::info("=======================================================\n");121 else
123 Log::info(" glmark2 Score: %u \n", loop.score());122 loop = new MainLoop(canvas, benchmark_collection.benchmarks());
124 Log::info("=======================================================\n");123
124 while (loop->step());
125
126 Log::info("=======================================================\n");
127 Log::info(" glmark2 Score: %u \n", loop->score());
128 Log::info("=======================================================\n");
129
130 delete loop;
125}131}
126132
127void133void
128do_validation(Canvas &canvas)134do_validation(Canvas &canvas)
129{135{
130 MainLoopValidation loop(canvas);136 BenchmarkCollection benchmark_collection;
131 loop.add_benchmarks();137
138 benchmark_collection.populate_from_options();
139
140 MainLoopValidation loop(canvas, benchmark_collection.benchmarks());
132141
133 while (loop.step());142 while (loop.step());
134}143}
135144
=== modified file 'src/options.cpp'
--- src/options.cpp 2012-01-27 12:10:17 +0000
+++ src/options.cpp 2012-02-15 17:41:11 +0000
@@ -38,9 +38,9 @@
38bool Options::list_scenes = false;38bool Options::list_scenes = false;
39bool Options::show_all_options = false;39bool Options::show_all_options = false;
40bool Options::show_debug = false;40bool Options::show_debug = false;
41bool Options::show_fps = false;
42bool Options::show_help = false;41bool Options::show_help = false;
43bool Options::reuse_context = false;42bool Options::reuse_context = false;
43bool Options::run_forever = false;
4444
45static struct option long_options[] = {45static struct option long_options[] = {
46 {"benchmark", 1, 0, 0},46 {"benchmark", 1, 0, 0},
@@ -48,10 +48,10 @@
48 {"validate", 0, 0, 0},48 {"validate", 0, 0, 0},
49 {"no-swap-buffers", 0, 0, 0},49 {"no-swap-buffers", 0, 0, 0},
50 {"reuse-context", 0, 0, 0},50 {"reuse-context", 0, 0, 0},
51 {"run-forever", 0, 0, 0},
51 {"size", 1, 0, 0},52 {"size", 1, 0, 0},
52 {"list-scenes", 0, 0, 0},53 {"list-scenes", 0, 0, 0},
53 {"show-all-options", 0, 0, 0},54 {"show-all-options", 0, 0, 0},
54 {"show-fps", 0, 0, 0},
55 {"debug", 0, 0, 0},55 {"debug", 0, 0, 0},
56 {"help", 0, 0, 0},56 {"help", 0, 0, 0},
57 {0, 0, 0, 0}57 {0, 0, 0, 0}
@@ -103,8 +103,8 @@
103 " and their options\n"103 " and their options\n"
104 " --show-all-options Show all scene option values used for benchmarks\n"104 " --show-all-options Show all scene option values used for benchmarks\n"
105 " (only explicitly set options are shown by default)\n"105 " (only explicitly set options are shown by default)\n"
106 " --show-fps Show live FPS count on screen (showing live FPS\n"106 " --run-forever Run indefinitely, looping from the last benchmark\n"
107 " affects benchmarking results, use with care!)\n"107 " back to the first\n"
108 " -d, --debug Display debug messages\n"108 " -d, --debug Display debug messages\n"
109 " -h, --help Display help\n");109 " -h, --help Display help\n");
110}110}
@@ -143,8 +143,8 @@
143 Options::list_scenes = true;143 Options::list_scenes = true;
144 else if (!strcmp(optname, "show-all-options"))144 else if (!strcmp(optname, "show-all-options"))
145 Options::show_all_options = true;145 Options::show_all_options = true;
146 else if (!strcmp(optname, "show-fps"))146 else if (!strcmp(optname, "run-forever"))
147 Options::show_fps = true;147 Options::run_forever = true;
148 else if (c == 'd' || !strcmp(optname, "debug"))148 else if (c == 'd' || !strcmp(optname, "debug"))
149 Options::show_debug = true;149 Options::show_debug = true;
150 else if (c == 'h' || !strcmp(optname, "help"))150 else if (c == 'h' || !strcmp(optname, "help"))
151151
=== modified file 'src/options.h'
--- src/options.h 2012-01-18 17:13:28 +0000
+++ src/options.h 2012-02-15 17:41:11 +0000
@@ -39,9 +39,9 @@
39 static bool list_scenes;39 static bool list_scenes;
40 static bool show_all_options;40 static bool show_all_options;
41 static bool show_debug;41 static bool show_debug;
42 static bool show_fps;
43 static bool show_help;42 static bool show_help;
44 static bool reuse_context;43 static bool reuse_context;
44 static bool run_forever;
45};45};
4646
47#endif /* OPTIONS_H_ */47#endif /* OPTIONS_H_ */
4848
=== modified file 'src/scene.cpp'
--- src/scene.cpp 2012-02-09 01:28:16 +0000
+++ src/scene.cpp 2012-02-15 17:41:11 +0000
@@ -46,6 +46,20 @@
46 options_["fragment-precision"] = Scene::Option("fragment-precision",46 options_["fragment-precision"] = Scene::Option("fragment-precision",
47 "default,default,default,default",47 "default,default,default,default",
48 "The precision values for the fragment shader (\"int,float,sampler2d,samplercube\")");48 "The precision values for the fragment shader (\"int,float,sampler2d,samplercube\")");
49 /* FPS options */
50 options_["show-fps"] = Scene::Option("show-fps", "false",
51 "Show live FPS counter");
52 options_["fps-pos"] = Scene::Option("fps-pos", "-1.0,-1.0",
53 "The position on screen where to show FPS");
54 options_["fps-size"] = Scene::Option("fps-size", "0.03",
55 "The width of each glyph for the FPS");
56 /* Title options */
57 options_["title"] = Scene::Option("title", "",
58 "The scene title to show");
59 options_["title-pos"] = Scene::Option("title-pos", "-0.7,-1.0",
60 "The position on screen where to show the title");
61 options_["title-size"] = Scene::Option("title-size", "0.03",
62 "The width of each glyph in the title");
49}63}
5064
51Scene::~Scene()65Scene::~Scene()

Subscribers

People subscribed via source and target branches