2023-05-10 02:32:03 +08:00
|
|
|
|
#include<hgl/graph/VKDevice.h>
|
2021-06-16 11:43:19 +08:00
|
|
|
|
#include<hgl/graph/VKMaterial.h>
|
2023-03-20 13:55:47 +08:00
|
|
|
|
#include<hgl/graph/VKMaterialDescriptorManager.h>
|
2021-09-14 20:31:15 +08:00
|
|
|
|
#include<hgl/graph/VKMaterialParameters.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/VKShaderModuleMap.h>
|
2022-10-11 19:16:06 +08:00
|
|
|
|
#include<hgl/graph/VKVertexInputLayout.h>
|
2021-09-14 20:31:15 +08:00
|
|
|
|
#include"VKPipelineLayoutData.h"
|
2023-07-28 20:17:46 +08:00
|
|
|
|
#include<hgl/log/LogInfo.h>
|
2021-06-16 11:43:19 +08:00
|
|
|
|
|
|
|
|
|
VK_NAMESPACE_BEGIN
|
2023-06-02 20:45:19 +08:00
|
|
|
|
|
|
|
|
|
PipelineLayoutData *CreatePipelineLayoutData(VkDevice device,const MaterialDescriptorManager *desc_manager);
|
|
|
|
|
|
|
|
|
|
namespace
|
2021-09-14 20:31:15 +08:00
|
|
|
|
{
|
2023-06-02 20:45:19 +08:00
|
|
|
|
DescriptorSet *CreateDS(VkDevice device,VkDescriptorPool desc_pool,const PipelineLayoutData *pld,const DescriptorSetType &type)
|
|
|
|
|
{
|
|
|
|
|
RANGE_CHECK_RETURN_NULLPTR(type);
|
2021-09-14 20:31:15 +08:00
|
|
|
|
|
2024-05-25 22:08:01 +08:00
|
|
|
|
const uint32_t vab_count=pld->vab_count[size_t(type)];
|
2021-09-14 20:31:15 +08:00
|
|
|
|
|
2024-05-25 22:08:01 +08:00
|
|
|
|
if(!vab_count)
|
2023-06-02 20:45:19 +08:00
|
|
|
|
return(nullptr);
|
2021-09-14 20:31:15 +08:00
|
|
|
|
|
2023-06-02 20:45:19 +08:00
|
|
|
|
DescriptorSetAllocateInfo alloc_info;
|
2021-09-14 20:31:15 +08:00
|
|
|
|
|
2023-06-02 20:45:19 +08:00
|
|
|
|
alloc_info.descriptorPool = desc_pool;
|
|
|
|
|
alloc_info.descriptorSetCount = 1;
|
|
|
|
|
alloc_info.pSetLayouts = pld->layouts+size_t(type);
|
2021-09-14 20:31:15 +08:00
|
|
|
|
|
2023-06-02 20:45:19 +08:00
|
|
|
|
VkDescriptorSet desc_set;
|
2021-09-14 20:31:15 +08:00
|
|
|
|
|
2023-06-02 20:45:19 +08:00
|
|
|
|
if(vkAllocateDescriptorSets(device,&alloc_info,&desc_set)!=VK_SUCCESS)
|
|
|
|
|
return(nullptr);
|
2021-09-14 20:31:15 +08:00
|
|
|
|
|
2024-05-25 22:08:01 +08:00
|
|
|
|
return(new DescriptorSet(device,vab_count,pld->pipeline_layout,desc_set));
|
2023-06-02 20:45:19 +08:00
|
|
|
|
}
|
2023-06-06 21:03:13 +08:00
|
|
|
|
}//namespace
|
2021-09-14 20:31:15 +08:00
|
|
|
|
|
2023-06-14 16:49:19 +08:00
|
|
|
|
MaterialParameters *GPUDevice::CreateMP(const MaterialDescriptorManager *desc_manager,const PipelineLayoutData *pld,const DescriptorSetType &desc_set_type)
|
2021-06-16 11:43:19 +08:00
|
|
|
|
{
|
2023-06-14 16:49:19 +08:00
|
|
|
|
if(!desc_manager||!pld)return(nullptr);
|
|
|
|
|
RANGE_CHECK_RETURN_NULLPTR(desc_set_type)
|
2021-06-16 11:43:19 +08:00
|
|
|
|
|
2023-06-14 16:49:19 +08:00
|
|
|
|
DescriptorSet *ds=CreateDS(attr->device,attr->desc_pool,pld,desc_set_type);
|
2021-06-16 11:43:19 +08:00
|
|
|
|
|
2023-06-14 16:49:19 +08:00
|
|
|
|
if(!ds)return(nullptr);
|
2021-09-14 20:31:15 +08:00
|
|
|
|
|
2023-06-14 16:49:19 +08:00
|
|
|
|
#ifdef _DEBUG
|
2025-01-04 14:14:47 +08:00
|
|
|
|
const U8String addr_string=HexToString<u8char,uint64_t>((uint64_t)(ds->GetDescriptorSet()));
|
2021-09-14 20:31:15 +08:00
|
|
|
|
|
2025-01-04 14:14:47 +08:00
|
|
|
|
LOG_INFO(U8_TEXT("Create [DescriptSets:")+addr_string+U8_TEXT("] OK! Material Name: \"")+(const U8String &)(desc_manager->GetMaterialName())+U8_TEXT("\" Type: ")+(u8char *)(GetDescriptorSetTypeName(desc_set_type)));
|
2023-06-14 16:49:19 +08:00
|
|
|
|
#endif//_DEBUG
|
2021-09-14 20:31:15 +08:00
|
|
|
|
|
2023-06-14 16:49:19 +08:00
|
|
|
|
return(new MaterialParameters(desc_manager,desc_set_type,ds));
|
2021-06-16 11:43:19 +08:00
|
|
|
|
}
|
2021-09-14 20:31:15 +08:00
|
|
|
|
VK_NAMESPACE_END
|