optimized name of values.

This commit is contained in:
HuYingzhuo(hugo/hyzboy) 2023-02-23 13:25:05 +08:00
parent e31a6cca13
commit a6b71a449e
18 changed files with 39 additions and 39 deletions

View File

@ -98,7 +98,7 @@ private:
sky_mi=db->CreateMaterialInstance(sky_material);
if(!sky_mi)return(false);
if(!sky_mi->BindSampler(DescriptorSetType::Value,"tex" ,texture, sampler))return(false);
if(!sky_mi->BindImageSampler(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(DescriptorSetType::Value,"EnvCubemap" ,texture, sampler))return(false);
if(!envmap_mi->BindImageSampler(DescriptorSetType::Value,"EnvCubemap" ,texture, sampler))return(false);
solid_pipeline=CreatePipeline(envmap_mi,InlinePipeline::Solid3D,Prim::Triangles);
}

View File

@ -316,8 +316,8 @@ private:
if(!mp)
return(false);
mp->BindSampler("TexColor" ,texture.color, texture.color_sampler);
mp->BindSampler("TexNormal" ,texture.normal, texture.normal_sampler);
mp->BindImageSampler("TexColor" ,texture.color, texture.color_sampler);
mp->BindImageSampler("TexNormal" ,texture.normal, texture.normal_sampler);
mp->Update();
}
@ -330,9 +330,9 @@ private:
return(false);
mp->BindUBO("lights",ubo_lights);
mp->BindSampler("GB_Color" ,gbuffer.rt->GetColorTexture((uint)GBufferAttachment::Color),gbuffer.sampler);
mp->BindSampler("GB_Normal" ,gbuffer.rt->GetColorTexture((uint)GBufferAttachment::Normal),gbuffer.sampler);
mp->BindSampler("GB_Depth" ,gbuffer.rt->GetDepthTexture(),gbuffer.sampler);
mp->BindImageSampler("GB_Color" ,gbuffer.rt->GetColorTexture((uint)GBufferAttachment::Color),gbuffer.sampler);
mp->BindImageSampler("GB_Normal" ,gbuffer.rt->GetColorTexture((uint)GBufferAttachment::Normal),gbuffer.sampler);
mp->BindImageSampler("GB_Depth" ,gbuffer.rt->GetDepthTexture(),gbuffer.sampler);
mp->Update();
}

View File

@ -165,7 +165,7 @@ private:
sampler=db->CreateSampler();
if(!material_instance->BindSampler(DescriptorSetType::Value,"tex",tile_data->GetTexture(),sampler))return(false);
if(!material_instance->BindImageSampler(DescriptorSetType::Value,"tex",tile_data->GetTexture(),sampler))return(false);
return(true);
}

View File

@ -54,7 +54,7 @@ private:
envmap_mi=db->CreateMaterialInstance(OS_TEXT("res/material/EnvEquirectangularMap"));
if(!envmap_mi)return(false);
if(!envmap_mi->BindSampler(DescriptorSetType::Value,"Envmap" ,texture, sampler))return(false);
if(!envmap_mi->BindImageSampler(DescriptorSetType::Value,"Envmap" ,texture, sampler))return(false);
}
solid_pipeline=CreatePipeline(envmap_mi,InlinePipeline::Solid3D,Prim::Triangles);

View File

@ -134,8 +134,8 @@ private:
if(!mp_texture)
return(false);
mp_texture->BindSampler("TexColor" ,texture.color, texture.sampler);
mp_texture->BindSampler("TexNormal" ,texture.normal, texture.sampler);
mp_texture->BindImageSampler("TexColor" ,texture.color, texture.sampler);
mp_texture->BindImageSampler("TexNormal" ,texture.normal, texture.sampler);
}
}

View File

@ -135,7 +135,7 @@ public:
cube.sampler=db->CreateSampler();
if(!cube.sampler)return(false);
if(!cube.material_instance->BindSampler(DescriptorSetType::Value,"tex",os.render_taget->GetColorTexture(),cube.sampler))
if(!cube.material_instance->BindImageSampler(DescriptorSetType::Value,"tex",os.render_taget->GetColorTexture(),cube.sampler))
return(false);
{

View File

@ -59,7 +59,7 @@ private:
sampler=db->CreateSampler();
if(!material_instance->BindSampler(DescriptorSetType::Value,"tex",texture,sampler))return(false);
if(!material_instance->BindImageSampler(DescriptorSetType::Value,"tex",texture,sampler))return(false);
return(true);
}

