diff options
author | dan sinclair <dj2@everburning.com> | 2019-04-19 22:34:38 -0400 |
---|---|---|
committer | David Neto <dneto@google.com> | 2019-04-19 22:34:38 -0400 |
commit | 6832a926d1e8ea9fb1edfbf8e884a66e4364945b (patch) | |
tree | 1e940044649b7bd312a224901aeb378235bbb482 /samples | |
parent | 9d7d3bb684694eb43faff42bad8c400e533eaecd (diff) | |
download | amber-6832a926d1e8ea9fb1edfbf8e884a66e4364945b.tar.gz |
Add flag to log execute calls. (#483)
This CL adds a flag to the sample app and extends the Delgate to allow
logging command names before they're executed. This should allow easier
tracking down of the command which causes a segv during executing.
Diffstat (limited to 'samples')
-rw-r--r-- | samples/amber.cc | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/samples/amber.cc b/samples/amber.cc index 0541fce..48e6771 100644 --- a/samples/amber.cc +++ b/samples/amber.cc @@ -51,6 +51,7 @@ struct Options { bool show_version_info = false; bool log_graphics_calls = false; bool log_graphics_calls_time = false; + bool log_execute_calls = false; amber::EngineType engine = amber::kEngineTypeVulkan; std::string spv_env; }; @@ -72,6 +73,7 @@ const char kUsage[] = R"(Usage: amber [options] SCRIPT [SCRIPTS...] -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). + --log-execute-calls -- Log each execute call before run. -h -- This help text. )"; @@ -169,6 +171,8 @@ bool ParseArgs(const std::vector<std::string>& args, Options* opts) { opts->log_graphics_calls = true; } else if (arg == "--log-graphics-calls-time") { opts->log_graphics_calls_time = true; + } else if (arg == "--log-execute-calls") { + opts->log_execute_calls = true; } else if (arg.size() > 0 && arg[0] == '-') { std::cerr << "Unrecognized option " << arg << std::endl; return false; @@ -217,8 +221,7 @@ std::string ReadFile(const std::string& input_file) { class SampleDelegate : public amber::Delegate { public: - SampleDelegate() - : log_graphics_calls_(false), log_graphics_calls_time_(false) {} + SampleDelegate() = default; ~SampleDelegate() override = default; void Log(const std::string& message) override { @@ -226,15 +229,18 @@ class SampleDelegate : public amber::Delegate { } bool LogGraphicsCalls() const override { return log_graphics_calls_; } - void SetLogGraphicsCalls(bool log_graphics_calls) { log_graphics_calls_ = log_graphics_calls; } + bool LogExecuteCalls() const override { return log_execute_calls_; } + void SetLogExecuteCalls(bool log_execute_calls) { + log_execute_calls_ = log_execute_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) { @@ -248,8 +254,9 @@ class SampleDelegate : public amber::Delegate { } private: - bool log_graphics_calls_; - bool log_graphics_calls_time_; + bool log_graphics_calls_ = false; + bool log_graphics_calls_time_ = false; + bool log_execute_calls_ = false; }; } // namespace @@ -314,12 +321,12 @@ int main(int argc, const char** argv) { return 0; SampleDelegate delegate; - if (options.log_graphics_calls) { + if (options.log_graphics_calls) delegate.SetLogGraphicsCalls(true); - } - if (options.log_graphics_calls_time) { + if (options.log_graphics_calls_time) delegate.SetLogGraphicsCallsTime(true); - } + if (options.log_execute_calls) + delegate.SetLogExecuteCalls(true); amber::Options amber_options; amber_options.engine = options.engine; |