Added frame timing functions to android base class
This commit is contained in:
parent
4c217cef21
commit
4f5abb1ca7
1 changed files with 15 additions and 0 deletions
|
|
@ -16,6 +16,7 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
#include "vulkanandroid.h"
|
#include "vulkanandroid.h"
|
||||||
|
|
@ -25,6 +26,7 @@
|
||||||
class VulkanAndroidExampleBase
|
class VulkanAndroidExampleBase
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
std::chrono::high_resolution_clock::time_point tStart;
|
||||||
VkShaderModule loadShaderModule(const char *fileName, VkShaderStageFlagBits stage)
|
VkShaderModule loadShaderModule(const char *fileName, VkShaderStageFlagBits stage)
|
||||||
{
|
{
|
||||||
// Load shader from compressed asset
|
// Load shader from compressed asset
|
||||||
|
|
@ -58,6 +60,7 @@ public:
|
||||||
struct android_app* app;
|
struct android_app* app;
|
||||||
uint32_t width;
|
uint32_t width;
|
||||||
uint32_t height;
|
uint32_t height;
|
||||||
|
float frameTimer = 0;
|
||||||
|
|
||||||
struct Texture {
|
struct Texture {
|
||||||
VkSampler sampler;
|
VkSampler sampler;
|
||||||
|
|
@ -863,4 +866,16 @@ public:
|
||||||
vkFreeMemory(device, texture->deviceMemory, nullptr);
|
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<double, std::milli>(tEnd - tStart).count();
|
||||||
|
frameTimer = (float)tDiff;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
Loading…
Add table
Add a link
Reference in a new issue