optimized name of values.
This commit is contained in:
parent
e31a6cca13
commit
a6b71a449e
@ -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(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);
|
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(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);
|
solid_pipeline=CreatePipeline(envmap_mi,InlinePipeline::Solid3D,Prim::Triangles);
|
||||||
}
|
}
|
||||||
|
@ -316,8 +316,8 @@ private:
|
|||||||
if(!mp)
|
if(!mp)
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
mp->BindSampler("TexColor" ,texture.color, texture.color_sampler);
|
mp->BindImageSampler("TexColor" ,texture.color, texture.color_sampler);
|
||||||
mp->BindSampler("TexNormal" ,texture.normal, texture.normal_sampler);
|
mp->BindImageSampler("TexNormal" ,texture.normal, texture.normal_sampler);
|
||||||
mp->Update();
|
mp->Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -330,9 +330,9 @@ private:
|
|||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
mp->BindUBO("lights",ubo_lights);
|
mp->BindUBO("lights",ubo_lights);
|
||||||
mp->BindSampler("GB_Color" ,gbuffer.rt->GetColorTexture((uint)GBufferAttachment::Color),gbuffer.sampler);
|
mp->BindImageSampler("GB_Color" ,gbuffer.rt->GetColorTexture((uint)GBufferAttachment::Color),gbuffer.sampler);
|
||||||
mp->BindSampler("GB_Normal" ,gbuffer.rt->GetColorTexture((uint)GBufferAttachment::Normal),gbuffer.sampler);
|
mp->BindImageSampler("GB_Normal" ,gbuffer.rt->GetColorTexture((uint)GBufferAttachment::Normal),gbuffer.sampler);
|
||||||
mp->BindSampler("GB_Depth" ,gbuffer.rt->GetDepthTexture(),gbuffer.sampler);
|
mp->BindImageSampler("GB_Depth" ,gbuffer.rt->GetDepthTexture(),gbuffer.sampler);
|
||||||
mp->Update();
|
mp->Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ private:
|
|||||||
|
|
||||||
sampler=db->CreateSampler();
|
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);
|
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(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);
|
solid_pipeline=CreatePipeline(envmap_mi,InlinePipeline::Solid3D,Prim::Triangles);
|
||||||
|
@ -134,8 +134,8 @@ private:
|
|||||||
if(!mp_texture)
|
if(!mp_texture)
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
mp_texture->BindSampler("TexColor" ,texture.color, texture.sampler);
|
mp_texture->BindImageSampler("TexColor" ,texture.color, texture.sampler);
|
||||||
mp_texture->BindSampler("TexNormal" ,texture.normal, texture.sampler);
|
mp_texture->BindImageSampler("TexNormal" ,texture.normal, texture.sampler);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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(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);
|
return(false);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -59,7 +59,7 @@ private:
|
|||||||
|
|
||||||
sampler=db->CreateSampler();
|
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);
|
return(true);
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ private:
|
|||||||
|
|
||||||
sampler=db->CreateSampler();
|
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);
|
return(true);
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ public:
|
|||||||
bool BindSSBO (const int binding,const DeviceBuffer *buf,bool dynamic=false);
|
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 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 *);
|
bool BindInputAttachment(const int binding,ImageView *);
|
||||||
void Update();
|
void Update();
|
||||||
};//class DescriptorSet
|
};//class DescriptorSet
|
||||||
|
@ -25,10 +25,10 @@ class MaterialDescriptorSets
|
|||||||
ShaderDescriptor *sd_list;
|
ShaderDescriptor *sd_list;
|
||||||
uint sd_count;
|
uint sd_count;
|
||||||
|
|
||||||
ShaderDescriptorList descriptor_list[VK_DESCRIPTOR_TYPE_RANGE_SIZE];
|
ShaderDescriptorList sd_list_by_desc_type[VK_DESCRIPTOR_TYPE_RANGE_SIZE];
|
||||||
ShaderDescriptorList descriptor_list_by_set_type[size_t(DescriptorSetType::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];
|
Map<AnsiString,int> binding_map[VK_DESCRIPTOR_TYPE_RANGE_SIZE];
|
||||||
|
|
||||||
// int *binding_list[VK_DESCRIPTOR_TYPE_RANGE_SIZE];
|
// int *binding_list[VK_DESCRIPTOR_TYPE_RANGE_SIZE];
|
||||||
@ -46,16 +46,16 @@ public:
|
|||||||
|
|
||||||
const int GetBinding(const VkDescriptorType &desc_type,const AnsiString &name)const;
|
const int GetBinding(const VkDescriptorType &desc_type,const AnsiString &name)const;
|
||||||
|
|
||||||
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 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 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 GetImageSampler (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 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 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
|
};//class MaterialDescriptorSets
|
||||||
VK_NAMESPACE_END
|
VK_NAMESPACE_END
|
||||||
#endif//HGL_GRAPH_VULKAN_MATERIAL_DESCRIPTOR_SETS_INCLUDE
|
#endif//HGL_GRAPH_VULKAN_MATERIAL_DESCRIPTOR_SETS_INCLUDE
|
||||||
|
@ -30,7 +30,7 @@ public:
|
|||||||
|
|
||||||
bool BindUBO(const DescriptorSetType &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 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
|
};//class MaterialInstance
|
||||||
VK_NAMESPACE_END
|
VK_NAMESPACE_END
|
||||||
#endif//HGL_GRAPH_VULKAN_MATERIAL_INSTANCE_INCLUDE
|
#endif//HGL_GRAPH_VULKAN_MATERIAL_INSTANCE_INCLUDE
|
||||||
|
@ -45,7 +45,7 @@ public:
|
|||||||
|
|
||||||
bool BindUBO(const AnsiString &name,DeviceBuffer *ubo,bool dynamic=false);
|
bool BindUBO(const AnsiString &name,DeviceBuffer *ubo,bool dynamic=false);
|
||||||
bool BindSSBO(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 *);
|
bool BindInputAttachment(const AnsiString &name,ImageView *);
|
||||||
|
|
||||||
void Update();
|
void Update();
|
||||||
|
@ -148,7 +148,7 @@ bool DescriptorSet::BindSSBO(const int binding,const DeviceBuffer *buf,const VkD
|
|||||||
return(true);
|
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)
|
if(binding<0||!tex||!sampler)
|
||||||
return(false);
|
return(false);
|
||||||
|
@ -34,14 +34,14 @@ MaterialDescriptorSets::MaterialDescriptorSets(const UTF8String &name,ShaderDesc
|
|||||||
{
|
{
|
||||||
if(sp->desc_type>=VK_DESCRIPTOR_TYPE_BEGIN_RANGE
|
if(sp->desc_type>=VK_DESCRIPTOR_TYPE_BEGIN_RANGE
|
||||||
&&sp->desc_type<=VK_DESCRIPTOR_TYPE_END_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);
|
binding_map[size_t(sp->desc_type)].Add(sp->name,sp->binding);
|
||||||
|
|
||||||
++dsl_ci[size_t(sp->set_type)].bindingCount;
|
++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;
|
++sp;
|
||||||
}
|
}
|
||||||
@ -59,7 +59,7 @@ MaterialDescriptorSets::MaterialDescriptorSets(const UTF8String &name,ShaderDesc
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
ShaderDescriptorList *sdl=descriptor_list;
|
ShaderDescriptorList *sdl=sd_list_by_desc_type;
|
||||||
ShaderDescriptor **sdp;
|
ShaderDescriptor **sdp;
|
||||||
|
|
||||||
for(uint i=VK_DESCRIPTOR_TYPE_BEGIN_RANGE;
|
for(uint i=VK_DESCRIPTOR_TYPE_BEGIN_RANGE;
|
||||||
|
@ -52,14 +52,14 @@ bool MaterialInstance::BindSSBO(const DescriptorSetType &type,const AnsiString &
|
|||||||
return(true);
|
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);
|
MaterialParameters *mp=GetMP(type);
|
||||||
|
|
||||||
if(!mp)
|
if(!mp)
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
if(!mp->BindSampler(name,tex,sampler))return(false);
|
if(!mp->BindImageSampler(name,tex,sampler))return(false);
|
||||||
|
|
||||||
mp->Update();
|
mp->Update();
|
||||||
return(true);
|
return(true);
|
||||||
|
@ -48,17 +48,17 @@ bool MaterialParameters::BindSSBO(const AnsiString &name,DeviceBuffer *ssbo,bool
|
|||||||
return(true);
|
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)
|
if(name.IsEmpty()||!tex||!sampler)
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
const int index=mds->GetSampler(name);
|
const int index=mds->GetImageSampler(name);
|
||||||
|
|
||||||
if(index<0)
|
if(index<0)
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
if(!descriptor_set->BindSampler(index,tex,sampler))
|
if(!descriptor_set->BindImageSampler(index,tex,sampler))
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
@ -69,7 +69,7 @@ bool MaterialParameters::BindInputAttachment(const AnsiString &name,ImageView *i
|
|||||||
if(name.IsEmpty()||!iv)
|
if(name.IsEmpty()||!iv)
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
const int index=mds->GetAttachment(name);
|
const int index=mds->GetInputAttachment(name);
|
||||||
|
|
||||||
if(index<0)
|
if(index<0)
|
||||||
return(false);
|
return(false);
|
||||||
|
@ -167,7 +167,7 @@ Material *RenderResource::CreateMaterial(const OSString &filename)
|
|||||||
|
|
||||||
if(count>0)
|
if(count>0)
|
||||||
{
|
{
|
||||||
ShaderDescriptor *sd_list=hgl_zero_new<ShaderDescriptor>(count);
|
ShaderDescriptor *sd_list=new ShaderDescriptor[count];
|
||||||
|
|
||||||
LoadShaderDescriptor(sp,sd_list,count,ver);
|
LoadShaderDescriptor(sp,sd_list,count,ver);
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ namespace hgl
|
|||||||
if(!mp)
|
if(!mp)
|
||||||
return(false);
|
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);
|
if(!mp->BindUBO("color_material",ubo_color))return(false);
|
||||||
|
|
||||||
mp->Update();
|
mp->Update();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user