diff --git a/example/Vulkan/Cubemap.cpp b/example/Vulkan/Cubemap.cpp index 2bb56629..cf6bd086 100644 --- a/example/Vulkan/Cubemap.cpp +++ b/example/Vulkan/Cubemap.cpp @@ -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); } diff --git a/example/Vulkan/DeferredRender.cpp b/example/Vulkan/DeferredRender.cpp index b93314a8..1f9a76f3 100644 --- a/example/Vulkan/DeferredRender.cpp +++ b/example/Vulkan/DeferredRender.cpp @@ -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(); } diff --git a/example/Vulkan/DrawTile.cpp b/example/Vulkan/DrawTile.cpp index 98aa0c58..ba1fa091 100644 --- a/example/Vulkan/DrawTile.cpp +++ b/example/Vulkan/DrawTile.cpp @@ -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); } diff --git a/example/Vulkan/EquirectangularMap.cpp b/example/Vulkan/EquirectangularMap.cpp index e4067114..fa83b7a7 100644 --- a/example/Vulkan/EquirectangularMap.cpp +++ b/example/Vulkan/EquirectangularMap.cpp @@ -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); diff --git a/example/Vulkan/InlineGeometryScene.cpp b/example/Vulkan/InlineGeometryScene.cpp index 16e3e102..c8eb8ddf 100644 --- a/example/Vulkan/InlineGeometryScene.cpp +++ b/example/Vulkan/InlineGeometryScene.cpp @@ -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); } } diff --git a/example/Vulkan/OffscreenRender.cpp b/example/Vulkan/OffscreenRender.cpp index a68c754d..3f081b3b 100644 --- a/example/Vulkan/OffscreenRender.cpp +++ b/example/Vulkan/OffscreenRender.cpp @@ -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); { diff --git a/example/Vulkan/RectanglePrimitive.cpp b/example/Vulkan/RectanglePrimitive.cpp index c46e74df..b1f5d5c6 100644 --- a/example/Vulkan/RectanglePrimitive.cpp +++ b/example/Vulkan/RectanglePrimitive.cpp @@ -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); } diff --git a/example/Vulkan/texture_rect.cpp b/example/Vulkan/texture_rect.cpp index 5b772bc7..a1458efb 100644 --- a/example/Vulkan/texture_rect.cpp +++ b/example/Vulkan/texture_rect.cpp @@ -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); } diff --git a/inc/hgl/graph/VKDescriptorSet.h b/inc/hgl/graph/VKDescriptorSet.h index d20adaa6..2bf019a3 100644 --- a/inc/hgl/graph/VKDescriptorSet.h +++ b/inc/hgl/graph/VKDescriptorSet.h @@ -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 diff --git a/inc/hgl/graph/VKMaterialDescriptorSets.h b/inc/hgl/graph/VKMaterialDescriptorSets.h index 1488379f..c08365c6 100644 --- a/inc/hgl/graph/VKMaterialDescriptorSets.h +++ b/inc/hgl/graph/VKMaterialDescriptorSets.h @@ -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 sd_by_name; +// Map sd_by_name; Map binding_map[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 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 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 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 diff --git a/inc/hgl/graph/VKMaterialInstance.h b/inc/hgl/graph/VKMaterialInstance.h index 9d6f4c89..a941c5cb 100644 --- a/inc/hgl/graph/VKMaterialInstance.h +++ b/inc/hgl/graph/VKMaterialInstance.h @@ -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 diff --git a/inc/hgl/graph/VKMaterialParameters.h b/inc/hgl/graph/VKMaterialParameters.h index ae1e07b0..78b9c6b7 100644 --- a/inc/hgl/graph/VKMaterialParameters.h +++ b/inc/hgl/graph/VKMaterialParameters.h @@ -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(); diff --git a/src/SceneGraph/Vulkan/VKDescriptorSet.cpp b/src/SceneGraph/Vulkan/VKDescriptorSet.cpp index 81ca4ffd..b821af76 100644 --- a/src/SceneGraph/Vulkan/VKDescriptorSet.cpp +++ b/src/SceneGraph/Vulkan/VKDescriptorSet.cpp @@ -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); diff --git a/src/SceneGraph/Vulkan/VKMaterialDescriptorSets.cpp b/src/SceneGraph/Vulkan/VKMaterialDescriptorSets.cpp index e78a818c..9c559a5a 100644 --- a/src/SceneGraph/Vulkan/VKMaterialDescriptorSets.cpp +++ b/src/SceneGraph/Vulkan/VKMaterialDescriptorSets.cpp @@ -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; diff --git a/src/SceneGraph/Vulkan/VKMaterialInstance.cpp b/src/SceneGraph/Vulkan/VKMaterialInstance.cpp index 6ab0cf43..40205258 100644 --- a/src/SceneGraph/Vulkan/VKMaterialInstance.cpp +++ b/src/SceneGraph/Vulkan/VKMaterialInstance.cpp @@ -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); diff --git a/src/SceneGraph/Vulkan/VKMaterialParameters.cpp b/src/SceneGraph/Vulkan/VKMaterialParameters.cpp index f0f3c570..435dc8de 100644 --- a/src/SceneGraph/Vulkan/VKMaterialParameters.cpp +++ b/src/SceneGraph/Vulkan/VKMaterialParameters.cpp @@ -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); diff --git a/src/SceneGraph/Vulkan/VKRenderResourceMaterial.cpp b/src/SceneGraph/Vulkan/VKRenderResourceMaterial.cpp index b6243670..ea1e2609 100644 --- a/src/SceneGraph/Vulkan/VKRenderResourceMaterial.cpp +++ b/src/SceneGraph/Vulkan/VKRenderResourceMaterial.cpp @@ -167,7 +167,7 @@ Material *RenderResource::CreateMaterial(const OSString &filename) if(count>0) { - ShaderDescriptor *sd_list=hgl_zero_new(count); + ShaderDescriptor *sd_list=new ShaderDescriptor[count]; LoadShaderDescriptor(sp,sd_list,count,ver); diff --git a/src/SceneGraph/font/TextRender.cpp b/src/SceneGraph/font/TextRender.cpp index 3d735052..2f411068 100644 --- a/src/SceneGraph/font/TextRender.cpp +++ b/src/SceneGraph/font/TextRender.cpp @@ -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();