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