SpiecsEngine
 
Loading...
Searching...
No Matches
MeshPack.h
Go to the documentation of this file.
1/**
2* @file MeshPack.h.
3* @brief The MeshPack Class Definitions.
4* @author Spices.
5*/
6
7#pragma once
8#include "Core/Core.h"
9#include "Vertex.h"
10#include "Resources/Material/Material.h"
11#include "Render/Vulkan/VulkanBuffer.h"
12#include "Resources/ResourcePool/ResourcePool.h"
13#include "MeshProcessor.h"
14#include "Attribute.h"
15
16#include <optional>
17
18#ifdef RENDERAPI_VULKAN
19#include "Render/Vulkan/VulkanRayTracing.h"
20#endif
21
22namespace Spices {
23
24 /**
25 * @brief Lod Data.
26 */
27 struct Lod
28 {
29 uint32_t primVertexOffset; /* @brief Lod PrimVertexOffset (also PrimPointOffset). */
30 uint32_t nPrimitives; /* @brief Lod PrimVertics Count (also PrimPoints Count). */
31 uint32_t meshletOffset; /* @brief Lod MeshletOffset. */
32 uint32_t nMeshlets; /* @brief Lod Meshlets Count. */
33 };
34
35 /**
36 * @brief Mesh Resources Data.
37 */
39 {
40 /**
41 * @brief Constructor Function.
42 */
43 MeshResource() = default;
44
45 /**
46 * @brief Destructor Function.
47 */
48 virtual ~MeshResource() = default;
49
50 /**
51 * @brief Declare value Type.
52 */
53 using Positions = Attribute<glm::vec3>; // @brief Position.(also as Point)
54 using Normals = Attribute<glm::vec3>; // @brief Normal
55 using Colors = Attribute<glm::vec3>; // @brief Color
56 using TexCoords = Attribute<glm::vec2>; // @brief TexCoord
57 using Vertices = Attribute<glm::uvec4>; // @brief Vertex.
58
59 using PrimitivePoints = Attribute<glm::uvec3>; // @brief PrimPoints
60 using PrimitiveVertices = Attribute<glm::uvec3>; // @brief PrimVertices
61 using PrimitiveLocations = Attribute<glm::uvec3>; // @brief PrimLocation
62 using Meshlets = Attribute<Meshlet>; // @brief PrimMeshlet
63 using Lods = Attribute<Lod>; // @brief Lod
64
65 /**
66 * @brief Declare value.
67 */
76 Meshlets meshlets;
77 Lods lods;
78
79 /**
80 * @brief Create MeshResource Buffers.
81 * @param[in] name MeshPack Name.
82 */
83 void CreateBuffer(const std::string& name);
84 };
85
86 /**
87 * @brief Add Construction Functions to SpicesShader::MeshDesc.
88 */
90 {
91
92#define Update_F(item)
93 void Update##item(std::shared_ptr<VulkanBuffer> buffer)
94 {
95 if(buffer)
96 {
97 item = static_cast<decltype(item)>(buffer->GetAddress());
98 }
99 else
100 {
101 item = static_cast<decltype(item)>(0);
102 }
103 m_Buffer->WriteToBuffer(&item, sizeof(item), offsetof(MeshDesc, item));
104 }
105 void Update##item(uint64_t p)
106 {
107 item = static_cast<decltype(item)>(p);
108 m_Buffer->WriteToBuffer(&item, sizeof(item), offsetof(MeshDesc, item));
109 }
110
111 /**
112 * @brief Constructor Function.
113 */
114 MeshDesc();
115
116 /**
117 * @brief Copy a MeshDesc from this.
118 */
119 MeshDesc Copy() const;
120
121 /**
122 * @brief Get m_Buffer's Address.
123 * @return Returns the m_Buffer's Address.
124 */
125 uint64_t GetBufferAddress() const;
126
127 /**
128 * @brief Update Function.
129 */
130 Update_F(modelAddress )
131 Update_F(positionsAddress )
132 Update_F(normalsAddress )
133 Update_F(colorsAddress )
134 Update_F(texCoordsAddress )
135 Update_F(verticesAddress )
136 Update_F(primitivePointsAddress )
137 Update_F(primitiveVerticesAddress )
138 Update_F(primitiveLocationsAddress )
139 Update_F(materialParameterAddress )
140 Update_F(meshletsAddress )
141 Update_F(nMeshlets )
142 Update_F(entityID )
143
144 /**
145 * @brief Buffer of this.
146 */
147 std::shared_ptr<VulkanBuffer> m_Buffer;
148 };
149
150 /**
151 * @brief MeshPack Class.
152 * This class defines some basic behaves and variables.
153 * This class need to be inherited while use.
154 */
156 {
157 public:
158
159 /**
160 * @brief Constructor Function.
161 * @param[in] name MeshPack Name.
162 * @param[in] instanced Is this maesh pack instanced.
163 */
164 MeshPack(const std::string& name, bool instanced);
165
166 /**
167 * @brief Destructor Function.
168 */
169 virtual ~MeshPack() = default;
170
171 /**
172 * @brief Copy Constructor Function.
173 * @note This Class not allowed copy behaves.
174 */
175 MeshPack(const MeshPack&) = delete;
176
177 /**
178 * @brief Copy Constructor Function.
179 * @note This Class not allowed copy behaves.
180 */
181 MeshPack& operator=(const MeshPack&) = delete;
182
183 /**
184 * @brief This interface is used for build specific mesh pack data.
185 * @param[in] isCreateBuffer Whether it needs to create buffer.
186 * @return Returns true if copy resource from Pool.
187 */
188 virtual bool OnCreatePack(bool isCreateBuffer = true);
189
190 /**
191 * @brief Set specific material for this class.
192 * @param[in] materialPath Material path in disk.
193 */
194 void SetMaterial(const std::string& materialPath);
195
196 /**
197 * @brief Set specific material for this class.
198 * @param[in] material Material Pointer.
199 */
200 void SetMaterial(std::shared_ptr<Material> material);
201
202 /**
203 * @brief Get material in this class.
204 * @return Returns the material in this class.
205 */
206 std::shared_ptr<Material> GetMaterial() { return m_Material; }
207
208 /**
209 * @brief Set hit shader Handle.
210 * @param[in] handle the material handle.
211 */
212 void SetHitShaderHandle(uint32_t handle) { m_HitShaderHandle = handle; }
213
214 /**
215 * @brief Set hit shader Handle.
216 * @param[in] handle the material handle.
217 */
218 void SetShaderGroupHandle(uint32_t handle) { m_ShaderGroupHandle = handle; }
219
220 /**
221 * @brief Get Hit Shader Handle, which accessed by ray gen shader.
222 * @return Returns the material handle.
223 */
224 uint32_t GetHitShaderHandle() const;
225
226 /**
227 * @brief Get ShaderGroup Handle, which accessed by gdc buffer.
228 * @return Returns the material handle.
229 */
230 uint32_t GetShaderGroupHandle() const;
231
232 /**
233 * @brief Get mesh pack UUID.
234 */
235 UUID GetUUID() const { return m_UUID; }
236
237 /**
238 * @brief Bind VBO and EBO.
239 * @param[in] commandBuffer Which command buffer we will submit commands.
240 */
241 void OnBind(const VkCommandBuffer& commandBuffer) const;
242
243 /**
244 * @brief Draw indexed.
245 * @param[in] commandBuffer Which command buffer we will submit commands.
246 */
247 void OnDraw(const VkCommandBuffer& commandBuffer) const;
248
249 /**
250 * @brief Draw Mesh Tasks.
251 * @param[in] commandBuffer Which command buffer we will submit commands.
252 */
253 void OnDrawMeshTasks(const VkCommandBuffer& commandBuffer) const;
254
255 /**
256 * @brief Get Meshlets array.
257 * @return Returns the Meshlets array.
258 */
259 const std::vector<Meshlet>& GetMeshlets() const { return *m_MeshResource.meshlets.attributes; }
260
261 /**
262 * @brief Get NTasks.
263 * @return Returns the NTasks.
264 */
265 uint32_t GetNTasks() const { return m_NTasks; }
266
267 /**
268 * @brief Get Mesh Description.
269 * @return Returns the Mesh Description.
270 */
271 MeshDesc& GetMeshDesc() { return m_Desc; }
272
273 /**
274 * @brief Get Draw Command.
275 * @return Returns Draw Command.
276 */
277 const VkDrawMeshTasksIndirectCommandNV& GetDrawCommand() const { return m_MeshTaskIndirectDrawCommand; }
278
279 /**
280 * @brief Get Pack Type.
281 * @return Returns the Pack Type.
282 */
283 const std::string& GetPackType() const { return m_PackType; }
284
285 /**
286 * @brief Convert MeshPack into the ray tracing geometry used to build the BLAS.
287 * @return Returns VulkanRayTracing::BlasInput.
288 */
290
291 /**
292 * @brief Is this meshPack has a valid blas.
293 * @return Returns true if has a valid blas.
294 */
295 bool HasBlasAccel();
296
297 /**
298 * @brief Get this accel.
299 * @return Returns this accel.
300 */
302
303 /**
304 * @brief Get Resource.
305 * @return Returns the Resource.
306 */
307 const MeshResource& GetResource() const { return m_MeshResource; }
308
309 protected:
310
311 /**
312 * @brief Create Vertices buffer anf Indices buffer.
313 */
314 void CreateBuffer();
315
316 protected:
317
318 /**
319 * @brief MeshPack Name.
320 */
321 std::string m_MeshPackName;
322
323 /**
324 * @brief If this mesh pack needs instanced.
325 */
327
328 /**
329 * @brief Mesh Resources.
330 */
332
333 /**
334 * @brief Task Shader Work Group Size.
335 */
336 uint32_t m_NTasks;
337
338 /**
339 * @brief specific material pointer.
340 */
341 std::shared_ptr<Material> m_Material;
342
343 /**
344 * @brief specific hit shader handle.
345 * Used in RayTracing Pipeline.
346 */
348
349 /**
350 * @brief specific shader group handle.
351 * Used in IndirectDGCPipeline.
352 */
354
355 /**
356 * @brief Mesh Description.
357 */
359
360 /**
361 * @brief specific mesh pack type.
362 */
363 std::string m_PackType;
364
365 /**
366 * @brief This meshPack blas accel.
367 */
369
370 /**
371 * @brief True if required accel by BLAS Build.
372 */
373 std::atomic_bool m_IsRequiredAccel;
374
375 /**
376 * @brief UUID for mesh pack.
377 */
379
380 /**
381 * @brief Draw Command.
382 */
384
385 /**
386 * @brief Allow MeshLoader access all data.
387 */
388 friend class MeshLoader;
389 friend class MeshProcessor;
390 };
391
392 /**
393 * @brief PlanePack Class.
394 * This class defines plane type mesh pack.
395 */
396 class PlanePack : public MeshPack
397 {
398 public:
399
400 /**
401 * @brief Constructor Function.
402 * Init member variables.
403 * @param[in] rows The rows number.
404 * @param[in] columns The columns number.
405 * @param[in] instanced Is this mesh pack instanced.
406 */
407 PlanePack(uint32_t rows = 2, uint32_t columns = 2, bool instanced = true)
408 : MeshPack("Plane", instanced)
409 , m_Rows(rows)
410 , m_Columns(columns)
411 {
412 m_PackType = "PlanePack";
413 }
414
415 /**
416 * @brief Destructor Function.
417 */
418 virtual ~PlanePack() override = default;
419
420 /**
421 * @brief This interface is used for build specific mesh pack data.
422 * @param[in] isCreateBuffer Whether it needs to create buffer.
423 * @return Returns true if Create Pack successfully.
424 */
425 virtual bool OnCreatePack(bool isCreateBuffer = true) override;
426
427 private:
428
429 /**
430 * @brief How much rows number we use.
431 */
432 uint32_t m_Rows;
433
434 /**
435 * @brief How much cols number we use.
436 */
437 uint32_t m_Columns;
438 };
439
440
441 /**
442 * @brief CubePack Class.
443 * This class defines box type mesh pack.
444 */
445 class CubePack : public MeshPack
446 {
447 public:
448
449 /**
450 * @brief Constructor Function.
451 * Init member variables.
452 * @param[in] rows The rows number.
453 * @param[in] columns The columns number.
454 * @param[in] instanced Is this mesh pack instanced.
455 */
456 CubePack(uint32_t rows = 2, uint32_t columns = 2, bool instanced = true)
457 : MeshPack("Cube", instanced)
458 , m_Rows(rows)
459 , m_Columns(columns)
460 {
461 m_PackType = "CubePack";
462 }
463
464 /**
465 * @brief Destructor Function.
466 */
467 virtual ~CubePack() override = default;
468
469 /**
470 * @brief This interface is used for build specific mesh pack data.
471 * @param[in] isCreateBuffer Whether it needs to create buffer.
472 * @return Returns true if Create Pack successfully.
473 */
474 virtual bool OnCreatePack(bool isCreateBuffer = true) override;
475
476 private:
477
478 /**
479 * @brief How much rows number we use.
480 */
481 uint32_t m_Rows;
482
483 /**
484 * @brief How much cols number we use.
485 */
486 uint32_t m_Columns;
487 };
488
489 /**
490 * @brief SpherePack Class.
491 * This class defines sphere type mesh pack.
492 */
493 class SpherePack : public MeshPack
494 {
495 public:
496
497 /**
498 * @brief Constructor Function.
499 * Init member variables.
500 * @param[in] rows The rows number.
501 * @param[in] columns The columns number.
502 * @param[in] instanced Is this mesh pack instanced.
503 */
504 SpherePack(uint32_t rows = 15, uint32_t columns = 24, bool instanced = true)
505 : MeshPack("Sphere", instanced)
506 , m_Rows(rows)
507 , m_Columns(columns)
508 {
509 m_PackType = "SpherePack";
510 }
511
512 /**
513 * @brief Destructor Function.
514 */
515 virtual ~SpherePack() override = default;
516
517 /**
518 * @brief This interface is used for build specific mesh pack data.
519 * @param[in] isCreateBuffer Whether it needs to create buffer.
520 * @return Returns true if Create Pack successfully.
521 */
522 virtual bool OnCreatePack(bool isCreateBuffer = true) override;
523
524 private:
525
526 /**
527 * @brief How much rows number we use.
528 */
529 uint32_t m_Rows;
530
531 /**
532 * @brief How much cols number we use.
533 */
534 uint32_t m_Columns;
535 };
536
537 /**
538 * @brief FilePack Class.
539 * This class defines file type mesh pack.
540 */
541 class FilePack : public MeshPack
542 {
543 public:
544
545 /**
546 * @brief Constructor Function.
547 * Init member variables.
548 * @param[in] filePath The mesh file path in disk.
549 * @param[in] instanced Is this mesh pack instanced.
550 */
551 FilePack(const std::string& filePath, bool instanced = true)
552 : MeshPack(filePath, instanced)
553 , m_Path(filePath)
554 {
555 m_PackType = "FilePack";
556 }
557
558 /**
559 * @brief Destructor Function.
560 */
561 virtual ~FilePack() override = default;
562
563 /**
564 * @brief This interface is used for build specific mesh pack data.
565 * @param[in] isCreateBuffer Whether it needs to create buffer.
566 * @return Returns true if Create Pack successfully.
567 */
568 virtual bool OnCreatePack(bool isCreateBuffer = true) override;
569
570 private:
571
572 /**
573 * @brief The mesh file path in disk.
574 */
575 std::string m_Path;
576 };
577}
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 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
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
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 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
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
AccelStructure Wrapper.
Definition Attribute.h:17
MeshResource's item template.
Definition Attribute.h:28
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
Meshlet Class. This class defines what Meshlet data.
Definition Vertex.h:58
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.
This struct contains all Vulkan object in used global.
Definition VulkanUtils.h:74
std::size_t operator()(const Spices::UUID &uuid) const noexcept
Definition UUID.h:62