2021-09-14 20:31:15 +08:00
|
|
|
|
#include"VKPipelineLayoutData.h"
|
2023-02-13 11:50:55 +08:00
|
|
|
|
#include<hgl/graph/VKDescriptorSet.h>
|
2021-09-14 20:31:15 +08:00
|
|
|
|
#include<hgl/graph/VKDevice.h>
|
2023-03-20 13:55:47 +08:00
|
|
|
|
#include<hgl/graph/VKMaterialDescriptorManager.h>
|
2021-09-14 20:31:15 +08:00
|
|
|
|
|
|
|
|
|
VK_NAMESPACE_BEGIN
|
2023-06-02 20:45:19 +08:00
|
|
|
|
PipelineLayoutData *CreatePipelineLayoutData(VkDevice device,const MaterialDescriptorManager *desc_manager)
|
2021-09-14 20:31:15 +08:00
|
|
|
|
{
|
|
|
|
|
PipelineLayoutData *pld=hgl_zero_new<PipelineLayoutData>();
|
|
|
|
|
|
2023-03-21 21:46:16 +08:00
|
|
|
|
if(desc_manager)
|
2021-09-14 20:31:15 +08:00
|
|
|
|
{
|
2023-02-22 21:53:51 +08:00
|
|
|
|
ENUM_CLASS_FOR(DescriptorSetType,int,i)
|
2022-06-20 21:39:04 +08:00
|
|
|
|
{
|
2023-03-21 21:46:16 +08:00
|
|
|
|
const DescriptorSetLayoutCreateInfo *dslci=desc_manager->GetDSLCI((DescriptorSetType)i);
|
2022-06-20 21:39:04 +08:00
|
|
|
|
|
|
|
|
|
if(!dslci||dslci->bindingCount<=0)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if(pld->layouts[i])
|
2023-06-02 20:45:19 +08:00
|
|
|
|
vkDestroyDescriptorSetLayout(device,pld->layouts[i],nullptr);
|
2022-06-20 21:39:04 +08:00
|
|
|
|
|
2023-06-02 20:45:19 +08:00
|
|
|
|
if(vkCreateDescriptorSetLayout(device,dslci,nullptr,pld->layouts+i)!=VK_SUCCESS)
|
2022-06-20 21:39:04 +08:00
|
|
|
|
{
|
|
|
|
|
delete pld;
|
|
|
|
|
return(nullptr);
|
|
|
|
|
}
|
2021-09-14 20:31:15 +08:00
|
|
|
|
|
2022-06-20 21:39:04 +08:00
|
|
|
|
pld->binding_count[i]=dslci->bindingCount;
|
2021-09-14 20:31:15 +08:00
|
|
|
|
|
2022-06-20 21:39:04 +08:00
|
|
|
|
pld->fin_dsl[pld->fin_dsl_count]=pld->layouts[i];
|
|
|
|
|
++pld->fin_dsl_count;
|
|
|
|
|
}
|
2021-09-14 20:31:15 +08:00
|
|
|
|
|
2022-06-20 21:39:04 +08:00
|
|
|
|
if(pld->fin_dsl_count<=0)
|
2021-09-14 20:31:15 +08:00
|
|
|
|
{
|
|
|
|
|
delete pld;
|
|
|
|
|
return(nullptr);
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-06-20 21:39:04 +08:00
|
|
|
|
else
|
2021-09-14 20:31:15 +08:00
|
|
|
|
{
|
2023-02-13 11:48:53 +08:00
|
|
|
|
//没有任何DescriptorSet的情况也是存在的
|
2021-09-14 20:31:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//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;
|
|
|
|
|
|
2023-06-02 20:45:19 +08:00
|
|
|
|
pld->device=device;
|
2021-09-14 20:31:15 +08:00
|
|
|
|
|
2023-06-02 20:45:19 +08:00
|
|
|
|
if(vkCreatePipelineLayout(device,&pPipelineLayoutCreateInfo,nullptr,&(pld->pipeline_layout))!=VK_SUCCESS)
|
2021-09-14 20:31:15 +08:00
|
|
|
|
{
|
|
|
|
|
delete pld;
|
|
|
|
|
return(nullptr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return(pld);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PipelineLayoutData::~PipelineLayoutData()
|
|
|
|
|
{
|
|
|
|
|
vkDestroyPipelineLayout(device,pipeline_layout,nullptr);
|
|
|
|
|
|
2023-02-22 21:53:51 +08:00
|
|
|
|
ENUM_CLASS_FOR(DescriptorSetType,int,i)
|
2021-09-14 20:31:15 +08:00
|
|
|
|
if(layouts[i])
|
|
|
|
|
vkDestroyDescriptorSetLayout(device,layouts[i],nullptr);
|
|
|
|
|
}
|
|
|
|
|
VK_NAMESPACE_END
|
|
|
|
|
|