diff --git a/src/RenderDevice/Vulkan/VKMaterial.cpp b/src/RenderDevice/Vulkan/VKMaterial.cpp index bd9082d2..61debcd9 100644 --- a/src/RenderDevice/Vulkan/VKMaterial.cpp +++ b/src/RenderDevice/Vulkan/VKMaterial.cpp @@ -14,9 +14,9 @@ Material *CreateMaterial(Device *dev,ShaderModuleMap *shader_maps) if(shader_count<2) return(nullptr); - const ShaderModule *vsm; + const ShaderModule *sm; - if(!shader_maps->Get(VK_SHADER_STAGE_VERTEX_BIT,vsm)) + if(!shader_maps->Get(VK_SHADER_STAGE_VERTEX_BIT,sm)) return(nullptr); DescriptorSetLayoutCreater *dsl_creater=new DescriptorSetLayoutCreater(dev); @@ -29,16 +29,20 @@ Material *CreateMaterial(Device *dev,ShaderModuleMap *shader_maps) auto **itp=shader_maps->GetDataList(); for(int i=0;iright; - memcpy(p,vsm->GetCreateInfo(),sizeof(VkPipelineShaderStageCreateInfo)); + sm=(*itp)->right; + memcpy(p,sm->GetCreateInfo(),sizeof(VkPipelineShaderStageCreateInfo)); - dsl_creater->Bind(vsm->GetDescriptorList(),vsm->GetStage()); + dsl_creater->Bind(sm->GetDescriptorList(),sm->GetStage()); ++p; ++itp; } - dsl_creater->CreatePipelineLayout(); + if(!dsl_creater->CreatePipelineLayout()) + { + delete shader_maps; + return(nullptr); + } return(new Material(dev,shader_maps,shader_stage_list,dsl_creater)); } @@ -68,8 +72,11 @@ Material::~Material() { delete dsl_creater; - vertex_sm->Release(vab); - delete vab; + if(vab) + { + vertex_sm->Release(vab); + delete vab; + } delete shader_stage_list; delete shader_maps; diff --git a/src/RenderDevice/Vulkan/VKShaderModule.cpp b/src/RenderDevice/Vulkan/VKShaderModule.cpp index 6c51d3e2..c96191e3 100644 --- a/src/RenderDevice/Vulkan/VKShaderModule.cpp +++ b/src/RenderDevice/Vulkan/VKShaderModule.cpp @@ -69,7 +69,7 @@ VertexShaderModule::~VertexShaderModule() VertexAttributeBinding *VertexShaderModule::CreateVertexAttributeBinding() { - VertexAttributeBinding *vab=new VertexAttributeBinding(this); + VertexAttributeBinding *vab=new VertexAttributeBinding(attr_count,binding_list,attribute_list); vab_sets.Add(vab); diff --git a/src/RenderDevice/Vulkan/VKVertexAttributeBinding.cpp b/src/RenderDevice/Vulkan/VKVertexAttributeBinding.cpp index 451d2a3a..e76e4c6d 100644 --- a/src/RenderDevice/Vulkan/VKVertexAttributeBinding.cpp +++ b/src/RenderDevice/Vulkan/VKVertexAttributeBinding.cpp @@ -2,11 +2,9 @@ #include VK_NAMESPACE_BEGIN -VertexAttributeBinding::VertexAttributeBinding(VertexShaderModule *s) +VertexAttributeBinding::VertexAttributeBinding(const uint32_t count,const VkVertexInputBindingDescription *bind_list,const VkVertexInputAttributeDescription *attr_list) { - vsm=s; - - attr_count=vsm->GetAttrCount(); + attr_count=count; if(attr_count<=0) { @@ -15,21 +13,14 @@ VertexAttributeBinding::VertexAttributeBinding(VertexShaderModule *s) return; } - binding_list=hgl_copy_new(attr_count,vsm->GetDescList()); - attribute_list=hgl_copy_new(attr_count,vsm->GetAttrList()); + binding_list=hgl_copy_new(attr_count,bind_list); + attribute_list=hgl_copy_new(attr_count,attr_list); } VertexAttributeBinding::~VertexAttributeBinding() { delete[] attribute_list; delete[] binding_list; - - vsm->Release(this); -} - -const uint VertexAttributeBinding::GetStageInputBinding(const AnsiString &name) -{ - return vsm->GetStageInputBinding(name); } bool VertexAttributeBinding::SetInstance(const uint index,bool instance) @@ -70,12 +61,10 @@ bool VertexAttributeBinding::SetOffset(const uint index,const uint32_t offset) void VertexAttributeBinding::Write(VkPipelineVertexInputStateCreateInfo &vis_create_info) const { - const uint32_t count=vsm->GetAttrCount(); - - vis_create_info.vertexBindingDescriptionCount = count; + vis_create_info.vertexBindingDescriptionCount = attr_count; vis_create_info.pVertexBindingDescriptions = binding_list; - vis_create_info.vertexAttributeDescriptionCount = count; + vis_create_info.vertexAttributeDescriptionCount = attr_count; vis_create_info.pVertexAttributeDescriptions = attribute_list; } VK_NAMESPACE_END