redesigned the WriteDescriptorSet
This commit is contained in:
parent
33330c6942
commit
b02638e840
@ -1 +1 @@
|
|||||||
Subproject commit c4642ea87cb4abf4b68e94a63d868bdd66666dbe
|
Subproject commit ad2504b4bd5390b887ef9abfc395552493cd5d0c
|
@ -34,8 +34,8 @@ public:
|
|||||||
|
|
||||||
virtual ~GPUBuffer();
|
virtual ~GPUBuffer();
|
||||||
|
|
||||||
VkBuffer GetBuffer (){return buf.buffer;}
|
VkBuffer GetBuffer ()const{return buf.buffer;}
|
||||||
GPUMemory * GetMemory (){return buf.memory;}
|
GPUMemory * GetMemory ()const{return buf.memory;}
|
||||||
const VkDescriptorBufferInfo * GetBufferInfo()const{return &buf.info;}
|
const VkDescriptorBufferInfo * GetBufferInfo()const{return &buf.info;}
|
||||||
|
|
||||||
void * Map () {return buf.memory->Map();}
|
void * Map () {return buf.memory->Map();}
|
||||||
|
@ -15,7 +15,8 @@ class DescriptorSets
|
|||||||
|
|
||||||
VkPipelineLayout pipeline_layout;
|
VkPipelineLayout pipeline_layout;
|
||||||
|
|
||||||
ObjectList<VkDescriptorImageInfo> desc_image_info;
|
ObjectList<VkDescriptorBufferInfo> buffer_list;
|
||||||
|
ObjectList<VkDescriptorImageInfo> image_list;
|
||||||
List<VkWriteDescriptorSet> wds_list;
|
List<VkWriteDescriptorSet> wds_list;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -40,6 +41,7 @@ public:
|
|||||||
|
|
||||||
void Clear();
|
void Clear();
|
||||||
bool BindUBO(const int binding,const GPUBuffer *);
|
bool BindUBO(const int binding,const GPUBuffer *);
|
||||||
|
bool BindUBO(const int binding,const GPUBuffer *,const VkDeviceSize offset,const VkDeviceSize range);
|
||||||
bool BindUBODynamic(const int binding,const GPUBuffer *);
|
bool BindUBODynamic(const int binding,const GPUBuffer *);
|
||||||
bool BindSampler(const int binding,Texture *,Sampler *);
|
bool BindSampler(const int binding,Texture *,Sampler *);
|
||||||
void Update();
|
void Update();
|
||||||
|
@ -5,10 +5,42 @@
|
|||||||
#include<hgl/graph/VKSampler.h>
|
#include<hgl/graph/VKSampler.h>
|
||||||
|
|
||||||
VK_NAMESPACE_BEGIN
|
VK_NAMESPACE_BEGIN
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
struct WriteDescriptorSet:public vkstruct<VkWriteDescriptorSet,VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
WriteDescriptorSet(VkDescriptorSet desc_set,const uint32_t binding,const VkDescriptorType desc_type)
|
||||||
|
{
|
||||||
|
dstSet = desc_set;
|
||||||
|
dstBinding = binding;
|
||||||
|
dstArrayElement = 0;
|
||||||
|
descriptorCount = 1;
|
||||||
|
descriptorType = desc_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
WriteDescriptorSet(VkDescriptorSet desc_set,const uint32_t binding,const VkDescriptorBufferInfo *buf_info,const VkDescriptorType desc_type=VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER):WriteDescriptorSet(desc_set,binding,desc_type)
|
||||||
|
{
|
||||||
|
pImageInfo = nullptr;
|
||||||
|
pBufferInfo = buf_info;
|
||||||
|
pTexelBufferView = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
WriteDescriptorSet(VkDescriptorSet desc_set,const uint32_t binding,const VkDescriptorImageInfo *img_info):WriteDescriptorSet(desc_set,binding,VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)
|
||||||
|
{
|
||||||
|
pImageInfo = img_info;
|
||||||
|
pBufferInfo = nullptr;
|
||||||
|
pTexelBufferView= nullptr;
|
||||||
|
}
|
||||||
|
};//struct WriteDescriptorSet
|
||||||
|
}//namespace
|
||||||
|
|
||||||
void DescriptorSets::Clear()
|
void DescriptorSets::Clear()
|
||||||
{
|
{
|
||||||
|
buffer_list.ClearData();
|
||||||
|
image_list.ClearData();
|
||||||
wds_list.ClearData();
|
wds_list.ClearData();
|
||||||
desc_image_info.ClearData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DescriptorSets::BindUBO(const int binding,const GPUBuffer *buf)
|
bool DescriptorSets::BindUBO(const int binding,const GPUBuffer *buf)
|
||||||
@ -16,16 +48,26 @@ bool DescriptorSets::BindUBO(const int binding,const GPUBuffer *buf)
|
|||||||
if(binding<0||!buf)
|
if(binding<0||!buf)
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
WriteDescriptorSet wds;
|
WriteDescriptorSet wds(desc_set,binding,buf->GetBufferInfo());
|
||||||
|
|
||||||
wds.dstSet = desc_set;
|
wds_list.Add(wds);
|
||||||
wds.dstBinding = binding;
|
return(true);
|
||||||
wds.dstArrayElement = 0;
|
}
|
||||||
wds.descriptorCount = 1;
|
|
||||||
wds.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
bool DescriptorSets::BindUBO(const int binding,const GPUBuffer *buf,const VkDeviceSize offset,const VkDeviceSize range)
|
||||||
wds.pImageInfo = nullptr;
|
{
|
||||||
wds.pBufferInfo = buf->GetBufferInfo();
|
if(binding<0||!buf)
|
||||||
wds.pTexelBufferView = nullptr;
|
return(false);
|
||||||
|
|
||||||
|
VkDescriptorBufferInfo *buf_info=new VkDescriptorBufferInfo;
|
||||||
|
|
||||||
|
buf_info->buffer=buf->GetBuffer();
|
||||||
|
buf_info->offset=offset;
|
||||||
|
buf_info->range=range;
|
||||||
|
|
||||||
|
buffer_list.Add(buf_info);
|
||||||
|
|
||||||
|
WriteDescriptorSet wds(desc_set,binding,buf_info);
|
||||||
|
|
||||||
wds_list.Add(wds);
|
wds_list.Add(wds);
|
||||||
return(true);
|
return(true);
|
||||||
@ -36,16 +78,7 @@ bool DescriptorSets::BindUBODynamic(const int binding,const GPUBuffer *buf)
|
|||||||
if(binding<0||!buf)
|
if(binding<0||!buf)
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
WriteDescriptorSet wds;
|
WriteDescriptorSet wds(desc_set,binding,buf->GetBufferInfo(),VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC);
|
||||||
|
|
||||||
wds.dstSet = desc_set;
|
|
||||||
wds.dstBinding = binding;
|
|
||||||
wds.dstArrayElement = 0;
|
|
||||||
wds.descriptorCount = 1;
|
|
||||||
wds.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC;
|
|
||||||
wds.pImageInfo = nullptr;
|
|
||||||
wds.pBufferInfo = buf->GetBufferInfo();
|
|
||||||
wds.pTexelBufferView = nullptr;
|
|
||||||
|
|
||||||
wds_list.Add(wds);
|
wds_list.Add(wds);
|
||||||
return(true);
|
return(true);
|
||||||
@ -57,23 +90,15 @@ bool DescriptorSets::BindSampler(const int binding,Texture *tex,Sampler *sampler
|
|||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
VkDescriptorImageInfo *image_info=new VkDescriptorImageInfo;
|
VkDescriptorImageInfo *image_info=new VkDescriptorImageInfo;
|
||||||
|
|
||||||
image_info->imageView =tex->GetVulkanImageView();
|
image_info->imageView =tex->GetVulkanImageView();
|
||||||
//image_info->imageLayout =tex->GetImageLayout();
|
// image_info.imageLayout =tex->GetImageLayout();
|
||||||
image_info->imageLayout =VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
image_info->imageLayout =VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
||||||
image_info->sampler =*sampler;
|
image_info->sampler =*sampler;
|
||||||
|
|
||||||
desc_image_info.Add(image_info);
|
image_list.Add(image_info);
|
||||||
|
|
||||||
WriteDescriptorSet wds;
|
|
||||||
|
|
||||||
wds.dstSet = desc_set;
|
WriteDescriptorSet wds(desc_set,binding,image_info);
|
||||||
wds.dstBinding = binding;
|
|
||||||
wds.dstArrayElement = 0;
|
|
||||||
wds.descriptorCount = 1;
|
|
||||||
wds.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
|
||||||
wds.pImageInfo = image_info;
|
|
||||||
wds.pBufferInfo = nullptr;
|
|
||||||
wds.pTexelBufferView = nullptr;
|
|
||||||
|
|
||||||
wds_list.Add(wds);
|
wds_list.Add(wds);
|
||||||
return(true);
|
return(true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user