Merge lp:~linaro-graphics-wg/glmark2/options-finite-value-set into lp:glmark2/2011.11

Proposed by Alexandros Frantzis
Status: Merged
Merged at revision: 233
Proposed branch: lp:~linaro-graphics-wg/glmark2/options-finite-value-set
Merge into: lp:glmark2/2011.11
Diff against target: 505 lines (+138/-57)
17 files modified
src/benchmark.cpp (+12/-1)
src/main.cpp (+16/-0)
src/scene-buffer.cpp (+6/-3)
src/scene-build.cpp (+9/-8)
src/scene-bump.cpp (+2/-1)
src/scene-conditionals.cpp (+2/-2)
src/scene-default-options.cpp (+13/-1)
src/scene-desktop.cpp (+4/-3)
src/scene-effect-2d.cpp (+2/-1)
src/scene-function.cpp (+4/-4)
src/scene-loop.cpp (+6/-4)
src/scene-pulsar.cpp (+6/-3)
src/scene-shading.cpp (+7/-7)
src/scene-terrain.cpp (+4/-2)
src/scene-texture.cpp (+14/-14)
src/scene.cpp (+26/-1)
src/scene.h (+5/-2)
To merge this branch: bzr merge lp:~linaro-graphics-wg/glmark2/options-finite-value-set
Reviewer Review Type Date Requested Status
Jesse Barker Approve
Review via email: mp+115358@code.launchpad.net

Description of the change

Add support for options that have a finite set of acceptable values.

This includes listing the values in --list-scenes, and warning the user if they use unacceptable values.

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

Looks good. I take it this makes it easier for us to present the options in the Android UI (i.e., rather than the user having to type option values, they might be able to select them from a list/menu of some sort)?

