VKDescriptorSets增加安全性判断

This commit is contained in:
hyzboy 2019-08-01 15:37:03 +08:00
parent eb76cbef2e
commit e39ccb709a
2 changed files with 13 additions and 7 deletions

View File

@ -40,9 +40,9 @@ public:
const VkPipelineLayout GetPipelineLayout ()const{return pipeline_layout;} const VkPipelineLayout GetPipelineLayout ()const{return pipeline_layout;}
void Clear(); void Clear();
bool BindUBO(const uint32_t binding,const Buffer *); bool BindUBO(const int binding,const Buffer *);
bool BindUBODynamic(const uint32_t binding,const Buffer *); bool BindUBODynamic(const int binding,const Buffer *);
bool BindSampler(const uint32_t binding,Texture *,Sampler *); bool BindSampler(const int binding,Texture *,Sampler *);
void Update(); void Update();
};//class DescriptorSets };//class DescriptorSets
VK_NAMESPACE_END VK_NAMESPACE_END

View File

@ -11,8 +11,11 @@ void DescriptorSets::Clear()
desc_image_info.ClearData(); desc_image_info.ClearData();
} }
bool DescriptorSets::BindUBO(const uint32_t binding,const Buffer *buf) bool DescriptorSets::BindUBO(const int binding,const Buffer *buf)
{ {
if(binding<0||!buf)
return(false);
VkWriteDescriptorSet writeDescriptorSet; VkWriteDescriptorSet writeDescriptorSet;
writeDescriptorSet.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; writeDescriptorSet.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
@ -30,8 +33,11 @@ bool DescriptorSets::BindUBO(const uint32_t binding,const Buffer *buf)
return(true); return(true);
} }
bool DescriptorSets::BindUBODynamic(const uint32_t binding,const Buffer *buf) bool DescriptorSets::BindUBODynamic(const int binding,const Buffer *buf)
{ {
if(binding<0||!buf)
return(false);
VkWriteDescriptorSet writeDescriptorSet; VkWriteDescriptorSet writeDescriptorSet;
writeDescriptorSet.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; writeDescriptorSet.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
@ -49,9 +55,9 @@ bool DescriptorSets::BindUBODynamic(const uint32_t binding,const Buffer *buf)
return(true); return(true);
} }
bool DescriptorSets::BindSampler(const uint32_t binding,Texture *tex,Sampler *sampler) bool DescriptorSets::BindSampler(const int binding,Texture *tex,Sampler *sampler)
{ {
if(!tex||!sampler) if(binding<0||!tex||!sampler)
return(false); return(false);
VkDescriptorImageInfo *image_info=new VkDescriptorImageInfo; VkDescriptorImageInfo *image_info=new VkDescriptorImageInfo;