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
1=== modified file 'src/android.cpp'
2--- src/android.cpp 2012-02-14 15:29:48 +0000
3+++ src/android.cpp 2012-02-15 17:41:11 +0000
4@@ -31,21 +31,22 @@
5 #include "options.h"
6 #include "log.h"
7 #include "util.h"
8-#include "default-benchmarks.h"
9 #include "main-loop.h"
10+#include "benchmark-collection.h"
11
12 static Canvas *g_canvas;
13 static MainLoop *g_loop;
14+static BenchmarkCollection *g_benchmark_collection;
15
16 class MainLoopAndroid : public MainLoop
17 {
18 public:
19- MainLoopAndroid(Canvas &canvas) :
20- MainLoop(canvas) {}
21-
22- virtual void after_scene_setup() {}
23-
24- virtual void before_scene_teardown()
25+ MainLoopAndroid(Canvas &canvas, const std::vector<Benchmark *> &benchmarks) :
26+ MainLoop(canvas, benchmarks) {}
27+
28+ virtual void log_scene_info() {}
29+
30+ virtual void log_scene_result()
31 {
32 Log::info("%s FPS: %u", scene_->info_string().c_str(),
33 scene_->average_fps());
34@@ -55,12 +56,12 @@
35 class MainLoopDecorationAndroid : public MainLoopDecoration
36 {
37 public:
38- MainLoopDecorationAndroid(Canvas &canvas) :
39- MainLoopDecoration(canvas) {}
40-
41- virtual void after_scene_setup() {}
42-
43- virtual void before_scene_teardown()
44+ MainLoopDecorationAndroid(Canvas &canvas, const std::vector<Benchmark *> &benchmarks) :
45+ MainLoopDecoration(canvas, benchmarks) {}
46+
47+ virtual void log_scene_info() {}
48+
49+ virtual void log_scene_result()
50 {
51 Log::info("%s FPS: %u", scene_->info_string().c_str(),
52 scene_->average_fps());
53@@ -186,12 +187,17 @@
54 Benchmark::register_scene(*new SceneDesktop(*g_canvas));
55 Benchmark::register_scene(*new SceneBuffer(*g_canvas));
56
57- if (Options::show_fps)
58- g_loop = new MainLoopDecorationAndroid(*g_canvas);
59- else
60- g_loop = new MainLoopAndroid(*g_canvas);
61+ g_benchmark_collection = new BenchmarkCollection();
62+ g_benchmark_collection->populate_from_options();
63
64- g_loop->add_benchmarks();
65+ if (g_benchmark_collection->needs_decoration()) {
66+ g_loop = new MainLoopDecorationAndroid(*g_canvas,
67+ g_benchmark_collection->benchmarks());
68+ }
69+ else {
70+ g_loop = new MainLoopAndroid(*g_canvas,
71+ g_benchmark_collection->benchmarks());
72+ }
73 }
74
75 void
76@@ -213,6 +219,7 @@
77 static_cast<void>(env);
78
79 delete g_loop;
80+ delete g_benchmark_collection;
81 delete g_canvas;
82 }
83
84
85=== added file 'src/benchmark-collection.cpp'
86--- src/benchmark-collection.cpp 1970-01-01 00:00:00 +0000
87+++ src/benchmark-collection.cpp 2012-02-15 17:41:11 +0000
88@@ -0,0 +1,113 @@
89+/*
90+ * Copyright © 2012 Linaro Limited
91+ *
92+ * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
93+ *
94+ * glmark2 is free software: you can redistribute it and/or modify it under the
95+ * terms of the GNU General Public License as published by the Free Software
96+ * Foundation, either version 3 of the License, or (at your option) any later
97+ * version.
98+ *
99+ * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
100+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
101+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
102+ * details.
103+ *
104+ * You should have received a copy of the GNU General Public License along with
105+ * glmark2. If not, see <http://www.gnu.org/licenses/>.
106+ *
107+ * Authors:
108+ * Alexandros Frantzis
109+ */
110+#include <fstream>
111+#include "benchmark-collection.h"
112+#include "default-benchmarks.h"
113+#include "options.h"
114+#include "log.h"
115+#include "util.h"
116+
117+BenchmarkCollection::~BenchmarkCollection()
118+{
119+ Util::dispose_pointer_vector(benchmarks_);
120+}
121+
122+void
123+BenchmarkCollection::add(const std::vector<std::string> &benchmarks)
124+{
125+ for (std::vector<std::string>::const_iterator iter = benchmarks.begin();
126+ iter != benchmarks.end();
127+ iter++)
128+ {
129+ benchmarks_.push_back(new Benchmark(*iter));
130+ }
131+}
132+
133+void
134+BenchmarkCollection::populate_from_options()
135+{
136+ if (!Options::benchmarks.empty())
137+ add(Options::benchmarks);
138+
139+ if (!Options::benchmark_files.empty())
140+ add_benchmarks_from_files();
141+
142+ if (!benchmarks_contain_normal_scenes())
143+ add(DefaultBenchmarks::get());
144+}
145+
146+bool
147+BenchmarkCollection::needs_decoration()
148+{
149+ for (std::vector<Benchmark *>::const_iterator bench_iter = benchmarks_.begin();
150+ bench_iter != benchmarks_.end();
151+ bench_iter++)
152+ {
153+ const Benchmark *bench = *bench_iter;
154+ if (bench->needs_decoration())
155+ return true;
156+ }
157+
158+ return false;
159+}
160+
161+
162+void
163+BenchmarkCollection::add_benchmarks_from_files()
164+{
165+ for (std::vector<std::string>::const_iterator iter = Options::benchmark_files.begin();
166+ iter != Options::benchmark_files.end();
167+ iter++)
168+ {
169+ std::ifstream ifs(iter->c_str());
170+
171+ if (!ifs.fail()) {
172+ std::string line;
173+
174+ while (getline(ifs, line)) {
175+ if (!line.empty())
176+ benchmarks_.push_back(new Benchmark(line));
177+ }
178+ }
179+ else {
180+ Log::error("Cannot open benchmark file %s\n",
181+ iter->c_str());
182+ }
183+
184+ }
185+}
186+
187+bool
188+BenchmarkCollection::benchmarks_contain_normal_scenes()
189+{
190+ for (std::vector<Benchmark *>::const_iterator bench_iter = benchmarks_.begin();
191+ bench_iter != benchmarks_.end();
192+ bench_iter++)
193+ {
194+ const Benchmark *bench = *bench_iter;
195+ if (!bench->scene().name().empty())
196+ return true;
197+ }
198+
199+ return false;
200+}
201+
202
203=== added file 'src/benchmark-collection.h'
204--- src/benchmark-collection.h 1970-01-01 00:00:00 +0000
205+++ src/benchmark-collection.h 2012-02-15 17:41:11 +0000
206@@ -0,0 +1,54 @@
207+/*
208+ * Copyright © 2012 Linaro Limited
209+ *
210+ * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
211+ *
212+ * glmark2 is free software: you can redistribute it and/or modify it under the
213+ * terms of the GNU General Public License as published by the Free Software
214+ * Foundation, either version 3 of the License, or (at your option) any later
215+ * version.
216+ *
217+ * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
218+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
219+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
220+ * details.
221+ *
222+ * You should have received a copy of the GNU General Public License along with
223+ * glmark2. If not, see <http://www.gnu.org/licenses/>.
224+ *
225+ * Authors:
226+ * Alexandros Frantzis
227+ */
228+#include <vector>
229+#include <string>
230+#include "benchmark.h"
231+
232+class BenchmarkCollection
233+{
234+public:
235+ BenchmarkCollection() {}
236+ ~BenchmarkCollection();
237+
238+ /*
239+ * Adds benchmarks to the collection.
240+ */
241+ void add(const std::vector<std::string> &benchmarks);
242+
243+ /*
244+ * Populates the collection guided by the global options.
245+ */
246+ void populate_from_options();
247+
248+ /*
249+ * Whether the benchmarks in this collection need decoration.
250+ */
251+ bool needs_decoration();
252+
253+ const std::vector<Benchmark *>& benchmarks() { return benchmarks_; }
254+
255+private:
256+ void add_benchmarks_from_files();
257+ bool benchmarks_contain_normal_scenes();
258+
259+ std::vector<Benchmark *> benchmarks_;
260+};
261
262=== modified file 'src/benchmark.cpp'
263--- src/benchmark.cpp 2011-10-26 11:12:19 +0000
264+++ src/benchmark.cpp 2012-02-15 17:41:11 +0000
265@@ -120,6 +120,23 @@
266 scene_.unload();
267 }
268
269+bool
270+Benchmark::needs_decoration() const
271+{
272+ for (vector<OptionPair>::const_iterator iter = options_.begin();
273+ iter != options_.end();
274+ iter++)
275+ {
276+ if ((iter->first == "show-fps" && iter->second == "true") ||
277+ (iter->first == "title" && !iter->second.empty()))
278+ {
279+ return true;
280+ }
281+ }
282+
283+ return false;
284+}
285+
286 void
287 Benchmark::load_options()
288 {
289
290=== modified file 'src/benchmark.h'
291--- src/benchmark.h 2012-01-17 15:41:29 +0000
292+++ src/benchmark.h 2012-02-15 17:41:11 +0000
293@@ -91,6 +91,11 @@
294 void teardown_scene();
295
296 /**
297+ * Whether the benchmark needs extra decoration.
298+ */
299+ bool needs_decoration() const;
300+
301+ /**
302 * Registers a Scene, so that it becomes accessible by name.
303 */
304 static void register_scene(Scene &scene);
305
306=== modified file 'src/main-loop.cpp'
307--- src/main-loop.cpp 2012-02-14 13:08:26 +0000
308+++ src/main-loop.cpp 2012-02-15 17:41:11 +0000
309@@ -23,26 +23,20 @@
310 #include "main-loop.h"
311 #include "util.h"
312 #include "log.h"
313-#include "default-benchmarks.h"
314
315 #include <string>
316 #include <sstream>
317-#include <fstream>
318
319 /************
320 * MainLoop *
321 ************/
322
323-MainLoop::MainLoop(Canvas &canvas) :
324- canvas_(canvas)
325+MainLoop::MainLoop(Canvas &canvas, const std::vector<Benchmark *> &benchmarks) :
326+ canvas_(canvas), benchmarks_(benchmarks)
327 {
328 reset();
329 }
330
331-MainLoop::~MainLoop()
332-{
333- Util::dispose_pointer_vector(benchmarks_);
334-}
335
336 void
337 MainLoop::reset()
338@@ -53,28 +47,6 @@
339 bench_iter_ = benchmarks_.begin();
340 }
341
342-void
343-MainLoop::add_benchmarks()
344-{
345- if (!Options::benchmarks.empty())
346- add_custom_benchmarks();
347-
348- if (!Options::benchmark_files.empty())
349- add_custom_benchmarks_from_files();
350-
351- if (!benchmarks_contain_normal_scenes())
352- add_default_benchmarks();
353-
354- bench_iter_ = benchmarks_.begin();
355-}
356-
357-void
358-MainLoop::add_benchmarks(const std::vector<Benchmark *> &benchmarks)
359-{
360- benchmarks_.insert(benchmarks_.end(), benchmarks.begin(), benchmarks.end());
361- bench_iter_ = benchmarks_.begin();
362-}
363-
364 unsigned int
365 MainLoop::score()
366 {
367@@ -102,7 +74,7 @@
368 else
369 break;
370
371- bench_iter_++;
372+ next_benchmark();
373 }
374
375 /* If we have found a valid scene, set it up */
376@@ -112,6 +84,7 @@
377 before_scene_setup();
378 scene_ = &(*bench_iter_)->setup_scene();
379 after_scene_setup();
380+ log_scene_info();
381 }
382 else {
383 /* ... otherwise we are done */
384@@ -130,10 +103,10 @@
385 */
386 if (!scene_->running() || should_quit) {
387 score_ += scene_->average_fps();
388- before_scene_teardown();
389+ log_scene_result();
390 (*bench_iter_)->teardown_scene();
391 scene_ = 0;
392- bench_iter_++;
393+ next_benchmark();
394 benchmarks_run_++;
395 }
396
397@@ -152,90 +125,34 @@
398 }
399
400 void
401-MainLoop::after_scene_setup()
402+MainLoop::log_scene_info()
403 {
404 Log::info("%s", scene_->info_string().c_str());
405 Log::flush();
406 }
407
408 void
409-MainLoop::before_scene_teardown()
410+MainLoop::log_scene_result()
411 {
412 static const std::string format(Log::continuation_prefix + " FPS: %u\n");
413 Log::info(format.c_str(), scene_->average_fps());
414 }
415
416 void
417-MainLoop::add_default_benchmarks()
418-{
419- const std::vector<std::string> &default_benchmarks = DefaultBenchmarks::get();
420-
421- for (std::vector<std::string>::const_iterator iter = default_benchmarks.begin();
422- iter != default_benchmarks.end();
423- iter++)
424- {
425- benchmarks_.push_back(new Benchmark(*iter));
426- }
427-}
428-
429-void
430-MainLoop::add_custom_benchmarks()
431-{
432- for (std::vector<std::string>::const_iterator iter = Options::benchmarks.begin();
433- iter != Options::benchmarks.end();
434- iter++)
435- {
436- benchmarks_.push_back(new Benchmark(*iter));
437- }
438-}
439-
440-void
441-MainLoop::add_custom_benchmarks_from_files()
442-{
443- for (std::vector<std::string>::const_iterator iter = Options::benchmark_files.begin();
444- iter != Options::benchmark_files.end();
445- iter++)
446- {
447- std::ifstream ifs(iter->c_str());
448-
449- if (!ifs.fail()) {
450- std::string line;
451-
452- while (getline(ifs, line)) {
453- if (!line.empty())
454- benchmarks_.push_back(new Benchmark(line));
455- }
456- }
457- else {
458- Log::error("Cannot open benchmark file %s\n",
459- iter->c_str());
460- }
461-
462- }
463-}
464-
465-bool
466-MainLoop::benchmarks_contain_normal_scenes()
467-{
468- for (std::vector<Benchmark *>::const_iterator bench_iter = benchmarks_.begin();
469- bench_iter != benchmarks_.end();
470- bench_iter++)
471- {
472- const Benchmark *bench = *bench_iter;
473- if (!bench->scene().name().empty())
474- return true;
475- }
476-
477- return false;
478-}
479-
480+MainLoop::next_benchmark()
481+{
482+ bench_iter_++;
483+ if (bench_iter_ == benchmarks_.end() && Options::run_forever)
484+ bench_iter_ = benchmarks_.begin();
485+}
486
487 /**********************
488 * MainLoopDecoration *
489 **********************/
490
491-MainLoopDecoration::MainLoopDecoration(Canvas &canvas) :
492- MainLoop(canvas), fps_renderer_(0), last_fps_(0)
493+MainLoopDecoration::MainLoopDecoration(Canvas &canvas, const std::vector<Benchmark *> &benchmarks) :
494+ MainLoop(canvas, benchmarks), show_fps_(false), show_title_(false),
495+ fps_renderer_(0), title_renderer_(0), last_fps_(0)
496 {
497
498 }
499@@ -244,36 +161,79 @@
500 {
501 delete fps_renderer_;
502 fps_renderer_ = 0;
503+ delete title_renderer_;
504+ title_renderer_ = 0;
505 }
506
507 void
508 MainLoopDecoration::draw()
509 {
510 static const unsigned int fps_interval = 500000;
511- uint64_t now = Util::get_timestamp_us();
512
513 canvas_.clear();
514
515 scene_->draw();
516 scene_->update();
517
518- if (now - fps_timestamp_ >= fps_interval) {
519- last_fps_ = scene_->average_fps();
520+ if (show_fps_) {
521+ uint64_t now = Util::get_timestamp_us();
522+ if (now - fps_timestamp_ >= fps_interval) {
523+ last_fps_ = scene_->average_fps();
524+ fps_renderer_update_text(last_fps_);
525+ fps_timestamp_ = now;
526+ }
527+ fps_renderer_->render();
528+ }
529+
530+ if (show_title_)
531+ title_renderer_->render();
532+
533+ canvas_.update();
534+}
535+
536+void
537+MainLoopDecoration::before_scene_setup()
538+{
539+ delete fps_renderer_;
540+ fps_renderer_ = 0;
541+ delete title_renderer_;
542+ title_renderer_ = 0;
543+}
544+
545+void
546+MainLoopDecoration::after_scene_setup()
547+{
548+ const Scene::Option &show_fps_option(scene_->options().find("show-fps")->second);
549+ const Scene::Option &title_option(scene_->options().find("title")->second);
550+ show_fps_ = show_fps_option.value == "true";
551+ show_title_ = !title_option.value.empty();
552+
553+ if (show_fps_) {
554+ const Scene::Option &fps_pos_option(scene_->options().find("fps-pos")->second);
555+ const Scene::Option &fps_size_option(scene_->options().find("fps-size")->second);
556+ fps_renderer_ = new TextRenderer(canvas_);
557+ fps_renderer_->position(vec2_from_pos_string(fps_pos_option.value));
558+ fps_renderer_->size(Util::fromString<float>(fps_size_option.value));
559 fps_renderer_update_text(last_fps_);
560- fps_timestamp_ = now;
561- }
562- fps_renderer_->render();
563-
564- canvas_.update();
565-}
566-
567-void
568-MainLoopDecoration::before_scene_setup()
569-{
570- delete fps_renderer_;
571- fps_renderer_ = new TextRenderer(canvas_);
572- fps_renderer_update_text(last_fps_);
573- fps_timestamp_ = Util::get_timestamp_us();
574+ fps_timestamp_ = Util::get_timestamp_us();
575+ }
576+
577+ if (show_title_) {
578+ const Scene::Option &title_pos_option(scene_->options().find("title-pos")->second);
579+ const Scene::Option &title_size_option(scene_->options().find("title-size")->second);
580+ title_renderer_ = new TextRenderer(canvas_);
581+ title_renderer_->position(vec2_from_pos_string(title_pos_option.value));
582+ title_renderer_->size(Util::fromString<float>(title_size_option.value));
583+
584+ if (title_option.value == "#info#")
585+ title_renderer_->text(scene_->info_string());
586+ else if (title_option.value == "#name#")
587+ title_renderer_->text(scene_->name());
588+ else if (title_option.value == "#r2d2#")
589+ title_renderer_->text("Help me, Obi-Wan Kenobi. You're my only hope.");
590+ else
591+ title_renderer_->text(title_option.value);
592+ }
593 }
594
595 void
596@@ -284,12 +244,28 @@
597 fps_renderer_->text(ss.str());
598 }
599
600+LibMatrix::vec2
601+MainLoopDecoration::vec2_from_pos_string(const std::string &s)
602+{
603+ LibMatrix::vec2 v(0.0, 0.0);
604+ std::vector<std::string> elems;
605+ Util::split(s, ',', elems);
606+
607+ if (elems.size() > 0)
608+ v.x(Util::fromString<float>(elems[0]));
609+
610+ if (elems.size() > 1)
611+ v.y(Util::fromString<float>(elems[1]));
612+
613+ return v;
614+}
615+
616 /**********************
617 * MainLoopValidation *
618 **********************/
619
620-MainLoopValidation::MainLoopValidation(Canvas &canvas) :
621- MainLoop(canvas)
622+MainLoopValidation::MainLoopValidation(Canvas &canvas, const std::vector<Benchmark *> &benchmarks) :
623+ MainLoop(canvas, benchmarks)
624 {
625 }
626
627@@ -307,7 +283,7 @@
628 }
629
630 void
631-MainLoopValidation::before_scene_teardown()
632+MainLoopValidation::log_scene_result()
633 {
634 static const std::string format(Log::continuation_prefix + " Validation: %s\n");
635 std::string result;
636
637=== modified file 'src/main-loop.h'
638--- src/main-loop.h 2012-02-14 13:08:26 +0000
639+++ src/main-loop.h 2012-02-15 17:41:11 +0000
640@@ -25,6 +25,7 @@
641 #include "canvas.h"
642 #include "benchmark.h"
643 #include "text-renderer.h"
644+#include "vec.h"
645 #include <vector>
646
647 /**
648@@ -33,9 +34,9 @@
649 class MainLoop
650 {
651 public:
652- MainLoop(Canvas &canvas);
653+ MainLoop(Canvas &canvas, const std::vector<Benchmark *> &benchmarks);
654
655- virtual ~MainLoop();
656+ virtual ~MainLoop() {}
657
658 /**
659 * Resets the main loop.
660@@ -45,19 +46,6 @@
661 */
662 void reset();
663
664- /**
665- * Adds benchmarks.
666- *
667- * This method takes into account benchmark related command line options
668- * to decide which benchmarks to add.
669- */
670- void add_benchmarks();
671-
672- /**
673- * Adds user defined benchmarks.
674- */
675- void add_benchmarks(const std::vector<Benchmark *> &benchmarks);
676-
677 /**
678 * Gets the current total benchmarking score.
679 */
680@@ -83,27 +71,27 @@
681 /**
682 * Overridable method for post scene-setup customizations.
683 */
684- virtual void after_scene_setup();
685-
686- /**
687- * Overridable method for pre scene-teardown customizations.
688- */
689- virtual void before_scene_teardown();
690+ virtual void after_scene_setup() {}
691+
692+ /**
693+ * Overridable method for logging scene info.
694+ */
695+ virtual void log_scene_info();
696+
697+ /**
698+ * Overridable method for logging scene result.
699+ */
700+ virtual void log_scene_result();
701
702 protected:
703+ void next_benchmark();
704 Canvas &canvas_;
705 Scene *scene_;
706- std::vector<Benchmark *> benchmarks_;
707+ const std::vector<Benchmark *> &benchmarks_;
708 unsigned int score_;
709 unsigned int benchmarks_run_;
710
711 std::vector<Benchmark *>::const_iterator bench_iter_;
712-
713-private:
714- void add_default_benchmarks();
715- void add_custom_benchmarks();
716- void add_custom_benchmarks_from_files();
717- bool benchmarks_contain_normal_scenes();
718 };
719
720 /**
721@@ -112,15 +100,21 @@
722 class MainLoopDecoration : public MainLoop
723 {
724 public:
725- MainLoopDecoration(Canvas &canvas);
726+ MainLoopDecoration(Canvas &canvas, const std::vector<Benchmark *> &benchmarks);
727 virtual ~MainLoopDecoration();
728
729 virtual void draw();
730 virtual void before_scene_setup();
731+ virtual void after_scene_setup();
732
733 protected:
734 void fps_renderer_update_text(unsigned int fps);
735+ LibMatrix::vec2 vec2_from_pos_string(const std::string &s);
736+
737+ bool show_fps_;
738+ bool show_title_;
739 TextRenderer *fps_renderer_;
740+ TextRenderer *title_renderer_;
741 unsigned int last_fps_;
742 uint64_t fps_timestamp_;
743 };
744@@ -131,10 +125,10 @@
745 class MainLoopValidation : public MainLoop
746 {
747 public:
748- MainLoopValidation(Canvas &canvas);
749+ MainLoopValidation(Canvas &canvas, const std::vector<Benchmark *> &benchmarks);
750
751 virtual void draw();
752- virtual void before_scene_teardown();
753+ virtual void log_scene_result();
754 };
755
756 #endif /* GLMARK2_MAIN_LOOP_H_ */
757
758=== modified file 'src/main.cpp'
759--- src/main.cpp 2012-02-14 13:08:26 +0000
760+++ src/main.cpp 2012-02-15 17:41:11 +0000
761@@ -28,9 +28,9 @@
762 #include "options.h"
763 #include "log.h"
764 #include "util.h"
765-#include "default-benchmarks.h"
766 #include "text-renderer.h"
767 #include "main-loop.h"
768+#include "benchmark-collection.h"
769
770 #include <iostream>
771 #include <fstream>
772@@ -111,24 +111,33 @@
773 void
774 do_benchmark(Canvas &canvas)
775 {
776- MainLoop loop_normal(canvas);
777- MainLoopDecoration loop_decoration(canvas);
778+ BenchmarkCollection benchmark_collection;
779+ MainLoop *loop;
780
781- MainLoop &loop(Options::show_fps ? loop_decoration : loop_normal);
782- loop.add_benchmarks();
783+ benchmark_collection.populate_from_options();
784
785- while (loop.step());
786-
787- Log::info("=======================================================\n");
788- Log::info(" glmark2 Score: %u \n", loop.score());
789- Log::info("=======================================================\n");
790+ if (benchmark_collection.needs_decoration())
791+ loop = new MainLoopDecoration(canvas, benchmark_collection.benchmarks());
792+ else
793+ loop = new MainLoop(canvas, benchmark_collection.benchmarks());
794+
795+ while (loop->step());
796+
797+ Log::info("=======================================================\n");
798+ Log::info(" glmark2 Score: %u \n", loop->score());
799+ Log::info("=======================================================\n");
800+
801+ delete loop;
802 }
803
804 void
805 do_validation(Canvas &canvas)
806 {
807- MainLoopValidation loop(canvas);
808- loop.add_benchmarks();
809+ BenchmarkCollection benchmark_collection;
810+
811+ benchmark_collection.populate_from_options();
812+
813+ MainLoopValidation loop(canvas, benchmark_collection.benchmarks());
814
815 while (loop.step());
816 }
817
818=== modified file 'src/options.cpp'
819--- src/options.cpp 2012-01-27 12:10:17 +0000
820+++ src/options.cpp 2012-02-15 17:41:11 +0000
821@@ -38,9 +38,9 @@
822 bool Options::list_scenes = false;
823 bool Options::show_all_options = false;
824 bool Options::show_debug = false;
825-bool Options::show_fps = false;
826 bool Options::show_help = false;
827 bool Options::reuse_context = false;
828+bool Options::run_forever = false;
829
830 static struct option long_options[] = {
831 {"benchmark", 1, 0, 0},
832@@ -48,10 +48,10 @@
833 {"validate", 0, 0, 0},
834 {"no-swap-buffers", 0, 0, 0},
835 {"reuse-context", 0, 0, 0},
836+ {"run-forever", 0, 0, 0},
837 {"size", 1, 0, 0},
838 {"list-scenes", 0, 0, 0},
839 {"show-all-options", 0, 0, 0},
840- {"show-fps", 0, 0, 0},
841 {"debug", 0, 0, 0},
842 {"help", 0, 0, 0},
843 {0, 0, 0, 0}
844@@ -103,8 +103,8 @@
845 " and their options\n"
846 " --show-all-options Show all scene option values used for benchmarks\n"
847 " (only explicitly set options are shown by default)\n"
848- " --show-fps Show live FPS count on screen (showing live FPS\n"
849- " affects benchmarking results, use with care!)\n"
850+ " --run-forever Run indefinitely, looping from the last benchmark\n"
851+ " back to the first\n"
852 " -d, --debug Display debug messages\n"
853 " -h, --help Display help\n");
854 }
855@@ -143,8 +143,8 @@
856 Options::list_scenes = true;
857 else if (!strcmp(optname, "show-all-options"))
858 Options::show_all_options = true;
859- else if (!strcmp(optname, "show-fps"))
860- Options::show_fps = true;
861+ else if (!strcmp(optname, "run-forever"))
862+ Options::run_forever = true;
863 else if (c == 'd' || !strcmp(optname, "debug"))
864 Options::show_debug = true;
865 else if (c == 'h' || !strcmp(optname, "help"))
866
867=== modified file 'src/options.h'
868--- src/options.h 2012-01-18 17:13:28 +0000
869+++ src/options.h 2012-02-15 17:41:11 +0000
870@@ -39,9 +39,9 @@
871 static bool list_scenes;
872 static bool show_all_options;
873 static bool show_debug;
874- static bool show_fps;
875 static bool show_help;
876 static bool reuse_context;
877+ static bool run_forever;
878 };
879
880 #endif /* OPTIONS_H_ */
881
882=== modified file 'src/scene.cpp'
883--- src/scene.cpp 2012-02-09 01:28:16 +0000
884+++ src/scene.cpp 2012-02-15 17:41:11 +0000
885@@ -46,6 +46,20 @@
886 options_["fragment-precision"] = Scene::Option("fragment-precision",
887 "default,default,default,default",
888 "The precision values for the fragment shader (\"int,float,sampler2d,samplercube\")");
889+ /* FPS options */
890+ options_["show-fps"] = Scene::Option("show-fps", "false",
891+ "Show live FPS counter");
892+ options_["fps-pos"] = Scene::Option("fps-pos", "-1.0,-1.0",
893+ "The position on screen where to show FPS");
894+ options_["fps-size"] = Scene::Option("fps-size", "0.03",
895+ "The width of each glyph for the FPS");
896+ /* Title options */
897+ options_["title"] = Scene::Option("title", "",
898+ "The scene title to show");
899+ options_["title-pos"] = Scene::Option("title-pos", "-0.7,-1.0",
900+ "The position on screen where to show the title");
901+ options_["title-size"] = Scene::Option("title-size", "0.03",
902+ "The width of each glyph in the title");
903 }
904
905 Scene::~Scene()

Subscribers

People subscribed via source and target branches