diff mbox

[Branch,~glmark2-dev/glmark2/trunk] Rev 207: SceneIdeas: Updates to the fly around speed options. Create a special option

Message ID 20120511190209.1529.87303.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Jesse Barker May 11, 2012, 7:02 p.m. UTC
------------------------------------------------------------
revno: 207
committer: Jesse Barker <jesse.barker@linaro.org>
branch nick: trunk
timestamp: Fri 2012-05-11 11:58:09 -0700
message:
  SceneIdeas: Updates to the fly around speed options.  Create a special option
  value ("speed=duration") that computes the time factor as a function of the
  "duration" option.  Make other speeds raw number values (help text explains
  that 1.0 is "real" or "wall clock" time, <1.0 is slower and >1.0 is faster).
  Update default benchmark list to reflect the use of the duration option.
modified:
  src/default-benchmarks.h
  src/scene-ideas.cpp


--
lp:glmark2
https://code.launchpad.net/~glmark2-dev/glmark2/trunk

You are subscribed to branch lp:glmark2.
To unsubscribe from this branch go to https://code.launchpad.net/~glmark2-dev/glmark2/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'src/default-benchmarks.h'
--- src/default-benchmarks.h	2012-05-09 16:06:33 +0000
+++ src/default-benchmarks.h	2012-05-11 18:58:09 +0000
@@ -60,7 +60,7 @@ 
         benchmarks.push_back("buffer:update-fraction=0.5:update-dispersion=0.9:columns=200:update-method=map:interleave=false");
         benchmarks.push_back("buffer:update-fraction=0.5:update-dispersion=0.9:columns=200:update-method=subdata:interleave=false");
         benchmarks.push_back("buffer:update-fraction=0.5:update-dispersion=0.9:columns=200:update-method=map:interleave=true");
-        benchmarks.push_back("ideas:speed=max:duration=12");
+        benchmarks.push_back("ideas:speed=duration");
         benchmarks.push_back("conditionals:vertex-steps=0:fragment-steps=0");
         benchmarks.push_back("conditionals:vertex-steps=0:fragment-steps=5");
         benchmarks.push_back("conditionals:vertex-steps=5:fragment-steps=0");

=== modified file 'src/scene-ideas.cpp'
--- src/scene-ideas.cpp	2012-05-09 20:38:24 +0000
+++ src/scene-ideas.cpp	2012-05-11 18:58:09 +0000
@@ -36,13 +36,14 @@ 
 using LibMatrix::vec4;
 using LibMatrix::uvec3;
 using std::string;
+using std::map;
 
 class SceneIdeasPrivate
 {
 public:
     SceneIdeasPrivate() :
         valid_(false),
-        currentSpeed_(SPEED_MAXIMUM),
+        currentSpeed_(1.0), // Real time.
         currentTime_(START_TIME_),
         timeOffset_(START_TIME_)
     {
@@ -52,14 +53,13 @@ 
     ~SceneIdeasPrivate()
     {
     }
-    void initialize(const string& speed);
+    void initialize(map<string, Scene::Option>& options);
     void reset_time();
     void update_time();
     void update_projection(const mat4& proj);
     void draw();
 
 private:
-    float speed_from_optval(const string& optval);
     void postIdle();
     void initLights();
     bool valid_;
@@ -72,10 +72,6 @@ 
     static const float CYCLE_TIME_;
     static const float TIME_;
     static const float START_TIME_;
-    static const float SPEED_SLOW;
-    static const float SPEED_MEDIUM;
-    static const float SPEED_FAST;
-    static const float SPEED_MAXIMUM;
     // Table
     Table table_;
     // Logo
@@ -100,10 +96,6 @@ 
     vec4 lightPositions_[3];
 };
 
-const float SceneIdeasPrivate::SPEED_SLOW(0.2);
-const float SceneIdeasPrivate::SPEED_MEDIUM(0.4);
-const float SceneIdeasPrivate::SPEED_FAST(0.7);
-const float SceneIdeasPrivate::SPEED_MAXIMUM(1.0);
 const float SceneIdeasPrivate::TIME_(15.0);
 const float SceneIdeasPrivate::CYCLE_TIME_(TIME_ * 1.0 - 3.0);
 const float SceneIdeasPrivate::START_TIME_(0.6);
@@ -121,7 +113,7 @@ 
 }
 
 void
-SceneIdeasPrivate::initialize(const string& speed)
+SceneIdeasPrivate::initialize(map<string, Scene::Option>& options)
 {
     // Initialize the positions for the lights we'll use.
     initLights();
@@ -148,7 +140,19 @@ 
 
     reset_time();
 
-    currentSpeed_ = speed_from_optval(speed);
+    // If the option string tells us the user wants the speed to be a function
+    // of the scene duration, do it.  Otherwise, take the value explicitly.
+    static const string durationLabel("duration");
+    static const string speedLabel("speed");
+    if (options[speedLabel].value == durationLabel)
+    {
+        float duration = Util::fromString<float>(options[durationLabel].value);
+        currentSpeed_ = (CYCLE_TIME_ - START_TIME_) / duration;
+    }
+    else
+    {
+        currentSpeed_ = Util::fromString<float>(options[speedLabel].value);
+    }
 
     // If we're here, we're okay to run.
     valid_ = true;
@@ -195,35 +199,11 @@ 
     projection_ *= proj;
 }
 
-float
-SceneIdeasPrivate::speed_from_optval(const string& optval)
-{
-    float retVal(SPEED_MAXIMUM);
-    if (optval == "slow")
-    {
-        retVal = SPEED_SLOW;
-    }
-    else if (optval == "medium")
-    {
-        retVal = SPEED_MEDIUM;
-    }
-    else if (optval == "fast")
-    {
-        retVal = SPEED_FAST;
-    }
-    else if (optval != "max")
-    {
-        Log::error("Unknown speed option '%s', using default.\n", optval.c_str());
-    }
-
-    return retVal;
-}
-
 SceneIdeas::SceneIdeas(Canvas& canvas) :
     Scene(canvas, "ideas")
 {
-    options_["speed"] = Scene::Option("speed", "max",
-                                      "Rendering speed [slow, medium, fast, max]");
+    options_["speed"] = Scene::Option("speed", "duration",
+                                      "Time coefficient (1.0 is \"wall clock\" speed, <1.0 is slower, >1.0 is faster).  A special value of \"duration\" computes this as a function of the \"duration\" option");
 }
 
 SceneIdeas::~SceneIdeas()
@@ -248,7 +228,7 @@ 
 {
     Scene::setup();
     priv_ = new SceneIdeasPrivate();
-    priv_->initialize(options_["speed"].value);
+    priv_->initialize(options_);
     priv_->update_projection(canvas_.projection());
 
     // Core Scene state