diff options
author | Hugues Evrard <hevrard@users.noreply.github.com> | 2019-03-12 18:52:26 +0100 |
---|---|---|
committer | dan sinclair <dj2@everburning.com> | 2019-03-12 13:52:26 -0400 |
commit | 06e174dcbf63370ea802fe302e07250845bf74cf (patch) | |
tree | 616a0e0e8661419d2f9c6d19aa4550c8f8fd234f /tools | |
parent | 532a274fb38a0b17acd3c2e913355c12e016c744 (diff) | |
download | amber-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 'tools')
-rwxr-xr-x | tools/update_vk_wrappers.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/tools/update_vk_wrappers.py b/tools/update_vk_wrappers.py index bb7dd45..995558d 100755 --- a/tools/update_vk_wrappers.py +++ b/tools/update_vk_wrappers.py @@ -89,7 +89,6 @@ def gen_wrappers(methods, xml): return_variable = 'ret' call_prefix = return_type + ' ' + return_variable + ' = ' - template = Template(R'''{ PFN_${method} ptr = reinterpret_cast<PFN_${method}>(getInstanceProcAddr(instance_, "${method}")); if (!ptr) { @@ -98,7 +97,23 @@ def gen_wrappers(methods, xml): if (delegate && delegate->LogGraphicsCalls()) { ptrs_.${method} = [ptr, delegate](${signature}) -> ${return_type} { delegate->Log("${method}"); + uint64_t timestamp_start = 0; + if (delegate->LogGraphicsCallsTime()) { + timestamp_start = delegate->GetTimestampNs(); + } ${call_prefix}ptr(${arguments}); + if (delegate->LogGraphicsCallsTime()) { + uint64_t timestamp_end = delegate->GetTimestampNs(); + uint64_t duration = timestamp_end - timestamp_start; + std::ostringstream out; + out << "time "; + // name of method on 40 characters + out << std::left << std::setw(40) << "${method}"; + // duration in nanoseconds on 12 characters, right-aligned + out << std::right << std::setw(12) << duration; + out << " ns"; + delegate->Log(out.str()); + } return ${return_variable}; }; } else { |