View File

@ -73,7 +73,7 @@ private:
sampler=db->CreateSampler();
if(!material_instance->BindSampler(DescriptorSetType::Value,"tex",texture,sampler))return(false);
if(!material_instance->BindImageSampler(DescriptorSetType::Value,"tex",texture,sampler))return(false);
return(true);
}

View File

@ -54,7 +54,7 @@ public:
bool BindSSBO (const int binding,const DeviceBuffer *buf,bool dynamic=false);
bool BindSSBO (const int binding,const DeviceBuffer *buf,const VkDeviceSize offset,const VkDeviceSize range,bool dynamic=false);
bool BindSampler(const int binding,Texture *,Sampler *);
bool BindImageSampler(const int binding,Texture *,Sampler *);
bool BindInputAttachment(const int binding,ImageView *);
void Update();
};//class DescriptorSet

View File

@ -25,10 +25,10 @@ class MaterialDescriptorSets
ShaderDescriptor *sd_list;
uint sd_count;
ShaderDescriptorList descriptor_list[VK_DESCRIPTOR_TYPE_RANGE_SIZE];
ShaderDescriptorList descriptor_list_by_set_type[size_t(DescriptorSetType::RANGE_SIZE)];
ShaderDescriptorList sd_list_by_desc_type[VK_DESCRIPTOR_TYPE_RANGE_SIZE];
ShaderDescriptorList sd_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];
// int *binding_list[VK_DESCRIPTOR_TYPE_RANGE_SIZE];
@ -48,14 +48,14 @@ public:
const int GetUBO (const AnsiString &name,bool dynamic)const{return GetBinding(dynamic?VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:VK_DESCRIPTOR_TYPE_UNIFORM_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 GetAttachment (const AnsiString &name )const{return GetBinding(VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,name);}
const int GetImageSampler (const AnsiString &name )const{return GetBinding(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,name);}
const int GetInputAttachment(const AnsiString &name )const{return GetBinding(VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,name);}
const DescriptorSetLayoutCreateInfo *GetDSLCI(const DescriptorSetType &type)const{return dsl_ci+size_t(type);}
const ShaderDescriptorList &GetDescriptorList(const DescriptorSetType &type)const{return descriptor_list_by_set_type[size_t(type)];}
const ShaderDescriptorList &GetDescriptorList(const DescriptorSetType &type)const{return sd_list_by_set_type[size_t(type)];}
const bool hasSet(const DescriptorSetType &type)const{return !descriptor_list_by_set_type[size_t(type)].IsEmpty();}
const bool hasSet(const DescriptorSetType &type)const{return !sd_list_by_set_type[size_t(type)].IsEmpty();}
};//class MaterialDescriptorSets
VK_NAMESPACE_END
#endif//HGL_GRAPH_VULKAN_MATERIAL_DESCRIPTOR_SETS_INCLUDE

View File

@ -30,7 +30,7 @@ public:
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);
bool BindImageSampler(const DescriptorSetType &type,const AnsiString &name,Texture *tex,Sampler *sampler);
};//class MaterialInstance
VK_NAMESPACE_END
#endif//HGL_GRAPH_VULKAN_MATERIAL_INSTANCE_INCLUDE

View File

@ -45,7 +45,7 @@ public:
bool BindUBO(const AnsiString &name,DeviceBuffer *ubo,bool dynamic=false);
bool BindSSBO(const AnsiString &name,DeviceBuffer *ubo,bool dynamic=false);
bool BindSampler(const AnsiString &name,Texture *tex,Sampler *sampler);
bool BindImageSampler(const AnsiString &name,Texture *tex,Sampler *sampler);
bool BindInputAttachment(const AnsiString &name,ImageView *);
void Update();

View File