review: Approve
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Yes. In fact, I already have some experimental code for Android GUI integration. It needs some cleanup, but if all goes well we can merge it in time for 2012.07.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/benchmark.cpp'
2--- src/benchmark.cpp 2012-02-15 16:22:18 +0000
3+++ src/benchmark.cpp 2012-07-17 14:39:31 +0000
4@@ -144,7 +144,18 @@
5 iter != options_.end();
6 iter++)
7 {
8- scene_.set_option(iter->first, iter->second);
9+ if (!scene_.set_option(iter->first, iter->second)) {
10+ map<string, Scene::Option>::const_iterator opt_iter = scene_.options().find(iter->first);
11+
12+ if (opt_iter == scene_.options().end()) {
13+ Log::info("Warning: Scene '%s' doesn't accept option '%s'\n",
14+ scene_.name().c_str(), iter->first.c_str());
15+ }
16+ else {
17+ Log::info("Warning: Scene '%s' doesn't accept value '%s' for option '%s'\n",
18+ scene_.name().c_str(), iter->second.c_str(), iter->first.c_str());
19+ }
20+ }
21 }
22 }
23
24
25=== modified file 'src/main.cpp'
26--- src/main.cpp 2012-07-09 15:54:30 +0000
27+++ src/main.cpp 2012-07-17 14:39:31 +0000
28@@ -99,6 +99,22 @@
29 opt.name.c_str(),
30 opt.description.c_str(),
31 opt.default_value.c_str());
32+
33+ /* Display list of acceptable values (if defined) */
34+ if (!opt.acceptable_values.empty()) {
35+ Log::info(" Acceptable Values: ");
36+ for (vector<string>::const_iterator val_iter = opt.acceptable_values.begin();
37+ val_iter != opt.acceptable_values.end();
38+ val_iter++)
39+ {
40+ std::string format_value(Log::continuation_prefix + "%s");
41+ if (val_iter + 1 != opt.acceptable_values.end())
42+ format_value += ",";
43+ else
44+ format_value += "\n";
45+ Log::info(format_value.c_str(), val_iter->c_str());
46+ }
47+ }
48 }
49 }
50 }
51
52=== modified file 'src/scene-buffer.cpp'
53--- src/scene-buffer.cpp 2012-01-13 13:50:31 +0000
54+++ src/scene-buffer.cpp 2012-07-17 14:39:31 +0000
55@@ -303,9 +303,11 @@
56 {
57 priv_ = new SceneBufferPrivate();
58 options_["interleave"] = Scene::Option("interleave", "false",
59- "Whether to interleave vertex attribute data [true,false]");
60+ "Whether to interleave vertex attribute data",
61+ "false,true");
62 options_["update-method"] = Scene::Option("update-method", "map",
63- "[map,subdata]");
64+ "Which method to use to update vertex data",
65+ "map,subdata");
66 options_["update-fraction"] = Scene::Option("update-fraction", "1.0",
67 "The fraction of the mesh length that is updated at every iteration (0.0-1.0)");
68 options_["update-dispersion"] = Scene::Option("update-dispersion", "0.0",
69@@ -315,7 +317,8 @@
70 options_["rows"] = Scene::Option("rows", "20",
71 "The number of mesh subdisivisions width-wise");
72 options_["buffer-usage"] = Scene::Option("buffer-usage", "static",
73- "How the buffer will be used [static,stream,dynamic]");
74+ "How the buffer will be used",
75+ "static,stream,dynamic");
76 }
77
78 SceneBuffer::~SceneBuffer()
79
80=== modified file 'src/scene-build.cpp'
81--- src/scene-build.cpp 2012-05-22 08:46:33 +0000
82+++ src/scene-build.cpp 2012-07-17 14:39:31 +0000
83@@ -36,7 +36,7 @@
84 orientModel_(false)
85 {
86 const ModelMap& modelMap = Model::find_models();
87- std::string optionDesc("Which model to use [");
88+ std::string optionValues;
89 for (ModelMap::const_iterator modelIt = modelMap.begin();
90 modelIt != modelMap.end();
91 modelIt++)
92@@ -44,19 +44,20 @@
93 static bool doSeparator(false);
94 if (doSeparator)
95 {
96- optionDesc += ", ";
97+ optionValues += ",";
98 }
99 const std::string& curName = modelIt->first;
100- optionDesc += curName;
101+ optionValues += curName;
102 doSeparator = true;
103 }
104- optionDesc += "]";
105 options_["use-vbo"] = Scene::Option("use-vbo", "true",
106- "Whether to use VBOs for rendering [true,false]");
107+ "Whether to use VBOs for rendering",
108+ "false,true");
109 options_["interleave"] = Scene::Option("interleave", "false",
110- "Whether to interleave vertex attribute data [true,false]");
111- options_["model"] = Scene::Option("model", "horse",
112- optionDesc);
113+ "Whether to interleave vertex attribute data",
114+ "false,true");
115+ options_["model"] = Scene::Option("model", "horse", "Which model to use",
116+ optionValues);
117 }
118
119 SceneBuild::~SceneBuild()
120
121=== modified file 'src/scene-bump.cpp'
122--- src/scene-bump.cpp 2012-05-15 18:38:47 +0000
123+++ src/scene-bump.cpp 2012-07-17 14:39:31 +0000
124@@ -35,7 +35,8 @@
125 texture_(0), rotation_(0.0f), rotationSpeed_(0.0f)
126 {
127 options_["bump-render"] = Scene::Option("bump-render", "off",
128- "How to render bumps [off, normals, normals-tangent, height, high-poly]");
129+ "How to render bumps",
130+ "off,normals,normals-tangent,height,high-poly");
131 }
132
133 SceneBump::~SceneBump()
134
135=== modified file 'src/scene-conditionals.cpp'
136--- src/scene-conditionals.cpp 2011-11-11 11:07:15 +0000
137+++ src/scene-conditionals.cpp 2012-07-17 14:39:31 +0000
138@@ -42,11 +42,11 @@
139 options_["fragment-steps"] = Scene::Option("fragment-steps", "1",
140 "The number of computational steps in the fragment shader");
141 options_["fragment-conditionals"] = Scene::Option("fragment-conditionals", "true",
142- "Whether each computational step includes an if-else clause");
143+ "Whether each computational step includes an if-else clause", "false,true");
144 options_["vertex-steps"] = Scene::Option("vertex-steps", "1",
145 "The number of computational steps in the vertex shader");
146 options_["vertex-conditionals"] = Scene::Option("vertex-conditionals", "true",
147- "Whether each computational step includes an if-else clause");
148+ "Whether each computational step includes an if-else clause", "false,true");
149 }
150
151 SceneConditionals::~SceneConditionals()
152
153=== modified file 'src/scene-default-options.cpp'
154--- src/scene-default-options.cpp 2011-10-26 14:09:17 +0000
155+++ src/scene-default-options.cpp 2012-07-17 14:39:31 +0000
156@@ -21,6 +21,7 @@
157 */
158 #include "scene.h"
159 #include "benchmark.h"
160+#include "log.h"
161
162 void
163 SceneDefaultOptions::setup()
164@@ -35,7 +36,18 @@
165 scene_iter != scenes.end();
166 scene_iter++)
167 {
168- scene_iter->second->set_option_default(iter->first, iter->second);
169+ Scene &scene(*(scene_iter->second));
170+
171+ /*
172+ * Display warning only if the option value is unsupported, not if
173+ * the scene doesn't support the option at all.
174+ */
175+ if (!scene.set_option_default(iter->first, iter->second) &&
176+ scene.options().find(iter->first) != scene.options().end())
177+ {
178+ Log::info("Warning: Scene '%s' doesn't accept default value '%s' for option '%s'\n",
179+ scene.name().c_str(), iter->second.c_str(), iter->first.c_str());
180+ }
181 }
182 }
183 }
184
185=== modified file 'src/scene-desktop.cpp'
186--- src/scene-desktop.cpp 2012-05-15 18:38:47 +0000
187+++ src/scene-desktop.cpp 2012-07-17 14:39:31 +0000
188@@ -759,8 +759,8 @@
189 Scene(canvas, "desktop")
190 {
191 priv_ = new SceneDesktopPrivate(canvas);
192- options_["effect"] = Scene::Option("effect", "blur",
193- "the effect to use [blur]");
194+ options_["effect"] = Scene::Option("effect", "blur", "The effect to use",
195+ "blur,shadow");
196 options_["windows"] = Scene::Option("windows", "4",
197 "the number of windows");
198 options_["window-size"] = Scene::Option("window-size", "0.35",
199@@ -770,7 +770,8 @@
200 options_["blur-radius"] = Scene::Option("blur-radius", "5",
201 "the blur effect radius (in pixels)");
202 options_["separable"] = Scene::Option("separable", "true",
203- "use separable convolution for the blur effect");
204+ "use separable convolution for the blur effect",
205+ "false,true");
206 options_["shadow-size"] = Scene::Option("shadow-size", "20",
207 "the size of the shadow (in pixels)");
208 }
209
210=== modified file 'src/scene-effect-2d.cpp'
211--- src/scene-effect-2d.cpp 2012-05-15 18:38:47 +0000
212+++ src/scene-effect-2d.cpp 2012-07-17 14:39:31 +0000
213@@ -41,7 +41,8 @@
214 "0,0,0;0,1,0;0,0,0",
215 "The convolution kernel matrix to use [format: \"a,b,c...;d,e,f...\"");;
216 options_["normalize"] = Scene::Option("normalize", "true",
217- "Whether to normalize the supplied convolution kernel matrix [true,false]");
218+ "Whether to normalize the supplied convolution kernel matrix",
219+ "false,true");
220 }
221
222 SceneEffect2D::~SceneEffect2D()
223
224=== modified file 'src/scene-function.cpp'
225--- src/scene-function.cpp 2011-11-11 11:07:15 +0000
226+++ src/scene-function.cpp 2012-07-17 14:39:31 +0000
227@@ -43,15 +43,15 @@
228 options_["fragment-steps"] = Scene::Option("fragment-steps", "1",
229 "The number of computational steps in the fragment shader");
230 options_["fragment-function"] = Scene::Option("fragment-function", "true",
231- "Whether each computational step includes a function call");
232+ "Whether each computational step includes a function call", "false,true");
233 options_["vertex-steps"] = Scene::Option("vertex-steps", "1",
234 "The number of computational steps in the vertex shader");
235 options_["vertex-function"] = Scene::Option("vertex-function", "true",
236- "Whether each computational step includes an if-else clause");
237+ "Whether each computational step includes an if-else clause", "false,true");
238 options_["vertex-complexity"] = Scene::Option("vertex-complexity", "low",
239- "The complexity of each computational step in the vertex shader");
240+ "The complexity of each computational step in the vertex shader", "low,medium");
241 options_["fragment-complexity"] = Scene::Option("fragment-complexity", "low",
242- "The complexity of each computational step in the fragment shader");
243+ "The complexity of each computational step in the fragment shader", "low,medium");
244 }
245
246 SceneFunction::~SceneFunction()
247
248=== modified file 'src/scene-loop.cpp'
249--- src/scene-loop.cpp 2011-11-11 11:07:15 +0000
250+++ src/scene-loop.cpp 2012-07-17 14:39:31 +0000
251@@ -42,15 +42,17 @@
252 options_["fragment-steps"] = Scene::Option("fragment-steps", "1",
253 "The number of computational steps in the fragment shader");
254 options_["fragment-loop"] = Scene::Option("fragment-function", "true",
255- "Whether to execute the steps in the vertex shader using a for loop");
256+ "Whether to execute the steps in the vertex shader using a for loop", "false,true");
257 options_["vertex-steps"] = Scene::Option("vertex-steps", "1",
258 "The number of computational steps in the vertex shader");
259 options_["vertex-loop"] = Scene::Option("vertex-function", "true",
260- "Whether to execute the steps in the vertex shader using a for loop");
261+ "Whether to execute the steps in the vertex shader using a for loop", "false,true");
262 options_["vertex-uniform"] = Scene::Option("vertex-uniform", "true",
263- "Whether to use a uniform in the vertex shader for the number of loop iterations to perform (i.e. vertex-steps)");
264+ "Whether to use a uniform in the vertex shader for the number of loop iterations to perform (i.e. vertex-steps)",
265+ "false,true");
266 options_["fragment-uniform"] = Scene::Option("fragment-uniform", "true",
267- "Whether to use a uniform in the fragment shader for the number of loop iterations to perform (i.e. fragment-steps)");
268+ "Whether to use a uniform in the fragment shader for the number of loop iterations to perform (i.e. fragment-steps)",
269+ "false,true");
270 }
271
272 SceneLoop::~SceneLoop()
273
274=== modified file 'src/scene-pulsar.cpp'
275--- src/scene-pulsar.cpp 2012-05-15 18:38:47 +0000
276+++ src/scene-pulsar.cpp 2012-07-17 14:39:31 +0000
277@@ -46,9 +46,12 @@
278 texture_(0)
279 {
280 options_["quads"] = Scene::Option("quads", "5", "Number of quads to render");
281- options_["texture"] = Scene::Option("texture", "false", "Enable texturing");
282- options_["light"] = Scene::Option("light", "false", "Enable lighting");
283- options_["random"] = Scene::Option("random", "false", "Enable random rotation speeds");
284+ options_["texture"] = Scene::Option("texture", "false", "Enable texturing",
285+ "false,true");
286+ options_["light"] = Scene::Option("light", "false", "Enable lighting",
287+ "false,true");
288+ options_["random"] = Scene::Option("random", "false", "Enable random rotation speeds",
289+ "false,true");
290 }
291
292 ScenePulsar::~ScenePulsar()
293
294=== modified file 'src/scene-shading.cpp'
295--- src/scene-shading.cpp 2012-05-22 08:46:33 +0000
296+++ src/scene-shading.cpp 2012-07-17 14:39:31 +0000
297@@ -43,7 +43,7 @@
298 orientModel_(false)
299 {
300 const ModelMap& modelMap = Model::find_models();
301- std::string optionDesc("Which model to use [");
302+ std::string optionValues;
303 for (ModelMap::const_iterator modelIt = modelMap.begin();
304 modelIt != modelMap.end();
305 modelIt++)
306@@ -51,19 +51,19 @@
307 static bool doSeparator(false);
308 if (doSeparator)
309 {
310- optionDesc += ", ";
311+ optionValues += ",";
312 }
313 const std::string& curName = modelIt->first;
314- optionDesc += curName;
315+ optionValues += curName;
316 doSeparator = true;
317 }
318- optionDesc += "]";
319 options_["shading"] = Scene::Option("shading", "gouraud",
320- "[gouraud, blinn-phong-inf, phong]");
321+ "Which shading method to use",
322+ "gouraud,blinn-phong-inf,phong");
323 options_["num-lights"] = Scene::Option("num-lights", "1",
324 "The number of lights applied to the scene (phong only)");
325- options_["model"] = Scene::Option("model", "cat",
326- optionDesc);
327+ options_["model"] = Scene::Option("model", "cat", "Which model to use",
328+ optionValues);
329 }
330
331 SceneShading::~SceneShading()
332
333=== modified file 'src/scene-terrain.cpp'
334--- src/scene-terrain.cpp 2012-07-03 09:56:14 +0000
335+++ src/scene-terrain.cpp 2012-07-17 14:39:31 +0000
336@@ -218,9 +218,11 @@
337 options_["repeat-overlay"] = Scene::Option("repeat-overlay", "6.0",
338 "How many times to repeat the terrain texture on the terrain plane (per side)");
339 options_["bloom"] = Scene::Option("bloom", "true",
340- "Use bloom post-processing effect [true,false]");
341+ "Use bloom post-processing effect",
342+ "false,true");
343 options_["tilt-shift"] = Scene::Option("tilt-shift", "true",
344- "Use tilt-shift post-processing effect [true,false]");
345+ "Use tilt-shift post-processing effect",
346+ "false,true");
347 }
348
349 SceneTerrain::~SceneTerrain()
350
351=== modified file 'src/scene-texture.cpp'
352--- src/scene-texture.cpp 2012-07-04 10:07:42 +0000
353+++ src/scene-texture.cpp 2012-07-17 14:39:31 +0000
354@@ -42,7 +42,7 @@
355 orientModel_(false), orientationAngle_(0.0)
356 {
357 const ModelMap& modelMap = Model::find_models();
358- string optionDesc("Which model to use [");
359+ string optionValues;
360 for (ModelMap::const_iterator modelIt = modelMap.begin();
361 modelIt != modelMap.end();
362 modelIt++)
363@@ -50,18 +50,18 @@
364 static bool doSeparator(false);
365 if (doSeparator)
366 {
367- optionDesc += ", ";
368+ optionValues += ",";
369 }
370 const std::string& curName = modelIt->first;
371- optionDesc += curName;
372+ optionValues += curName;
373 doSeparator = true;
374 }
375- optionDesc += "]";
376- options_["model"] = Scene::Option("model", "cube",
377- optionDesc);
378+ options_["model"] = Scene::Option("model", "cube", "Which model to use",
379+ optionValues);
380 options_["texture-filter"] = Scene::Option("texture-filter", "nearest",
381- "[nearest, linear, linear-shader, mipmap]");
382- optionDesc = "Which texture to use [";
383+ "The texture filter to use",
384+ "nearest,linear,linear-shader,mipmap");
385+ optionValues = "";
386 const TextureMap& textureMap = Texture::find_textures();
387 for (TextureMap::const_iterator textureIt = textureMap.begin();
388 textureIt != textureMap.end();
389@@ -70,17 +70,17 @@
390 static bool doSeparator(false);
391 if (doSeparator)
392 {
393- optionDesc += ", ";
394+ optionValues += ",";
395 }
396 const std::string& curName = textureIt->first;
397- optionDesc += curName;
398+ optionValues += curName;
399 doSeparator = true;
400 }
401- optionDesc += "]";
402- options_["texture"] = Scene::Option("texture", "crate-base",
403- optionDesc);
404+ options_["texture"] = Scene::Option("texture", "crate-base", "Which texture to use",
405+ optionValues);
406 options_["texgen"] = Scene::Option("texgen", "false",
407- "Whether to generate texcoords in the shader");
408+ "Whether to generate texcoords in the shader",
409+ "false,true");
410 }
411
412 SceneTexture::~SceneTexture()
413
414=== modified file 'src/scene.cpp'
415--- src/scene.cpp 2012-02-15 16:22:18 +0000
416+++ src/scene.cpp 2012-07-17 14:39:31 +0000
417@@ -28,11 +28,19 @@
418 #include "util.h"
419 #include <sstream>
420 #include <cmath>
421+#include <algorithm>
422
423 using std::stringstream;
424 using std::string;
425 using std::map;
426
427+Scene::Option::Option(const std::string &nam, const std::string &val, const std::string &desc,
428+ const std::string &values) :
429+name(nam), value(val), default_value(val), description(desc), set(false)
430+{
431+ Util::split(values, ',', acceptable_values);
432+}
433+
434 Scene::Scene(Canvas &pCanvas, const string &name) :
435 canvas_(pCanvas), name_(name),
436 startTime_(0), lastUpdateTime_(0), currentFrame_(0),
437@@ -48,7 +56,8 @@
438 "The precision values for the fragment shader (\"int,float,sampler2d,samplercube\")");
439 /* FPS options */
440 options_["show-fps"] = Scene::Option("show-fps", "false",
441- "Show live FPS counter");
442+ "Show live FPS counter",
443+ "false,true");
444 options_["fps-pos"] = Scene::Option("fps-pos", "-1.0,-1.0",
445 "The position on screen where to show FPS");
446 options_["fps-size"] = Scene::Option("fps-size", "0.03",
447@@ -143,6 +152,14 @@
448 if (iter == options_.end())
449 return false;
450
451+ std::vector<std::string> &values(iter->second.acceptable_values);
452+
453+ if (!values.empty() &&
454+ std::find(values.begin(), values.end(), val) == values.end())
455+ {
456+ return false;
457+ }
458+
459 iter->second.value = val;
460 iter->second.set = true;
461
462@@ -171,6 +188,14 @@
463 if (iter == options_.end())
464 return false;
465
466+ std::vector<std::string> &values(iter->second.acceptable_values);
467+
468+ if (!values.empty() &&
469+ std::find(values.begin(), values.end(), val) == values.end())
470+ {
471+ return false;
472+ }
473+
474 iter->second.default_value = val;
475
476 return true;
477
478=== modified file 'src/scene.h'
479--- src/scene.h 2012-07-09 15:54:30 +0000
480+++ src/scene.h 2012-07-17 14:39:31 +0000
481@@ -37,6 +37,7 @@
482 #include <string>
483 #include <map>
484 #include <list>
485+#include <vector>
486 #include "canvas.h"
487
488 /**
489@@ -51,13 +52,15 @@
490 * Scene options.
491 */
492 struct Option {
493- Option(const std::string &nam, const std::string &val, const std::string &desc) :
494- name(nam), value(val), default_value(val), description(desc), set(false) {}
495+ Option(const std::string &nam, const std::string &val, const std::string &desc,
496+ const std::string &values = "");
497+
498 Option() {}
499 std::string name;
500 std::string value;
501 std::string default_value;
502 std::string description;
503+ std::vector<std::string> acceptable_values;
504 bool set;
505 };
506

Subscribers

People subscribed via source and target branches