SpiecsEngine
 
Loading...
Searching...
No Matches
TracyProfilerWrapper.h
Go to the documentation of this file.
1/**
2* @file TracyProfilerWrapper.h file.
3* @brief The TracyProfilerWrapper Class Definitions.
4* @author Spices.
5*/
6
7#pragma once
8
9#include "Core/Core.h"
10
11#include <vulkan/vulkan.h>
12#include <tracy/Tracy.hpp>
13#include <tracy/TracyC.h>
14#include <tracy/TracyVulkan.hpp>
15#include <vector>
16#include <memory>
17
18namespace Spices {
19
20 struct VulkanState;
21
22 /**
23 * @brief Wapper of Tracy GPU collect features.
24 */
26 {
27 public:
28
29 /**
30 * @brief Constructor Function.
31 * @param[in] state VulkanState.
32 */
34
35 /**
36 * @brief Destructor Function.
37 */
38 virtual ~TracyGPUContext() = default;
39
40 /**
41 * @brief Create this Single Instance.
42 * @param[in] state VulkanState.
43 */
44 static void CreateInstance(VulkanState& state);
45
46 /**
47 * @brief Get this Single Instance.
48 * @return Returns this Single Instance.
49 */
50 static TracyGPUContext& Get() { return *m_TracyGPUContext; }
51
52 /**
53 * @brief Get Context.
54 * @return Returns Context.
55 */
56 tracy::VkCtx*& GetContext() { return m_Context; }
57
58 private:
59
60 /**
61 * @brief VulkanState.
62 */
64
65 /**
66 * @brief This Single Instance.
67 */
68 static std::shared_ptr<TracyGPUContext> m_TracyGPUContext;
69
70 /**
71 * @brief Tracy Vulkan Context.
72 */
74
75 };
76
77#ifdef TRACY_ENABLE
78
79#define SPICES_PROFILE_GPU_CREATEINSTANCE(...) { TracyGPUContext::CreateInstance(__VA_ARGS__); }
80#define SPICES_PROFILE_FRAME FrameMark
81#define SPICES_PROFILE_ZONE ZoneScoped
82#define SPICES_PROFILE_ZONEN(...) ZoneScopedN(__VA_ARGS__)
83#define SPICES_PROFILE_ALLOC(ptr, size) TracySecureAllocS(ptr, size, 20)
84#define SPICES_PROFILE_FREE(ptr) TracySecureFreeS(ptr, 20)
85#define SPICES_PROFILE_ALLOC_N(ptr, size, name) TracySecureAllocNS(ptr, size, 20, name)
86#define SPICES_PROFILE_FREE_N(ptr, name) TracySecureFreeNS(ptr, 20, name)
87#define SPICES_PROFILE_MARK(...) TracyMessageL(__VA_ARGS__)
88#define SPICES_PROFILE_IMAGE(...) FrameImage(__VA_ARGS__)
89
90#define SPICES_PROFILE_VK_CONTEXHOSTCALIBRATED(pd, d, qr, ctd, ct) //TracyVkContextHostCalibrated(pd, d, qr, ctd, ct)
91#define SPICES_PROFILE_VK_DESTROY //TracyVkDestroy(TracyGPUContext::Get().GetContext())
92#define SPICES_PROFILE_VK_CONTEXTNAME(ctx, name, size) //TracyVkContextName(ctx, name, size)
93#define SPICES_PROFILE_VK_ZONE(cmdbuf, name) //TracyVkZone(TracyGPUContext::Get().GetContext(), cmdbuf, name)
94#define SPICES_PROFILE_VK_COLLECT(cmdbuf) //TracyVkCollect(TracyGPUContext::Get().GetContext(), cmdbuf)
95
96#else
97
98#define SPICES_PROFILE_GPU_CREATEINSTANCE(...)
99#define SPICES_PROFILE_FRAME
100#define SPICES_PROFILE_ZONE
101#define SPICES_PROFILE_ZONEN(...)
102#define SPICES_PROFILE_ALLOC(ptr, size)
103#define SPICES_PROFILE_FREE(ptr)
104#define SPICES_PROFILE_ALLOC_N(ptr, size, name)
105#define SPICES_PROFILE_FREE_N(ptr, name)
106#define SPICES_PROFILE_MARK(...)
107#define SPICES_PROFILE_IMAGE(...)
108
109#define SPICES_PROFILE_VK_CONTEXHOSTCALIBRATED(pd, d, qr, ctd, ct)
110#define SPICES_PROFILE_VK_DESTROY
111#define SPICES_PROFILE_VK_CONTEXTNAME(ctx, name, size)
112#define SPICES_PROFILE_VK_ZONE(cmdbuf, name)
113#define SPICES_PROFILE_VK_COLLECT(cmdbuf)
114
115#endif
116
117#ifdef TRACY_ENABLE
118
119/********************************************* Those Macros and enviroment must be defined in preprocesser ******************************************************/
120
121/**
122* @brief tracy Feature Enable.
123*
124* #define TRACY_ENABLE
125*/
126
127/**
128* @brief Used profile a short-lived program.
129* Tracy connection won't be finisd even application is quit.
130*
131* #define TRACY_NO_EXIT
132*/
133
134/**
135* @brief Used if want profile on demand.
136* Enable profiling only when there¡¯s an established connection with the server.
137*
138* #define TRACY_ON_DEMAND
139*/
140
141/**
142* @brief Disable announce its presence to the local network.
143* The program name that is sent out in the broadcast messages can be customized by using the
144* TracySetProgramName(name) macro
145*
146* #define TRACY_NO_BROADCAST
147*/
148
149/**
150* @brief Only listen on localhost interfaces.
151*
152* #define TRACY_ONLY_LOCALHOST
153*/
154
155/**
156* @brief Extra listened address.
157*
158* TRACY_CLIENT_ADDRESS = xxx.xxx.x.xxx
159*/
160
161/**
162* @brief Restrict it to only listening on IPv4 interfaces.
163*
164* #define TRACY_ONLY_IPV4
165*/
166
167/**
168* @brief About multiple DLL.
169*
170* #define TRACY_MANUAL_LIFETIME
171*/
172
173/**
174* @brief Display advanced information .
175*
176* #define TRACY_VERBOSE
177*/
178
179/**
180* @brief The data connection port
181*
182* TRACY_BROADCAST_PORT = xx
183* TRACY_PORT = xx
184*/
185
186/**
187* @brief Controls whether a system load/save dialog is compiled in. If it¡¯s enabled,
188* the saved traces will be named trace.tracy.
189*
190* #define TRACY_NO_FILESELECTOR
191*/
192
193/**
194* @brief Tracy will perform statistical data collection on the fly, if this macro is not
195* defined. This allows extended trace analysis (for example, you can perform a live search for matching
196* zones) at a small CPU processing cost and a considerable memory usage increase (at least 8 bytes per
197* zone).
198*
199* #define TRACY_NO_STATISTICS
200*/
201
202/**
203* @brief the main profiler view won¡¯t occupy the whole window if this macro is
204* defined. Additional setup is required for this to work. If you want to embed the server into your
205* application, you probably should enable this option.
206*
207* #define TRACY_NO_ROOT_WINDOW
208*/
209
210/**
211* @brief Set adapt to the system DPI scaling.
212*
213* TRACY_DPI_SCALE = xx
214*/
215
216/**
217* @brief Disable the built in crash handling.
218*
219* #define TRACY_NO_CRASH_HANDLER
220*/
221
222/**
223* @brief Disable Frame Image Feature.
224*
225* /#define TRACY_NO_FRAME_IMAGE
226*/
227
228#endif
229
230}
int main()
Main Function.
Definition EntryPoint.h:15
#define PROCESS_INSTANCE_ENTRY
Macros of modify Process instance state.
#define PROCESS_INSTANCE_EXIT
#define SPICES_PROFILE_ZONE
Application()
Constructor Function.
static void Run()
Run Our World.
Application Class. Our Engine Start here.
Definition Application.h:20
static TracyGPUContext & Get()
Get this Single Instance.
static std::shared_ptr< TracyGPUContext > m_TracyGPUContext
This Single Instance.
virtual ~TracyGPUContext()=default
Destructor Function.
tracy::VkCtx * m_Context
Tracy Vulkan Context.
TracyGPUContext(VulkanState &state)
Constructor Function.
VulkanState & m_VulkanState
VulkanState.
tracy::VkCtx *& GetContext()
Get Context.
static void CreateInstance(VulkanState &state)
Create this Single Instance.
Wapper of Tracy GPU collect features.
World Class. This class defines the basic behaves of World. When we create an new world,...
Definition World.h:41
static const char * memoryPoolNames[3]
MemoryPool's name.
Definition Core.h:43
std::shared_ptr< World > CreateWorld()
extern WorldCreation definition in Game.
Definition EntryPoint.cpp:6
This struct contains all Vulkan object in used global.
Definition VulkanUtils.h:74