SpiecsEngine
 
Loading...
Searching...
No Matches
TimestampQueryer.cpp
Go to the documentation of this file.
1/**
2* @file TimestampQueryer.cpp.
3* @brief The TimestampQuerier Class Implementation.
4* @author Spices.
5*/
6
7#include "Pchheader.h"
9#include "Render/Vulkan/VulkanRenderBackend.h"
10
11namespace Spices {
12
15 {
17
18 m_QueryPool = std::make_unique<VulkanQueryPool>(state, VK_QUERY_TYPE_TIMESTAMP, 2);
19 m_Result = std::make_shared<Result>();
20 }
21
22 void TimestampQuerier::BeginQuery(VkCommandBuffer commandBuffer)
23 {
25
26 m_QueryPool->Reset(commandBuffer);
27 m_QueryPool->WriteTimeStamp(commandBuffer, 0);
28 }
29
30 void TimestampQuerier::EndQuery(VkCommandBuffer commandBuffer)
31 {
33
34 m_QueryPool->WriteTimeStamp(commandBuffer, 1);
35 }
36
38 {
40
41 Result* result = static_cast<Result*>(m_Result.get());
42
43 uint64_t poolResult[3] = {};
44 m_QueryPool->QueryResults(poolResult);
45
46 result->valid = poolResult[2];
47 result->valid = true;
48 if (result->valid)
49 {
50 // timestampPeriod is the number of nanoseconds per timestamp value increment.
51 const float msPerTick = 1e-6f * VulkanDevice::GetDeviceProperties().limits.timestampPeriod;
52 result->timeStamp = msPerTick * (poolResult[1] - poolResult[0]);
53 }
54 }
55}
#define SPICES_PROFILE_ZONE
Querier(StatisticsBits type)
Constructor Function.
Definition Querier.h:69
StatisticsBits
Statistics types.
Definition Querier.h:24
Basic interface of Queries.
Definition Querier.h:17
virtual void StorePoolResult() override
Store QueryPool Result.
virtual void EndQuery(VkCommandBuffer commandBuffer) override
End QueryPool.
virtual void BeginQuery(VkCommandBuffer commandBuffer) override
Begin QueryPool.
TimestampQuerier(VulkanState &state)
Constructor Function.
Querier of GPU Timestamp.
bool valid
True if result is valid.
Definition Querier.h:54
This struct contains all Vulkan object in used global.
Definition VulkanUtils.h:74