support MI_MAX_COUNT in ShaderGen

This commit is contained in:
2023-06-02 20:45:19 +08:00
parent 22bc5f6653
commit f4a8406ad8
27 changed files with 318 additions and 189 deletions

View File

@@ -8,35 +8,61 @@
#include"VKPipelineLayoutData.h"
VK_NAMESPACE_BEGIN
DescriptorSet *GPUDevice::CreateDS(const PipelineLayoutData *pld,const DescriptorSetType &type)const
PipelineLayoutData *CreatePipelineLayoutData(VkDevice device,const MaterialDescriptorManager *desc_manager);
namespace
{
RANGE_CHECK_RETURN_NULLPTR(type);
DescriptorSet *CreateDS(VkDevice device,VkDescriptorPool desc_pool,const PipelineLayoutData *pld,const DescriptorSetType &type)
{
RANGE_CHECK_RETURN_NULLPTR(type);
const uint32_t binding_count=pld->binding_count[size_t(type)];
const uint32_t binding_count=pld->binding_count[size_t(type)];
if(!binding_count)
return(nullptr);
if(!binding_count)
return(nullptr);
DescriptorSetAllocateInfo alloc_info;
DescriptorSetAllocateInfo alloc_info;
alloc_info.descriptorPool = attr->desc_pool;
alloc_info.descriptorSetCount = 1;
alloc_info.pSetLayouts = pld->layouts+size_t(type);
alloc_info.descriptorPool = desc_pool;
alloc_info.descriptorSetCount = 1;
alloc_info.pSetLayouts = pld->layouts+size_t(type);
VkDescriptorSet desc_set;
VkDescriptorSet desc_set;
if(vkAllocateDescriptorSets(attr->device,&alloc_info,&desc_set)!=VK_SUCCESS)
return(nullptr);
if(vkAllocateDescriptorSets(device,&alloc_info,&desc_set)!=VK_SUCCESS)
return(nullptr);
return(new DescriptorSet(attr->device,binding_count,pld->pipeline_layout,desc_set));
}
return(new DescriptorSet(device,binding_count,pld->pipeline_layout,desc_set));
}
void CreateShaderStageList(List<VkPipelineShaderStageCreateInfo> &shader_stage_list,ShaderModuleMap *shader_maps)
{
const ShaderModule *sm;
const int shader_count=shader_maps->GetCount();
shader_stage_list.SetCount(shader_count);
VkPipelineShaderStageCreateInfo *p=shader_stage_list.GetData();
auto **itp=shader_maps->GetDataList();
for(int i=0;i<shader_count;i++)
{
sm=(*itp)->value;
hgl_cpy(p,sm->GetCreateInfo(),1);
++p;
++itp;
}
}
}//namespace
MaterialParameters *GPUDevice::CreateMP(const MaterialDescriptorManager *desc_manager,const PipelineLayoutData *pld,const DescriptorSetType &desc_set_type)
{
if(!desc_manager||!pld)return(nullptr);
RANGE_CHECK_RETURN_NULLPTR(desc_set_type)
DescriptorSet *ds=CreateDS(pld,desc_set_type);
DescriptorSet *ds=CreateDS(attr->device,attr->desc_pool,pld,desc_set_type);
if(!ds)return(nullptr);
@@ -56,26 +82,6 @@ MaterialParameters *GPUDevice::CreateMP(Material *mtl,const DescriptorSetType &d
return CreateMP(mtl->GetDescriptorSets(),mtl->GetPipelineLayoutData(),desc_set_type);
}
void CreateShaderStageList(List<VkPipelineShaderStageCreateInfo> &shader_stage_list,ShaderModuleMap *shader_maps)
{
const ShaderModule *sm;
const int shader_count=shader_maps->GetCount();
shader_stage_list.SetCount(shader_count);
VkPipelineShaderStageCreateInfo *p=shader_stage_list.GetData();
auto **itp=shader_maps->GetDataList();
for(int i=0;i<shader_count;i++)
{
sm=(*itp)->value;
hgl_cpy(p,sm->GetCreateInfo(),1);
++p;
++itp;
}
}
Material *GPUDevice::CreateMaterial(const UTF8String &mtl_name,ShaderModuleMap *shader_maps,MaterialDescriptorManager *desc_manager,VertexInput *vi)
{
const int shader_count=shader_maps->GetCount();
@@ -83,7 +89,7 @@ Material *GPUDevice::CreateMaterial(const UTF8String &mtl_name,ShaderModuleMap *
if(shader_count<1)
return(nullptr);
PipelineLayoutData *pld=CreatePipelineLayoutData(desc_manager);
PipelineLayoutData *pld=CreatePipelineLayoutData(attr->device,desc_manager);
if(!pld)
{

View File

@@ -4,7 +4,7 @@
#include<hgl/graph/VKMaterialDescriptorManager.h>
VK_NAMESPACE_BEGIN
PipelineLayoutData *GPUDevice::CreatePipelineLayoutData(const MaterialDescriptorManager *desc_manager)
PipelineLayoutData *CreatePipelineLayoutData(VkDevice device,const MaterialDescriptorManager *desc_manager)
{
PipelineLayoutData *pld=hgl_zero_new<PipelineLayoutData>();
@@ -18,9 +18,9 @@ PipelineLayoutData *GPUDevice::CreatePipelineLayoutData(const MaterialDescriptor
continue;
if(pld->layouts[i])
vkDestroyDescriptorSetLayout(attr->device,pld->layouts[i],nullptr);
vkDestroyDescriptorSetLayout(device,pld->layouts[i],nullptr);
if(vkCreateDescriptorSetLayout(attr->device,dslci,nullptr,pld->layouts+i)!=VK_SUCCESS)
if(vkCreateDescriptorSetLayout(device,dslci,nullptr,pld->layouts+i)!=VK_SUCCESS)
{
delete pld;
return(nullptr);
@@ -56,9 +56,9 @@ PipelineLayoutData *GPUDevice::CreatePipelineLayoutData(const MaterialDescriptor
pPipelineLayoutCreateInfo.pushConstantRangeCount = 0;//1;
pPipelineLayoutCreateInfo.pPushConstantRanges = nullptr;//&push_constant_range;
pld->device=attr->device;
pld->device=device;
if(vkCreatePipelineLayout(attr->device,&pPipelineLayoutCreateInfo,nullptr,&(pld->pipeline_layout))!=VK_SUCCESS)
if(vkCreatePipelineLayout(device,&pPipelineLayoutCreateInfo,nullptr,&(pld->pipeline_layout))!=VK_SUCCESS)
{
delete pld;
return(nullptr);