renamed to DescriptorSetType instead of DescriptorSetsType
This commit is contained in:
parent
b35ef27610
commit
af4b9cd6d4
@ -82,7 +82,7 @@ private:
|
|||||||
cam.RefreshCameraInfo();
|
cam.RefreshCameraInfo();
|
||||||
|
|
||||||
{
|
{
|
||||||
MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetsType::Global);
|
MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetType::Global);
|
||||||
|
|
||||||
if(!mp_global)
|
if(!mp_global)
|
||||||
return(false);
|
return(false);
|
||||||
@ -95,7 +95,7 @@ private:
|
|||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
MaterialParameters *mp_value=material_instance->GetMP(DescriptorSetsType::Value);
|
MaterialParameters *mp_value=material_instance->GetMP(DescriptorSetType::Value);
|
||||||
|
|
||||||
if(!mp_value)
|
if(!mp_value)
|
||||||
return(false);
|
return(false);
|
||||||
|
@ -94,7 +94,7 @@ private:
|
|||||||
cam.RefreshCameraInfo();
|
cam.RefreshCameraInfo();
|
||||||
|
|
||||||
{
|
{
|
||||||
MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetsType::Global);
|
MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetType::Global);
|
||||||
|
|
||||||
if(!mp_global)
|
if(!mp_global)
|
||||||
return(false);
|
return(false);
|
||||||
@ -108,7 +108,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
MaterialParameters *mp_value=material_instance->GetMP(DescriptorSetsType::Value);
|
MaterialParameters *mp_value=material_instance->GetMP(DescriptorSetType::Value);
|
||||||
|
|
||||||
if(!mp_value)
|
if(!mp_value)
|
||||||
return(false);
|
return(false);
|
||||||
|
@ -67,7 +67,7 @@ private:
|
|||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
{
|
{
|
||||||
MaterialParameters *mp=material_instance->GetMP(DescriptorSetsType::Value);
|
MaterialParameters *mp=material_instance->GetMP(DescriptorSetType::Value);
|
||||||
|
|
||||||
if(!mp)return(false);
|
if(!mp)return(false);
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ private:
|
|||||||
sky_mi=db->CreateMaterialInstance(sky_material);
|
sky_mi=db->CreateMaterialInstance(sky_material);
|
||||||
if(!sky_mi)return(false);
|
if(!sky_mi)return(false);
|
||||||
|
|
||||||
if(!sky_mi->BindSampler(DescriptorSetsType::Value,"tex" ,texture, sampler))return(false);
|
if(!sky_mi->BindSampler(DescriptorSetType::Value,"tex" ,texture, sampler))return(false);
|
||||||
|
|
||||||
sky_pipeline=CreatePipeline(sky_mi,InlinePipeline::Sky,Prim::Triangles);
|
sky_pipeline=CreatePipeline(sky_mi,InlinePipeline::Sky,Prim::Triangles);
|
||||||
if(!sky_pipeline)return(false);
|
if(!sky_pipeline)return(false);
|
||||||
@ -111,7 +111,7 @@ private:
|
|||||||
envmap_mi=db->CreateMaterialInstance(envmap_material);
|
envmap_mi=db->CreateMaterialInstance(envmap_material);
|
||||||
if(!envmap_mi)return(false);
|
if(!envmap_mi)return(false);
|
||||||
|
|
||||||
if(!envmap_mi->BindSampler(DescriptorSetsType::Value,"EnvCubemap" ,texture, sampler))return(false);
|
if(!envmap_mi->BindSampler(DescriptorSetType::Value,"EnvCubemap" ,texture, sampler))return(false);
|
||||||
|
|
||||||
solid_pipeline=CreatePipeline(envmap_mi,InlinePipeline::Solid3D,Prim::Triangles);
|
solid_pipeline=CreatePipeline(envmap_mi,InlinePipeline::Solid3D,Prim::Triangles);
|
||||||
}
|
}
|
||||||
|
@ -311,7 +311,7 @@ private:
|
|||||||
BindCameraUBO(sp_gbuffer.material_instance);
|
BindCameraUBO(sp_gbuffer.material_instance);
|
||||||
|
|
||||||
{
|
{
|
||||||
MaterialParameters *mp=sp_gbuffer.material_instance->GetMP(DescriptorSetsType::Value);
|
MaterialParameters *mp=sp_gbuffer.material_instance->GetMP(DescriptorSetType::Value);
|
||||||
|
|
||||||
if(!mp)
|
if(!mp)
|
||||||
return(false);
|
return(false);
|
||||||
@ -324,7 +324,7 @@ private:
|
|||||||
BindCameraUBO(sp_composition.material_instance);
|
BindCameraUBO(sp_composition.material_instance);
|
||||||
|
|
||||||
{
|
{
|
||||||
MaterialParameters *mp=sp_composition.material_instance->GetMP(DescriptorSetsType::Value);
|
MaterialParameters *mp=sp_composition.material_instance->GetMP(DescriptorSetType::Value);
|
||||||
|
|
||||||
if(!mp)
|
if(!mp)
|
||||||
return(false);
|
return(false);
|
||||||
|
@ -165,7 +165,7 @@ private:
|
|||||||
|
|
||||||
sampler=db->CreateSampler();
|
sampler=db->CreateSampler();
|
||||||
|
|
||||||
if(!material_instance->BindSampler(DescriptorSetsType::Value,"tex",tile_data->GetTexture(),sampler))return(false);
|
if(!material_instance->BindSampler(DescriptorSetType::Value,"tex",tile_data->GetTexture(),sampler))return(false);
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ private:
|
|||||||
envmap_mi=db->CreateMaterialInstance(OS_TEXT("res/material/EnvEquirectangularMap"));
|
envmap_mi=db->CreateMaterialInstance(OS_TEXT("res/material/EnvEquirectangularMap"));
|
||||||
if(!envmap_mi)return(false);
|
if(!envmap_mi)return(false);
|
||||||
|
|
||||||
if(!envmap_mi->BindSampler(DescriptorSetsType::Value,"Envmap" ,texture, sampler))return(false);
|
if(!envmap_mi->BindSampler(DescriptorSetType::Value,"Envmap" ,texture, sampler))return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
solid_pipeline=CreatePipeline(envmap_mi,InlinePipeline::Solid3D,Prim::Triangles);
|
solid_pipeline=CreatePipeline(envmap_mi,InlinePipeline::Solid3D,Prim::Triangles);
|
||||||
|
@ -129,7 +129,7 @@ private:
|
|||||||
if(!material_instance)return(false);
|
if(!material_instance)return(false);
|
||||||
|
|
||||||
{
|
{
|
||||||
MaterialParameters *mp_texture=material_instance->GetMP(DescriptorSetsType::Value);
|
MaterialParameters *mp_texture=material_instance->GetMP(DescriptorSetType::Value);
|
||||||
|
|
||||||
if(!mp_texture)
|
if(!mp_texture)
|
||||||
return(false);
|
return(false);
|
||||||
@ -216,7 +216,7 @@ private:
|
|||||||
ubo_phong=db->CreateUBO(sizeof(PhongMaterial),&phong);
|
ubo_phong=db->CreateUBO(sizeof(PhongMaterial),&phong);
|
||||||
|
|
||||||
{
|
{
|
||||||
MaterialParameters *mp_value=material_instance->GetMP(DescriptorSetsType::Value);
|
MaterialParameters *mp_value=material_instance->GetMP(DescriptorSetType::Value);
|
||||||
|
|
||||||
if(!mp_value)
|
if(!mp_value)
|
||||||
return(false);
|
return(false);
|
||||||
|
@ -135,7 +135,7 @@ public:
|
|||||||
cube.sampler=db->CreateSampler();
|
cube.sampler=db->CreateSampler();
|
||||||
if(!cube.sampler)return(false);
|
if(!cube.sampler)return(false);
|
||||||
|
|
||||||
if(!cube.material_instance->BindSampler(DescriptorSetsType::Value,"tex",os.render_taget->GetColorTexture(),cube.sampler))
|
if(!cube.material_instance->BindSampler(DescriptorSetType::Value,"tex",os.render_taget->GetColorTexture(),cube.sampler))
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -59,7 +59,7 @@ private:
|
|||||||
|
|
||||||
sampler=db->CreateSampler();
|
sampler=db->CreateSampler();
|
||||||
|
|
||||||
if(!material_instance->BindSampler(DescriptorSetsType::Value,"tex",texture,sampler))return(false);
|
if(!material_instance->BindSampler(DescriptorSetType::Value,"tex",texture,sampler))return(false);
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ private:
|
|||||||
if(!ubo_sun)return(false);
|
if(!ubo_sun)return(false);
|
||||||
|
|
||||||
{
|
{
|
||||||
MaterialParameters *mp=material_instance->GetMP(DescriptorSetsType::Value);
|
MaterialParameters *mp=material_instance->GetMP(DescriptorSetType::Value);
|
||||||
|
|
||||||
if(!mp)return(false);
|
if(!mp)return(false);
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ private:
|
|||||||
if(!ubo_sky_color)
|
if(!ubo_sky_color)
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
if(!material_instance->BindUBO(DescriptorSetsType::Value,"sky_color",ubo_sky_color))
|
if(!material_instance->BindUBO(DescriptorSetType::Value,"sky_color",ubo_sky_color))
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
|
@ -73,7 +73,7 @@ private:
|
|||||||
|
|
||||||
sampler=db->CreateSampler();
|
sampler=db->CreateSampler();
|
||||||
|
|
||||||
if(!material_instance->BindSampler(DescriptorSetsType::Value,"tex",texture,sampler))return(false);
|
if(!material_instance->BindSampler(DescriptorSetType::Value,"tex",texture,sampler))return(false);
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,7 @@ public:
|
|||||||
|
|
||||||
bool BindCameraUBO(MaterialInstance *mi)
|
bool BindCameraUBO(MaterialInstance *mi)
|
||||||
{
|
{
|
||||||
return mi->BindUBO(DescriptorSetsType::Global,"g_camera",ubo_camera_info);
|
return mi->BindUBO(DescriptorSetType::Global,"g_camera",ubo_camera_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Resize(int w,int h)
|
virtual void Resize(int w,int h)
|
||||||
|
@ -39,7 +39,7 @@ namespace hgl
|
|||||||
MVPArrayBuffer *mvp_array;
|
MVPArrayBuffer *mvp_array;
|
||||||
List<Renderable *> ri_list;
|
List<Renderable *> ri_list;
|
||||||
|
|
||||||
VkDescriptorSet ds_list[(size_t)DescriptorSetsType::RANGE_SIZE];
|
VkDescriptorSet ds_list[(size_t)DescriptorSetType::RANGE_SIZE];
|
||||||
DescriptorSet *renderable_desc_sets;
|
DescriptorSet *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)DescriptorSetsType::RANGE_SIZE];
|
MaterialParameters *last_mp[(size_t)DescriptorSetType::RANGE_SIZE];
|
||||||
uint32_t last_vbo;
|
uint32_t last_vbo;
|
||||||
|
|
||||||
void Render(Renderable *);
|
void Render(Renderable *);
|
||||||
|
@ -70,7 +70,7 @@ class DeviceRenderPassManage;
|
|||||||
class Fence;
|
class Fence;
|
||||||
class Semaphore;
|
class Semaphore;
|
||||||
|
|
||||||
enum class DescriptorSetsType
|
enum class DescriptorSetType
|
||||||
{
|
{
|
||||||
//设计使其对应shader中的set
|
//设计使其对应shader中的set
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ constexpr char *DescriptSetsTypeName[]=
|
|||||||
"Global","PerFrame","PerMaterial","PerObject","Instance","Skeleton"
|
"Global","PerFrame","PerMaterial","PerObject","Instance","Skeleton"
|
||||||
};
|
};
|
||||||
|
|
||||||
inline const char *GetDescriptorSetsTypeName(const enum class DescriptorSetsType &type)
|
inline const char *GetDescriptorSetTypeName(const enum class DescriptorSetType &type)
|
||||||
{
|
{
|
||||||
RANGE_CHECK_RETURN_NULLPTR(type);
|
RANGE_CHECK_RETURN_NULLPTR(type);
|
||||||
|
|
||||||
|
@ -219,9 +219,9 @@ public: //shader & material
|
|||||||
PipelineLayoutData *CreatePipelineLayoutData(const MaterialDescriptorSets *);
|
PipelineLayoutData *CreatePipelineLayoutData(const MaterialDescriptorSets *);
|
||||||
void Destroy(PipelineLayoutData *);
|
void Destroy(PipelineLayoutData *);
|
||||||
|
|
||||||
DescriptorSet * CreateDescriptorSets(const PipelineLayoutData *,const DescriptorSetsType &type)const;
|
DescriptorSet * CreateDescriptorSets(const PipelineLayoutData *,const DescriptorSetType &type)const;
|
||||||
MaterialParameters *CreateMP(const MaterialDescriptorSets *,const PipelineLayoutData *,const DescriptorSetsType &);
|
MaterialParameters *CreateMP(const MaterialDescriptorSets *,const PipelineLayoutData *,const DescriptorSetType &);
|
||||||
MaterialParameters *CreateMP(Material *,const DescriptorSetsType &);
|
MaterialParameters *CreateMP(Material *,const DescriptorSetType &);
|
||||||
|
|
||||||
ShaderModule *CreateShaderModule(ShaderResource *);
|
ShaderModule *CreateShaderModule(ShaderResource *);
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
VK_NAMESPACE_BEGIN
|
VK_NAMESPACE_BEGIN
|
||||||
using ShaderStageCreateInfoList=List<VkPipelineShaderStageCreateInfo>;
|
using ShaderStageCreateInfoList=List<VkPipelineShaderStageCreateInfo>;
|
||||||
|
|
||||||
using MaterialParameterArray=MaterialParameters *[size_t(DescriptorSetsType::RANGE_SIZE)];
|
using MaterialParameterArray=MaterialParameters *[size_t(DescriptorSetType::RANGE_SIZE)];
|
||||||
|
|
||||||
struct MaterialData
|
struct MaterialData
|
||||||
{
|
{
|
||||||
@ -63,14 +63,14 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
MaterialParameters * GetMP (const DescriptorSetsType &type)
|
MaterialParameters * GetMP (const DescriptorSetType &type)
|
||||||
{
|
{
|
||||||
RANGE_CHECK_RETURN_NULLPTR(type)
|
RANGE_CHECK_RETURN_NULLPTR(type)
|
||||||
|
|
||||||
return data->mp_array[size_t(type)];
|
return data->mp_array[size_t(type)];
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool hasSet (const DescriptorSetsType &type)const;
|
const bool hasSet (const DescriptorSetType &type)const;
|
||||||
};//class Material
|
};//class Material
|
||||||
VK_NAMESPACE_END
|
VK_NAMESPACE_END
|
||||||
#endif//HGL_GRAPH_VULKAN_MATERIAL_INCLUDE
|
#endif//HGL_GRAPH_VULKAN_MATERIAL_INCLUDE
|
||||||
|
@ -10,7 +10,7 @@ struct ShaderDescriptor
|
|||||||
char name[128];
|
char name[128];
|
||||||
|
|
||||||
VkDescriptorType desc_type;
|
VkDescriptorType desc_type;
|
||||||
DescriptorSetsType set_type;
|
DescriptorSetType set_type;
|
||||||
uint32_t set;
|
uint32_t set;
|
||||||
uint32_t binding;
|
uint32_t binding;
|
||||||
uint32_t stage_flag;
|
uint32_t stage_flag;
|
||||||
@ -26,7 +26,7 @@ class MaterialDescriptorSets
|
|||||||
uint sd_count;
|
uint sd_count;
|
||||||
|
|
||||||
ShaderDescriptorList descriptor_list[VK_DESCRIPTOR_TYPE_RANGE_SIZE];
|
ShaderDescriptorList descriptor_list[VK_DESCRIPTOR_TYPE_RANGE_SIZE];
|
||||||
ShaderDescriptorList descriptor_list_by_set_type[size_t(DescriptorSetsType::RANGE_SIZE)];
|
ShaderDescriptorList descriptor_list_by_set_type[size_t(DescriptorSetType::RANGE_SIZE)];
|
||||||
|
|
||||||
Map<AnsiString,ShaderDescriptor *> sd_by_name;
|
Map<AnsiString,ShaderDescriptor *> sd_by_name;
|
||||||
Map<AnsiString,int> binding_map[VK_DESCRIPTOR_TYPE_RANGE_SIZE];
|
Map<AnsiString,int> binding_map[VK_DESCRIPTOR_TYPE_RANGE_SIZE];
|
||||||
@ -35,7 +35,7 @@ class MaterialDescriptorSets
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
DescriptorSetLayoutCreateInfo dsl_ci[size_t(DescriptorSetsType::RANGE_SIZE)];
|
DescriptorSetLayoutCreateInfo dsl_ci[size_t(DescriptorSetType::RANGE_SIZE)];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -51,11 +51,11 @@ public:
|
|||||||
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 int GetAttachment (const AnsiString &name )const{return GetBinding(VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,name);}
|
const int GetAttachment (const AnsiString &name )const{return GetBinding(VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,name);}
|
||||||
|
|
||||||
const DescriptorSetLayoutCreateInfo *GetDSLCI(const DescriptorSetsType &type)const{return dsl_ci+size_t(type);}
|
const DescriptorSetLayoutCreateInfo *GetDSLCI(const DescriptorSetType &type)const{return dsl_ci+size_t(type);}
|
||||||
|
|
||||||
const ShaderDescriptorList &GetDescriptorList(const DescriptorSetsType &type)const{return descriptor_list_by_set_type[size_t(type)];}
|
const ShaderDescriptorList &GetDescriptorList(const DescriptorSetType &type)const{return descriptor_list_by_set_type[size_t(type)];}
|
||||||
|
|
||||||
const bool hasSet(const DescriptorSetsType &type)const{return !descriptor_list_by_set_type[size_t(type)].IsEmpty();}
|
const bool hasSet(const DescriptorSetType &type)const{return !descriptor_list_by_set_type[size_t(type)].IsEmpty();}
|
||||||
};//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
|
||||||
|
@ -26,11 +26,11 @@ public:
|
|||||||
|
|
||||||
const VIL *GetVIL()const{return vil;}
|
const VIL *GetVIL()const{return vil;}
|
||||||
MaterialParameters *GetMP(){return mp_per_mi;}
|
MaterialParameters *GetMP(){return mp_per_mi;}
|
||||||
MaterialParameters *GetMP(const DescriptorSetsType &type){return material->GetMP(type);}
|
MaterialParameters *GetMP(const DescriptorSetType &type){return material->GetMP(type);}
|
||||||
|
|
||||||
bool BindUBO(const DescriptorSetsType &type,const AnsiString &name,DeviceBuffer *ubo,bool dynamic=false);
|
bool BindUBO(const DescriptorSetType &type,const AnsiString &name,DeviceBuffer *ubo,bool dynamic=false);
|
||||||
bool BindSSBO(const DescriptorSetsType &type,const AnsiString &name,DeviceBuffer *ubo,bool dynamic=false);
|
bool BindSSBO(const DescriptorSetType &type,const AnsiString &name,DeviceBuffer *ubo,bool dynamic=false);
|
||||||
bool BindSampler(const DescriptorSetsType &type,const AnsiString &name,Texture *tex,Sampler *sampler);
|
bool BindSampler(const DescriptorSetType &type,const AnsiString &name,Texture *tex,Sampler *sampler);
|
||||||
};//class MaterialInstance
|
};//class MaterialInstance
|
||||||
VK_NAMESPACE_END
|
VK_NAMESPACE_END
|
||||||
#endif//HGL_GRAPH_VULKAN_MATERIAL_INSTANCE_INCLUDE
|
#endif//HGL_GRAPH_VULKAN_MATERIAL_INSTANCE_INCLUDE
|
||||||
|
@ -9,7 +9,7 @@ class MaterialParameters
|
|||||||
{
|
{
|
||||||
const MaterialDescriptorSets *mds;
|
const MaterialDescriptorSets *mds;
|
||||||
|
|
||||||
DescriptorSetsType ds_type;
|
DescriptorSetType ds_type;
|
||||||
|
|
||||||
DescriptorSet *descriptor_sets;
|
DescriptorSet *descriptor_sets;
|
||||||
|
|
||||||
@ -17,11 +17,11 @@ private:
|
|||||||
|
|
||||||
friend class GPUDevice;
|
friend class GPUDevice;
|
||||||
|
|
||||||
MaterialParameters(const MaterialDescriptorSets *,const DescriptorSetsType &type,DescriptorSet *);
|
MaterialParameters(const MaterialDescriptorSets *,const DescriptorSetType &type,DescriptorSet *);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
const DescriptorSetsType GetType (){return ds_type;}
|
const DescriptorSetType GetType (){return ds_type;}
|
||||||
DescriptorSet * GetDescriptorSet (){return descriptor_sets;}
|
DescriptorSet * 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==DescriptorSetsType::name;}
|
#define MP_TYPE_IS(name) const bool is##name()const{return ds_type==DescriptorSetType::name;}
|
||||||
MP_TYPE_IS(Skeleton)
|
MP_TYPE_IS(Skeleton)
|
||||||
MP_TYPE_IS(Instance)
|
MP_TYPE_IS(Instance)
|
||||||
MP_TYPE_IS(PerObject)
|
MP_TYPE_IS(PerObject)
|
||||||
|
@ -52,7 +52,7 @@ public:
|
|||||||
|
|
||||||
const uint32_t GetBufferHash ()const{return buffer_hash;}
|
const uint32_t GetBufferHash ()const{return buffer_hash;}
|
||||||
|
|
||||||
MaterialParameters *GetMP (const DescriptorSetsType &type){return mat_inst->GetMP(type);}
|
MaterialParameters *GetMP (const DescriptorSetType &type){return mat_inst->GetMP(type);}
|
||||||
|
|
||||||
public: //instance support
|
public: //instance support
|
||||||
|
|
||||||
|
@ -37,12 +37,12 @@ int Comparator<RenderNodePointer>::compare(const RenderNodePointer &obj_one,cons
|
|||||||
|
|
||||||
//比较材质实例
|
//比较材质实例
|
||||||
{
|
{
|
||||||
for(int i =(int)hgl::graph::DescriptorSetsType::BEGIN_RANGE;
|
for(int i =(int)hgl::graph::DescriptorSetType::BEGIN_RANGE;
|
||||||
i<=(int)hgl::graph::DescriptorSetsType::END_RANGE;
|
i<=(int)hgl::graph::DescriptorSetType::END_RANGE;
|
||||||
i++)
|
i++)
|
||||||
{
|
{
|
||||||
off=ri_one->GetMP((hgl::graph::DescriptorSetsType)i)
|
off=ri_one->GetMP((hgl::graph::DescriptorSetType)i)
|
||||||
-ri_two->GetMP((hgl::graph::DescriptorSetsType)i);
|
-ri_two->GetMP((hgl::graph::DescriptorSetType)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(DescriptorSetsType::PerObject);
|
MaterialParameters *mp=mtl->GetMP(DescriptorSetType::PerObject);
|
||||||
|
|
||||||
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)DescriptorSetsType::BEGIN_RANGE;
|
for(int i=(int)DescriptorSetType::BEGIN_RANGE;
|
||||||
i<(int)DescriptorSetsType::PerObject;
|
i<(int)DescriptorSetType::PerObject;
|
||||||
i++)
|
i++)
|
||||||
{
|
{
|
||||||
mp=ri->GetMP((DescriptorSetsType)i);
|
mp=ri->GetMP((DescriptorSetType)i);
|
||||||
|
|
||||||
if(last_mp[i]!=mp)
|
if(last_mp[i]!=mp)
|
||||||
{
|
{
|
||||||
@ -242,7 +242,7 @@ namespace hgl
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
mp=ri->GetMP(DescriptorSetsType::PerObject);
|
mp=ri->GetMP(DescriptorSetType::PerObject);
|
||||||
|
|
||||||
if(mp)
|
if(mp)
|
||||||
{
|
{
|
||||||
|
@ -112,18 +112,18 @@ bool RenderCmdBuffer::BindDescriptorSets(Renderable *ri)
|
|||||||
uint32_t count=0;
|
uint32_t count=0;
|
||||||
|
|
||||||
MaterialParameters *mp;
|
MaterialParameters *mp;
|
||||||
VkDescriptorSet ds[(size_t)DescriptorSetsType::RANGE_SIZE];
|
VkDescriptorSet ds[(size_t)DescriptorSetType::RANGE_SIZE];
|
||||||
|
|
||||||
ENUM_CLASS_FOR(DescriptorSetsType,int,i)
|
ENUM_CLASS_FOR(DescriptorSetType,int,i)
|
||||||
{
|
{
|
||||||
mp=ri->GetMP((DescriptorSetsType)i);
|
mp=ri->GetMP((DescriptorSetType)i);
|
||||||
|
|
||||||
if(mp)
|
if(mp)
|
||||||
{
|
{
|
||||||
ds[count]=mp->GetVkDescriptorSet();
|
ds[count]=mp->GetVkDescriptorSet();
|
||||||
++count;
|
++count;
|
||||||
|
|
||||||
if((DescriptorSetsType)i==DescriptorSetsType::PerObject)
|
if((DescriptorSetType)i==DescriptorSetType::PerObject)
|
||||||
{
|
{
|
||||||
dynamic_count=mp->GetCount();
|
dynamic_count=mp->GetCount();
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#include"VKPipelineLayoutData.h"
|
#include"VKPipelineLayoutData.h"
|
||||||
|
|
||||||
VK_NAMESPACE_BEGIN
|
VK_NAMESPACE_BEGIN
|
||||||
DescriptorSet *GPUDevice::CreateDescriptorSets(const PipelineLayoutData *pld,const DescriptorSetsType &type)const
|
DescriptorSet *GPUDevice::CreateDescriptorSets(const PipelineLayoutData *pld,const DescriptorSetType &type)const
|
||||||
{
|
{
|
||||||
RANGE_CHECK_RETURN_NULLPTR(type);
|
RANGE_CHECK_RETURN_NULLPTR(type);
|
||||||
|
|
||||||
@ -31,10 +31,10 @@ DescriptorSet *GPUDevice::CreateDescriptorSets(const PipelineLayoutData *pld,con
|
|||||||
return(new DescriptorSet(attr->device,binding_count,pld->pipeline_layout,desc_set));
|
return(new DescriptorSet(attr->device,binding_count,pld->pipeline_layout,desc_set));
|
||||||
}
|
}
|
||||||
|
|
||||||
MaterialParameters *GPUDevice::CreateMP(const MaterialDescriptorSets *mds,const PipelineLayoutData *pld,const DescriptorSetsType &desc_set_type)
|
MaterialParameters *GPUDevice::CreateMP(const MaterialDescriptorSets *mds,const PipelineLayoutData *pld,const DescriptorSetType &desc_set_type)
|
||||||
{
|
{
|
||||||
if(!mds||!pld)return(nullptr);
|
if(!mds||!pld)return(nullptr);
|
||||||
if(!RangeCheck<DescriptorSetsType>(desc_set_type))
|
if(!RangeCheck<DescriptorSetType>(desc_set_type))
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
|
|
||||||
DescriptorSet *ds=CreateDescriptorSets(pld,desc_set_type);
|
DescriptorSet *ds=CreateDescriptorSets(pld,desc_set_type);
|
||||||
@ -44,13 +44,13 @@ MaterialParameters *GPUDevice::CreateMP(const MaterialDescriptorSets *mds,const
|
|||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
const UTF8String addr_string=HexToString<char,uint64_t>((uint64_t)(ds->GetDescriptorSet()));
|
const UTF8String addr_string=HexToString<char,uint64_t>((uint64_t)(ds->GetDescriptorSet()));
|
||||||
|
|
||||||
LOG_INFO(U8_TEXT("Create [DescriptSets:")+addr_string+("] OK! Material Name: \"")+mds->GetMaterialName()+U8_TEXT("\" Type: ")+GetDescriptorSetsTypeName(desc_set_type));
|
LOG_INFO(U8_TEXT("Create [DescriptSets:")+addr_string+("] OK! Material Name: \"")+mds->GetMaterialName()+U8_TEXT("\" Type: ")+GetDescriptorSetTypeName(desc_set_type));
|
||||||
#endif//_DEBUG
|
#endif//_DEBUG
|
||||||
|
|
||||||
return(new MaterialParameters(mds,desc_set_type,ds));
|
return(new MaterialParameters(mds,desc_set_type,ds));
|
||||||
}
|
}
|
||||||
|
|
||||||
MaterialParameters *GPUDevice::CreateMP(Material *mtl,const DescriptorSetsType &desc_set_type)
|
MaterialParameters *GPUDevice::CreateMP(Material *mtl,const DescriptorSetType &desc_set_type)
|
||||||
{
|
{
|
||||||
if(!mtl)return(nullptr);
|
if(!mtl)return(nullptr);
|
||||||
|
|
||||||
@ -111,10 +111,10 @@ Material *GPUDevice::CreateMaterial(const UTF8String &mtl_name,ShaderModuleMap *
|
|||||||
|
|
||||||
if(mds)
|
if(mds)
|
||||||
{
|
{
|
||||||
ENUM_CLASS_FOR(DescriptorSetsType,int,dst)
|
ENUM_CLASS_FOR(DescriptorSetType,int,dst)
|
||||||
{
|
{
|
||||||
if(mds->hasSet((DescriptorSetsType)dst))
|
if(mds->hasSet((DescriptorSetType)dst))
|
||||||
data->mp_array[dst]=CreateMP(mds,pld,(DescriptorSetsType)dst);
|
data->mp_array[dst]=CreateMP(mds,pld,(DescriptorSetType)dst);
|
||||||
else
|
else
|
||||||
data->mp_array[dst]=nullptr;
|
data->mp_array[dst]=nullptr;
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
VK_NAMESPACE_BEGIN
|
VK_NAMESPACE_BEGIN
|
||||||
MaterialData::~MaterialData()
|
MaterialData::~MaterialData()
|
||||||
{
|
{
|
||||||
for(int i=0;i<int(DescriptorSetsType::RANGE_SIZE);i++)
|
for(int i=0;i<int(DescriptorSetType::RANGE_SIZE);i++)
|
||||||
if(mp_array[i])
|
if(mp_array[i])
|
||||||
delete mp_array[i];
|
delete mp_array[i];
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ const VkPipelineLayout Material::GetPipelineLayout()const
|
|||||||
return data->pipeline_layout_data->pipeline_layout;
|
return data->pipeline_layout_data->pipeline_layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool Material::hasSet(const DescriptorSetsType &dst)const
|
const bool Material::hasSet(const DescriptorSetType &dst)const
|
||||||
{
|
{
|
||||||
return data->mds->hasSet(dst);
|
return data->mds->hasSet(dst);
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ MaterialDescriptorSets::MaterialDescriptorSets(const UTF8String &name,ShaderDesc
|
|||||||
if(sd_count<=0)return;
|
if(sd_count<=0)return;
|
||||||
|
|
||||||
{
|
{
|
||||||
ENUM_CLASS_FOR(DescriptorSetsType,int,i)
|
ENUM_CLASS_FOR(DescriptorSetType,int,i)
|
||||||
{
|
{
|
||||||
dsl_ci[i].bindingCount=0;
|
dsl_ci[i].bindingCount=0;
|
||||||
dsl_ci[i].pBindings=nullptr;
|
dsl_ci[i].pBindings=nullptr;
|
||||||
@ -47,10 +47,10 @@ MaterialDescriptorSets::MaterialDescriptorSets(const UTF8String &name,ShaderDesc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VkDescriptorSetLayoutBinding *sds_ptr[size_t(DescriptorSetsType::RANGE_SIZE)];
|
VkDescriptorSetLayoutBinding *sds_ptr[size_t(DescriptorSetType::RANGE_SIZE)];
|
||||||
|
|
||||||
{
|
{
|
||||||
ENUM_CLASS_FOR(DescriptorSetsType,int,i)
|
ENUM_CLASS_FOR(DescriptorSetType,int,i)
|
||||||
if(dsl_ci[i].bindingCount>0)
|
if(dsl_ci[i].bindingCount>0)
|
||||||
{
|
{
|
||||||
dsl_ci[i].pBindings=new VkDescriptorSetLayoutBinding[dsl_ci[i].bindingCount];
|
dsl_ci[i].pBindings=new VkDescriptorSetLayoutBinding[dsl_ci[i].bindingCount];
|
||||||
@ -95,7 +95,7 @@ MaterialDescriptorSets::MaterialDescriptorSets(const UTF8String &name,ShaderDesc
|
|||||||
|
|
||||||
MaterialDescriptorSets::~MaterialDescriptorSets()
|
MaterialDescriptorSets::~MaterialDescriptorSets()
|
||||||
{
|
{
|
||||||
ENUM_CLASS_FOR(DescriptorSetsType,int,i)
|
ENUM_CLASS_FOR(DescriptorSetType,int,i)
|
||||||
if(dsl_ci[i].bindingCount)
|
if(dsl_ci[i].bindingCount)
|
||||||
delete[] dsl_ci[i].pBindings;
|
delete[] dsl_ci[i].pBindings;
|
||||||
|
|
||||||
|
@ -23,10 +23,10 @@ MaterialInstance::MaterialInstance(Material *mtl,VIL *v)
|
|||||||
|
|
||||||
vil=v;
|
vil=v;
|
||||||
|
|
||||||
mp_per_mi=mtl->GetMP(DescriptorSetsType::PerMaterial);
|
mp_per_mi=mtl->GetMP(DescriptorSetType::PerMaterial);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MaterialInstance::BindUBO(const DescriptorSetsType &type,const AnsiString &name,DeviceBuffer *ubo,bool dynamic)
|
bool MaterialInstance::BindUBO(const DescriptorSetType &type,const AnsiString &name,DeviceBuffer *ubo,bool dynamic)
|
||||||
{
|
{
|
||||||
MaterialParameters *mp=GetMP(type);
|
MaterialParameters *mp=GetMP(type);
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ bool MaterialInstance::BindUBO(const DescriptorSetsType &type,const AnsiString &
|
|||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MaterialInstance::BindSSBO(const DescriptorSetsType &type,const AnsiString &name,DeviceBuffer *ubo,bool dynamic)
|
bool MaterialInstance::BindSSBO(const DescriptorSetType &type,const AnsiString &name,DeviceBuffer *ubo,bool dynamic)
|
||||||
{
|
{
|
||||||
MaterialParameters *mp=GetMP(type);
|
MaterialParameters *mp=GetMP(type);
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ bool MaterialInstance::BindSSBO(const DescriptorSetsType &type,const AnsiString
|
|||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MaterialInstance::BindSampler(const DescriptorSetsType &type,const AnsiString &name,Texture *tex,Sampler *sampler)
|
bool MaterialInstance::BindSampler(const DescriptorSetType &type,const AnsiString &name,Texture *tex,Sampler *sampler)
|
||||||
{
|
{
|
||||||
MaterialParameters *mp=GetMP(type);
|
MaterialParameters *mp=GetMP(type);
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include<hgl/graph/VKDescriptorSet.h>
|
#include<hgl/graph/VKDescriptorSet.h>
|
||||||
|
|
||||||
VK_NAMESPACE_BEGIN
|
VK_NAMESPACE_BEGIN
|
||||||
MaterialParameters::MaterialParameters(const MaterialDescriptorSets *_mds,const DescriptorSetsType &type,DescriptorSet *ds)
|
MaterialParameters::MaterialParameters(const MaterialDescriptorSets *_mds,const DescriptorSetType &type,DescriptorSet *ds)
|
||||||
{
|
{
|
||||||
mds=_mds;
|
mds=_mds;
|
||||||
ds_type=type;
|
ds_type=type;
|
||||||
|
@ -10,9 +10,9 @@ PipelineLayoutData *GPUDevice::CreatePipelineLayoutData(const MaterialDescriptor
|
|||||||
|
|
||||||
if(mds)
|
if(mds)
|
||||||
{
|
{
|
||||||
ENUM_CLASS_FOR(DescriptorSetsType,int,i)
|
ENUM_CLASS_FOR(DescriptorSetType,int,i)
|
||||||
{
|
{
|
||||||
const DescriptorSetLayoutCreateInfo *dslci=mds->GetDSLCI((DescriptorSetsType)i);
|
const DescriptorSetLayoutCreateInfo *dslci=mds->GetDSLCI((DescriptorSetType)i);
|
||||||
|
|
||||||
if(!dslci||dslci->bindingCount<=0)
|
if(!dslci||dslci->bindingCount<=0)
|
||||||
continue;
|
continue;
|
||||||
@ -71,7 +71,7 @@ PipelineLayoutData::~PipelineLayoutData()
|
|||||||
{
|
{
|
||||||
vkDestroyPipelineLayout(device,pipeline_layout,nullptr);
|
vkDestroyPipelineLayout(device,pipeline_layout,nullptr);
|
||||||
|
|
||||||
ENUM_CLASS_FOR(DescriptorSetsType,int,i)
|
ENUM_CLASS_FOR(DescriptorSetType,int,i)
|
||||||
if(layouts[i])
|
if(layouts[i])
|
||||||
vkDestroyDescriptorSetLayout(device,layouts[i],nullptr);
|
vkDestroyDescriptorSetLayout(device,layouts[i],nullptr);
|
||||||
}
|
}
|
||||||
|
@ -9,10 +9,10 @@ struct PipelineLayoutData
|
|||||||
{
|
{
|
||||||
VkDevice device;
|
VkDevice device;
|
||||||
|
|
||||||
int binding_count[size_t(DescriptorSetsType::RANGE_SIZE)];
|
int binding_count[size_t(DescriptorSetType::RANGE_SIZE)];
|
||||||
VkDescriptorSetLayout layouts[size_t(DescriptorSetsType::RANGE_SIZE)];
|
VkDescriptorSetLayout layouts[size_t(DescriptorSetType::RANGE_SIZE)];
|
||||||
|
|
||||||
VkDescriptorSetLayout fin_dsl[size_t(DescriptorSetsType::RANGE_SIZE)];
|
VkDescriptorSetLayout fin_dsl[size_t(DescriptorSetType::RANGE_SIZE)];
|
||||||
uint32_t fin_dsl_count;
|
uint32_t fin_dsl_count;
|
||||||
|
|
||||||
VkPipelineLayout pipeline_layout;
|
VkPipelineLayout pipeline_layout;
|
||||||
|
@ -56,14 +56,14 @@ void LoadShaderDescriptor(const uint8 *data,ShaderDescriptor *sd_list,const uint
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(ver==3)
|
if(ver==3)
|
||||||
sd->set_type =(DescriptorSetsType)*data++;
|
sd->set_type =(DescriptorSetType)*data++;
|
||||||
else
|
else
|
||||||
if(ver==2) //以下是旧的,未来不用了,现仅保证能运行
|
if(ver==2) //以下是旧的,未来不用了,现仅保证能运行
|
||||||
{
|
{
|
||||||
if(sd->name[0]=='g')sd->set_type=DescriptorSetsType::Global;else
|
if(sd->name[0]=='g')sd->set_type=DescriptorSetType::Global;else
|
||||||
if(sd->name[0]=='m')sd->set_type=DescriptorSetsType::PerMaterial;else
|
if(sd->name[0]=='m')sd->set_type=DescriptorSetType::PerMaterial;else
|
||||||
if(sd->name[0]=='r')sd->set_type=DescriptorSetsType::PerObject;else
|
if(sd->name[0]=='r')sd->set_type=DescriptorSetType::PerObject;else
|
||||||
sd->set_type=DescriptorSetsType::PerFrame;
|
sd->set_type=DescriptorSetType::PerFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
sd->set =*data++;
|
sd->set =*data++;
|
||||||
@ -71,7 +71,7 @@ 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);
|
||||||
|
|
||||||
if(sd->set_type==DescriptorSetsType::PerObject)
|
if(sd->set_type==DescriptorSetType::PerObject)
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
@ -98,7 +98,7 @@ namespace hgl
|
|||||||
sampler=db->CreateSampler();
|
sampler=db->CreateSampler();
|
||||||
|
|
||||||
{
|
{
|
||||||
MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetsType::Global);
|
MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetType::Global);
|
||||||
|
|
||||||
if(!mp_global)
|
if(!mp_global)
|
||||||
return(false);
|
return(false);
|
||||||
@ -109,7 +109,7 @@ namespace hgl
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
MaterialParameters *mp=material_instance->GetMP(DescriptorSetsType::PerMaterial);
|
MaterialParameters *mp=material_instance->GetMP(DescriptorSetType::PerMaterial);
|
||||||
|
|
||||||
if(!mp)
|
if(!mp)
|
||||||
return(false);
|
return(false);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user