@ -148,7 +148,7 @@ bool DescriptorSet::BindSSBO(const int binding,const DeviceBuffer *buf,const VkD
return(true);
}
bool DescriptorSet::BindSampler(const int binding,Texture *tex,Sampler *sampler)
bool DescriptorSet::BindImageSampler(const int binding,Texture *tex,Sampler *sampler)
{
if(binding<0||!tex||!sampler)
return(false);

View File

@ -34,14 +34,14 @@ MaterialDescriptorSets::MaterialDescriptorSets(const UTF8String &name,ShaderDesc
{
if(sp->desc_type>=VK_DESCRIPTOR_TYPE_BEGIN_RANGE
&&sp->desc_type<=VK_DESCRIPTOR_TYPE_END_RANGE)
descriptor_list[(size_t)sp->desc_type].Add(sp);
sd_list_by_desc_type[(size_t)sp->desc_type].Add(sp);
sd_by_name.Add(sp->name,sp);
// sd_by_name.Add(sp->name,sp);
binding_map[size_t(sp->desc_type)].Add(sp->name,sp->binding);
++dsl_ci[size_t(sp->set_type)].bindingCount;
descriptor_list_by_set_type[size_t(sp->set_type)].Add(sp);
sd_list_by_set_type[size_t(sp->set_type)].Add(sp);
++sp;
}
@ -59,7 +59,7 @@ MaterialDescriptorSets::MaterialDescriptorSets(const UTF8String &name,ShaderDesc
}
{
ShaderDescriptorList *sdl=descriptor_list;
ShaderDescriptorList *sdl=sd_list_by_desc_type;
ShaderDescriptor **sdp;
for(uint i=VK_DESCRIPTOR_TYPE_BEGIN_RANGE;

View File

@ -52,14 +52,14 @@ bool MaterialInstance::BindSSBO(const DescriptorSetType &type,const AnsiString &
return(true);
}
bool MaterialInstance::BindSampler(const DescriptorSetType &type,const AnsiString &name,Texture *tex,Sampler *sampler)
bool MaterialInstance::BindImageSampler(const DescriptorSetType &type,const AnsiString &name,Texture *tex,Sampler *sampler)
{
MaterialParameters *mp=GetMP(type);
if(!mp)
return(false);
if(!mp->BindSampler(name,tex,sampler))return(false);
if(!mp->BindImageSampler(name,tex,sampler))return(false);
mp->Update();
return(true);

View File

@ -48,17 +48,17 @@ bool MaterialParameters::BindSSBO(const AnsiString &name,DeviceBuffer *ssbo,bool
return(true);
}
bool MaterialParameters::BindSampler(const AnsiString &name,Texture *tex,Sampler *sampler)
bool MaterialParameters::BindImageSampler(const AnsiString &name,Texture *tex,Sampler *sampler)
{
if(name.IsEmpty()||!tex||!sampler)
return(false);
const int index=mds->GetSampler(name);
const int index=mds->GetImageSampler(name);
if(index<0)
return(false);
if(!descriptor_set->BindSampler(index,tex,sampler))
if(!descriptor_set->BindImageSampler(index,tex,sampler))
return(false);
return(true);
@ -69,7 +69,7 @@ bool MaterialParameters::BindInputAttachment(const AnsiString &name,ImageView *i
if(name.IsEmpty()||!iv)
return(false);
const int index=mds->GetAttachment(name);
const int index=mds->GetInputAttachment(name);
if(index<0)
return(false);

View File

@ -167,7 +167,7 @@ Material *RenderResource::CreateMaterial(const OSString &filename)
if(count>0)
{
ShaderDescriptor *sd_list=hgl_zero_new<ShaderDescriptor>(count);
ShaderDescriptor *sd_list=new ShaderDescriptor[count];
LoadShaderDescriptor(sp,sd_list,count,ver);

View File

@ -114,7 +114,7 @@ namespace hgl
if(!mp)
return(false);
if(!mp->BindSampler("lum_texture",tile_font->GetTexture(),sampler))return(false);
if(!mp->BindImageSampler("lum_texture",tile_font->GetTexture(),sampler))return(false);
if(!mp->BindUBO("color_material",ubo_color))return(false);
mp->Update();