2
3
4
5
9#include "..\..\..\assets\Shaders\src\Header\ShaderCommon.h"
15#define GLM_FORCE_RADIANS
16#define GLM_ENABLE_EXPERIMENTAL
18#include <glm/gtx/hash.hpp>
20#include <src/meshoptimizer.h>
29
30
31
35
36
37
41
42
43
47
48
49
54
55
56
62
63
67
68
69
70
74
75
76
77
78 void FromMeshopt(
const meshopt_Meshlet& m,
const meshopt_Bounds& bounds);
82
83
84
90
91
95
96
97
98
99 Edge(uint32_t f, uint32_t s)
106
107
108
109
113
114
115
116
118 return (first == other.first && second == other.second) ||
119 (first == other.second && second == other.first);
123
124
125
126
128 return first < other.first;
133
134
135
141
142
146
147
148
149
157
158
159
160
164
165
166
167
169 return first == other.first && second == other.second;
173
174
175
176
178 return first < other.first;
183
184
185
191
192
200
201
202
203
204
212
213
214
221
222
233
234
237 return ((hash<uint32_t>()(edge.first) ^ (hash<uint32_t>()(edge.second) << 1)) >> 1)
238 + ((hash<uint32_t>()(edge.second) ^ (hash<uint32_t>()(edge.first) << 1)) >> 1);
243
244
247 return ((hash<uint32_t>()(edge.first) ^ (hash<uint32_t>()(edge.second) << 1)) >> 1);
252
253
256 return hash<glm::uvec3>()({ edgeP.next, edgeP.prev, edgeP.self }) +
257 hash<glm::uvec3>()({ edgeP.prev, edgeP.next, edgeP.self });
#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.
EdgePoint(uint32_t prev, uint32_t self, uint32_t next)
Constructor Function.
bool valid()
Determine whether this edge point is valid.
EdgePoint()
Constructor Function.
EdgePoint Class. This class defines what EdgePoint data.
Edge()=default
Constructor Function.
bool operator==(const Edge &other) const
Destructor Function. @attemtion Why Destructor causes bug here.
Edge(uint32_t f, uint32_t s)
Constructor Function.
bool operator<(const Edge &other) const
Less Operation.
Edge Class. This class defines what Edge data.
bool operator<(const HalfEdge &other) const
Less Operation.
HalfEdge()=default
Constructor Function.
bool operator==(const HalfEdge &other) const
Destructor Function. @attemtion Why Destructor causes bug here.
HalfEdge(uint32_t f, uint32_t s)
Constructor Function.
HalfEdge Class. This class defines what HalfEdge data.
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.
void FromMeshopt(const meshopt_Meshlet &m, const meshopt_Bounds &bounds)
Destructor Function. @attemtion Why Destructor causes bug here.
Meshlet()=default
Constructor Function.
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.
size_t operator()(Spices::EdgePoint const &edgeP) const
size_t operator()(Spices::Edge const &edge) const
size_t operator()(Spices::HalfEdge const &edge) const
std::size_t operator()(const Spices::UUID &uuid) const noexcept