2
3
4
5
13
14
20
21
22
23
24
26 VkCommandBuffer cmdBuffer ,
27 const std::string& caption ,
28 glm::vec4 color =
glm::
vec4(1.0f)
32
33
34
35 static void EndLabel(VkCommandBuffer cmdBuffer);
38
39
40
41
42
44 VkCommandBuffer cmdBuffer ,
45 const std::string& caption ,
46 glm::vec4 color =
glm::
vec4(1.0f)
50
51
52
53
54
57 const std::string& caption ,
58 glm::vec4 color =
glm::
vec4(1.0f)
62
63
64
68
69
70
71
72
75 const std::string& caption ,
76 glm::vec4 color =
glm::
vec4(1.0f)
80
81
82
83
84
85
90 const std::string& caption
94
95
96
97
98
99
104 const std::vector<
char*>& captions
110#define DEBUGUTILS_BEGINLABEL(...) { ::Spices::VulkanDebugUtils::BeginLabel (__VA_ARGS__) ; }
111#define DEBUGUTILS_ENDLABEL(...) { ::Spices::VulkanDebugUtils::EndLabel (__VA_ARGS__) ; }
112#define DEBUGUTILS_INSERTLABEL(...) { ::Spices::VulkanDebugUtils::InsertLabel (__VA_ARGS__) ; }
113#define DEBUGUTILS_BEGINQUEUELABEL(...) { ::Spices::VulkanDebugUtils::BeginQueueLabel (__VA_ARGS__) ; }
114#define DEBUGUTILS_ENDQUEUELABEL(...) { ::Spices::VulkanDebugUtils::EndQueueLabel (__VA_ARGS__) ; }
115#define DEBUGUTILS_INSERTQUEUELABEL(...) { ::Spices::VulkanDebugUtils::InsertQueueLabel (__VA_ARGS__) ; }
116#define DEBUGUTILS_SETOBJECTNAME(...) { ::Spices::VulkanDebugUtils::SetObjectName (__VA_ARGS__) ; }
117#define DEBUGUTILS_SETOBJECTTAG(...) { ::Spices::VulkanDebugUtils::SetObjectTag (__VA_ARGS__) ; }
123#define DEBUGUTILS_BEGINLABEL(...)
124#define DEBUGUTILS_ENDLABEL(...)
125#define DEBUGUTILS_INSERTLABEL(...)
126#define DEBUGUTILS_BEGINQUEUELABEL(...)
127#define DEBUGUTILS_ENDQUEUELABEL(...)
128#define DEBUGUTILS_INSERTQUEUELABEL(...)
129#define DEBUGUTILS_SETOBJECTNAME(...)
130#define DEBUGUTILS_SETOBJECTTAG(...)
#define ASSERT(expr)
Assert macro.
#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.
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...
void PushToTextureParams(const std::string &name, const TextureParam &texture)
Push item to ShaderPath.
const std::vector< std::string > & GetShaderPath(const std::string &stage)
Get material shader path.
scl::linked_unordered_map< std::string, ConstantParams > m_ConstantParams
Constant parameters. Key: parameter name, Value: parameter value.
T GetDefaultConstantParams(const std::string &name)
Get default material constant parameter.
bool m_AlreadyBuild
True if this material already build a buffer.
const std::unordered_map< std::string, std::vector< std::string > > & GetShaderPath() const
Get material shader path.
void UpdateMaterial()
Update material data to buffer.
std::unordered_map< std::string, std::vector< std::string > > m_Shaders
Shader path Key: shader usage, Value: shader file name.
void Deserialize()
Deserialize the data from a disk file(.material) to this class.
void PushToShaderPath(const std::string &name, const std::string &shader)
Push item to ShaderPath.
std::unordered_map< std::string, std::vector< std::string > > m_DefaultShaders
void PushToConstParams(const std::string &name, const ConstantParam ¶m)
Push item to ConstParams.
uint64_t GetMaterialParamsAddress() const
Get material parameter address on GPU.
const std::string & GetName() const
Get Material Path.
scl::runtime_memory_block m_Buffermemoryblocks
m_Buffers's c++ data container. Key: set, Value: scl::runtime_memory_block.
Material()=default
Constructor Function.
scl::linked_unordered_map< std::string, TextureParam > m_DefaultTextureParams
bool GetIsDrawWindow() const
Get boolean of whether draw a material window.
void SetIsDrawWindow(bool isDrawWindow)
Set boolean of whether draw a material window.
scl::linked_unordered_map< std::string, TextureParam > & GetTextureParams()
Get material texture parameters.
void SetName(const std::string &path)
Set material path.
bool m_IsDrawWindow
True if this material needs to draw a window.
scl::linked_unordered_map< std::string, ConstantParams > & GetConstantParams()
Get material constant parameters.
Material(const std::string &materialPath)
Constructor Function. Deserialize immediately. Usually call it.
scl::linked_unordered_map< std::string, TextureParam > m_TextureParams
Texture parameters. Key: parameter name, Value: parameter value.
std::mutex m_Mutex
Mutex of this material.
virtual ~Material()
Destructor Function.
std::unique_ptr< VulkanBuffer > m_MaterialParameterBuffer
MaterialProperties m_Properties
Properties of render options.
std::string m_MaterialPath
void Serialize()
Serialize this class data to a disk file(.material).
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.
Texture2DCube Class. This class defines the basic behaves of Texture2DCube.
Texture2D(const RendererResourceCreateInfo &info)
Constructor Function. Used for create render resource.
Texture2D(const std::string &path)
Constructor Function. Init class variable, load date immediately. Usually call it.
virtual ~Texture2D() override=default
Destructor Function.
Texture2D()=default
Constructor Function.
Texture2D Class. This class defines the basic behaves of texture2D.
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.
Texture(const std::string &path)
Constructor Function. Init class variable. Usually call it.
Texture()=default
Constructor Function.
std::shared_ptr< T > GetResource()
Get Specific resource, usually is a wrapper of VulkanImage.
std::any m_Resource
Texture's resource, coule be any kind of type.
Texture Class. This class defines the basic behaves of texture. When we add an new Texture,...
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 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.
ShaderStage m_ShaderStage
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.
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,...
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.
TextureType
The enum of all Texture Type.
std::shared_ptr< World > CreateWorld()
extern WorldCreation definition in Game.
static void HandleVkResult(VkResult result)
Handle VkResult Function.
constexpr uint32_t MaxFrameInFlight
Max In Flight Frame. 2 buffers are enough in this program.
MeshResource's item template.
This struct's data is defined from .material file.
ConstantParam defaultValue
This struct's data is defined from .material file.
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.
This struct defines the data used to create a texture2d. From render pass.
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's data is defined from .material file.
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
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
uint32_t m_GraphicQueueFamily
VulkanState()=default
Constructor Function.
std::array< VkSemaphore, MaxFrameInFlight > m_GraphicImageSemaphore
std::array< VkCommandBuffer, MaxFrameInFlight > m_ComputeCommandBuffer
VkPhysicalDevice m_PhysicalDevice
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.
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