2
3
4
5
10#include "Resources/Material/Material.h"
11#include "Render/Vulkan/VulkanBuffer.h"
12#include "Resources/ResourcePool/ResourcePool.h"
18#ifdef RENDERAPI_VULKAN
19#include "Render/Vulkan/VulkanRayTracing.h"
25
26
36
37
41
42
46
47
51
52
66
67
80
81
82
87
88
93 void Update##item(std::shared_ptr<VulkanBuffer> buffer)
97 item = static_cast<decltype(item)>(buffer->GetAddress());
101 item = static_cast<decltype(item)>(0
);
103 m_Buffer->WriteToBuffer(&item, sizeof(item), offsetof(MeshDesc, item));
105 void Update##item(uint64_t p)
107 item = static_cast<decltype(item)>(p);
108 m_Buffer->WriteToBuffer(&item, sizeof(item), offsetof(MeshDesc, item));
112
113
117
118
122
123
124
128
129
138 Update_F(primitiveLocationsAddress )
145
146
151
152
153
154
160
161
162
163
164 MeshPack(
const std::string& name,
bool instanced);
167
168
172
173
174
178
179
180
184
185
186
187
191
192
193
197
198
199
203
204
205
209
210
211
215
216
217
221
222
223
227
228
229
233
234
238
239
240
241 void OnBind(
const VkCommandBuffer& commandBuffer)
const;
244
245
246
247 void OnDraw(
const VkCommandBuffer& commandBuffer)
const;
250
251
252
256
257
258
262
263
264
268
269
270
274
275
276
280
281
282
286
287
288
292
293
294
298
299
300
304
305
306
312
313
319
320
324
325
329
330
334
335
339
340
344
345
346
350
351
352
356
357
361
362
366
367
371
372
376
377
381
382
386
387
393
394
395
401
402
403
404
405
406
407 PlanePack(uint32_t rows = 2, uint32_t columns = 2,
bool instanced =
true)
416
417
421
422
423
424
425 virtual bool OnCreatePack(
bool isCreateBuffer =
true)
override;
430
431
435
436
442
443
444
450
451
452
453
454
455
456 CubePack(uint32_t rows = 2, uint32_t columns = 2,
bool instanced =
true)
465
466
470
471
472
473
474 virtual bool OnCreatePack(
bool isCreateBuffer =
true)
override;
479
480
484
485
490
491
492
498
499
500
501
502
503
504 SpherePack(uint32_t rows = 15, uint32_t columns = 24,
bool instanced =
true)
513
514
518
519
520
521
522 virtual bool OnCreatePack(
bool isCreateBuffer =
true)
override;
527
528
532
533
538
539
540
546
547
548
549
550
551 FilePack(
const std::string& filePath,
bool instanced =
true)
559
560
564
565
566
567
568 virtual bool OnCreatePack(
bool isCreateBuffer =
true)
override;
573
574
#define PROCESS_INSTANCE_ENTRY
Macros of modify Process instance state.
#define PROCESS_INSTANCE_EXIT
#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.
virtual bool OnCreatePack(bool isCreateBuffer=true) override
This interface is used for build specific mesh pack data.
uint32_t m_Columns
How much cols number we use.
uint32_t m_Rows
How much rows number we use.
CubePack(uint32_t rows=2, uint32_t columns=2, bool instanced=true)
Constructor Function. Init member variables.
virtual ~CubePack() override=default
Destructor Function.
CubePack Class. This class defines box type mesh pack.
Entity Class. This class defines the specific behaves of Entity.
virtual bool OnCreatePack(bool isCreateBuffer=true) override
This interface is used for build specific mesh pack data.
virtual ~FilePack() override=default
Destructor Function.
FilePack(const std::string &filePath, bool instanced=true)
Constructor Function. Init member variables.
std::string m_Path
The mesh file path in disk.
FilePack Class. This class defines file type mesh pack.
static std::shared_ptr< spdlog::logger > s_ClientLogger
Game Stage Logger.
static bool m_IsInitialized
static std::shared_ptr< spdlog::logger > s_CoreLogger
Engine Stage Logger.
static void Init()
Init Log.
static std::shared_ptr< spdlog::logger > & GetCoreLogger()
Get Engine Stage Logger.
static std::shared_ptr< spdlog::logger > & GetClientLogger()
Get Game Stage Logger.
static void PostHandle(format_string_t< Args... > fmt, Args &&...args)
Post handle with log message.
static void ShutDown()
Shutdown Log.
Material Class. This class contains a branch of parameter and shader, also descriptor.
MeshLoader Class. This class only defines static function for load data from mesh file.
AccelKHR m_Accel
This meshPack blas accel.
UUID GetUUID() const
Get mesh pack UUID.
std::optional< std::atomic_uint32_t > m_ShaderGroupHandle
specific shader group handle. Used in IndirectDGCPipeline.
void SetHitShaderHandle(uint32_t handle)
Set hit shader Handle.
std::string m_MeshPackName
MeshPack Name.
uint32_t GetNTasks() const
Get NTasks.
void OnDraw(const VkCommandBuffer &commandBuffer) const
Draw indexed.
virtual bool OnCreatePack(bool isCreateBuffer=true)
This interface is used for build specific mesh pack data.
MeshResource m_MeshResource
Mesh Resources.
uint32_t GetShaderGroupHandle() const
Get ShaderGroup Handle, which accessed by gdc buffer.
std::optional< std::atomic_uint32_t > m_HitShaderHandle
specific hit shader handle. Used in RayTracing Pipeline.
void OnDrawMeshTasks(const VkCommandBuffer &commandBuffer) const
Draw Mesh Tasks.
VkDrawMeshTasksIndirectCommandNV m_MeshTaskIndirectDrawCommand
Draw Command.
MeshDesc & GetMeshDesc()
Get Mesh Description.
const std::string & GetPackType() const
Get Pack Type.
uint32_t GetHitShaderHandle() const
Get Hit Shader Handle, which accessed by ray gen shader.
MeshPack(const std::string &name, bool instanced)
Constructor Function.
bool HasBlasAccel()
Is this meshPack has a valid blas.
std::string m_PackType
specific mesh pack type.
void CreateBuffer()
Create Vertices buffer anf Indices buffer.
VulkanRayTracing::BlasInput MeshPackToVkGeometryKHR()
Convert MeshPack into the ray tracing geometry used to build the BLAS.
std::atomic_bool m_IsRequiredAccel
True if required accel by BLAS Build.
void OnBind(const VkCommandBuffer &commandBuffer) const
Bind VBO and EBO.
MeshDesc m_Desc
Mesh Description.
std::shared_ptr< Material > GetMaterial()
Get material in this class.
const VkDrawMeshTasksIndirectCommandNV & GetDrawCommand() const
Get Draw Command.
void SetMaterial(std::shared_ptr< Material > material)
Set specific material for this class.
MeshPack & operator=(const MeshPack &)=delete
Copy Constructor Function.
void SetShaderGroupHandle(uint32_t handle)
Set hit shader Handle.
const MeshResource & GetResource() const
Get Resource.
std::shared_ptr< Material > m_Material
specific material pointer.
void SetMaterial(const std::string &materialPath)
Set specific material for this class.
uint32_t m_NTasks
Task Shader Work Group Size.
virtual ~MeshPack()=default
Destructor Function.
UUID m_UUID
UUID for mesh pack.
const std::vector< Meshlet > & GetMeshlets() const
Get Meshlets array.
MeshPack(const MeshPack &)=delete
Copy Constructor Function.
bool m_Instanced
If this mesh pack needs instanced.
AccelKHR & GetAccel()
Get this accel.
MeshPack Class. This class defines some basic behaves and variables. This class need to be inherited ...
Class for provide functions of process Meshpack.
uint32_t m_Columns
How much cols number we use.
uint32_t m_Rows
How much rows number we use.
virtual bool OnCreatePack(bool isCreateBuffer=true) override
This interface is used for build specific mesh pack data.
PlanePack(uint32_t rows=2, uint32_t columns=2, bool instanced=true)
Constructor Function. Init member variables.
virtual ~PlanePack() override=default
Destructor Function.
PlanePack Class. This class defines plane type mesh pack.
SpherePack(uint32_t rows=15, uint32_t columns=24, bool instanced=true)
Constructor Function. Init member variables.
uint32_t m_Rows
How much rows number we use.
virtual ~SpherePack() override=default
Destructor Function.
virtual bool OnCreatePack(bool isCreateBuffer=true) override
This interface is used for build specific mesh pack data.
uint32_t m_Columns
How much cols number we use.
SpherePack Class. This class defines sphere type mesh pack.
float m_FrameTime
time step(s) during frames.
std::chrono::steady_clock::time_point m_StartTime
Engine Start time.
void Flush()
Refresh time in each engine loop.
const float & ft() const
Get time step during frames.
TimeStep(const TimeStep &)=delete
Copy Constructor Function.
const uint64_t & fs() const
Get frames count.
TimeStep()
Constructor Function.
virtual ~TimeStep()=default
Destructor Function.
std::chrono::steady_clock::time_point m_LastTime
Last frame time.
float m_GameTime
time step(s) since Engine Start.
uint64_t m_Frames
Frames since Engine Start.
TimeStep & operator=(const TimeStep &)=delete
Copy Assignment Operation.
const float & gt() const
Get time step since Engine Start.
This Class handles our engine time step during frames. Global Unique.
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.
UUID(uint64_t uuid)
Constructor Function.
UUID(const UUID &)=default
Destructor Function.
std::string ToString()
Transform UUID to String.
operator uint64_t() const
Operator Function.
This class helps to generate a uuid for one resource.
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.
WorldMarkFlags GetMarker() const
Get WorldMarkFlags this frame.
void ViewComponent(const std::vector< uint32_t > &ranges, uint32_t floor, uint32_t ceil, F &&fn)
View all component in this world in ranges.
void Mark(WorldMarkFlags flags)
Mark WorldMarkFlags with flags.
Entity CreateEntity(const std::string &name="None")
Create a new empty entity in this world.
void OnComponentAdded(Entity *entity, T &component)
Called On any Component Added to this world.
void ReserMark()
Reset WorldMarkFlags to Clean.
void ViewRoot(F &&fn)
View all root in this world.
Entity CreateEmptyEntity(UUID uuid)
Entity CreateEntityWithUUID(UUID uuid, const std::string &name="None")
Create a new empty entity with a uuid in this world.
void ViewComponent(F &&fn)
View all component in this world.
void ViewComponent(const std::vector< uint32_t > &ranges, F &&fn)
View all component in this world in ranges.
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).
virtual void OnPreActivate()=0
This interface define the specific world behaves before on activated.
entt::registry m_Registry
This variable handles all entity.
std::shared_mutex m_Mutex
Mutex for world.
void DestroyEntity(Entity &entity)
Destroy a entity from this world.
T & GetComponent(entt::entity e)
Get Component owned by this entity.
void RemoveComponent(entt::entity e)
Remove Component owned from this entity.
WorldMarkFlags m_Marker
World State this frame.
entt::registry & GetRegistry()
Get Registry variable.
void RemoveFromRoot(Entity &entity)
Remove a entity from this world root.
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.
World()=default
Constructor Function.
std::unordered_map< UUID, entt::entity > m_RootEntityMap
This variable is a cache. @noto Not in use now.
bool IsRootEntity(Entity &entity)
Determine if a entity is in root.
void ClearMarkerWithBits(WorldMarkFlags flags)
Clear WorldMarkFlags with flags.
bool HasComponent(entt::entity e)
If Component is owned by this entity or not.
T & AddComponent(entt::entity e, Args &&... args)
Template Function. Used for add specific component to entity.
World Class. This class defines the basic behaves of World. When we create an new world,...
static const char * memoryPoolNames[3]
MemoryPool's name.
std::shared_ptr< World > CreateWorld()
extern WorldCreation definition in Game.
MeshResource's item template.
uint32_t primVertexOffset
MeshDesc()
Constructor Function.
MeshDesc Copy() const
Copy a MeshDesc from this.
uint64_t GetBufferAddress() const
Get m_Buffer's Address.
Add Construction Functions to SpicesShader::MeshDesc.
MeshResource()=default
Constructor Function.
Positions positions
Declare value.
PrimitiveVertices primitiveVertices
PrimitiveLocations primitiveLocations
PrimitivePoints primitivePoints
virtual ~MeshResource()=default
Destructor Function.
void CreateBuffer(const std::string &name)
Create MeshResource Buffers.
Meshlet Class. This class defines what Meshlet data.
static constexpr char const * name
static constexpr uint32_t id
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.
std::size_t operator()(const Spices::UUID &uuid) const noexcept