aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoey-lunarg <joey@lunarg.com>2016-11-03 13:49:49 -0600
committerjoey-lunarg <joey@lunarg.com>2016-11-10 09:54:00 -0700
commit20e10a9ba8ae79d13c42f5386eec98be5fef8f72 (patch)
tree4c447615954e07f108ddf0947303fe29c4b03513
parent7bc603db086cdc3831b19490d263eee7626fad35 (diff)
downloadusermoji-20e10a9ba8ae79d13c42f5386eec98be5fef8f72.tar.xz
demos: Add testing features for smoke
Smoketest will now output # of frames rendered and elapsed ms. Command line argument added to limit the rendered frames, usage: 'smoketest --c <framecount>' Change-Id: Id6bc0186169b6511823c4406be655f6d8ca18324
-rw-r--r--demos/smoke/CMakeLists.txt1
-rw-r--r--demos/smoke/Game.h20
-rw-r--r--demos/smoke/Smoke.cpp10
3 files changed, 29 insertions, 2 deletions
diff --git a/demos/smoke/CMakeLists.txt b/demos/smoke/CMakeLists.txt
index 756b6482..bbc00854 100644
--- a/demos/smoke/CMakeLists.txt
+++ b/demos/smoke/CMakeLists.txt
@@ -21,6 +21,7 @@ glsl_to_spirv(Smoke.vert)
glsl_to_spirv(Smoke.push_constant.vert)
set(sources
+ Game.cpp
Game.h
Helpers.h
HelpersDispatchTable.cpp
diff --git a/demos/smoke/Game.h b/demos/smoke/Game.h
index 65357ae6..15d3d668 100644
--- a/demos/smoke/Game.h
+++ b/demos/smoke/Game.h
@@ -17,6 +17,8 @@
#ifndef GAME_H
#define GAME_H
+#include <chrono>
+#include <iostream>
#include <string>
#include <vector>
@@ -44,6 +46,8 @@ public:
bool no_tick;
bool no_render;
bool no_present;
+
+ int max_frame_count;
};
const Settings &settings() const { return settings_; }
@@ -68,7 +72,12 @@ public:
virtual void on_frame(float frame_pred) {}
-protected:
+ void print_stats();
+ void quit();
+ protected:
+ int frame_count;
+ std::chrono::time_point<std::chrono::system_clock> start_time;
+
Game(const std::string &name, const std::vector<std::string> &args)
: settings_(), shell_(nullptr)
{
@@ -88,7 +97,13 @@ protected:
settings_.no_render = false;
settings_.no_present = false;
+ settings_.max_frame_count = -1;
+
parse_args(args);
+
+ frame_count = 0;
+ // Record start time for printing stats later
+ start_time = std::chrono::system_clock::now();
}
Settings settings_;
@@ -119,6 +134,9 @@ private:
settings_.no_render = true;
} else if (*it == "-np") {
settings_.no_present = true;
+ } else if (*it == "--c") {
+ ++it;
+ settings_.max_frame_count = std::stoi(*it);
}
}
}
diff --git a/demos/smoke/Smoke.cpp b/demos/smoke/Smoke.cpp
index 76a9a90c..68f949d3 100644
--- a/demos/smoke/Smoke.cpp
+++ b/demos/smoke/Smoke.cpp
@@ -734,7 +734,7 @@ void Smoke::on_key(Key key)
switch (key) {
case KEY_SHUTDOWN:
case KEY_ESC:
- shell_->quit();
+ quit();
break;
case KEY_UP:
camera_.eye_pos -= glm::vec3(0.05f);
@@ -763,6 +763,14 @@ void Smoke::on_tick()
void Smoke::on_frame(float frame_pred)
{
+ // Limit number of frames if argument was specified
+ if (settings_.max_frame_count != -1 &&
+ frame_count == settings_.max_frame_count) {
+ quit();
+ return;
+ }
+ frame_count++;
+
auto &data = frame_data_[frame_data_index_];
// wait for the last submission since we reuse frame data