SpiecsEngine
 
Loading...
Searching...
No Matches
NsightAftermathGpuCrashTracker.h
Go to the documentation of this file.
1/**
2* @file NsightAftermathGpuCrashTracker.h
3* @brief The GpuCrashTracker Class Definitions.
4* @author NVIDIA
5* @see https://github.com/NVIDIA/nsight-aftermath-samples
6*/
7
8#pragma once
9
10#include <map>
11#include <mutex>
12
14#include "NsightAftermathShaderDataBase.h"
15
16namespace Spices {
17
18 /**
19 * @brief Implements GPU crash dump tracking using the Nsight Aftermath API.
20 */
22 {
23 public:
24
25 /**
26 * @brief keep four frames worth of marker history.
27 */
28 constexpr static unsigned int c_MarkerFrameHistory = 4;
30
31 public:
32
33 /**
34 * @brief Constructor Function.
35 */
37
38 /**
39 * @brief Destructor Function.
40 */
41 virtual ~GpuCrashTracker();
42
43 /**
44 * @brief Initialize the GPU crash dump tracker.
45 */
46 void Initialize();
47
48 /**
49 * @brief Create single instance of this class.
50 */
51 static void Init();
52
53 /**
54 * @brief Aftermath handle device lost function.
55 */
56 static void AftermathDeviceLostCheck();
57
58 /**
59 * @brief Get single instance of this class.
60 * @return Return this reference.
61 */
62 static GpuCrashTracker& Get() { return *m_GpuCrashTracker; }
63
64 /**
65 * @brief Set FrameCut.
66 * @param[in] frameCut FrameCut.
67 */
68 void SetFrameCut(uint64_t frameCut);
69
70 /**
71 * @brief Set Marker.
72 * @param[in] markerId Marker Id.
73 * @param[in] info Marker information.
74 */
75 void SetMarker(uint64_t& markerId, const std::string& info);
76
77 /**
78 * @brief Get ShaderDataBase.
79 * @return Returns ShaderDataBase.
80 */
81 ShaderDataBase& GetShaderDataBase() { return m_ShaderDataBase; }
82
83 private:
84
85 /**
86 * @brief Handler for GPU crash dump callbacks from Nsight Aftermath.
87 * @param[in] pGpuCrashDump .
88 * @param[in] gpuCrashDumpSize .
89 */
90 void OnCrashDump(const void* pGpuCrashDump, const uint32_t gpuCrashDumpSize);
91
92 /**
93 * @brief Handler for shader debug information callbacks.
94 * @param[in] pShaderDebugInfo .
95 * @param[in] shaderDebugInfoSize .
96 */
97 void OnShaderDebugInfo(const void* pShaderDebugInfo, const uint32_t shaderDebugInfoSize);
98
99 /**
100 * @brief Handler for GPU crash dump description callbacks.
101 * @param[in] addDescription PFN_GFSDK_Aftermath_AddGpuCrashDumpDescription.
102 */
103 static void OnDescription(PFN_GFSDK_Aftermath_AddGpuCrashDumpDescription addDescription);
104
105 /**
106 * @brief Handler for app-managed marker resolve callback.
107 * @param[in] pMarkerData .
108 * @param[in] markerDataSize .
109 * @param[in] ppResolvedMarkerData .
110 * @param[in] pResolvedMarkerDataSize .
111 */
112 void OnResolveMarker(
113 const void* pMarkerData ,
114 const uint32_t markerDataSize ,
115 void** ppResolvedMarkerData ,
116 uint32_t* pResolvedMarkerDataSize
117 );
118
119 /**
120 * @brief Helper for writing a GPU crash dump to a file.
121 * @param[in] pGpuCrashDump .
122 * @param[in] gpuCrashDumpSize .
123 */
124 void WriteGpuCrashDumpToFile(const void* pGpuCrashDump, const uint32_t gpuCrashDumpSize);
125
126 /**
127 * @brief Helper for writing shader debug information to a file.
128 * @param[in] identifier GFSDK_Aftermath_ShaderDebugInfoIdentifier.
129 * @param[in] pShaderDebugInfo .
130 * @param[in] shaderDebugInfoSize .
131 */
133 GFSDK_Aftermath_ShaderDebugInfoIdentifier identifier ,
134 const void* pShaderDebugInfo ,
135 const uint32_t shaderDebugInfoSize
136 ) const;
137
138 /**
139 * @brief Handler for shader debug information lookup callbacks.
140 * This is used by the JSON decoder for mapping shader instruction
141 * addresses to SPIR-V IL lines or GLSL source lines.
142 * @param[in] identifier GFSDK_Aftermath_ShaderDebugInfoIdentifier.
143 * @param[in] setShaderDebugInfo PFN_GFSDK_Aftermath_SetData.
144 */
146 const GFSDK_Aftermath_ShaderDebugInfoIdentifier& identifier ,
147 PFN_GFSDK_Aftermath_SetData setShaderDebugInfo
148 ) const;
149
150 /**
151 * @brief Handler for shader lookup callbacks.
152 * This is used by the JSON decoder for mapping shader instruction
153 * addresses to SPIR-V IL lines or GLSL source lines.
154 * NOTE: If the application loads stripped shader binaries (ie; --strip-all in spirv-remap),
155 * Aftermath will require access to both the stripped and the not stripped
156 * shader binaries.
157 * @param[in] shaderHash GFSDK_Aftermath_ShaderBinaryHash.
158 * @param[in] setShaderBinary PFN_GFSDK_Aftermath_SetData.
159 */
160 void OnShaderLookup(
161 const GFSDK_Aftermath_ShaderBinaryHash& shaderHash ,
162 PFN_GFSDK_Aftermath_SetData setShaderBinary
163 ) const;
164
165 /**
166 * @brief Handler for shader source debug info lookup callbacks.
167 * This is used by the JSON decoder for mapping shader instruction addresses to
168 * GLSL source lines, if the shaders used by the application were compiled with
169 * separate debug info data files.
170 * @param[in] shaderDebugName GFSDK_Aftermath_ShaderDebugName.
171 * @param[in] setShaderBinary PFN_GFSDK_Aftermath_SetData.
172 */
174 const GFSDK_Aftermath_ShaderDebugName& shaderDebugName ,
175 PFN_GFSDK_Aftermath_SetData setShaderBinary
176 ) const;
177
178 /**
179 * @brief GPU crash dump callback.
180 * @param[in] pGpuCrashDump .
181 * @param[in] gpuCrashDumpSize .
182 * @param[in] pUserData .
183 */
184 static void GpuCrashDumpCallback(
185 const void* pGpuCrashDump ,
186 const uint32_t gpuCrashDumpSize ,
187 void* pUserData
188 );
189
190 /**
191 * @brief Shader debug information callback.
192 * @param[in] pShaderDebugInfo .
193 * @param[in] shaderDebugInfoSize .
194 * @param[in] pUserData .
195 */
196 static void ShaderDebugInfoCallback(
197 const void* pShaderDebugInfo ,
198 const uint32_t shaderDebugInfoSize ,
199 void* pUserData
200 );
201
202 /**
203 * @brief GPU crash dump description callback.
204 * @param[in] addDescription PFN_GFSDK_Aftermath_AddGpuCrashDumpDescription.
205 * @param[in] pUserData .
206 */
208 PFN_GFSDK_Aftermath_AddGpuCrashDumpDescription addDescription,
209 void* pUserData
210 );
211
212 /**
213 * @brief App-managed marker resolve callback.
214 * @param[in] pMarkerData .
215 * @param[in] markerDataSize .
216 * @param[in] pUserData .
217 * @param[in] ppResolvedMarkerData .
218 * @param[in] pResolvedMarkerDataSize .
219 */
220 static void ResolveMarkerCallback(
221 const void* pMarkerData ,
222 const uint32_t markerDataSize ,
223 void* pUserData ,
224 void** ppResolvedMarkerData ,
225 uint32_t* pResolvedMarkerDataSize
226 );
227
228 /**
229 * @brief Shader debug information lookup callback.
230 * @param[in] pIdentifier GFSDK_Aftermath_ShaderDebugInfoIdentifier.
231 * @param[in] setShaderDebugInfo PFN_GFSDK_Aftermath_SetData.
232 * @param[in] pUserData .
233 */
235 const GFSDK_Aftermath_ShaderDebugInfoIdentifier* pIdentifier ,
236 PFN_GFSDK_Aftermath_SetData setShaderDebugInfo ,
237 void* pUserData
238 );
239
240 /**
241 * @brief Shader lookup callback.
242 * @param[in] pShaderHash GFSDK_Aftermath_ShaderBinaryHash.
243 * @param[in] setShaderBinary PFN_GFSDK_Aftermath_SetData.
244 * @param[in] pUserData .
245 */
246 static void ShaderLookupCallback(
247 const GFSDK_Aftermath_ShaderBinaryHash* pShaderHash ,
248 PFN_GFSDK_Aftermath_SetData setShaderBinary ,
249 void* pUserData
250 );
251
252 /**
253 * @brief Shader source debug info lookup callback.
254 * @param[in] pShaderDebugName GFSDK_Aftermath_ShaderDebugName.
255 * @param[in] setShaderBinary PFN_GFSDK_Aftermath_SetData.
256 * @param[in] pUserData .
257 */
259 const GFSDK_Aftermath_ShaderDebugName* pShaderDebugName ,
260 PFN_GFSDK_Aftermath_SetData setShaderBinary ,
261 void* pUserData
262 );
263
264 private:
265
266 /**
267 * @brief Is the GPU crash dump tracker initialized?
268 */
270
271 /**
272 * @brief For thread-safe access of GPU crash tracker state.
273 */
274 mutable std::mutex m_Mutex;
275
276 /**
277 * @brief List of Shader Debug Information by ShaderDebugInfoIdentifier.
278 */
280
281 /**
282 * @brief The mock shader database.
283 */
285
286 /**
287 * @brief App-managed marker tracking.
288 */
290
291 /**
292 * @brief Frame Count cut.
293 */
294 uint32_t m_FrameCut;
295
296 /**
297 * @brief GpuCrashTracker single instance.
298 */
300 };
301
302#ifdef SPICES_DEBUG
303
304#define NSIGHTAFTERMATH_GPUCRASHTRACKER_INIT { ::Spices::GpuCrashTracker::Init(); }
305#define NSIGHTAFTERMATH_GPUCRASHTRACKER_DEVICELOSECHECK(val) { if (val == VK_ERROR_DEVICE_LOST){ GpuCrashTracker::AftermathDeviceLostCheck(); } }
306#define NSIGHTAFTERMATH_GPUCRASHTRACKER_SETFRAMECUT(...) { ::Spices::GpuCrashTracker::Get().SetFrameCut(__VA_ARGS__); }
307#define NSIGHTAFTERMATH_GPUCRASHTRACKER_SETCHECKPOINT(commandBuffer, funcLibrary, string) { uint64_t markId; ::Spices::GpuCrashTracker::Get().SetMarker(markId, string); funcLibrary.vkCmdSetCheckpointNV(commandBuffer, (const void*)markId); }
308#define NSIGHTAFTERMATH_GPUCRASHTRACKER_ADDSHADERBINARY(...) { ::Spices::GpuCrashTracker::Get().GetShaderDataBase().AddShaderBinary(__VA_ARGS__); }
309#define NSIGHTAFTERMATH_GPUCRASHTRACKER_ADDSHADERBINARY_WITHDEBUGINFO(...) { ::Spices::GpuCrashTracker::Get().GetShaderDataBase().AddShaderBinaryWithDebugInfo(__VA_ARGS__); }
310#define NSIGHTAFTERMATH_GPUCRASHTRACKER_ADDSHADERSOURCE(...) { ::Spices::GpuCrashTracker::Get().GetShaderDataBase().AddShaderSource(__VA_ARGS__); }
311#define NSIGHTAFTERMATH_GPUCRASHTRACKER_ADDSHADERSOURCE_WITHDEBUGINFO(...) { ::Spices::GpuCrashTracker::Get().GetShaderDataBase().AddShaderSourceWithDebugInfo(__VA_ARGS__); }
312
313#endif
314
315#ifdef SPICES_RELEASE
316
317#define NSIGHTAFTERMATH_GPUCRASHTRACKER_INIT
318#define NSIGHTAFTERMATH_GPUCRASHTRACKER_DEVICELOSECHECK(val)
319#define NSIGHTAFTERMATH_GPUCRASHTRACKER_SETFRAMECUT(...)
320#define NSIGHTAFTERMATH_GPUCRASHTRACKER_SETCHECKPOINT(commandBuffer, funcLibrary, string)
321#define NSIGHTAFTERMATH_GPUCRASHTRACKER_ADDSHADERBINARY(...)
322#define NSIGHTAFTERMATH_GPUCRASHTRACKER_ADDSHADERBINARY_WITHDEBUGINFO(...)
323#define NSIGHTAFTERMATH_GPUCRASHTRACKER_ADDSHADERSOURCE(...)
324#define NSIGHTAFTERMATH_GPUCRASHTRACKER_ADDSHADERSOURCE_WITHDEBUGINFO(...)
325
326#endif
327
328}
#define ASSERT(expr)
Assert macro.
Definition Core.h:29
int main()
Main Function.
Definition EntryPoint.h:15
#define PROCESS_INSTANCE_ENTRY
Macros of modify Process instance state.
#define PROCESS_INSTANCE_EXIT
#define Update_F(item)
Definition MeshPack.h:92
#define SPICES_PROFILE_ZONE
Application(const Application &)=delete
Copy Constructor Function.
virtual ~Application()
Destructor Function.
Application & operator=(const Application &)=delete
Copy Assignment Operation.
Application()
Constructor Function.
static void Run()
Run Our World.
Application Class. Our Engine Start here.
Definition Application.h:20
virtual bool OnCreatePack(bool isCreateBuffer=true) override
This interface is used for build specific mesh pack data.
Definition MeshPack.cpp:359
uint32_t m_Columns
How much cols number we use.
Definition MeshPack.h:486
uint32_t m_Rows
How much rows number we use.
Definition MeshPack.h:481
CubePack(uint32_t rows=2, uint32_t columns=2, bool instanced=true)
Constructor Function. Init member variables.
Definition MeshPack.h:456
virtual ~CubePack() override=default
Destructor Function.
CubePack Class. This class defines box type mesh pack.
Definition MeshPack.h:446
Entity Class. This class defines the specific behaves of Entity.
Definition Entity.h:20
virtual bool OnCreatePack(bool isCreateBuffer=true) override
This interface is used for build specific mesh pack data.
Definition MeshPack.cpp:551
virtual ~FilePack() override=default
Destructor Function.
FilePack(const std::string &filePath, bool instanced=true)
Constructor Function. Init member variables.
Definition MeshPack.h:551
std::string m_Path
The mesh file path in disk.
Definition MeshPack.h:575
FilePack Class. This class defines file type mesh pack.
Definition MeshPack.h:542
static void CrashDumpDescriptionCallback(PFN_GFSDK_Aftermath_AddGpuCrashDumpDescription addDescription, void *pUserData)
GPU crash dump description callback.
static void Init()
Create single instance of this class.
static constexpr unsigned int c_MarkerFrameHistory
keep four frames worth of marker history.
void WriteShaderDebugInformationToFile(GFSDK_Aftermath_ShaderDebugInfoIdentifier identifier, const void *pShaderDebugInfo, const uint32_t shaderDebugInfoSize) const
Helper for writing shader debug information to a file.
void SetMarker(uint64_t &markerId, const std::string &info)
Set Marker.
MarkerMap m_MarkerMap
App-managed marker tracking.
void OnShaderLookup(const GFSDK_Aftermath_ShaderBinaryHash &shaderHash, PFN_GFSDK_Aftermath_SetData setShaderBinary) const
Handler for shader lookup callbacks. This is used by the JSON decoder for mapping shader instruction ...
void SetFrameCut(uint64_t frameCut)
Set FrameCut.
static void OnDescription(PFN_GFSDK_Aftermath_AddGpuCrashDumpDescription addDescription)
Handler for GPU crash dump description callbacks.
virtual ~GpuCrashTracker()
Destructor Function.
static void ShaderSourceDebugInfoLookupCallback(const GFSDK_Aftermath_ShaderDebugName *pShaderDebugName, PFN_GFSDK_Aftermath_SetData setShaderBinary, void *pUserData)
Shader source debug info lookup callback.
static void AftermathDeviceLostCheck()
Aftermath handle device lost function.
void OnResolveMarker(const void *pMarkerData, const uint32_t markerDataSize, void **ppResolvedMarkerData, uint32_t *pResolvedMarkerDataSize)
Handler for app-managed marker resolve callback.
std::mutex m_Mutex
For thread-safe access of GPU crash tracker state.
static std::unique_ptr< GpuCrashTracker > m_GpuCrashTracker
GpuCrashTracker single instance.
static void ShaderDebugInfoCallback(const void *pShaderDebugInfo, const uint32_t shaderDebugInfoSize, void *pUserData)
Shader debug information callback.
bool m_Initialized
Is the GPU crash dump tracker initialized?
std::array< std::map< uint64_t, std::string >, c_MarkerFrameHistory > MarkerMap
static void ShaderDebugInfoLookupCallback(const GFSDK_Aftermath_ShaderDebugInfoIdentifier *pIdentifier, PFN_GFSDK_Aftermath_SetData setShaderDebugInfo, void *pUserData)
Shader debug information lookup callback.
void OnCrashDump(const void *pGpuCrashDump, const uint32_t gpuCrashDumpSize)
Handler for GPU crash dump callbacks from Nsight Aftermath.
void OnShaderDebugInfo(const void *pShaderDebugInfo, const uint32_t shaderDebugInfoSize)
Handler for shader debug information callbacks.
void Initialize()
Initialize the GPU crash dump tracker.
static void GpuCrashDumpCallback(const void *pGpuCrashDump, const uint32_t gpuCrashDumpSize, void *pUserData)
GPU crash dump callback.
static GpuCrashTracker & Get()
Get single instance of this class.
ShaderDataBase m_ShaderDataBase
The mock shader database.
ShaderDataBase & GetShaderDataBase()
Get ShaderDataBase.
void OnShaderSourceDebugInfoLookup(const GFSDK_Aftermath_ShaderDebugName &shaderDebugName, PFN_GFSDK_Aftermath_SetData setShaderBinary) const
Handler for shader source debug info lookup callbacks. This is used by the JSON decoder for mapping s...
void WriteGpuCrashDumpToFile(const void *pGpuCrashDump, const uint32_t gpuCrashDumpSize)
Helper for writing a GPU crash dump to a file.
static void ResolveMarkerCallback(const void *pMarkerData, const uint32_t markerDataSize, void *pUserData, void **ppResolvedMarkerData, uint32_t *pResolvedMarkerDataSize)
App-managed marker resolve callback.
void OnShaderDebugInfoLookup(const GFSDK_Aftermath_ShaderDebugInfoIdentifier &identifier, PFN_GFSDK_Aftermath_SetData setShaderDebugInfo) const
Handler for shader debug information lookup callbacks. This is used by the JSON decoder for mapping s...
static void ShaderLookupCallback(const GFSDK_Aftermath_ShaderBinaryHash *pShaderHash, PFN_GFSDK_Aftermath_SetData setShaderBinary, void *pUserData)
Shader lookup callback.
Implements GPU crash dump tracking using the Nsight Aftermath API.
static std::vector< VkVertexInputAttributeDescription > GetAttributeDescriptions()
Get VkVertexInputAttributeDescription for IA.
Definition Vertex.cpp:25
static std::vector< VkVertexInputBindingDescription > GetBindingDescriptions()
Get VkVertexInputBindingDescription for IA.
Definition Vertex.cpp:12
static std::vector< VkVertexInputAttributeDescription > GetSlateAttributeDescriptions()
Get Slate VkVertexInputAttributeDescription for IA.
Definition Vertex.cpp:60
static std::vector< VkVertexInputBindingDescription > GetSlateBindingDescriptions()
Get Slate VkVertexInputBindingDescription for IA.
Definition Vertex.cpp:39
static std::shared_ptr< spdlog::logger > s_ClientLogger
Game Stage Logger.
Definition Log.h:80
static bool m_IsInitialized
Definition Log.h:28
static std::shared_ptr< spdlog::logger > s_CoreLogger
Engine Stage Logger.
Definition Log.h:75
static void Init()
Init Log.
Definition Log.cpp:24
static std::shared_ptr< spdlog::logger > & GetCoreLogger()
Get Engine Stage Logger.
Definition Log.h:46
static std::shared_ptr< spdlog::logger > & GetClientLogger()
Get Game Stage Logger.
Definition Log.h:52
static void PostHandle(format_string_t< Args... > fmt, Args &&...args)
Post handle with log message.
Definition Log.h:84
static void ShutDown()
Shutdown Log.
Definition Log.cpp:82
static bool SaveDefaultMaterial()
Test function.
static bool Load(const std::string &fileName, Material *outMaterial)
Public called API, it is entrance.
static bool LoadFromSASSET(const std::string &fileName, Material *outMaterial)
Load data from a .sasset file.
static bool LoadFromMaterial(const std::string &fileName, Material *outMaterial)
Load data from a .material file.
This enum defines tree types of material file.
Wrapper of material render options.
void BuildMaterial(bool isAutoRegistry=true)
This interface need to be overwritten by specific material. It defines how we build texture and descr...
Definition Material.cpp:136
void PushToTextureParams(const std::string &name, const TextureParam &texture)
Push item to ShaderPath.
Definition Material.cpp:101
const std::vector< std::string > & GetShaderPath(const std::string &stage)
Get material shader path.
Definition Material.cpp:76
scl::linked_unordered_map< std::string, ConstantParams > m_ConstantParams
Constant parameters. Key: parameter name, Value: parameter value.
Definition Material.h:226
T GetDefaultConstantParams(const std::string &name)
Get default material constant parameter.
Definition Material.h:261
bool m_AlreadyBuild
True if this material already build a buffer.
Definition Material.h:252
const std::unordered_map< std::string, std::vector< std::string > > & GetShaderPath() const
Get material shader path.
Definition Material.h:111
void UpdateMaterial()
Update material data to buffer.
Definition Material.cpp:369
std::unordered_map< std::string, std::vector< std::string > > m_Shaders
Shader path Key: shader usage, Value: shader file name.
Definition Material.h:212
void Deserialize()
Deserialize the data from a disk file(.material) to this class.
Definition Material.cpp:63
void PushToShaderPath(const std::string &name, const std::string &shader)
Push item to ShaderPath.
Definition Material.cpp:91
std::unordered_map< std::string, std::vector< std::string > > m_DefaultShaders
Definition Material.h:213
void PushToConstParams(const std::string &name, const ConstantParam &param)
Push item to ConstParams.
Definition Material.cpp:111
uint64_t GetMaterialParamsAddress() const
Get material parameter address on GPU.
Definition Material.cpp:120
const std::string & GetName() const
Get Material Path.
Definition Material.h:98
scl::runtime_memory_block m_Buffermemoryblocks
m_Buffers's c++ data container. Key: set, Value: scl::runtime_memory_block.
Definition Material.h:232
Material()=default
Constructor Function.
scl::linked_unordered_map< std::string, TextureParam > m_DefaultTextureParams
Definition Material.h:220
bool GetIsDrawWindow() const
Get boolean of whether draw a material window.
Definition Material.h:170
void SetIsDrawWindow(bool isDrawWindow)
Set boolean of whether draw a material window.
Definition Material.h:176
scl::linked_unordered_map< std::string, TextureParam > & GetTextureParams()
Get material texture parameters.
Definition Material.h:117
void SetName(const std::string &path)
Set material path.
Definition Material.h:129
bool m_IsDrawWindow
True if this material needs to draw a window.
Definition Material.h:247
scl::linked_unordered_map< std::string, ConstantParams > & GetConstantParams()
Get material constant parameters.
Definition Material.h:123
Material(const std::string &materialPath)
Constructor Function. Deserialize immediately. Usually call it.
Definition Material.cpp:20
scl::linked_unordered_map< std::string, TextureParam > m_TextureParams
Texture parameters. Key: parameter name, Value: parameter value.
Definition Material.h:219
std::mutex m_Mutex
Mutex of this material.
Definition Material.h:257
virtual ~Material()
Destructor Function.
Definition Material.cpp:33
std::unique_ptr< VulkanBuffer > m_MaterialParameterBuffer
Definition Material.h:237
MaterialProperties m_Properties
Properties of render options.
Definition Material.h:242
std::string m_MaterialPath
Definition Material.h:206
void Serialize()
Serialize this class data to a disk file(.material).
Definition Material.cpp:53
Material Class. This class contains a branch of parameter and shader, also descriptor.
Definition Material.h:62
MeshLoader Class. This class only defines static function for load data from mesh file.
Definition MeshLoader.h:48
AccelKHR m_Accel
This meshPack blas accel.
Definition MeshPack.h:368
UUID GetUUID() const
Get mesh pack UUID.
Definition MeshPack.h:235
std::optional< std::atomic_uint32_t > m_ShaderGroupHandle
specific shader group handle. Used in IndirectDGCPipeline.
Definition MeshPack.h:353
void SetHitShaderHandle(uint32_t handle)
Set hit shader Handle.
Definition MeshPack.h:212
std::string m_MeshPackName
MeshPack Name.
Definition MeshPack.h:321
uint32_t GetNTasks() const
Get NTasks.
Definition MeshPack.h:265
void OnDraw(const VkCommandBuffer &commandBuffer) const
Draw indexed.
Definition MeshPack.cpp:96
virtual bool OnCreatePack(bool isCreateBuffer=true)
This interface is used for build specific mesh pack data.
Definition MeshPack.cpp:119
MeshResource m_MeshResource
Mesh Resources.
Definition MeshPack.h:331
uint32_t GetShaderGroupHandle() const
Get ShaderGroup Handle, which accessed by gdc buffer.
Definition MeshPack.cpp:180
std::optional< std::atomic_uint32_t > m_HitShaderHandle
specific hit shader handle. Used in RayTracing Pipeline.
Definition MeshPack.h:347
void OnDrawMeshTasks(const VkCommandBuffer &commandBuffer) const
Draw Mesh Tasks.
Definition MeshPack.cpp:112
VkDrawMeshTasksIndirectCommandNV m_MeshTaskIndirectDrawCommand
Draw Command.
Definition MeshPack.h:383
MeshDesc & GetMeshDesc()
Get Mesh Description.
Definition MeshPack.h:271
const std::string & GetPackType() const
Get Pack Type.
Definition MeshPack.h:283
uint32_t GetHitShaderHandle() const
Get Hit Shader Handle, which accessed by ray gen shader.
Definition MeshPack.cpp:165
MeshPack(const std::string &name, bool instanced)
Constructor Function.
Definition MeshPack.cpp:78
bool HasBlasAccel()
Is this meshPack has a valid blas.
Definition MeshPack.cpp:251
std::string m_PackType
specific mesh pack type.
Definition MeshPack.h:363
void CreateBuffer()
Create Vertices buffer anf Indices buffer.
Definition MeshPack.cpp:278
VulkanRayTracing::BlasInput MeshPackToVkGeometryKHR()
Convert MeshPack into the ray tracing geometry used to build the BLAS.
Definition MeshPack.cpp:195
std::atomic_bool m_IsRequiredAccel
True if required accel by BLAS Build.
Definition MeshPack.h:373
void OnBind(const VkCommandBuffer &commandBuffer) const
Bind VBO and EBO.
Definition MeshPack.cpp:86
MeshDesc m_Desc
Mesh Description.
Definition MeshPack.h:358
std::shared_ptr< Material > GetMaterial()
Get material in this class.
Definition MeshPack.h:206
const VkDrawMeshTasksIndirectCommandNV & GetDrawCommand() const
Get Draw Command.
Definition MeshPack.h:277
void SetMaterial(std::shared_ptr< Material > material)
Set specific material for this class.
Definition MeshPack.cpp:155
MeshPack & operator=(const MeshPack &)=delete
Copy Constructor Function.
void SetShaderGroupHandle(uint32_t handle)
Set hit shader Handle.
Definition MeshPack.h:218
const MeshResource & GetResource() const
Get Resource.
Definition MeshPack.h:307
std::shared_ptr< Material > m_Material
specific material pointer.
Definition MeshPack.h:341
void SetMaterial(const std::string &materialPath)
Set specific material for this class.
Definition MeshPack.cpp:145
uint32_t m_NTasks
Task Shader Work Group Size.
Definition MeshPack.h:336
virtual ~MeshPack()=default
Destructor Function.
UUID m_UUID
UUID for mesh pack.
Definition MeshPack.h:378
const std::vector< Meshlet > & GetMeshlets() const
Get Meshlets array.
Definition MeshPack.h:259
MeshPack(const MeshPack &)=delete
Copy Constructor Function.
bool m_Instanced
If this mesh pack needs instanced.
Definition MeshPack.h:326
AccelKHR & GetAccel()
Get this accel.
Definition MeshPack.cpp:261
MeshPack Class. This class defines some basic behaves and variables. This class need to be inherited ...
Definition MeshPack.h:156
Class for provide functions of process Meshpack.
uint32_t m_Columns
How much cols number we use.
Definition MeshPack.h:437
uint32_t m_Rows
How much rows number we use.
Definition MeshPack.h:432
virtual bool OnCreatePack(bool isCreateBuffer=true) override
This interface is used for build specific mesh pack data.
Definition MeshPack.cpp:315
PlanePack(uint32_t rows=2, uint32_t columns=2, bool instanced=true)
Constructor Function. Init member variables.
Definition MeshPack.h:407
virtual ~PlanePack() override=default
Destructor Function.
PlanePack Class. This class defines plane type mesh pack.
Definition MeshPack.h:397
SpherePack(uint32_t rows=15, uint32_t columns=24, bool instanced=true)
Constructor Function. Init member variables.
Definition MeshPack.h:504
uint32_t m_Rows
How much rows number we use.
Definition MeshPack.h:529
virtual ~SpherePack() override=default
Destructor Function.
virtual bool OnCreatePack(bool isCreateBuffer=true) override
This interface is used for build specific mesh pack data.
Definition MeshPack.cpp:563
uint32_t m_Columns
How much cols number we use.
Definition MeshPack.h:534
SpherePack Class. This class defines sphere type mesh pack.
Definition MeshPack.h:494
Texture2DCube Class. This class defines the basic behaves of Texture2DCube.
Texture2D(const RendererResourceCreateInfo &info)
Constructor Function. Used for create render resource.
Definition Texture2D.cpp:15
Texture2D(const std::string &path)
Constructor Function. Init class variable, load date immediately. Usually call it.
Definition Texture2D.cpp:93
virtual ~Texture2D() override=default
Destructor Function.
Texture2D()=default
Constructor Function.
Texture2D Class. This class defines the basic behaves of texture2D.
Definition Texture2D.h:20
static void Load(const std::string &fileName, Texture2DCube *outTexture)
Load image to a Texture2DCube object.
static void Load(const std::string &fileName, Texture2D *outTexture)
Load image to a Texture2D object.
static bool LoadSrc(const std::string &fileName, const std::string &it, Texture2D *outTexture, bool isCreateCompressTexture=true)
Function of load a src file.
static bool SearchFile(const std::string &fileName, std::function< void(const std::string &)> binF, std::function< void(const std::string &)> srcF)
Search texture file and load.
static bool LoadBin(const std::string &fileName, const std::string &it, Texture2D *outTexture)
Function of load a ktx file.
TextureLoader Class. This class only defines static function for load data from image file.
virtual ~Texture()=default
Destructor Function.
std::string m_ResourcePath
Texture's path in disk.
Definition Texture.h:74
Texture(const std::string &path)
Constructor Function. Init class variable. Usually call it.
Definition Texture.h:47
Texture()=default
Constructor Function.
std::shared_ptr< T > GetResource()
Get Specific resource, usually is a wrapper of VulkanImage.
Definition Texture.h:78
std::any m_Resource
Texture's resource, coule be any kind of type.
Definition Texture.h:68
Texture Class. This class defines the basic behaves of texture. When we add an new Texture,...
Definition Texture.h:33
float m_FrameTime
time step(s) during frames.
Definition TimeStep.h:85
std::chrono::steady_clock::time_point m_StartTime
Engine Start time.
Definition TimeStep.h:75
void Flush()
Refresh time in each engine loop.
Definition TimeStep.cpp:26
const float & ft() const
Get time step during frames.
Definition TimeStep.h:51
TimeStep(const TimeStep &)=delete
Copy Constructor Function.
const uint64_t & fs() const
Get frames count.
Definition TimeStep.h:63
TimeStep()
Constructor Function.
Definition TimeStep.cpp:12
virtual ~TimeStep()=default
Destructor Function.
std::chrono::steady_clock::time_point m_LastTime
Last frame time.
Definition TimeStep.h:80
float m_GameTime
time step(s) since Engine Start.
Definition TimeStep.h:90
uint64_t m_Frames
Frames since Engine Start.
Definition TimeStep.h:95
TimeStep & operator=(const TimeStep &)=delete
Copy Assignment Operation.
const float & gt() const
Get time step since Engine Start.
Definition TimeStep.h:57
This Class handles our engine time step during frames. Global Unique.
Definition TimeStep.h:22
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.
UUID()
Constructor Function.
Definition UUID.cpp:18
uint64_t m_UUID
UUID.
Definition UUID.h:52
UUID(uint64_t uuid)
Constructor Function.
Definition UUID.cpp:22
UUID(const UUID &)=default
Destructor Function.
std::string ToString()
Transform UUID to String.
Definition UUID.cpp:26
operator uint64_t() const
Operator Function.
Definition UUID.h:39
This class helps to generate a uuid for one resource.
Definition UUID.h:16
This Class is a Wrapper of VulkanBuffer.
static void EndLabel(VkCommandBuffer cmdBuffer)
End Record Commands with a Label.
static void BeginLabel(VkCommandBuffer cmdBuffer, const std::string &caption, glm::vec4 color=glm::vec4(1.0f))
Start Record Commands with a Label.
static void BeginQueueLabel(VkQueue queue, const std::string &caption, glm::vec4 color=glm::vec4(1.0f))
Start Record Queue with a Label.
static void SetObjectName(VkObjectType type, uint64_t handle, VkDevice &device, const std::string &caption)
Set Vulkan Object with a name, which can be captured.
static void InsertQueueLabel(VkQueue queue, const std::string &caption, glm::vec4 color=glm::vec4(1.0f))
Insert Record Queue with a Label.
static void SetObjectTag(VkObjectType type, uint64_t handle, VkDevice &device, const std::vector< char * > &captions)
Set Vulkan Object with tags, which can be captured.
static void InsertLabel(VkCommandBuffer cmdBuffer, const std::string &caption, glm::vec4 color=glm::vec4(1.0f))
Insert Record Commands with a Label.
static void EndQueueLabel(VkQueue queue)
End Record Queue with a Label.
This Class Defines static function for helping vulkan debug.
VulkanObject(const VulkanObject &)=delete
Copy Constructor Function.
virtual ~VulkanObject()=default
Destructor Function. We destroy pipeline layout here.
VulkanObject & operator=(const VulkanObject &)=delete
Copy Assignment Operation.
VulkanState & m_VulkanState
The global VulkanState Referenced from VulkanRenderBackend.
VulkanObject(VulkanState &vulkanState)
Constructor Function. Init member variables.
VulkanObject Class. This class defines the basic behaves of VulkanObject. When we create an new Vulka...
VkPipelineShaderStageCreateInfo GetShaderStageCreateInfo() const
virtual ~VulkanShaderModule() override
Destructor Function.
std::string GetShaderPath(const std::string &name, const std::string &shaderType)
Get shader path string.
VkShaderModule m_ShaderModule
The VkShaderModule this class handled.
VkShaderModule & Get()
Get VkShaderModule this class handled.
VulkanShaderModule(VulkanState &vulkanState, const std::string &shaderName, const std::string &shaderStage)
Constructor Function. Create VkShaderModule.
VulkanShaderModule(VulkanState &vulkanState, const std::string &shaderName, const ShaderStage &shaderStage, const std::vector< uint8_t > &spirv, const std::string &fullPath)
Constructor Function. Create VkShaderModule.
This Class is a Wrapper of VkShaderModule.
static void CreateMeshEntity(World *world, const std::string &name, const std::shared_ptr< Mesh > &mesh, std::function< void(Entity &)> onAdded=nullptr)
Create Entity with MeshComponent. Lightweight for game thread.
static void CreateMeshEntity(World *world, const std::string &name, std::function< std::shared_ptr< Mesh >()> onMeshCreated, std::function< void(Entity &)> onAdded=nullptr)
Create Entity with a Basic MeshComponent Async.
World Functions Class.
WorldMarkFlags GetMarker() const
Get WorldMarkFlags this frame.
Definition World.h:119
void ViewComponent(const std::vector< uint32_t > &ranges, uint32_t floor, uint32_t ceil, F &&fn)
View all component in this world in ranges.
Definition World.h:309
uint32_t WorldMarkFlags
Definition World.h:53
void Mark(WorldMarkFlags flags)
Mark WorldMarkFlags with flags.
Definition World.h:125
Entity CreateEntity(const std::string &name="None")
Create a new empty entity in this world.
Definition World.cpp:13
void OnComponentAdded(Entity *entity, T &component)
Called On any Component Added to this world.
Definition World.h:386
void ReserMark()
Reset WorldMarkFlags to Clean.
Definition World.h:130
void ViewRoot(F &&fn)
View all root in this world.
Definition World.h:329
Entity CreateEmptyEntity(UUID uuid)
Definition World.cpp:85
Entity CreateEntityWithUUID(UUID uuid, const std::string &name="None")
Create a new empty entity with a uuid in this world.
Definition World.cpp:20
void ViewComponent(F &&fn)
View all component in this world.
Definition World.h:276
void ViewComponent(const std::vector< uint32_t > &ranges, F &&fn)
View all component in this world in ranges.
Definition World.h:293
virtual void OnDeactivate()=0
This interface defines the specific world behaves after on activated.
virtual ~World()=default
Destructor Function.
Entity QueryEntitybyID(uint32_t id)
Get World Entity by id(entt::entity).
Definition World.cpp:41
virtual void OnPreActivate()=0
This interface define the specific world behaves before on activated.
entt::registry m_Registry
This variable handles all entity.
Definition World.h:250
std::shared_mutex m_Mutex
Mutex for world.
Definition World.h:245
void DestroyEntity(Entity &entity)
Destroy a entity from this world.
Definition World.cpp:31
T & GetComponent(entt::entity e)
Get Component owned by this entity.
Definition World.h:353
@ FrushStableFrame
Definition World.h:48
@ MeshAddedToWorld
Definition World.h:47
@ NeedUpdateTLAS
Definition World.h:49
void RemoveComponent(entt::entity e)
Remove Component owned from this entity.
Definition World.h:366
WorldMarkFlags m_Marker
World State this frame.
Definition World.h:272
entt::registry & GetRegistry()
Get Registry variable.
Definition World.h:106
void RemoveFromRoot(Entity &entity)
Remove a entity from this world root.
Definition World.cpp:58
virtual void OnActivate(TimeStep &ts)=0
This interface define the specific world behaves on activated.
void AddToRoot(Entity &entity)
Add a entity to this world root.
Definition World.cpp:67
World()=default
Constructor Function.
std::unordered_map< UUID, entt::entity > m_RootEntityMap
This variable is a cache. @noto Not in use now.
Definition World.h:257
bool IsRootEntity(Entity &entity)
Determine if a entity is in root.
Definition World.cpp:76
void ClearMarkerWithBits(WorldMarkFlags flags)
Clear WorldMarkFlags with flags.
Definition World.cpp:48
bool HasComponent(entt::entity e)
If Component is owned by this entity or not.
Definition World.h:376
T & AddComponent(entt::entity e, Args &&... args)
Template Function. Used for add specific component to entity.
Definition World.h:343
World Class. This class defines the basic behaves of World. When we create an new world,...
Definition World.h:41
The container combines hashmap and list together. Used in the case that we want iter a hashmap in ord...
The container is wrapper of a continue memory block. Used in Material::BuildMaterial(),...
ShaderStage
enum of shader stage.
static const char * memoryPoolNames[3]
MemoryPool's name.
Definition Core.h:43
TextureType
The enum of all Texture Type.
Definition Texture.h:20
std::shared_ptr< World > CreateWorld()
extern WorldCreation definition in Game.
Definition EntryPoint.cpp:6
static void HandleVkResult(VkResult result)
Handle VkResult Function.
Definition VulkanUtils.h:39
constexpr uint32_t MaxFrameInFlight
Max In Flight Frame. 2 buffers are enough in this program.
Definition VulkanUtils.h:22
AccelStructure Wrapper.
Definition Attribute.h:17
MeshResource's item template.
Definition Attribute.h:28
std::string paramType
Definition Material.h:38
This struct's data is defined from .material file.
Definition Material.h:37
ConstantParam value
Definition Material.h:47
ConstantParam max
Definition Material.h:54
ConstantParam defaultValue
Definition Material.h:48
ConstantParam min
Definition Material.h:51
This struct's data is defined from .material file.
Definition Material.h:46
uint32_t prev
datas.
Definition Vertex.h:223
EdgePoint(uint32_t prev, uint32_t self, uint32_t next)
Constructor Function.
Definition Vertex.h:205
uint32_t next
Definition Vertex.h:225
bool valid()
Determine whether this edge point is valid.
Definition Vertex.h:215
EdgePoint()
Constructor Function.
Definition Vertex.h:193
uint32_t self
Definition Vertex.h:224
EdgePoint Class. This class defines what EdgePoint data.
Definition Vertex.h:187
Edge()=default
Constructor Function.
bool operator==(const Edge &other) const
Destructor Function. @attemtion Why Destructor causes bug here.
Definition Vertex.h:117
Edge(uint32_t f, uint32_t s)
Constructor Function.
Definition Vertex.h:99
bool operator<(const Edge &other) const
Less Operation.
Definition Vertex.h:127
Edge Class. This class defines what Edge data.
Definition Vertex.h:86
bool operator<(const HalfEdge &other) const
Less Operation.
Definition Vertex.h:177
HalfEdge()=default
Constructor Function.
bool operator==(const HalfEdge &other) const
Destructor Function. @attemtion Why Destructor causes bug here.
Definition Vertex.h:168
HalfEdge(uint32_t f, uint32_t s)
Constructor Function.
Definition Vertex.h:150
HalfEdge Class. This class defines what HalfEdge data.
Definition Vertex.h:137
uint32_t meshletOffset
Definition MeshPack.h:31
uint32_t nMeshlets
Definition MeshPack.h:32
uint32_t nPrimitives
Definition MeshPack.h:30
uint32_t primVertexOffset
Definition MeshPack.h:29
Lod Data.
Definition MeshPack.h:28
MeshDesc()
Constructor Function.
Definition MeshPack.cpp:29
MeshDesc Copy() const
Copy a MeshDesc from this.
Definition MeshPack.cpp:61
uint64_t GetBufferAddress() const
Get m_Buffer's Address.
Definition MeshPack.cpp:71
Add Construction Functions to SpicesShader::MeshDesc.
Definition MeshPack.h:90
MeshResource()=default
Constructor Function.
TexCoords texCoords
Definition MeshPack.h:71
Positions positions
Declare value.
Definition MeshPack.h:68
PrimitiveVertices primitiveVertices
Definition MeshPack.h:74
PrimitiveLocations primitiveLocations
Definition MeshPack.h:75
PrimitivePoints primitivePoints
Definition MeshPack.h:73
virtual ~MeshResource()=default
Destructor Function.
void CreateBuffer(const std::string &name)
Create MeshResource Buffers.
Definition MeshPack.cpp:14
Mesh Resources Data.
Definition MeshPack.h:39
void FromMeshopt(const meshopt_Meshlet &m, const meshopt_Bounds &bounds)
Destructor Function. @attemtion Why Destructor causes bug here.
Definition Vertex.cpp:85
Meshlet()=default
Constructor Function.
Meshlet Class. This class defines what Meshlet data.
Definition Vertex.h:58
This struct defines the data used to create a texture2d. From render pass.
static constexpr char const * name
Define a named category tag type.
static constexpr char const * name
Define a custom domain tag type.
static constexpr char const * message
Define a registered string tag type.
std::string texturePath
Definition Material.h:29
std::string textureType
Definition Material.h:28
This struct's data is defined from .material file.
Definition Material.h:27
Vulkan Function Pointers Collection. It holds all function pointer which need get manually.
VulkanState(const VulkanState &)=delete
Copy Constructor Function.
VkSwapchainKHR m_SwapChain
VkCommandPool m_GraphicCommandPool
std::array< VkSemaphore, MaxFrameInFlight > m_ComputeQueueSemaphore
VmaAllocator m_VmaAllocator
Definition VulkanUtils.h:97
std::array< VkImage, MaxFrameInFlight > m_SwapChainImages
std::array< VkImageView, MaxFrameInFlight > m_SwapChainImageViews
std::array< VkSemaphore, MaxFrameInFlight > m_GraphicQueueSemaphore
std::array< VkFence, MaxFrameInFlight > m_ComputeFence
std::array< VkSampler, MaxFrameInFlight > m_SwapChainImageSamplers
uint32_t m_ComputeQueueFamily
std::array< VkCommandBuffer, MaxFrameInFlight > m_GraphicCommandBuffer
VulkanFunctions m_VkFunc
Definition VulkanUtils.h:98
GLFWwindow * m_Windows
Definition VulkanUtils.h:92
VkInstance m_Instance
Definition VulkanUtils.h:93
uint32_t m_GraphicQueueFamily
VulkanState()=default
Constructor Function.
std::array< VkSemaphore, MaxFrameInFlight > m_GraphicImageSemaphore
VkSurfaceKHR m_Surface
Definition VulkanUtils.h:94
std::array< VkCommandBuffer, MaxFrameInFlight > m_ComputeCommandBuffer
VkPhysicalDevice m_PhysicalDevice
Definition VulkanUtils.h:95
VkCommandPool m_ComputeCommandPool
std::array< VkFence, MaxFrameInFlight > m_GraphicFence
VulkanState & operator=(const VulkanState &)=delete
Copy Assignment Operation.
This struct contains all Vulkan object in used global.
Definition VulkanUtils.h:74
size_t operator()(Spices::EdgePoint const &edgeP) const
Definition Vertex.h:255
size_t operator()(Spices::Edge const &edge) const
Definition Vertex.h:236
size_t operator()(Spices::HalfEdge const &edge) const
Definition Vertex.h:246
std::size_t operator()(const Spices::UUID &uuid) const noexcept
Definition UUID.h:62