2024-05-25 17:58:39 +08:00
|
|
|
|
#pragma once
|
2023-03-06 14:06:20 +08:00
|
|
|
|
|
2023-03-17 10:14:07 +08:00
|
|
|
|
#include<hgl/shadergen/MaterialDescriptorInfo.h>
|
2023-03-17 10:08:41 +08:00
|
|
|
|
#include<hgl/shadergen/ShaderCreateInfoVertex.h>
|
|
|
|
|
#include<hgl/shadergen/ShaderCreateInfoGeometry.h>
|
|
|
|
|
#include<hgl/shadergen/ShaderCreateInfoFragment.h>
|
|
|
|
|
#include<hgl/shadergen/ShaderCreateInfoMap.h>
|
2023-05-15 21:52:57 +08:00
|
|
|
|
#include<hgl/graph/RenderTargetOutputConfig.h>
|
|
|
|
|
#include<hgl/graph/mtl/MaterialConfig.h>
|
2025-03-04 22:41:07 +08:00
|
|
|
|
#include<hgl/graph/mtl/ShaderBufferSource.h>
|
2023-03-06 14:06:20 +08:00
|
|
|
|
#include<hgl/graph/VKSamplerType.h>
|
|
|
|
|
|
2025-02-01 15:40:35 +08:00
|
|
|
|
namespace hgl::graph
|
2023-03-06 14:06:20 +08:00
|
|
|
|
{
|
2025-05-17 20:26:36 +08:00
|
|
|
|
struct VulkanDevAttr;
|
2023-09-05 20:19:53 +08:00
|
|
|
|
struct UBODescriptor;
|
2023-03-13 21:58:27 +08:00
|
|
|
|
|
2023-06-02 20:45:19 +08:00
|
|
|
|
namespace mtl
|
|
|
|
|
{
|
|
|
|
|
class MaterialCreateInfo
|
|
|
|
|
{
|
|
|
|
|
protected:
|
2023-03-06 14:06:20 +08:00
|
|
|
|
|
2023-06-02 20:45:19 +08:00
|
|
|
|
const MaterialCreateConfig *config;
|
2023-09-05 20:19:53 +08:00
|
|
|
|
uint32_t ubo_range;
|
|
|
|
|
uint32_t ssbo_range;
|
2023-03-06 14:06:20 +08:00
|
|
|
|
|
2023-06-02 20:45:19 +08:00
|
|
|
|
MaterialDescriptorInfo mdi; ///<材质描述符管理器
|
2023-05-10 11:26:42 +08:00
|
|
|
|
|
2023-06-02 20:45:19 +08:00
|
|
|
|
AnsiString mi_codes; ///<MaterialInstance代码
|
|
|
|
|
uint32_t mi_data_bytes; ///<MaterialInstance数据长度
|
|
|
|
|
uint32_t mi_shader_stage; ///<MaterialInstance着色器阶段
|
2023-09-05 20:19:53 +08:00
|
|
|
|
uint32_t mi_max_count;
|
|
|
|
|
UBODescriptor *mi_ubo;
|
|
|
|
|
|
2024-05-25 17:58:39 +08:00
|
|
|
|
uint32_t l2w_max_count;
|
2023-09-05 20:19:53 +08:00
|
|
|
|
uint32_t l2w_shader_stage;
|
2024-05-25 17:58:39 +08:00
|
|
|
|
UBODescriptor *l2w_ubo;
|
2023-03-06 14:06:20 +08:00
|
|
|
|
|
2023-06-02 20:45:19 +08:00
|
|
|
|
ShaderCreateInfoMap shader_map; ///<着色器列表
|
2023-03-06 14:06:20 +08:00
|
|
|
|
|
2023-06-02 20:45:19 +08:00
|
|
|
|
ShaderCreateInfoVertex *vert;
|
|
|
|
|
ShaderCreateInfoGeometry *geom;
|
|
|
|
|
ShaderCreateInfoFragment *frag;
|
2023-03-06 14:06:20 +08:00
|
|
|
|
|
2023-06-02 20:45:19 +08:00
|
|
|
|
public:
|
2023-03-17 21:06:05 +08:00
|
|
|
|
|
2023-06-12 15:45:34 +08:00
|
|
|
|
const uint32 GetShaderStage ()const{return config->shader_stage_flag_bit;}
|
2023-03-06 14:06:20 +08:00
|
|
|
|
|
2023-06-12 15:45:34 +08:00
|
|
|
|
bool hasShader (const VkShaderStageFlagBits ss)const{return config->shader_stage_flag_bit&ss;}
|
2023-03-06 14:06:20 +08:00
|
|
|
|
|
2023-06-02 20:45:19 +08:00
|
|
|
|
bool hasVertex ()const{return hasShader(VK_SHADER_STAGE_VERTEX_BIT);}
|
|
|
|
|
// bool hasTessCtrl ()const{return hasShader(VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT);}
|
|
|
|
|
// bool hasTessEval ()const{return hasShader(VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT);}
|
|
|
|
|
bool hasGeometry ()const{return hasShader(VK_SHADER_STAGE_GEOMETRY_BIT);}
|
|
|
|
|
bool hasFragment ()const{return hasShader(VK_SHADER_STAGE_FRAGMENT_BIT);}
|
|
|
|
|
// bool hasCompute ()const{return hasShader(VK_SHADER_STAGE_COMPUTE_BIT);}
|
2023-03-06 14:06:20 +08:00
|
|
|
|
|
2023-06-02 20:45:19 +08:00
|
|
|
|
ShaderCreateInfoVertex * GetVS()const{return vert;}
|
|
|
|
|
ShaderCreateInfoGeometry * GetGS()const{return geom;}
|
|
|
|
|
ShaderCreateInfoFragment * GetFS()const{return frag;}
|
2023-06-02 14:22:07 +08:00
|
|
|
|
|
2023-06-14 16:49:19 +08:00
|
|
|
|
const ShaderCreateInfoMap &GetShaderMap()const{return shader_map;}
|
|
|
|
|
|
2023-06-02 20:45:19 +08:00
|
|
|
|
public:
|
2023-06-02 14:22:07 +08:00
|
|
|
|
|
2023-06-02 20:45:19 +08:00
|
|
|
|
const MaterialDescriptorInfo &GetMDI()const{return mdi;}
|
2023-06-14 16:49:19 +08:00
|
|
|
|
|
|
|
|
|
const uint32_t GetMIDataBytes ()const{return mi_data_bytes;}
|
|
|
|
|
const uint32_t GetMIMaxCount ()const{return mi_max_count;}
|
2023-03-06 14:06:20 +08:00
|
|
|
|
|
2023-06-02 20:45:19 +08:00
|
|
|
|
public:
|
2023-03-06 14:06:20 +08:00
|
|
|
|
|
2023-06-02 20:45:19 +08:00
|
|
|
|
MaterialCreateInfo(const MaterialCreateConfig *);
|
|
|
|
|
~MaterialCreateInfo()=default;
|
2023-05-10 11:26:42 +08:00
|
|
|
|
|
2023-09-05 20:19:53 +08:00
|
|
|
|
bool SetMaterialInstance(const AnsiString &mi_glsl_codes,const uint32_t mi_struct_bytes,const uint32_t shader_stage_flag_bits);
|
|
|
|
|
|
|
|
|
|
bool SetLocalToWorld(const uint32_t shader_stage_flag_bits);
|
2023-03-06 14:06:20 +08:00
|
|
|
|
|
2023-06-02 20:45:19 +08:00
|
|
|
|
bool AddStruct(const AnsiString &ubo_typename,const AnsiString &codes);
|
|
|
|
|
bool AddStruct(const ShaderBufferSource &ss){return AddStruct(ss.struct_name,ss.codes);}
|
2023-03-08 14:02:51 +08:00
|
|
|
|
|
2024-03-09 22:25:03 +08:00
|
|
|
|
bool AddUBO(const VkShaderStageFlagBits flag_bits,const DescriptorSetType set_type,const AnsiString &struct_name,const AnsiString &name);
|
|
|
|
|
bool AddUBO(const uint32_t flag_bits,const DescriptorSetType &set_type,const AnsiString &struct_name,const AnsiString &name);
|
|
|
|
|
bool AddUBO(const uint32_t flag_bits,const DescriptorSetType &set_type,const ShaderBufferSource &ss){return AddUBO(flag_bits,set_type,ss.struct_name,ss.name);}
|
2023-06-02 20:45:19 +08:00
|
|
|
|
|
2024-03-09 23:23:34 +08:00
|
|
|
|
bool AddSampler(const VkShaderStageFlagBits flag_bits,const DescriptorSetType set_type,const SamplerType &st,const AnsiString &name);
|
|
|
|
|
|
2025-05-17 20:26:36 +08:00
|
|
|
|
bool CreateShader(const VulkanDevAttr *dev_attr);
|
2023-06-02 20:45:19 +08:00
|
|
|
|
};//class MaterialCreateInfo
|
|
|
|
|
}//namespace mtl
|
2025-02-01 15:40:35 +08:00
|
|
|
|
}//namespace hgl::graph
|