renamed type DescriptorSetType to DescriptorSetsType

This commit is contained in:
hyzboy 2021-09-27 21:20:22 +08:00
parent e56730ec87
commit 7ba2d0cf6f
32 changed files with 94 additions and 94 deletions

View File

@ -67,7 +67,7 @@ private:
return(false); return(false);
{ {
MaterialParameters *mp=material_instance->GetMP(DescriptorSetType::Value); MaterialParameters *mp=material_instance->GetMP(DescriptorSetsType::Value);
if(!mp)return(false); if(!mp)return(false);

View File

@ -38,7 +38,7 @@ constexpr VkFormat gbuffer_depth_format=PF_D16UN;
struct alignas(16) PhongPointLight struct alignas(16) PhongPointLight
{ {
Vector3f color; Vector4f color;
Vector4f position; Vector4f position;
float radius; float radius;
};// };//
@ -198,7 +198,7 @@ private:
sampler=db->CreateSampler(&sampler_create_info); sampler=db->CreateSampler(&sampler_create_info);
{ {
MaterialParameters *mp_global=sp_gbuffer.material_instance->GetMP(DescriptorSetType::Global); MaterialParameters *mp_global=sp_gbuffer.material_instance->GetMP(DescriptorSetsType::Global);
if(!mp_global) if(!mp_global)
return(false); return(false);
@ -209,7 +209,7 @@ private:
} }
{ {
MaterialParameters *mp=sp_gbuffer.material_instance->GetMP(DescriptorSetType::Value); MaterialParameters *mp=sp_gbuffer.material_instance->GetMP(DescriptorSetsType::Value);
if(!mp) if(!mp)
return(false); return(false);
@ -220,7 +220,7 @@ private:
} }
{ {
MaterialParameters *mp_global=sp_composition.material_instance->GetMP(DescriptorSetType::Global); MaterialParameters *mp_global=sp_composition.material_instance->GetMP(DescriptorSetsType::Global);
if(!mp_global) if(!mp_global)
return(false); return(false);
@ -231,7 +231,7 @@ private:
} }
{ {
MaterialParameters *mp=sp_composition.material_instance->GetMP(DescriptorSetType::Value); MaterialParameters *mp=sp_composition.material_instance->GetMP(DescriptorSetsType::Value);
if(!mp) if(!mp)
return(false); return(false);
@ -379,8 +379,8 @@ public:
// White // White
lights.position = Vector4f(0.0f, 0.0f, 50.0f, 0.0f); lights.position = Vector4f(0.0f, 0.0f, 50.0f, 0.0f);
lights.color = Vector3f(105.0f); lights.color = Vector4f(1.0f);
lights.radius = 150.0f; lights.radius = 15.0f;
lights.position.x = sin(hgl_rad2deg(timer/100)) * 100.0f; lights.position.x = sin(hgl_rad2deg(timer/100)) * 100.0f;
lights.position.y = cos(hgl_rad2deg(timer/100)) * 100.0f; lights.position.y = cos(hgl_rad2deg(timer/100)) * 100.0f;

View File

@ -65,7 +65,7 @@ private:
sampler=db->CreateSampler(); sampler=db->CreateSampler();
{ {
MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetType::Global); MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetsType::Global);
if(!mp_global) if(!mp_global)
return(false); return(false);
@ -76,7 +76,7 @@ private:
} }
{ {
MaterialParameters *mp=material_instance->GetMP(DescriptorSetType::Value); MaterialParameters *mp=material_instance->GetMP(DescriptorSetsType::Value);
if(!mp) if(!mp)
return(false); return(false);

View File

@ -167,7 +167,7 @@ private:
sampler=db->CreateSampler(); sampler=db->CreateSampler();
{ {
MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetType::Global); MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetsType::Global);
if(!mp_global) if(!mp_global)
return(false); return(false);
@ -178,7 +178,7 @@ private:
} }
{ {
MaterialParameters *mp_texture=material_instance->GetMP(DescriptorSetType::Value); MaterialParameters *mp_texture=material_instance->GetMP(DescriptorSetsType::Value);
if(!mp_texture) if(!mp_texture)
return(false); return(false);

View File

@ -61,7 +61,7 @@ private:
return(false); return(false);
{ {
MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetType::Global); MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetsType::Global);
if(!mp_global) if(!mp_global)
return(false); return(false);

View File

@ -45,7 +45,7 @@ private:
return(false); return(false);
{ {
MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetType::Global); MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetsType::Global);
if(!mp_global) if(!mp_global)
return(false); return(false);

View File

@ -161,7 +161,7 @@ private:
if(!mir->material_instance)return(false); if(!mir->material_instance)return(false);
{ {
MaterialParameters *mp_global=mir->material_instance->GetMP(DescriptorSetType::Global); MaterialParameters *mp_global=mir->material_instance->GetMP(DescriptorSetsType::Global);
if(!mp_global) if(!mp_global)
return(false); return(false);
@ -172,7 +172,7 @@ private:
} }
{ {
MaterialParameters *mp_texture=mir->material_instance->GetMP(DescriptorSetType::Value); MaterialParameters *mp_texture=mir->material_instance->GetMP(DescriptorSetsType::Value);
if(!mp_texture) if(!mp_texture)
return(false); return(false);

View File

@ -130,7 +130,7 @@ private:
if(!material_instance)return(false); if(!material_instance)return(false);
{ {
MaterialParameters *mp_texture=material_instance->GetMP(DescriptorSetType::Value); MaterialParameters *mp_texture=material_instance->GetMP(DescriptorSetsType::Value);
if(!mp_texture) if(!mp_texture)
return(false); return(false);
@ -213,7 +213,7 @@ private:
ubo_phong=db->CreateUBO(sizeof(PhongMaterial),&phong); ubo_phong=db->CreateUBO(sizeof(PhongMaterial),&phong);
{ {
MaterialParameters *mp_value=material_instance->GetMP(DescriptorSetType::Value); MaterialParameters *mp_value=material_instance->GetMP(DescriptorSetsType::Value);
if(!mp_value) if(!mp_value)
return(false); return(false);
@ -225,7 +225,7 @@ private:
} }
{ {
MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetType::Global); MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetsType::Global);
if(!mp_global) if(!mp_global)
return(false); return(false);
@ -236,7 +236,7 @@ private:
} }
{ {
MaterialParameters *mp_global=axis_mi->GetMP(DescriptorSetType::Global); MaterialParameters *mp_global=axis_mi->GetMP(DescriptorSetsType::Global);
if(!mp_global) if(!mp_global)
return(false); return(false);

View File

@ -72,7 +72,7 @@ public:
return(false); return(false);
{ {
MaterialParameters *mp_global=ro->material_instance->GetMP(DescriptorSetType::Global); MaterialParameters *mp_global=ro->material_instance->GetMP(DescriptorSetsType::Global);
if(!mp_global) if(!mp_global)
return(false); return(false);
@ -143,7 +143,7 @@ public:
if(!cube.sampler)return(false); if(!cube.sampler)return(false);
{ {
MaterialParameters *mp_texture=cube.material_instance->GetMP(DescriptorSetType::Value); MaterialParameters *mp_texture=cube.material_instance->GetMP(DescriptorSetsType::Value);
if(!mp_texture) if(!mp_texture)
return(false); return(false);

View File

@ -61,7 +61,7 @@ private:
sampler=db->CreateSampler(); sampler=db->CreateSampler();
{ {
MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetType::Global); MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetsType::Global);
if(!mp_global) if(!mp_global)
return(false); return(false);
@ -72,7 +72,7 @@ private:
} }
{ {
MaterialParameters *mp_texture=material_instance->GetMP(DescriptorSetType::Value); MaterialParameters *mp_texture=material_instance->GetMP(DescriptorSetsType::Value);
if(!mp_texture) if(!mp_texture)
return(false); return(false);

View File

@ -71,7 +71,7 @@ private:
return(false); return(false);
{ {
MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetType::Global); MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetsType::Global);
if(!mp_global) if(!mp_global)
return(false); return(false);

View File

@ -70,7 +70,7 @@ private:
return(false); return(false);
{ {
MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetType::Global); MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetsType::Global);
if(!mp_global) if(!mp_global)
return(false); return(false);

View File

@ -75,7 +75,7 @@ private:
sampler=db->CreateSampler(); sampler=db->CreateSampler();
{ {
MaterialParameters *mp_texture=material_instance->GetMP(DescriptorSetType::Value); MaterialParameters *mp_texture=material_instance->GetMP(DescriptorSetsType::Value);
if(!mp_texture) if(!mp_texture)
return(false); return(false);
@ -103,7 +103,7 @@ private:
return(false); return(false);
{ {
MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetType::Global); MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetsType::Global);
if(!mp_global) if(!mp_global)
return(false); return(false);

View File

@ -71,7 +71,7 @@ private:
return(false); return(false);
{ {
MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetType::Global); MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetsType::Global);
if(!mp_global) if(!mp_global)
return(false); return(false);

View File

@ -39,7 +39,7 @@ namespace hgl
MVPArrayBuffer *mvp_array; MVPArrayBuffer *mvp_array;
List<RenderableInstance *> ri_list; List<RenderableInstance *> ri_list;
VkDescriptorSet ds_list[(size_t)DescriptorSetType::RANGE_SIZE]; VkDescriptorSet ds_list[(size_t)DescriptorSetsType::RANGE_SIZE];
DescriptorSets *renderable_desc_sets; DescriptorSets *renderable_desc_sets;
uint32_t ubo_offset; uint32_t ubo_offset;
@ -54,7 +54,7 @@ namespace hgl
private: private:
Pipeline * last_pipeline; Pipeline * last_pipeline;
MaterialParameters *last_mp[(size_t)DescriptorSetType::RANGE_SIZE]; MaterialParameters *last_mp[(size_t)DescriptorSetsType::RANGE_SIZE];
uint32_t last_vbo; uint32_t last_vbo;
void Render(RenderableInstance *); void Render(RenderableInstance *);

View File

@ -69,7 +69,7 @@ class DeviceRenderPassManage;
class GPUFence; class GPUFence;
class GPUSemaphore; class GPUSemaphore;
enum class DescriptorSetType enum class DescriptorSetsType
{ {
//设计使其对应shader中的set //设计使其对应shader中的set
@ -82,16 +82,16 @@ enum class DescriptorSetType
ENUM_CLASS_RANGE(Global,Renderable) ENUM_CLASS_RANGE(Global,Renderable)
};// };//
const DescriptorSetType CheckDescriptorSetType(const char *str); const DescriptorSetsType CheckDescriptorSetsType(const char *str);
constexpr char *DescriptSetsTypeName[]= constexpr char *DescriptSetsTypeName[]=
{ {
"Global","Material","Value","Renderable" "Global","Material","Value","Renderable"
}; };
inline const char *GetDescriptorSetsTypeName(const enum class DescriptorSetType &type) inline const char *GetDescriptorSetsTypeName(const enum class DescriptorSetsType &type)
{ {
if(!ENUM_CLASS_RANGE_CHECK(DescriptorSetType,type)) if(!ENUM_CLASS_RANGE_CHECK(DescriptorSetsType,type))
return nullptr; return nullptr;
return DescriptSetsTypeName[(size_t)type]; return DescriptSetsTypeName[(size_t)type];

View File

@ -196,9 +196,9 @@ public: //shader & material
PipelineLayoutData *CreatePipelineLayoutData(const MaterialDescriptorSets *); PipelineLayoutData *CreatePipelineLayoutData(const MaterialDescriptorSets *);
void Destroy(PipelineLayoutData *); void Destroy(PipelineLayoutData *);
DescriptorSets * CreateDescriptorSets(const PipelineLayoutData *,const DescriptorSetType &type)const; DescriptorSets * CreateDescriptorSets(const PipelineLayoutData *,const DescriptorSetsType &type)const;
MaterialParameters *CreateMP(const MaterialDescriptorSets *,const PipelineLayoutData *,const DescriptorSetType &); MaterialParameters *CreateMP(const MaterialDescriptorSets *,const PipelineLayoutData *,const DescriptorSetsType &);
MaterialParameters *CreateMP(Material *,const DescriptorSetType &); MaterialParameters *CreateMP(Material *,const DescriptorSetsType &);
ShaderModule *CreateShaderModule(ShaderResource *); ShaderModule *CreateShaderModule(ShaderResource *);

View File

@ -70,11 +70,11 @@ public:
public: public:
MaterialParameters * GetMP (const DescriptorSetType &type) MaterialParameters * GetMP (const DescriptorSetsType &type)
{ {
if(type==DescriptorSetType::Material )return data->mp.m;else if(type==DescriptorSetsType::Material )return data->mp.m;else
if(type==DescriptorSetType::Renderable )return data->mp.r;else if(type==DescriptorSetsType::Renderable )return data->mp.r;else
if(type==DescriptorSetType::Global )return data->mp.g;else if(type==DescriptorSetsType::Global )return data->mp.g;else
return(nullptr); return(nullptr);
} }
};//class Material };//class Material

View File

@ -10,7 +10,7 @@ struct ShaderDescriptor
char name[128]; char name[128];
VkDescriptorType desc_type; VkDescriptorType desc_type;
DescriptorSetType set_type; DescriptorSetsType set_type;
uint32_t set; uint32_t set;
uint32_t binding; uint32_t binding;
uint32_t stage_flag; uint32_t stage_flag;
@ -34,7 +34,7 @@ class MaterialDescriptorSets
private: private:
DescriptorSetLayoutCreateInfo sds[size_t(DescriptorSetType::RANGE_SIZE)]; DescriptorSetLayoutCreateInfo sds[size_t(DescriptorSetsType::RANGE_SIZE)];
public: public:
@ -49,7 +49,7 @@ public:
const int GetSSBO (const AnsiString &name,bool dynamic)const{return GetBinding(dynamic?VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,name);} const int GetSSBO (const AnsiString &name,bool dynamic)const{return GetBinding(dynamic?VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,name);}
const int GetSampler (const AnsiString &name )const{return GetBinding(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, name);} const int GetSampler (const AnsiString &name )const{return GetBinding(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, name);}
const DescriptorSetLayoutCreateInfo *GetBinding(const DescriptorSetType &type)const{return sds+size_t(type);} const DescriptorSetLayoutCreateInfo *GetBinding(const DescriptorSetsType &type)const{return sds+size_t(type);}
};//class MaterialDescriptorSets };//class MaterialDescriptorSets
VK_NAMESPACE_END VK_NAMESPACE_END
#endif//HGL_GRAPH_VULKAN_MATERIAL_DESCRIPTOR_SETS_INCLUDE #endif//HGL_GRAPH_VULKAN_MATERIAL_DESCRIPTOR_SETS_INCLUDE

View File

@ -23,7 +23,7 @@ public:
Material *GetMaterial(){return material;} Material *GetMaterial(){return material;}
MaterialParameters *GetMP(){return mp_value;} MaterialParameters *GetMP(){return mp_value;}
MaterialParameters *GetMP(const DescriptorSetType &type); MaterialParameters *GetMP(const DescriptorSetsType &type);
};//class MaterialInstance };//class MaterialInstance
VK_NAMESPACE_END VK_NAMESPACE_END
#endif//HGL_GRAPH_VULKAN_MATERIAL_INSTANCE_INCLUDE #endif//HGL_GRAPH_VULKAN_MATERIAL_INSTANCE_INCLUDE

View File

@ -9,7 +9,7 @@ class MaterialParameters
{ {
const MaterialDescriptorSets *mds; const MaterialDescriptorSets *mds;
DescriptorSetType ds_type; DescriptorSetsType ds_type;
DescriptorSets *descriptor_sets; DescriptorSets *descriptor_sets;
@ -17,11 +17,11 @@ private:
friend class GPUDevice; friend class GPUDevice;
MaterialParameters(const MaterialDescriptorSets *,const DescriptorSetType &type,DescriptorSets *); MaterialParameters(const MaterialDescriptorSets *,const DescriptorSetsType &type,DescriptorSets *);
public: public:
const DescriptorSetType GetType (){return ds_type;} const DescriptorSetsType GetType (){return ds_type;}
DescriptorSets * GetDescriptorSet (){return descriptor_sets;} DescriptorSets * GetDescriptorSet (){return descriptor_sets;}
const VkDescriptorSet GetVkDescriptorSet ()const{return descriptor_sets->GetDescriptorSet();} const VkDescriptorSet GetVkDescriptorSet ()const{return descriptor_sets->GetDescriptorSet();}
@ -30,7 +30,7 @@ public:
public: public:
#define MP_TYPE_IS(name) const bool is##name()const{return ds_type==DescriptorSetType::name;} #define MP_TYPE_IS(name) const bool is##name()const{return ds_type==DescriptorSetsType::name;}
MP_TYPE_IS(Material) MP_TYPE_IS(Material)
// MP_TYPE_IS(Texture) // MP_TYPE_IS(Texture)
MP_TYPE_IS(Value) MP_TYPE_IS(Value)

View File

@ -52,7 +52,7 @@ public:
const uint32_t GetBufferHash ()const{return buffer_hash;} const uint32_t GetBufferHash ()const{return buffer_hash;}
MaterialParameters *GetMP (const DescriptorSetType &type){return mat_inst->GetMP(type);} MaterialParameters *GetMP (const DescriptorSetsType &type){return mat_inst->GetMP(type);}
};//class RenderableInstance };//class RenderableInstance
RenderableInstance *CreateRenderableInstance(Renderable *,MaterialInstance *,Pipeline *); RenderableInstance *CreateRenderableInstance(Renderable *,MaterialInstance *,Pipeline *);

View File

@ -37,12 +37,12 @@ int Comparator<RenderNodePointer>::compare(const RenderNodePointer &obj_one,cons
//比较材质实例 //比较材质实例
{ {
for(int i =(int)hgl::graph::DescriptorSetType::BEGIN_RANGE; for(int i =(int)hgl::graph::DescriptorSetsType::BEGIN_RANGE;
i<=(int)hgl::graph::DescriptorSetType::END_RANGE; i<=(int)hgl::graph::DescriptorSetsType::END_RANGE;
i++) i++)
{ {
off=ri_one->GetMP((hgl::graph::DescriptorSetType)i) off=ri_one->GetMP((hgl::graph::DescriptorSetsType)i)
-ri_two->GetMP((hgl::graph::DescriptorSetType)i); -ri_two->GetMP((hgl::graph::DescriptorSetsType)i);
if(off) if(off)
return off; return off;
@ -151,7 +151,7 @@ namespace hgl
//为所有的材质绑定 //为所有的材质绑定
for(Material *mtl:material_sets) for(Material *mtl:material_sets)
{ {
MaterialParameters *mp=mtl->GetMP(DescriptorSetType::Renderable); MaterialParameters *mp=mtl->GetMP(DescriptorSetsType::Renderable);
if(mp) if(mp)
{ {
@ -218,11 +218,11 @@ namespace hgl
uint32_t first_set=0; uint32_t first_set=0;
MaterialParameters *mp; MaterialParameters *mp;
for(int i=(int)DescriptorSetType::BEGIN_RANGE; for(int i=(int)DescriptorSetsType::BEGIN_RANGE;
i<(int)DescriptorSetType::Renderable; i<(int)DescriptorSetsType::Renderable;
i++) i++)
{ {
mp=ri->GetMP((DescriptorSetType)i); mp=ri->GetMP((DescriptorSetsType)i);
if(last_mp[i]!=mp) if(last_mp[i]!=mp)
{ {
@ -242,7 +242,7 @@ namespace hgl
} }
{ {
mp=ri->GetMP(DescriptorSetType::Renderable); mp=ri->GetMP(DescriptorSetsType::Renderable);
if(mp) if(mp)
{ {

View File

@ -112,18 +112,18 @@ bool RenderCmdBuffer::BindDescriptorSets(RenderableInstance *ri)
uint32_t count=0; uint32_t count=0;
MaterialParameters *mp; MaterialParameters *mp;
VkDescriptorSet ds[(size_t)DescriptorSetType::RANGE_SIZE]; VkDescriptorSet ds[(size_t)DescriptorSetsType::RANGE_SIZE];
ENUM_CLASS_FOR(DescriptorSetType,int,i) ENUM_CLASS_FOR(DescriptorSetsType,int,i)
{ {
mp=ri->GetMP((DescriptorSetType)i); mp=ri->GetMP((DescriptorSetsType)i);
if(mp) if(mp)
{ {
ds[count]=mp->GetVkDescriptorSet(); ds[count]=mp->GetVkDescriptorSet();
++count; ++count;
if((DescriptorSetType)i==DescriptorSetType::Renderable) if((DescriptorSetsType)i==DescriptorSetsType::Renderable)
{ {
dynamic_count=mp->GetCount(); dynamic_count=mp->GetCount();

View File

@ -8,9 +8,9 @@
#include"VKPipelineLayoutData.h" #include"VKPipelineLayoutData.h"
VK_NAMESPACE_BEGIN VK_NAMESPACE_BEGIN
DescriptorSets *GPUDevice::CreateDescriptorSets(const PipelineLayoutData *pld,const DescriptorSetType &type)const DescriptorSets *GPUDevice::CreateDescriptorSets(const PipelineLayoutData *pld,const DescriptorSetsType &type)const
{ {
ENUM_CLASS_RANGE_ERROR_RETURN_NULLPTR(DescriptorSetType,type); ENUM_CLASS_RANGE_ERROR_RETURN_NULLPTR(DescriptorSetsType,type);
const uint32_t binding_count=pld->binding_count[size_t(type)]; const uint32_t binding_count=pld->binding_count[size_t(type)];
@ -31,10 +31,10 @@ DescriptorSets *GPUDevice::CreateDescriptorSets(const PipelineLayoutData *pld,co
return(new DescriptorSets(attr->device,binding_count,pld->pipeline_layout,desc_set)); return(new DescriptorSets(attr->device,binding_count,pld->pipeline_layout,desc_set));
} }
MaterialParameters *GPUDevice::CreateMP(const MaterialDescriptorSets *mds,const PipelineLayoutData *pld,const DescriptorSetType &desc_set_type) MaterialParameters *GPUDevice::CreateMP(const MaterialDescriptorSets *mds,const PipelineLayoutData *pld,const DescriptorSetsType &desc_set_type)
{ {
if(!mds||!pld)return(nullptr); if(!mds||!pld)return(nullptr);
if(!RangeCheck<DescriptorSetType>(desc_set_type)) if(!RangeCheck<DescriptorSetsType>(desc_set_type))
return(nullptr); return(nullptr);
DescriptorSets *ds=CreateDescriptorSets(pld,desc_set_type); DescriptorSets *ds=CreateDescriptorSets(pld,desc_set_type);
@ -50,7 +50,7 @@ MaterialParameters *GPUDevice::CreateMP(const MaterialDescriptorSets *mds,const
return(new MaterialParameters(mds,desc_set_type,ds)); return(new MaterialParameters(mds,desc_set_type,ds));
} }
MaterialParameters *GPUDevice::CreateMP(Material *mtl,const DescriptorSetType &desc_set_type) MaterialParameters *GPUDevice::CreateMP(Material *mtl,const DescriptorSetsType &desc_set_type)
{ {
if(!mtl)return(nullptr); if(!mtl)return(nullptr);
@ -108,9 +108,9 @@ Material *GPUDevice::CreateMaterial(const UTF8String &mtl_name,ShaderModuleMap *
CreateShaderStageList(data->shader_stage_list,shader_maps); CreateShaderStageList(data->shader_stage_list,shader_maps);
data->pipeline_layout_data=pld; data->pipeline_layout_data=pld;
data->mp.m=CreateMP(mds,pld,DescriptorSetType::Material ); data->mp.m=CreateMP(mds,pld,DescriptorSetsType::Material );
data->mp.r=CreateMP(mds,pld,DescriptorSetType::Renderable ); data->mp.r=CreateMP(mds,pld,DescriptorSetsType::Renderable );
data->mp.g=CreateMP(mds,pld,DescriptorSetType::Global ); data->mp.g=CreateMP(mds,pld,DescriptorSetsType::Global );
return(new Material(data)); return(new Material(data));
} }

View File

@ -21,7 +21,7 @@ MaterialDescriptorSets::MaterialDescriptorSets(const UTF8String &name,ShaderDesc
if(sd_count<=0)return; if(sd_count<=0)return;
{ {
ENUM_CLASS_FOR(DescriptorSetType,int,i) ENUM_CLASS_FOR(DescriptorSetsType,int,i)
{ {
sds[i].bindingCount=0; sds[i].bindingCount=0;
sds[i].pBindings=nullptr; sds[i].pBindings=nullptr;
@ -45,10 +45,10 @@ MaterialDescriptorSets::MaterialDescriptorSets(const UTF8String &name,ShaderDesc
} }
} }
VkDescriptorSetLayoutBinding *sds_ptr[size_t(DescriptorSetType::RANGE_SIZE)]; VkDescriptorSetLayoutBinding *sds_ptr[size_t(DescriptorSetsType::RANGE_SIZE)];
{ {
ENUM_CLASS_FOR(DescriptorSetType,int,i) ENUM_CLASS_FOR(DescriptorSetsType,int,i)
if(sds[i].bindingCount>0) if(sds[i].bindingCount>0)
{ {
sds[i].pBindings=new VkDescriptorSetLayoutBinding[sds[i].bindingCount]; sds[i].pBindings=new VkDescriptorSetLayoutBinding[sds[i].bindingCount];
@ -93,7 +93,7 @@ MaterialDescriptorSets::MaterialDescriptorSets(const UTF8String &name,ShaderDesc
MaterialDescriptorSets::~MaterialDescriptorSets() MaterialDescriptorSets::~MaterialDescriptorSets()
{ {
ENUM_CLASS_FOR(DescriptorSetType,int,i) ENUM_CLASS_FOR(DescriptorSetsType,int,i)
if(sds[i].bindingCount) if(sds[i].bindingCount)
delete[] sds[i].pBindings; delete[] sds[i].pBindings;

View File

@ -8,7 +8,7 @@ MaterialInstance *GPUDevice::CreateMI(Material *mtl)
{ {
if(!mtl)return(nullptr); if(!mtl)return(nullptr);
MaterialParameters *mp=CreateMP(mtl,DescriptorSetType::Value); MaterialParameters *mp=CreateMP(mtl,DescriptorSetsType::Value);
return(new MaterialInstance(mtl,mp)); return(new MaterialInstance(mtl,mp));
} }
@ -25,12 +25,12 @@ MaterialInstance::~MaterialInstance()
SAFE_CLEAR(mp_value); SAFE_CLEAR(mp_value);
} }
MaterialParameters *MaterialInstance::GetMP(const DescriptorSetType &type) MaterialParameters *MaterialInstance::GetMP(const DescriptorSetsType &type)
{ {
//if(type==DescriptorSetType::Texture //if(type==DescriptorSetsType::Texture
// return mp_texture; // return mp_texture;
if(type==DescriptorSetType::Value) if(type==DescriptorSetsType::Value)
return mp_value; return mp_value;
return material->GetMP(type); return material->GetMP(type);

View File

@ -4,7 +4,7 @@
#include<hgl/graph/VKDescriptorSets.h> #include<hgl/graph/VKDescriptorSets.h>
VK_NAMESPACE_BEGIN VK_NAMESPACE_BEGIN
MaterialParameters::MaterialParameters(const MaterialDescriptorSets *_mds,const DescriptorSetType &type,DescriptorSets *ds) MaterialParameters::MaterialParameters(const MaterialDescriptorSets *_mds,const DescriptorSetsType &type,DescriptorSets *ds)
{ {
mds=_mds; mds=_mds;
ds_type=type; ds_type=type;

View File

@ -8,9 +8,9 @@ PipelineLayoutData *GPUDevice::CreatePipelineLayoutData(const MaterialDescriptor
{ {
PipelineLayoutData *pld=hgl_zero_new<PipelineLayoutData>(); PipelineLayoutData *pld=hgl_zero_new<PipelineLayoutData>();
ENUM_CLASS_FOR(DescriptorSetType,int,i) ENUM_CLASS_FOR(DescriptorSetsType,int,i)
{ {
const DescriptorSetLayoutCreateInfo *dslci=mds->GetBinding((DescriptorSetType)i); const DescriptorSetLayoutCreateInfo *dslci=mds->GetBinding((DescriptorSetsType)i);
if(!dslci||dslci->bindingCount<=0) if(!dslci||dslci->bindingCount<=0)
continue; continue;
@ -64,7 +64,7 @@ PipelineLayoutData::~PipelineLayoutData()
{ {
vkDestroyPipelineLayout(device,pipeline_layout,nullptr); vkDestroyPipelineLayout(device,pipeline_layout,nullptr);
ENUM_CLASS_FOR(DescriptorSetType,int,i) ENUM_CLASS_FOR(DescriptorSetsType,int,i)
if(layouts[i]) if(layouts[i])
vkDestroyDescriptorSetLayout(device,layouts[i],nullptr); vkDestroyDescriptorSetLayout(device,layouts[i],nullptr);
} }

View File

@ -9,10 +9,10 @@ struct PipelineLayoutData
{ {
VkDevice device; VkDevice device;
int binding_count[size_t(DescriptorSetType::RANGE_SIZE)]; int binding_count[size_t(DescriptorSetsType::RANGE_SIZE)];
VkDescriptorSetLayout layouts[size_t(DescriptorSetType::RANGE_SIZE)]; VkDescriptorSetLayout layouts[size_t(DescriptorSetsType::RANGE_SIZE)];
VkDescriptorSetLayout fin_dsl[size_t(DescriptorSetType::RANGE_SIZE)]; VkDescriptorSetLayout fin_dsl[size_t(DescriptorSetsType::RANGE_SIZE)];
uint32_t fin_dsl_count; uint32_t fin_dsl_count;
VkPipelineLayout pipeline_layout; VkPipelineLayout pipeline_layout;

View File

@ -47,9 +47,9 @@ void LoadShaderDescriptor(const uint8 *data,ShaderDescriptor *sd_list,const uint
sd->stage_flag =*(uint32 *)data; sd->stage_flag =*(uint32 *)data;
data+=sizeof(uint32); data+=sizeof(uint32);
sd->set_type=CheckDescriptorSetType(sd->name); sd->set_type=CheckDescriptorSetsType(sd->name);
if(sd->set_type==DescriptorSetType::Renderable) if(sd->set_type==DescriptorSetsType::Renderable)
{ {
if(sd->desc_type==VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER)sd->desc_type=VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC;else if(sd->desc_type==VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER)sd->desc_type=VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC;else
if(sd->desc_type==VK_DESCRIPTOR_TYPE_STORAGE_BUFFER)sd->desc_type=VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC; if(sd->desc_type==VK_DESCRIPTOR_TYPE_STORAGE_BUFFER)sd->desc_type=VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC;

View File

@ -5,16 +5,16 @@
VK_NAMESPACE_BEGIN VK_NAMESPACE_BEGIN
const DescriptorSetType CheckDescriptorSetType(const char *str) const DescriptorSetsType CheckDescriptorSetsType(const char *str)
{ {
if(str[1]=='_') if(str[1]=='_')
{ {
if(str[0]=='m')return DescriptorSetType::Material; if(str[0]=='m')return DescriptorSetsType::Material;
if(str[0]=='g')return DescriptorSetType::Global; if(str[0]=='g')return DescriptorSetsType::Global;
if(str[0]=='r')return DescriptorSetType::Renderable; if(str[0]=='r')return DescriptorSetsType::Renderable;
} }
return DescriptorSetType::Value; return DescriptorSetsType::Value;
} }
#define AccessByPointer(data,type) *(type *)data;data+=sizeof(type); #define AccessByPointer(data,type) *(type *)data;data+=sizeof(type);