renamed to DescriptorSetType instead of DescriptorSetsType
This commit is contained in:
parent
b35ef27610
commit
af4b9cd6d4
@ -82,7 +82,7 @@ private:
|
||||
cam.RefreshCameraInfo();
|
||||
|
||||
{
|
||||
MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetsType::Global);
|
||||
MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetType::Global);
|
||||
|
||||
if(!mp_global)
|
||||
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)
|
||||
return(false);
|
||||
|
@ -94,7 +94,7 @@ private:
|
||||
cam.RefreshCameraInfo();
|
||||
|
||||
{
|
||||
MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetsType::Global);
|
||||
MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetType::Global);
|
||||
|
||||
if(!mp_global)
|
||||
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)
|
||||
return(false);
|
||||
|
@ -67,7 +67,7 @@ private:
|
||||
return(false);
|
||||
|
||||
{
|
||||
MaterialParameters *mp=material_instance->GetMP(DescriptorSetsType::Value);
|
||||
MaterialParameters *mp=material_instance->GetMP(DescriptorSetType::Value);
|
||||
|
||||
if(!mp)return(false);
|
||||
|
||||
|
@ -98,7 +98,7 @@ private:
|
||||
sky_mi=db->CreateMaterialInstance(sky_material);
|
||||
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);
|
||||
if(!sky_pipeline)return(false);
|
||||
@ -111,7 +111,7 @@ private:
|
||||
envmap_mi=db->CreateMaterialInstance(envmap_material);
|
||||
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);
|
||||
}
|
||||
|
@ -311,7 +311,7 @@ private:
|
||||
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)
|
||||
return(false);
|
||||
@ -324,7 +324,7 @@ private:
|
||||
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)
|
||||
return(false);
|
||||
|
@ -165,7 +165,7 @@ private:
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ private:
|
||||
envmap_mi=db->CreateMaterialInstance(OS_TEXT("res/material/EnvEquirectangularMap"));
|
||||
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);
|
||||
|
@ -129,7 +129,7 @@ private:
|
||||
if(!material_instance)return(false);
|
||||
|
||||
{
|
||||
MaterialParameters *mp_texture=material_instance->GetMP(DescriptorSetsType::Value);
|
||||
MaterialParameters *mp_texture=material_instance->GetMP(DescriptorSetType::Value);
|
||||
|
||||
if(!mp_texture)
|
||||
return(false);
|
||||
@ -216,7 +216,7 @@ private:
|
||||
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)
|
||||
return(false);
|
||||
|
@ -135,7 +135,7 @@ public:
|
||||
cube.sampler=db->CreateSampler();
|
||||
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);
|
||||
|
||||
{
|
||||
|
@ -59,7 +59,7 @@ private:
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ private:
|
||||
if(!ubo_sun)return(false);
|
||||
|
||||
{
|
||||
MaterialParameters *mp=material_instance->GetMP(DescriptorSetsType::Value);
|
||||
MaterialParameters *mp=material_instance->GetMP(DescriptorSetType::Value);
|
||||
|
||||
if(!mp)return(false);
|
||||
|
||||
|
@ -71,7 +71,7 @@ private:
|
||||
if(!ubo_sky_color)
|
||||
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(true);
|
||||
|
@ -73,7 +73,7 @@ private:
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ public:
|
||||
|
||||
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)
|
||||
|
@ -39,7 +39,7 @@ namespace hgl
|
||||
MVPArrayBuffer *mvp_array;
|
||||
List<Renderable *> ri_list;
|
||||
|
||||
VkDescriptorSet ds_list[(size_t)DescriptorSetsType::RANGE_SIZE];
|
||||
VkDescriptorSet ds_list[(size_t)DescriptorSetType::RANGE_SIZE];
|
||||
DescriptorSet *renderable_desc_sets;
|
||||
|
||||
uint32_t ubo_offset;
|
||||
@ -54,7 +54,7 @@ namespace hgl
|
||||
private:
|
||||
|
||||
Pipeline * last_pipeline;
|
||||
MaterialParameters *last_mp[(size_t)DescriptorSetsType::RANGE_SIZE];
|
||||
MaterialParameters *last_mp[(size_t)DescriptorSetType::RANGE_SIZE];
|
||||
uint32_t last_vbo;
|
||||
|
||||
void Render(Renderable *);
|
||||
|
@ -70,7 +70,7 @@ class DeviceRenderPassManage;
|
||||
class Fence;
|
||||
class Semaphore;
|
||||
|
||||
enum class DescriptorSetsType
|
||||
enum class DescriptorSetType
|
||||
{
|
||||
//设计使其对应shader中的set
|
||||
|
||||
@ -90,7 +90,7 @@ constexpr char *DescriptSetsTypeName[]=
|
||||
"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);
|
||||
|
||||
|
@ -219,9 +219,9 @@ public: //shader & material
|
||||
PipelineLayoutData *CreatePipelineLayoutData(const MaterialDescriptorSets *);
|
||||
void Destroy(PipelineLayoutData *);
|
||||
|
||||
DescriptorSet * CreateDescriptorSets(const PipelineLayoutData *,const DescriptorSetsType &type)const;
|
||||
MaterialParameters *CreateMP(const MaterialDescriptorSets *,const PipelineLayoutData *,const DescriptorSetsType &);
|
||||
MaterialParameters *CreateMP(Material *,const DescriptorSetsType &);
|
||||
DescriptorSet * CreateDescriptorSets(const PipelineLayoutData *,const DescriptorSetType &type)const;
|
||||
MaterialParameters *CreateMP(const MaterialDescriptorSets *,const PipelineLayoutData *,const DescriptorSetType &);
|
||||
MaterialParameters *CreateMP(Material *,const DescriptorSetType &);
|
||||
|
||||
ShaderModule *CreateShaderModule(ShaderResource *);
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
VK_NAMESPACE_BEGIN
|
||||
using ShaderStageCreateInfoList=List<VkPipelineShaderStageCreateInfo>;
|
||||
|
||||
using MaterialParameterArray=MaterialParameters *[size_t(DescriptorSetsType::RANGE_SIZE)];
|
||||
using MaterialParameterArray=MaterialParameters *[size_t(DescriptorSetType::RANGE_SIZE)];
|
||||
|
||||
struct MaterialData
|
||||
{
|
||||
@ -63,14 +63,14 @@ public:
|
||||
|
||||
public:
|
||||
|
||||
MaterialParameters * GetMP (const DescriptorSetsType &type)
|
||||
MaterialParameters * GetMP (const DescriptorSetType &type)
|
||||
{
|
||||
RANGE_CHECK_RETURN_NULLPTR(type)
|
||||
|
||||
return data->mp_array[size_t(type)];
|
||||
}
|
||||
|
||||
const bool hasSet (const DescriptorSetsType &type)const;
|
||||
const bool hasSet (const DescriptorSetType &type)const;
|
||||
};//class Material
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_MATERIAL_INCLUDE
|
||||
|
@ -10,7 +10,7 @@ struct ShaderDescriptor
|
||||
char name[128];
|
||||
|
||||
VkDescriptorType desc_type;
|
||||
DescriptorSetsType set_type;
|
||||
DescriptorSetType set_type;
|
||||
uint32_t set;
|
||||
uint32_t binding;
|
||||
uint32_t stage_flag;
|
||||
@ -26,7 +26,7 @@ class MaterialDescriptorSets
|
||||
uint sd_count;
|
||||
|
||||
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,int> binding_map[VK_DESCRIPTOR_TYPE_RANGE_SIZE];
|
||||
@ -35,7 +35,7 @@ class MaterialDescriptorSets
|
||||
|
||||
private:
|
||||
|
||||
DescriptorSetLayoutCreateInfo dsl_ci[size_t(DescriptorSetsType::RANGE_SIZE)];
|
||||
DescriptorSetLayoutCreateInfo dsl_ci[size_t(DescriptorSetType::RANGE_SIZE)];
|
||||
|
||||
public:
|
||||
|
||||
@ -51,11 +51,11 @@ public:
|
||||
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 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
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_MATERIAL_DESCRIPTOR_SETS_INCLUDE
|
||||
|
@ -26,11 +26,11 @@ public:
|
||||
|
||||
const VIL *GetVIL()const{return vil;}
|
||||
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 BindSSBO(const DescriptorSetsType &type,const AnsiString &name,DeviceBuffer *ubo,bool dynamic=false);
|
||||
bool BindSampler(const DescriptorSetsType &type,const AnsiString &name,Texture *tex,Sampler *sampler);
|
||||
bool BindUBO(const DescriptorSetType &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 DescriptorSetType &type,const AnsiString &name,Texture *tex,Sampler *sampler);
|
||||
};//class MaterialInstance
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_MATERIAL_INSTANCE_INCLUDE
|
||||
|
@ -9,7 +9,7 @@ class MaterialParameters
|
||||
{
|
||||
const MaterialDescriptorSets *mds;
|
||||
|
||||
DescriptorSetsType ds_type;
|
||||
DescriptorSetType ds_type;
|
||||
|
||||
DescriptorSet *descriptor_sets;
|
||||
|
||||
@ -17,11 +17,11 @@ private:
|
||||
|
||||
friend class GPUDevice;
|
||||
|
||||
MaterialParameters(const MaterialDescriptorSets *,const DescriptorSetsType &type,DescriptorSet *);
|
||||
MaterialParameters(const MaterialDescriptorSets *,const DescriptorSetType &type,DescriptorSet *);
|
||||
|
||||
public:
|
||||
|
||||
const DescriptorSetsType GetType (){return ds_type;}
|
||||
const DescriptorSetType GetType (){return ds_type;}
|
||||
DescriptorSet * GetDescriptorSet (){return descriptor_sets;}
|
||||
const VkDescriptorSet GetVkDescriptorSet ()const{return descriptor_sets->GetDescriptorSet();}
|
||||
|
||||
@ -30,7 +30,7 @@ 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(Instance)
|
||||
MP_TYPE_IS(PerObject)
|
||||
|
@ -52,7 +52,7 @@ public:
|
||||
|
||||
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
|
||||
|
||||
|
@ -37,12 +37,12 @@ int Comparator<RenderNodePointer>::compare(const RenderNodePointer &obj_one,cons
|
||||
|
||||
//比较材质实例
|
||||
{
|
||||
for(int i =(int)hgl::graph::DescriptorSetsType::BEGIN_RANGE;
|
||||
i<=(int)hgl::graph::DescriptorSetsType::END_RANGE;
|
||||
for(int i =(int)hgl::graph::DescriptorSetType::BEGIN_RANGE;
|
||||
i<=(int)hgl::graph::DescriptorSetType::END_RANGE;
|
||||
i++)
|
||||
{
|
||||
off=ri_one->GetMP((hgl::graph::DescriptorSetsType)i)
|
||||
-ri_two->GetMP((hgl::graph::DescriptorSetsType)i);
|
||||
off=ri_one->GetMP((hgl::graph::DescriptorSetType)i)
|
||||
-ri_two->GetMP((hgl::graph::DescriptorSetType)i);
|
||||
|
||||
if(off)
|
||||
return off;
|
||||
@ -151,7 +151,7 @@ namespace hgl
|
||||
//为所有的材质绑定
|
||||
for(Material *mtl:material_sets)
|
||||
{
|
||||
MaterialParameters *mp=mtl->GetMP(DescriptorSetsType::PerObject);
|
||||
MaterialParameters *mp=mtl->GetMP(DescriptorSetType::PerObject);
|
||||
|
||||
if(mp)
|
||||
{
|
||||
@ -218,11 +218,11 @@ namespace hgl
|
||||
uint32_t first_set=0;
|
||||
MaterialParameters *mp;
|
||||
|
||||
for(int i=(int)DescriptorSetsType::BEGIN_RANGE;
|
||||
i<(int)DescriptorSetsType::PerObject;
|
||||
for(int i=(int)DescriptorSetType::BEGIN_RANGE;
|
||||
i<(int)DescriptorSetType::PerObject;
|
||||
i++)
|
||||
{
|
||||
mp=ri->GetMP((DescriptorSetsType)i);
|
||||
mp=ri->GetMP((DescriptorSetType)i);
|
||||
|
||||
if(last_mp[i]!=mp)
|
||||
{
|
||||
@ -242,7 +242,7 @@ namespace hgl
|
||||
}
|
||||
|
||||
{
|
||||
mp=ri->GetMP(DescriptorSetsType::PerObject);
|
||||
mp=ri->GetMP(DescriptorSetType::PerObject);
|
||||
|
||||
if(mp)
|
||||
{
|
||||
|
@ -112,18 +112,18 @@ bool RenderCmdBuffer::BindDescriptorSets(Renderable *ri)
|
||||
uint32_t count=0;
|
||||
|
||||
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)
|
||||
{
|
||||
ds[count]=mp->GetVkDescriptorSet();
|
||||
++count;
|
||||
|
||||
if((DescriptorSetsType)i==DescriptorSetsType::PerObject)
|
||||
if((DescriptorSetType)i==DescriptorSetType::PerObject)
|
||||
{
|
||||
dynamic_count=mp->GetCount();
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include"VKPipelineLayoutData.h"
|
||||
|
||||
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);
|
||||
|
||||
@ -31,10 +31,10 @@ DescriptorSet *GPUDevice::CreateDescriptorSets(const PipelineLayoutData *pld,con
|
||||
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(!RangeCheck<DescriptorSetsType>(desc_set_type))
|
||||
if(!RangeCheck<DescriptorSetType>(desc_set_type))
|
||||
return(nullptr);
|
||||
|
||||
DescriptorSet *ds=CreateDescriptorSets(pld,desc_set_type);
|
||||
@ -44,13 +44,13 @@ MaterialParameters *GPUDevice::CreateMP(const MaterialDescriptorSets *mds,const
|
||||
#ifdef _DEBUG
|
||||
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
|
||||
|
||||
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);
|
||||
|
||||
@ -111,10 +111,10 @@ Material *GPUDevice::CreateMaterial(const UTF8String &mtl_name,ShaderModuleMap *
|
||||
|
||||
if(mds)
|
||||
{
|
||||
ENUM_CLASS_FOR(DescriptorSetsType,int,dst)
|
||||
ENUM_CLASS_FOR(DescriptorSetType,int,dst)
|
||||
{
|
||||
if(mds->hasSet((DescriptorSetsType)dst))
|
||||
data->mp_array[dst]=CreateMP(mds,pld,(DescriptorSetsType)dst);
|
||||
if(mds->hasSet((DescriptorSetType)dst))
|
||||
data->mp_array[dst]=CreateMP(mds,pld,(DescriptorSetType)dst);
|
||||
else
|
||||
data->mp_array[dst]=nullptr;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
VK_NAMESPACE_BEGIN
|
||||
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])
|
||||
delete mp_array[i];
|
||||
|
||||
@ -24,7 +24,7 @@ const VkPipelineLayout Material::GetPipelineLayout()const
|
||||
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);
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ MaterialDescriptorSets::MaterialDescriptorSets(const UTF8String &name,ShaderDesc
|
||||
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].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)
|
||||
{
|
||||
dsl_ci[i].pBindings=new VkDescriptorSetLayoutBinding[dsl_ci[i].bindingCount];
|
||||
@ -95,7 +95,7 @@ MaterialDescriptorSets::MaterialDescriptorSets(const UTF8String &name,ShaderDesc
|
||||
|
||||
MaterialDescriptorSets::~MaterialDescriptorSets()
|
||||
{
|
||||
ENUM_CLASS_FOR(DescriptorSetsType,int,i)
|
||||
ENUM_CLASS_FOR(DescriptorSetType,int,i)
|
||||
if(dsl_ci[i].bindingCount)
|
||||
delete[] dsl_ci[i].pBindings;
|
||||
|
||||
|
@ -23,10 +23,10 @@ MaterialInstance::MaterialInstance(Material *mtl,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);
|
||||
|
||||
@ -39,7 +39,7 @@ bool MaterialInstance::BindUBO(const DescriptorSetsType &type,const AnsiString &
|
||||
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);
|
||||
|
||||
@ -52,7 +52,7 @@ bool MaterialInstance::BindSSBO(const DescriptorSetsType &type,const AnsiString
|
||||
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);
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include<hgl/graph/VKDescriptorSet.h>
|
||||
|
||||
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;
|
||||
ds_type=type;
|
||||
|
@ -10,9 +10,9 @@ PipelineLayoutData *GPUDevice::CreatePipelineLayoutData(const MaterialDescriptor
|
||||
|
||||
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)
|
||||
continue;
|
||||
@ -71,7 +71,7 @@ PipelineLayoutData::~PipelineLayoutData()
|
||||
{
|
||||
vkDestroyPipelineLayout(device,pipeline_layout,nullptr);
|
||||
|
||||
ENUM_CLASS_FOR(DescriptorSetsType,int,i)
|
||||
ENUM_CLASS_FOR(DescriptorSetType,int,i)
|
||||
if(layouts[i])
|
||||
vkDestroyDescriptorSetLayout(device,layouts[i],nullptr);
|
||||
}
|
||||
|
@ -9,10 +9,10 @@ struct PipelineLayoutData
|
||||
{
|
||||
VkDevice device;
|
||||
|
||||
int binding_count[size_t(DescriptorSetsType::RANGE_SIZE)];
|
||||
VkDescriptorSetLayout layouts[size_t(DescriptorSetsType::RANGE_SIZE)];
|
||||
int binding_count[size_t(DescriptorSetType::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;
|
||||
|
||||
VkPipelineLayout pipeline_layout;
|
||||
|
@ -56,14 +56,14 @@ void LoadShaderDescriptor(const uint8 *data,ShaderDescriptor *sd_list,const uint
|
||||
}
|
||||
|
||||
if(ver==3)
|
||||
sd->set_type =(DescriptorSetsType)*data++;
|
||||
sd->set_type =(DescriptorSetType)*data++;
|
||||
else
|
||||
if(ver==2) //以下是旧的,未来不用了,现仅保证能运行
|
||||
{
|
||||
if(sd->name[0]=='g')sd->set_type=DescriptorSetsType::Global;else
|
||||
if(sd->name[0]=='m')sd->set_type=DescriptorSetsType::PerMaterial;else
|
||||
if(sd->name[0]=='r')sd->set_type=DescriptorSetsType::PerObject;else
|
||||
sd->set_type=DescriptorSetsType::PerFrame;
|
||||
if(sd->name[0]=='g')sd->set_type=DescriptorSetType::Global;else
|
||||
if(sd->name[0]=='m')sd->set_type=DescriptorSetType::PerMaterial;else
|
||||
if(sd->name[0]=='r')sd->set_type=DescriptorSetType::PerObject;else
|
||||
sd->set_type=DescriptorSetType::PerFrame;
|
||||
}
|
||||
|
||||
sd->set =*data++;
|
||||
@ -71,7 +71,7 @@ void LoadShaderDescriptor(const uint8 *data,ShaderDescriptor *sd_list,const uint
|
||||
sd->stage_flag =*(uint32 *)data;
|
||||
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_STORAGE_BUFFER)sd->desc_type=VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC;
|
||||
|
@ -98,7 +98,7 @@ namespace hgl
|
||||
sampler=db->CreateSampler();
|
||||
|
||||
{
|
||||
MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetsType::Global);
|
||||
MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetType::Global);
|
||||
|
||||
if(!mp_global)
|
||||
return(false);
|
||||
@ -109,7 +109,7 @@ namespace hgl
|
||||
}
|
||||
|
||||
{
|
||||
MaterialParameters *mp=material_instance->GetMP(DescriptorSetsType::PerMaterial);
|
||||
MaterialParameters *mp=material_instance->GetMP(DescriptorSetType::PerMaterial);
|
||||
|
||||
if(!mp)
|
||||
return(false);
|
||||
|
Loading…
x
Reference in New Issue
Block a user