aboutsummaryrefslogtreecommitdiff
path: root/samples/amber.cc
diff options
context:
space:
mode:
authorHugues Evrard <hevrard@users.noreply.github.com>2019-03-12 18:52:26 +0100
committerdan sinclair <dj2@everburning.com>2019-03-12 13:52:26 -0400
commit06e174dcbf63370ea802fe302e07250845bf74cf (patch)
tree616a0e0e8661419d2f9c6d19aa4550c8f8fd234f /samples/amber.cc
parent532a274fb38a0b17acd3c2e913355c12e016c744 (diff)
downloadamber-06e174dcbf63370ea802fe302e07250845bf74cf.tar.gz
Implement --log-graphics-calls-time flag (#351)
Add the necessary Delegate methods to implement timing of graphics API calls.
Diffstat (limited to 'samples/amber.cc')
-rw-r--r--samples/amber.cc28
1 files changed, 27 insertions, 1 deletions
diff --git a/samples/amber.cc b/samples/amber.cc
index 79d0cee..19c323f 100644
--- a/samples/amber.cc
+++ b/samples/amber.cc
@@ -26,6 +26,7 @@
#include "samples/config_helper.h"
#include "samples/png.h"
#include "samples/ppm.h"
+#include "samples/timestamp.h"
#include "src/build-versions.h"
#include "src/make_unique.h"
@@ -46,6 +47,7 @@ struct Options {
bool show_help = false;
bool show_version_info = false;
bool log_graphics_calls = false;
+ bool log_graphics_calls_time = false;
amber::EngineType engine = amber::kEngineTypeVulkan;
std::string spv_env;
};
@@ -66,6 +68,7 @@ const char kUsage[] = R"(Usage: amber [options] SCRIPT [SCRIPTS...]
-v <engine version> -- Engine version (eg, 1.1 for Vulkan). Default 1.0.
-V, --version -- Output version information for Amber and libraries.
--log-graphics-calls -- Log graphics API calls (only for Vulkan so far).
+ --log-graphics-calls-time -- Log timing of graphics API calls timing (Vulkan only).
-h -- This help text.
)";
@@ -161,6 +164,8 @@ bool ParseArgs(const std::vector<std::string>& args, Options* opts) {
opts->quiet = true;
} else if (arg == "--log-graphics-calls") {
opts->log_graphics_calls = true;
+ } else if (arg == "--log-graphics-calls-time") {
+ opts->log_graphics_calls_time = true;
} else if (arg.size() > 0 && arg[0] == '-') {
std::cerr << "Unrecognized option " << arg << std::endl;
return false;
@@ -209,7 +214,8 @@ std::string ReadFile(const std::string& input_file) {
class SampleDelegate : public amber::Delegate {
public:
- SampleDelegate() : log_graphics_calls_(false) {}
+ SampleDelegate()
+ : log_graphics_calls_(false), log_graphics_calls_time_(false) {}
~SampleDelegate() override = default;
void Log(const std::string& message) override {
@@ -222,8 +228,25 @@ class SampleDelegate : public amber::Delegate {
log_graphics_calls_ = log_graphics_calls;
}
+ bool LogGraphicsCallsTime() const override {
+ return log_graphics_calls_time_;
+ }
+
+ void SetLogGraphicsCallsTime(bool log_graphics_calls_time) {
+ log_graphics_calls_time_ = log_graphics_calls_time;
+ if (log_graphics_calls_time) {
+ // Make sure regular logging is also enabled
+ log_graphics_calls_ = true;
+ }
+ }
+
+ uint64_t GetTimestampNs() const override {
+ return timestamp::SampleGetTimestampNs();
+ }
+
private:
bool log_graphics_calls_;
+ bool log_graphics_calls_time_;
};
} // namespace
@@ -291,6 +314,9 @@ int main(int argc, const char** argv) {
if (options.log_graphics_calls) {
delegate.SetLogGraphicsCalls(true);
}
+ if (options.log_graphics_calls_time) {
+ delegate.SetLogGraphicsCallsTime(true);
+ }
amber::Options amber_options;
amber_options.engine = options.engine;