SpiecsEngine
 
Loading...
Searching...
No Matches
TracyProfilerWrapper.cpp
Go to the documentation of this file.
1/**
2* @file TracyProfilerWrapper.cpp file.
3* @brief The TracyProfilerWrapper Class Implementation.
4* @author Spices.
5*/
6
7#include "Pchheader.h"
9#include "Render/Vulkan/VulkanUtils.h"
10
11namespace Spices {
12
14
16 : m_VulkanState(state)
17 , m_Context(nullptr)
18 {
20
21 uint32_t count = 0;
22 VK_CHECK(state.m_VkFunc.vkGetPhysicalDeviceCalibrateableTimeDomainsEXT(state.m_PhysicalDevice, &count, nullptr))
23
24 std::vector<VkTimeDomainEXT> timeDomains;
25 timeDomains.resize(count);
26 VK_CHECK(state.m_VkFunc.vkGetPhysicalDeviceCalibrateableTimeDomainsEXT(state.m_PhysicalDevice, &count, timeDomains.data()))
27
28 bool hasDomain = false;
29 if (count > 0)
30 {
31 /**
32 * @brief This vector is essential to vkGetCalibratedTimestampsEXT, and only need to be registered once.
33 */
34 std::vector<VkCalibratedTimestampInfoEXT> timestampsInfo;
35
36 for (auto& domain : timeDomains)
37 {
38 /**
39 * @brief Initialize in-scope time stamp info variable.
40 */
41 VkCalibratedTimestampInfoEXT info{};
42 info.sType = VK_STRUCTURE_TYPE_CALIBRATED_TIMESTAMP_INFO_EXT;
43 info.pNext = nullptr;
44 info.timeDomain = domain;
45
46 /**
47 * @brief Push-back timestamp info to timestamps info vector.
48 */
49 timestampsInfo.push_back(info);
50 }
51
52 /**
53 * @brief timestamps vector.
54 */
55 std::vector<uint64_t> timestamps;
56 timestamps.resize(count);
57
58 /**
59 * @brief max deviations vector.
60 */
61 std::vector<uint64_t> maxDeviations;
62 maxDeviations.resize(count);
63
64 /**
65 * @brief Get calibrated timestamps.
66 */
67 VK_CHECK(state.m_VkFunc.vkGetCalibratedTimestampsEXT(state.m_Device, timestamps.size(), timestampsInfo.data(), timestamps.data(), maxDeviations.data()))
68
69 std::unordered_map<VkTimeDomainEXT, uint32_t> maps;
70 for (auto& domain : timeDomains)
71 {
72 maps[domain] = 1;
73 }
74
75 hasDomain = maps[VK_TIME_DOMAIN_DEVICE_EXT] && maps[VK_TIME_DOMAIN_QUERY_PERFORMANCE_COUNTER_EXT];
76 }
77
78 if (!hasDomain)
79 {
80 std::stringstream ss;
81 ss << "This Device not support VK_TIME_DOMAIN_DEVICE_EXT.";
82
83 SPICES_CORE_ERROR(ss.str());
84 }
85
86 /**
87 * @brief Create Context and set name.
88 */
89#ifdef TRACY_ENABLE
90
91 //m_Context = SPICES_PROFILE_VK_CONTEXHOSTCALIBRATED(state.m_PhysicalDevice, state.m_Device, state.m_VkFunc.vkResetQueryPool, state.m_VkFunc.vkGetPhysicalDeviceCalibrateableTimeDomainsEXT, state.m_VkFunc.vkGetCalibratedTimestampsEXT);
92 //SPICES_PROFILE_VK_CONTEXTNAME(m_Context, "SpicesEngineVulkanContext", 50);
93
94#endif
95
96 }
97
99 {
101
102 if (!m_TracyGPUContext)
103 {
104 m_TracyGPUContext = std::make_shared<TracyGPUContext>(state);
105 }
106 }
107}
#define SPICES_PROFILE_ZONE
#define VK_CHECK(expr)
Vulkan Check macro. Verify Vulkan API Effectiveness.
Definition VulkanUtils.h:68
static std::shared_ptr< TracyGPUContext > m_TracyGPUContext
This Single Instance.
TracyGPUContext(VulkanState &state)
Constructor Function.
VulkanState & m_VulkanState
VulkanState.
static void CreateInstance(VulkanState &state)
Create this Single Instance.
Wapper of Tracy GPU collect features.
This struct contains all Vulkan object in used global.
Definition VulkanUtils.h:74