From 4f5abb1ca729f9ae0a1c0da878bee5da5c30be16 Mon Sep 17 00:00:00 2001 From: saschawillems Date: Fri, 11 Mar 2016 19:38:23 +0100 Subject: [PATCH] Added frame timing functions to android base class --- android/base/vulkanandroidbase.hpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/android/base/vulkanandroidbase.hpp b/android/base/vulkanandroidbase.hpp index 8b3d05ba..3a468cbd 100644 --- a/android/base/vulkanandroidbase.hpp +++ b/android/base/vulkanandroidbase.hpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include "vulkanandroid.h" @@ -25,6 +26,7 @@ class VulkanAndroidExampleBase { private: + std::chrono::high_resolution_clock::time_point tStart; VkShaderModule loadShaderModule(const char *fileName, VkShaderStageFlagBits stage) { // Load shader from compressed asset @@ -58,6 +60,7 @@ public: struct android_app* app; uint32_t width; uint32_t height; + float frameTimer = 0; struct Texture { VkSampler sampler; @@ -863,4 +866,16 @@ public: vkFreeMemory(device, texture->deviceMemory, nullptr); } + void startTiming() + { + tStart = std::chrono::high_resolution_clock::now(); + } + + void endTiming() + { + auto tEnd = std::chrono::high_resolution_clock::now(); + auto tDiff = std::chrono::duration(tEnd - tStart).count(); + frameTimer = (float)tDiff; + } + }; \ No newline at end of file