78 lines
2.3 KiB
C++
78 lines
2.3 KiB
C++
|
#include"VKPipelineLayoutData.h"
|
|||
|
#include<hgl/graph/VKDescriptorSets.h>
|
|||
|
#include<hgl/graph/VKDevice.h>
|
|||
|
#include<hgl/graph/VKMaterialDescriptorSets.h>
|
|||
|
|
|||
|
VK_NAMESPACE_BEGIN
|
|||
|
PipelineLayoutData *GPUDevice::CreatePipelineLayoutData(const MaterialDescriptorSets *mds)
|
|||
|
{
|
|||
|
PipelineLayoutData *pld=hgl_zero_new<PipelineLayoutData>();
|
|||
|
|
|||
|
ENUM_CLASS_FOR(DescriptorSetType,int,i)
|
|||
|
{
|
|||
|
const int binding_count=mds->GetBindingCount((DescriptorSetType)i);
|
|||
|
|
|||
|
if(binding_count<=0)
|
|||
|
continue;
|
|||
|
|
|||
|
DescriptorSetLayoutCreateInfo descriptor_layout;
|
|||
|
|
|||
|
descriptor_layout.bindingCount = binding_count;
|
|||
|
descriptor_layout.pBindings = mds->GetBindingList((DescriptorSetType)i);
|
|||
|
|
|||
|
if(pld->layouts[i])
|
|||
|
vkDestroyDescriptorSetLayout(attr->device,pld->layouts[i],nullptr);
|
|||
|
|
|||
|
if(vkCreateDescriptorSetLayout(attr->device,&descriptor_layout,nullptr,pld->layouts+i)!=VK_SUCCESS)
|
|||
|
{
|
|||
|
delete pld;
|
|||
|
return(nullptr);
|
|||
|
}
|
|||
|
|
|||
|
pld->binding_count[i]=binding_count;
|
|||
|
|
|||
|
pld->fin_dsl[pld->fin_dsl_count]=pld->layouts[i];
|
|||
|
++pld->fin_dsl_count;
|
|||
|
}
|
|||
|
|
|||
|
if(pld->fin_dsl_count<=0)
|
|||
|
{
|
|||
|
delete pld;
|
|||
|
return(nullptr);
|
|||
|
}
|
|||
|
|
|||
|
//VkPushConstantRange push_constant_range;
|
|||
|
|
|||
|
//push_constant_range.stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
|
|||
|
//push_constant_range.size = MAX_PUSH_CONSTANT_BYTES;
|
|||
|
//push_constant_range.offset = 0;
|
|||
|
|
|||
|
PipelineLayoutCreateInfo pPipelineLayoutCreateInfo;
|
|||
|
|
|||
|
pPipelineLayoutCreateInfo.setLayoutCount = pld->fin_dsl_count;
|
|||
|
pPipelineLayoutCreateInfo.pSetLayouts = pld->fin_dsl;
|
|||
|
pPipelineLayoutCreateInfo.pushConstantRangeCount = 0;//1;
|
|||
|
pPipelineLayoutCreateInfo.pPushConstantRanges = nullptr;//&push_constant_range;
|
|||
|
|
|||
|
pld->device=attr->device;
|
|||
|
|
|||
|
if(vkCreatePipelineLayout(attr->device,&pPipelineLayoutCreateInfo,nullptr,&(pld->pipeline_layout))!=VK_SUCCESS)
|
|||
|
{
|
|||
|
delete pld;
|
|||
|
return(nullptr);
|
|||
|
}
|
|||
|
|
|||
|
return(pld);
|
|||
|
}
|
|||
|
|
|||
|
PipelineLayoutData::~PipelineLayoutData()
|
|||
|
{
|
|||
|
vkDestroyPipelineLayout(device,pipeline_layout,nullptr);
|
|||
|
|
|||
|
ENUM_CLASS_FOR(DescriptorSetType,int,i)
|
|||
|
if(layouts[i])
|
|||
|
vkDestroyDescriptorSetLayout(device,layouts[i],nullptr);
|
|||
|
}
|
|||
|
VK_NAMESPACE_END
|
|||
|
|