improved BindInputAttachment at DescriptorSets, added BindInputAttachment at MaterialParameters

This commit is contained in:
hyzboy 2022-03-28 17:41:25 +08:00
parent 3e81d05c81
commit 77836d7121
8 changed files with 35 additions and 10 deletions

View File

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

View File

@ -29,10 +29,10 @@ public:
virtual ~ImageView();
operator VkImageView(){return image_view;}
public:
VkImageView GetImageView () {return image_view;}
const VkImageViewType GetViewType ()const{return ivci->viewType;}
const VkFormat GetFormat ()const{return ivci->format;}
const VkExtent3D & GetExtent ()const{return extent;}

View File

@ -47,7 +47,8 @@ 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 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 *GetBinding(const DescriptorSetsType &type)const{return sds+size_t(type);}
};//class MaterialDescriptorSets

View File

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

View File

@ -25,7 +25,7 @@ public:
VkDeviceMemory GetDeviceMemory () {return data?data->memory->operator VkDeviceMemory():VK_NULL_HANDLE;}
VkImage GetImage () {return data?data->image:VK_NULL_HANDLE;}
VkImageLayout GetImageLayout () {return data?data->image_layout:VK_IMAGE_LAYOUT_UNDEFINED;}
VkImageView GetVulkanImageView () {return data?data->image_view->operator VkImageView():VK_NULL_HANDLE;}
VkImageView GetVulkanImageView () {return data?data->image_view->GetImageView():VK_NULL_HANDLE;}
GPUMemory * GetMemory () {return data?data->memory:nullptr;}
ImageView * GetImageView () {return data?data->image_view:nullptr;}

View File

@ -57,6 +57,13 @@ namespace
imageView=tex->GetVulkanImageView();
imageLayout=VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
}
DescriptorImageInfo(VkImageView iv)
{
sampler=VK_NULL_HANDLE;
imageView=iv;
imageLayout=VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
}
};//struct DescriptorImageInfo:public VkDescriptorImageInfo
}//namespace
@ -159,14 +166,14 @@ bool DescriptorSets::BindSampler(const int binding,Texture *tex,Sampler *sampler
return(true);
}
bool DescriptorSets::BindInputAttachment(const int binding,Texture *tex)
bool DescriptorSets::BindInputAttachment(const int binding,ImageView *iv)
{
if(binding<0||!tex)
if(binding<0||!iv)
return(false);
if(binded_sets.IsMember(binding))return(false);
DescriptorImageInfo *image_info=new DescriptorImageInfo(tex,nullptr);
DescriptorImageInfo *image_info=new DescriptorImageInfo(iv->GetImageView());
image_list.Add(image_info);

View File

@ -41,7 +41,7 @@ Framebuffer *GPUDevice::CreateFramebuffer(RenderPass *rp,ImageView **color_list,
if(*cf!=(*iv)->GetFormat())
return(nullptr);
*ap=**iv;
*ap=(*iv)->GetImageView();
++ap;
++cf;
@ -59,7 +59,7 @@ Framebuffer *GPUDevice::CreateFramebuffer(RenderPass *rp,ImageView **color_list,
return(nullptr);
}
attachments[color_count]=*depth;
attachments[color_count]=depth->GetImageView();
extent.width=depth->GetExtent().width;
extent.height=depth->GetExtent().height;

View File

@ -64,6 +64,22 @@ bool MaterialParameters::BindSampler(const AnsiString &name,Texture *tex,Sampler
return(true);
}
bool MaterialParameters::BindInputAttachment(const AnsiString &name,ImageView *iv)
{
if(name.IsEmpty()||!iv)
return(false);
const int index=mds->GetSampler(name);
if(index<0)
return(false);
if(!descriptor_sets->BindInputAttachment(index,iv))
return(false);
return(true);
}
void MaterialParameters::Update()
{
descriptor_sets->Update();