splited DescriptorSetLayoutCreater.
This commit is contained in:
parent
9b2b5d52b3
commit
99bfd4d257
@ -70,7 +70,6 @@ private:
|
|||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
if(!mp_global->BindUBO("g_camera",ubo_camera_info))return(false);
|
if(!mp_global->BindUBO("g_camera",ubo_camera_info))return(false);
|
||||||
if(!mp_global->BindUBO("g_frag_camera",ubo_camera_info))return(false);
|
|
||||||
|
|
||||||
mp_global->Update();
|
mp_global->Update();
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ enum class DescriptorSetType
|
|||||||
|
|
||||||
const DescriptorSetType CheckDescriptorSetType(const char *str);
|
const DescriptorSetType CheckDescriptorSetType(const char *str);
|
||||||
|
|
||||||
class DescriptorSetLayoutCreater;
|
struct PipelineLayoutData;
|
||||||
class DescriptorSets;
|
class DescriptorSets;
|
||||||
|
|
||||||
struct ShaderStage;
|
struct ShaderStage;
|
||||||
@ -95,7 +95,6 @@ class MaterialDescriptorSets;
|
|||||||
class Material;
|
class Material;
|
||||||
class MaterialParameters;
|
class MaterialParameters;
|
||||||
class MaterialInstance;
|
class MaterialInstance;
|
||||||
class PipelineLayout;
|
|
||||||
struct PipelineData;
|
struct PipelineData;
|
||||||
enum class InlinePipeline;
|
enum class InlinePipeline;
|
||||||
class Pipeline;
|
class Pipeline;
|
||||||
|
@ -9,9 +9,8 @@ class GPUBuffer;
|
|||||||
class DescriptorSets
|
class DescriptorSets
|
||||||
{
|
{
|
||||||
VkDevice device;
|
VkDevice device;
|
||||||
int layout_binding_count;
|
int binding_count;
|
||||||
VkDescriptorSet desc_set;
|
VkDescriptorSet desc_set;
|
||||||
// const BindingMapping *index_by_binding;
|
|
||||||
|
|
||||||
VkPipelineLayout pipeline_layout;
|
VkPipelineLayout pipeline_layout;
|
||||||
|
|
||||||
@ -21,30 +20,30 @@ class DescriptorSets
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
friend class DescriptorSetLayoutCreater;
|
friend class GPUDevice;
|
||||||
|
|
||||||
DescriptorSets(VkDevice dev,const int lbc,VkPipelineLayout pl,VkDescriptorSet ds)//,const BindingMapping *bi):index_by_binding(bi)
|
DescriptorSets(VkDevice dev,const int bc,VkPipelineLayout pl,VkDescriptorSet ds)
|
||||||
{
|
{
|
||||||
device=dev;
|
device =dev;
|
||||||
layout_binding_count=lbc;
|
binding_count =bc;
|
||||||
desc_set=ds;
|
desc_set =ds;
|
||||||
pipeline_layout=pl;
|
pipeline_layout =pl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
~DescriptorSets()=default;
|
~DescriptorSets()=default;
|
||||||
|
|
||||||
const uint32_t GetCount ()const{return layout_binding_count;}
|
const uint32_t GetCount ()const{return binding_count;}
|
||||||
const VkDescriptorSet GetDescriptorSet ()const{return desc_set;}
|
const VkDescriptorSet GetDescriptorSet ()const{return desc_set;}
|
||||||
const VkPipelineLayout GetPipelineLayout ()const{return pipeline_layout;}
|
const VkPipelineLayout GetPipelineLayout ()const{return pipeline_layout;}
|
||||||
|
|
||||||
void Clear();
|
void Clear();
|
||||||
|
|
||||||
bool BindUBO(const int binding,const GPUBuffer *buf,bool dynamic=false);
|
bool BindUBO (const int binding,const GPUBuffer *buf,bool dynamic=false);
|
||||||
bool BindUBO(const int binding,const GPUBuffer *buf,const VkDeviceSize offset,const VkDeviceSize range,bool dynamic=false);
|
bool BindUBO (const int binding,const GPUBuffer *buf,const VkDeviceSize offset,const VkDeviceSize range,bool dynamic=false);
|
||||||
bool BindSSBO(const int binding,const GPUBuffer *buf,bool dynamic=false);
|
bool BindSSBO (const int binding,const GPUBuffer *buf,bool dynamic=false);
|
||||||
bool BindSSBO(const int binding,const GPUBuffer *buf,const VkDeviceSize offset,const VkDeviceSize range,bool dynamic=false);
|
bool BindSSBO (const int binding,const GPUBuffer *buf,const VkDeviceSize offset,const VkDeviceSize range,bool dynamic=false);
|
||||||
|
|
||||||
bool BindSampler(const int binding,Texture *,Sampler *);
|
bool BindSampler(const int binding,Texture *,Sampler *);
|
||||||
bool BindInputAttachment(const int binding,Texture *);
|
bool BindInputAttachment(const int binding,Texture *);
|
||||||
|
@ -139,7 +139,7 @@ public: //Buffer相关
|
|||||||
public: //Image
|
public: //Image
|
||||||
|
|
||||||
VkImage CreateImage (VkImageCreateInfo *);
|
VkImage CreateImage (VkImageCreateInfo *);
|
||||||
void DestoryImage (VkImage);
|
void DestroyImage (VkImage);
|
||||||
|
|
||||||
private: //texture
|
private: //texture
|
||||||
|
|
||||||
@ -191,7 +191,12 @@ public: //
|
|||||||
|
|
||||||
public: //shader & material
|
public: //shader & material
|
||||||
|
|
||||||
DescriptorSetLayoutCreater *CreateDescriptorSetLayoutCreater(const MaterialDescriptorSets *);
|
PipelineLayoutData *CreatePipelineLayoutData(const MaterialDescriptorSets *);
|
||||||
|
void Destroy(PipelineLayoutData *);
|
||||||
|
|
||||||
|
DescriptorSets * CreateDescriptorSets(const PipelineLayoutData *,const DescriptorSetType &type)const;
|
||||||
|
MaterialParameters *CreateMP(const MaterialDescriptorSets *,const PipelineLayoutData *,const DescriptorSetType &);
|
||||||
|
MaterialParameters *CreateMP(Material *,const DescriptorSetType &);
|
||||||
|
|
||||||
ShaderModule *CreateShaderModule(ShaderResource *);
|
ShaderModule *CreateShaderModule(ShaderResource *);
|
||||||
|
|
||||||
@ -199,6 +204,8 @@ public: //shader & material
|
|||||||
Material *CreateMaterial(const UTF8String &mtl_name,const VertexShaderModule *vertex_shader_module,const ShaderModule *fragment_shader_module,MaterialDescriptorSets *);
|
Material *CreateMaterial(const UTF8String &mtl_name,const VertexShaderModule *vertex_shader_module,const ShaderModule *fragment_shader_module,MaterialDescriptorSets *);
|
||||||
Material *CreateMaterial(const UTF8String &mtl_name,const VertexShaderModule *vertex_shader_module,const ShaderModule *geometry_shader_module,const ShaderModule *fragment_shader_module,MaterialDescriptorSets *);
|
Material *CreateMaterial(const UTF8String &mtl_name,const VertexShaderModule *vertex_shader_module,const ShaderModule *geometry_shader_module,const ShaderModule *fragment_shader_module,MaterialDescriptorSets *);
|
||||||
|
|
||||||
|
MaterialInstance *CreateMI(Material *);
|
||||||
|
|
||||||
public: //Command Buffer 相关
|
public: //Command Buffer 相关
|
||||||
|
|
||||||
RenderCmdBuffer * CreateRenderCommandBuffer();
|
RenderCmdBuffer * CreateRenderCommandBuffer();
|
||||||
@ -212,7 +219,7 @@ public: //Command Buffer 相关
|
|||||||
RenderPass * CreateRenderPass( const RenderbufferInfo *);
|
RenderPass * CreateRenderPass( const RenderbufferInfo *);
|
||||||
|
|
||||||
GPUFence * CreateFence(bool);
|
GPUFence * CreateFence(bool);
|
||||||
GPUSemaphore * CreateSemaphore();
|
GPUSemaphore * CreateGPUSemaphore();
|
||||||
|
|
||||||
public: //FrameBuffer相关
|
public: //FrameBuffer相关
|
||||||
|
|
||||||
|
@ -7,7 +7,31 @@
|
|||||||
#include<hgl/graph/VKShaderModuleMap.h>
|
#include<hgl/graph/VKShaderModuleMap.h>
|
||||||
#include<hgl/graph/VKVertexAttributeBinding.h>
|
#include<hgl/graph/VKVertexAttributeBinding.h>
|
||||||
VK_NAMESPACE_BEGIN
|
VK_NAMESPACE_BEGIN
|
||||||
class DescriptorSetLayoutCreater;
|
struct MaterialData
|
||||||
|
{
|
||||||
|
UTF8String name;
|
||||||
|
|
||||||
|
ShaderModuleMap *shader_maps;
|
||||||
|
MaterialDescriptorSets *mds;
|
||||||
|
|
||||||
|
VertexShaderModule *vertex_sm;
|
||||||
|
VertexAttributeBinding *vab;
|
||||||
|
|
||||||
|
List<VkPipelineShaderStageCreateInfo> shader_stage_list;
|
||||||
|
|
||||||
|
PipelineLayoutData *pipeline_layout_data;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
MaterialParameters *m,*g,*r;
|
||||||
|
}mp;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
friend class Material;
|
||||||
|
|
||||||
|
~MaterialData();
|
||||||
|
};//struct MaterialData
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 材质类<br>
|
* 材质类<br>
|
||||||
@ -15,51 +39,44 @@ class DescriptorSetLayoutCreater;
|
|||||||
*/
|
*/
|
||||||
class Material
|
class Material
|
||||||
{
|
{
|
||||||
UTF8String mtl_name;
|
MaterialData *data;
|
||||||
|
|
||||||
ShaderModuleMap *shader_maps;
|
private:
|
||||||
MaterialDescriptorSets *mds;
|
|
||||||
|
|
||||||
VertexShaderModule *vertex_sm;
|
friend GPUDevice;
|
||||||
List<VkPipelineShaderStageCreateInfo> shader_stage_list;
|
|
||||||
|
|
||||||
DescriptorSetLayoutCreater *dsl_creater;
|
MaterialData *GetMaterialData(){return data;}
|
||||||
|
|
||||||
MaterialParameters *mp_m,*mp_g,*mp_r;
|
|
||||||
|
|
||||||
VertexAttributeBinding *vab;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Material(const UTF8String &name,ShaderModuleMap *smm,MaterialDescriptorSets *_mds,DescriptorSetLayoutCreater *);
|
Material(MaterialData *md):data(md){}
|
||||||
~Material();
|
~Material();
|
||||||
|
|
||||||
const UTF8String & GetName ()const{return mtl_name;}
|
const UTF8String & GetName ()const{return data->name;}
|
||||||
|
|
||||||
const VertexShaderModule * GetVertexShaderModule ()const{return vertex_sm;}
|
const VertexShaderModule * GetVertexShaderModule ()const{return data->vertex_sm;}
|
||||||
|
|
||||||
const uint32_t GetStageCount ()const{return shader_stage_list.GetCount();}
|
const uint32_t GetStageCount ()const{return data->shader_stage_list.GetCount();}
|
||||||
const VkPipelineShaderStageCreateInfo * GetStages ()const{return shader_stage_list.GetData();}
|
const VkPipelineShaderStageCreateInfo * GetStages ()const{return data->shader_stage_list.GetData();}
|
||||||
|
|
||||||
|
const MaterialDescriptorSets * GetDescriptorSets ()const{return data->mds;}
|
||||||
const VkPipelineLayout GetPipelineLayout ()const;
|
const VkPipelineLayout GetPipelineLayout ()const;
|
||||||
|
const PipelineLayoutData * GetPipelineLayoutData ()const{return data->pipeline_layout_data;}
|
||||||
|
|
||||||
const VertexAttributeBinding * GetVAB ()const{return vab;}
|
const VertexAttributeBinding * GetVAB ()const{return data->vab;}
|
||||||
const uint32_t GetVertexAttrCount ()const{return vab->GetVertexAttrCount();}
|
const uint32_t GetVertexAttrCount ()const{return data->vab->GetVertexAttrCount();}
|
||||||
const VkVertexInputBindingDescription * GetVertexBindingList ()const{return vab->GetVertexBindingList();}
|
const VkVertexInputBindingDescription * GetVertexBindingList ()const{return data->vab->GetVertexBindingList();}
|
||||||
const VkVertexInputAttributeDescription * GetVertexAttributeList ()const{return vab->GetVertexAttributeList();}
|
const VkVertexInputAttributeDescription * GetVertexAttributeList ()const{return data->vab->GetVertexAttributeList();}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
MaterialParameters * CreateMP (const DescriptorSetType &type)const;
|
|
||||||
MaterialParameters * GetMP (const DescriptorSetType &type)
|
MaterialParameters * GetMP (const DescriptorSetType &type)
|
||||||
{
|
{
|
||||||
if(type==DescriptorSetType::Material )return mp_m;else
|
if(type==DescriptorSetType::Material )return data->mp.m;else
|
||||||
if(type==DescriptorSetType::Renderable )return mp_r;else
|
if(type==DescriptorSetType::Renderable )return data->mp.r;else
|
||||||
if(type==DescriptorSetType::Global )return mp_g;else
|
if(type==DescriptorSetType::Global )return data->mp.g;else
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
MaterialInstance * CreateInstance();
|
|
||||||
};//class Material
|
};//class Material
|
||||||
VK_NAMESPACE_END
|
VK_NAMESPACE_END
|
||||||
#endif//HGL_GRAPH_VULKAN_MATERIAL_INCLUDE
|
#endif//HGL_GRAPH_VULKAN_MATERIAL_INCLUDE
|
||||||
|
@ -45,38 +45,14 @@ public:
|
|||||||
MaterialDescriptorSets(ShaderDescriptor *,const uint);
|
MaterialDescriptorSets(ShaderDescriptor *,const uint);
|
||||||
~MaterialDescriptorSets();
|
~MaterialDescriptorSets();
|
||||||
|
|
||||||
const ShaderDescriptorList * GetDescriptorList ()const {return descriptor_list;}
|
|
||||||
ShaderDescriptorList * GetDescriptorList (VkDescriptorType desc_type)
|
|
||||||
{
|
|
||||||
if(desc_type<VK_DESCRIPTOR_TYPE_BEGIN_RANGE
|
|
||||||
||desc_type>VK_DESCRIPTOR_TYPE_END_RANGE)return nullptr;
|
|
||||||
|
|
||||||
return descriptor_list+desc_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
//ShaderDescriptorList &GetUBO (){return descriptor_list[VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER];}
|
|
||||||
//ShaderDescriptorList &GetSSBO (){return descriptor_list[VK_DESCRIPTOR_TYPE_STORAGE_BUFFER];}
|
|
||||||
//ShaderDescriptorList &GetUBODynamic (){return descriptor_list[VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC];}
|
|
||||||
//ShaderDescriptorList &GetSSBODynamic(){return descriptor_list[VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC];}
|
|
||||||
//ShaderDescriptorList &GetSampler (){return descriptor_list[VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER];}
|
|
||||||
|
|
||||||
|
|
||||||
const int GetBinding(const VkDescriptorType &desc_type,const AnsiString &name)const;
|
const int GetBinding(const VkDescriptorType &desc_type,const AnsiString &name)const;
|
||||||
|
|
||||||
const int GetUBO(const AnsiString &name)const{return GetBinding(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,name);}
|
const int GetUBO (const AnsiString &name)const{return GetBinding(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, name);}
|
||||||
const int GetSSBO(const AnsiString &name)const{return GetBinding(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,name);}
|
const int GetSSBO (const AnsiString &name)const{return GetBinding(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, name);}
|
||||||
const int GetSampler(const AnsiString &name)const{return GetBinding(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,name);}
|
const int GetSampler(const AnsiString &name)const{return GetBinding(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, name);}
|
||||||
|
|
||||||
const int *GetBindingList(const VkDescriptorType &desc_type)const
|
const int GetBindingCount (const DescriptorSetType &type)const{return sds[(size_t)type].count;}
|
||||||
{
|
const VkDescriptorSetLayoutBinding *GetBindingList (const DescriptorSetType &type)const{return sds[(size_t)type].binding_list;}
|
||||||
if(desc_type<VK_DESCRIPTOR_TYPE_BEGIN_RANGE
|
|
||||||
||desc_type>VK_DESCRIPTOR_TYPE_END_RANGE)return nullptr;
|
|
||||||
|
|
||||||
return binding_list[(size_t)desc_type];
|
|
||||||
}
|
|
||||||
|
|
||||||
const int GetSetBindingCount(const DescriptorSetType &type)const{return sds[(size_t)type].count;}
|
|
||||||
const VkDescriptorSetLayoutBinding *GetSetBindingList(const DescriptorSetType &type)const{return sds[(size_t)type].binding_list;}
|
|
||||||
};//class MaterialDescriptorSets
|
};//class MaterialDescriptorSets
|
||||||
VK_NAMESPACE_END
|
VK_NAMESPACE_END
|
||||||
#endif//HGL_GRAPH_VULKAN_MATERIAL_DESCRIPTOR_SETS_INCLUDE
|
#endif//HGL_GRAPH_VULKAN_MATERIAL_DESCRIPTOR_SETS_INCLUDE
|
||||||
|
@ -12,7 +12,7 @@ class MaterialInstance
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
friend class Material;
|
friend class GPUDevice;
|
||||||
|
|
||||||
MaterialInstance(Material *,MaterialParameters *);
|
MaterialInstance(Material *,MaterialParameters *);
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ class MaterialParameters
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
friend class Material;
|
friend class GPUDevice;
|
||||||
|
|
||||||
MaterialParameters(const MaterialDescriptorSets *,const DescriptorSetType &type,DescriptorSets *);
|
MaterialParameters(const MaterialDescriptorSets *,const DescriptorSetType &type,DescriptorSets *);
|
||||||
|
|
||||||
|
@ -136,8 +136,8 @@ SOURCE_GROUP("Vulkan\\Device\\Memory" FILES ${VK_MEMORY_SOURCE})
|
|||||||
|
|
||||||
SET(VK_DESCRIPTOR_SETS_SOURCE ${SG_INCLUDE_PATH}/VKDescriptorSets.h
|
SET(VK_DESCRIPTOR_SETS_SOURCE ${SG_INCLUDE_PATH}/VKDescriptorSets.h
|
||||||
Vulkan/VKDescriptorSets.cpp
|
Vulkan/VKDescriptorSets.cpp
|
||||||
Vulkan/VKDescriptorSetLayoutCreater.cpp
|
Vulkan/VKPipelineLayoutData.h
|
||||||
Vulkan/VKDescriptorSetLayoutCreater.h)
|
Vulkan/VKPipelineLayoutData.cpp)
|
||||||
|
|
||||||
SOURCE_GROUP("Vulkan\\Descriptor Sets" FILES ${VK_DESCRIPTOR_SETS_SOURCE})
|
SOURCE_GROUP("Vulkan\\Descriptor Sets" FILES ${VK_DESCRIPTOR_SETS_SOURCE})
|
||||||
|
|
||||||
|
@ -1,108 +0,0 @@
|
|||||||
#include"VKDescriptorSetLayoutCreater.h"
|
|
||||||
#include<hgl/graph/VKDescriptorSets.h>
|
|
||||||
#include<hgl/graph/VKDevice.h>
|
|
||||||
#include<hgl/graph/VKMaterialDescriptorSets.h>
|
|
||||||
|
|
||||||
VK_NAMESPACE_BEGIN
|
|
||||||
DescriptorSetLayoutCreater *GPUDevice::CreateDescriptorSetLayoutCreater(const MaterialDescriptorSets *mds)
|
|
||||||
{
|
|
||||||
return(new DescriptorSetLayoutCreater(attr->device,attr->desc_pool,mds));
|
|
||||||
}
|
|
||||||
|
|
||||||
DescriptorSetLayoutCreater::DescriptorSetLayoutCreater(VkDevice dev,VkDescriptorPool dp,const MaterialDescriptorSets *_mds)
|
|
||||||
{
|
|
||||||
hgl_zero(fin_dsl);
|
|
||||||
fin_dsl_count=0;
|
|
||||||
device=dev;
|
|
||||||
pool=dp;
|
|
||||||
mds=_mds;
|
|
||||||
|
|
||||||
ENUM_CLASS_FOR(DescriptorSetType,int,i)
|
|
||||||
layouts[i]=nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
DescriptorSetLayoutCreater::~DescriptorSetLayoutCreater()
|
|
||||||
{
|
|
||||||
if(pipeline_layout)
|
|
||||||
vkDestroyPipelineLayout(device,pipeline_layout,nullptr);
|
|
||||||
|
|
||||||
ENUM_CLASS_FOR(DescriptorSetType,int,i)
|
|
||||||
if(layouts[i])
|
|
||||||
vkDestroyDescriptorSetLayout(device,layouts[i],nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DescriptorSetLayoutCreater::CreatePipelineLayout()
|
|
||||||
{
|
|
||||||
fin_dsl_count=0;
|
|
||||||
|
|
||||||
ENUM_CLASS_FOR(DescriptorSetType,int,i)
|
|
||||||
{
|
|
||||||
const int count=mds->GetSetBindingCount((DescriptorSetType)i);
|
|
||||||
|
|
||||||
if(count<=0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
DescriptorSetLayoutCreateInfo descriptor_layout;
|
|
||||||
|
|
||||||
descriptor_layout.bindingCount = count;
|
|
||||||
descriptor_layout.pBindings = mds->GetSetBindingList((DescriptorSetType)i);
|
|
||||||
|
|
||||||
if(layouts[i])
|
|
||||||
vkDestroyDescriptorSetLayout(device,layouts[i],nullptr);
|
|
||||||
|
|
||||||
if(vkCreateDescriptorSetLayout(device,&descriptor_layout,nullptr,layouts+i)!=VK_SUCCESS)
|
|
||||||
return(false);
|
|
||||||
|
|
||||||
fin_dsl[fin_dsl_count]=layouts[i];
|
|
||||||
++fin_dsl_count;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(fin_dsl_count<=0)
|
|
||||||
return(false);
|
|
||||||
|
|
||||||
//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 = fin_dsl_count;
|
|
||||||
pPipelineLayoutCreateInfo.pSetLayouts = fin_dsl;
|
|
||||||
pPipelineLayoutCreateInfo.pushConstantRangeCount = 0;//1;
|
|
||||||
pPipelineLayoutCreateInfo.pPushConstantRanges = nullptr;//&push_constant_range;
|
|
||||||
|
|
||||||
if(vkCreatePipelineLayout(device,&pPipelineLayoutCreateInfo,nullptr,&pipeline_layout)!=VK_SUCCESS)
|
|
||||||
return(false);
|
|
||||||
|
|
||||||
return(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
DescriptorSets *DescriptorSetLayoutCreater::Create(const DescriptorSetType &type)const
|
|
||||||
{
|
|
||||||
if(!pipeline_layout)
|
|
||||||
return(nullptr);
|
|
||||||
|
|
||||||
ENUM_CLASS_RANGE_ERROR_RETURN_NULLPTR(DescriptorSetType,type);
|
|
||||||
|
|
||||||
const uint32_t count=mds->GetSetBindingCount(type);
|
|
||||||
|
|
||||||
if(!count)
|
|
||||||
return(nullptr);
|
|
||||||
|
|
||||||
DescriptorSetAllocateInfo alloc_info;
|
|
||||||
|
|
||||||
alloc_info.descriptorPool = pool;
|
|
||||||
alloc_info.descriptorSetCount = 1;
|
|
||||||
alloc_info.pSetLayouts = layouts+size_t(type);
|
|
||||||
|
|
||||||
VkDescriptorSet desc_set;
|
|
||||||
|
|
||||||
if(vkAllocateDescriptorSets(device,&alloc_info,&desc_set)!=VK_SUCCESS)
|
|
||||||
return(nullptr);
|
|
||||||
|
|
||||||
return(new DescriptorSets(device,count,pipeline_layout,desc_set));//,bm));
|
|
||||||
}
|
|
||||||
VK_NAMESPACE_END
|
|
||||||
|
|
@ -1,59 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include<hgl/graph/VK.h>
|
|
||||||
#include<hgl/graph/VKShaderResource.h>
|
|
||||||
#include<hgl/type/Map.h>
|
|
||||||
#include<hgl/type/Sets.h>
|
|
||||||
VK_NAMESPACE_BEGIN
|
|
||||||
class DescriptorSets;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 描述符合集创造器
|
|
||||||
*/
|
|
||||||
class DescriptorSetLayoutCreater
|
|
||||||
{
|
|
||||||
VkDevice device;
|
|
||||||
VkDescriptorPool pool;
|
|
||||||
|
|
||||||
const MaterialDescriptorSets *mds;
|
|
||||||
|
|
||||||
VkDescriptorSetLayout layouts[size_t(DescriptorSetType::RANGE_SIZE)];
|
|
||||||
VkDescriptorSetLayout fin_dsl[size_t(DescriptorSetType::RANGE_SIZE)];
|
|
||||||
uint32_t fin_dsl_count;
|
|
||||||
|
|
||||||
VkPipelineLayout pipeline_layout=VK_NULL_HANDLE;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
DescriptorSetLayoutCreater(VkDevice,VkDescriptorPool,const MaterialDescriptorSets *);
|
|
||||||
~DescriptorSetLayoutCreater();
|
|
||||||
|
|
||||||
//以下代码不再需要,使用一个void Bind(const ShaderResource &sr,VkShaderStageFlagBits stage)即可全部替代,而且更方便,但以此为提示
|
|
||||||
//
|
|
||||||
//#define DESC_SET_BIND_FUNC(name,vkname) void Bind##name(const uint32_t binding,VkShaderStageFlagBits stage_flag){Bind(binding,VK_DESCRIPTOR_TYPE_##vkname,stage_flag);} \
|
|
||||||
// void Bind##name(const uint32_t *binding,const uint32_t count,VkShaderStageFlagBits stage_flag){Bind(binding,count,VK_DESCRIPTOR_TYPE_##vkname,stage_flag);}
|
|
||||||
//
|
|
||||||
// DESC_SET_BIND_FUNC(Sampler, SAMPLER);
|
|
||||||
//
|
|
||||||
// DESC_SET_BIND_FUNC(CombinedImageSampler, COMBINED_IMAGE_SAMPLER);
|
|
||||||
// DESC_SET_BIND_FUNC(SampledImage, SAMPLED_IMAGE);
|
|
||||||
// DESC_SET_BIND_FUNC(StorageImage, STORAGE_IMAGE);
|
|
||||||
//
|
|
||||||
// DESC_SET_BIND_FUNC(UTBO, UNIFORM_TEXEL_BUFFER);
|
|
||||||
// DESC_SET_BIND_FUNC(SSTBO, STORAGE_TEXEL_BUFFER);
|
|
||||||
// DESC_SET_BIND_FUNC(UBO, UNIFORM_BUFFER);
|
|
||||||
// DESC_SET_BIND_FUNC(SSBO, STORAGE_BUFFER);
|
|
||||||
// DESC_SET_BIND_FUNC(UBODynamic, UNIFORM_BUFFER_DYNAMIC);
|
|
||||||
// DESC_SET_BIND_FUNC(SSBODynamic, STORAGE_BUFFER_DYNAMIC);
|
|
||||||
//
|
|
||||||
// DESC_SET_BIND_FUNC(InputAttachment, INPUT_ATTACHMENT);
|
|
||||||
//
|
|
||||||
//#undef DESC_SET_BIND_FUNC
|
|
||||||
|
|
||||||
bool CreatePipelineLayout();
|
|
||||||
|
|
||||||
const VkPipelineLayout GetPipelineLayout()const{return pipeline_layout;}
|
|
||||||
|
|
||||||
DescriptorSets *Create(const DescriptorSetType &type)const;
|
|
||||||
};//class DescriptorSetLayoutCreater
|
|
||||||
VK_NAMESPACE_END
|
|
@ -110,7 +110,7 @@ GPUFence *GPUDevice::CreateFence(bool create_signaled)
|
|||||||
return(new GPUFence(attr->device,fence));
|
return(new GPUFence(attr->device,fence));
|
||||||
}
|
}
|
||||||
|
|
||||||
GPUSemaphore *GPUDevice::CreateSemaphore()
|
GPUSemaphore *GPUDevice::CreateGPUSemaphore()
|
||||||
{
|
{
|
||||||
SemaphoreCreateInfo SemaphoreCreateInfo;
|
SemaphoreCreateInfo SemaphoreCreateInfo;
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ VkImage GPUDevice::CreateImage(VkImageCreateInfo *ici)
|
|||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPUDevice::DestoryImage(VkImage img)
|
void GPUDevice::DestroyImage(VkImage img)
|
||||||
{
|
{
|
||||||
if(img==VK_NULL_HANDLE)return;
|
if(img==VK_NULL_HANDLE)return;
|
||||||
|
|
||||||
|
@ -1,9 +1,76 @@
|
|||||||
#include<hgl/graph/VKDevice.h>
|
#include<hgl/graph/VKDevice.h>
|
||||||
#include<hgl/graph/VKMaterial.h>
|
#include<hgl/graph/VKMaterial.h>
|
||||||
#include<hgl/graph/VKMaterialDescriptorSets.h>
|
#include<hgl/graph/VKMaterialDescriptorSets.h>
|
||||||
#include"VKDescriptorSetLayoutCreater.h"
|
#include<hgl/graph/VKMaterialParameters.h>
|
||||||
|
#include<hgl/graph/VKDescriptorSets.h>
|
||||||
|
#include<hgl/graph/VKShaderModuleMap.h>
|
||||||
|
#include<hgl/graph/VKVertexAttributeBinding.h>
|
||||||
|
#include"VKPipelineLayoutData.h"
|
||||||
|
|
||||||
VK_NAMESPACE_BEGIN
|
VK_NAMESPACE_BEGIN
|
||||||
|
DescriptorSets *GPUDevice::CreateDescriptorSets(const PipelineLayoutData *pld,const DescriptorSetType &type)const
|
||||||
|
{
|
||||||
|
ENUM_CLASS_RANGE_ERROR_RETURN_NULLPTR(DescriptorSetType,type);
|
||||||
|
|
||||||
|
const uint32_t binding_count=pld->binding_count[size_t(type)];
|
||||||
|
|
||||||
|
if(!binding_count)
|
||||||
|
return(nullptr);
|
||||||
|
|
||||||
|
DescriptorSetAllocateInfo alloc_info;
|
||||||
|
|
||||||
|
alloc_info.descriptorPool = attr->desc_pool;
|
||||||
|
alloc_info.descriptorSetCount = 1;
|
||||||
|
alloc_info.pSetLayouts = pld->layouts+size_t(type);
|
||||||
|
|
||||||
|
VkDescriptorSet desc_set;
|
||||||
|
|
||||||
|
if(vkAllocateDescriptorSets(attr->device,&alloc_info,&desc_set)!=VK_SUCCESS)
|
||||||
|
return(nullptr);
|
||||||
|
|
||||||
|
return(new DescriptorSets(attr->device,binding_count,pld->pipeline_layout,desc_set));
|
||||||
|
}
|
||||||
|
|
||||||
|
MaterialParameters *GPUDevice::CreateMP(const MaterialDescriptorSets *mds,const PipelineLayoutData *pld,const DescriptorSetType &desc_set_type)
|
||||||
|
{
|
||||||
|
if(!mds||!pld)return(nullptr);
|
||||||
|
if(!RangeCheck<DescriptorSetType>(desc_set_type))
|
||||||
|
return(nullptr);
|
||||||
|
|
||||||
|
DescriptorSets *ds=CreateDescriptorSets(pld,desc_set_type);
|
||||||
|
|
||||||
|
if(!ds)return(nullptr);
|
||||||
|
|
||||||
|
return(new MaterialParameters(mds,desc_set_type,ds));
|
||||||
|
}
|
||||||
|
|
||||||
|
MaterialParameters *GPUDevice::CreateMP(Material *mtl,const DescriptorSetType &desc_set_type)
|
||||||
|
{
|
||||||
|
if(!mtl)return(nullptr);
|
||||||
|
|
||||||
|
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)->right;
|
||||||
|
hgl_cpy(p,sm->GetCreateInfo());
|
||||||
|
|
||||||
|
++p;
|
||||||
|
++itp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Material *GPUDevice::CreateMaterial(const UTF8String &mtl_name,ShaderModuleMap *shader_maps,MaterialDescriptorSets *mds)
|
Material *GPUDevice::CreateMaterial(const UTF8String &mtl_name,ShaderModuleMap *shader_maps,MaterialDescriptorSets *mds)
|
||||||
{
|
{
|
||||||
const int shader_count=shader_maps->GetCount();
|
const int shader_count=shader_maps->GetCount();
|
||||||
@ -11,21 +78,35 @@ Material *GPUDevice::CreateMaterial(const UTF8String &mtl_name,ShaderModuleMap *
|
|||||||
if(shader_count<2)
|
if(shader_count<2)
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
|
|
||||||
const ShaderModule *sm;
|
const ShaderModule *vsm;
|
||||||
|
|
||||||
if(!shader_maps->Get(VK_SHADER_STAGE_VERTEX_BIT,sm))
|
if(!shader_maps->Get(VK_SHADER_STAGE_VERTEX_BIT,vsm))
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
|
|
||||||
DescriptorSetLayoutCreater *dsl_creater=CreateDescriptorSetLayoutCreater(mds);
|
PipelineLayoutData *pld=CreatePipelineLayoutData(mds);
|
||||||
|
|
||||||
if(!dsl_creater->CreatePipelineLayout())
|
if(!pld)
|
||||||
{
|
{
|
||||||
delete shader_maps;
|
delete shader_maps;
|
||||||
SAFE_CLEAR(mds);
|
SAFE_CLEAR(mds);
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return(new Material(mtl_name,shader_maps,mds,dsl_creater));
|
MaterialData *data=new MaterialData;
|
||||||
|
|
||||||
|
data->name=mtl_name;
|
||||||
|
data->shader_maps=shader_maps;
|
||||||
|
data->mds=mds;
|
||||||
|
data->vertex_sm=(VertexShaderModule *)vsm;
|
||||||
|
data->vab=data->vertex_sm->CreateVertexAttributeBinding();
|
||||||
|
|
||||||
|
CreateShaderStageList(data->shader_stage_list,shader_maps);
|
||||||
|
data->pipeline_layout_data=pld;
|
||||||
|
data->mp.m=CreateMP(mds,pld,DescriptorSetType::Material );
|
||||||
|
data->mp.r=CreateMP(mds,pld,DescriptorSetType::Renderable );
|
||||||
|
data->mp.g=CreateMP(mds,pld,DescriptorSetType::Global );
|
||||||
|
|
||||||
|
return(new Material(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
Material *GPUDevice::CreateMaterial(const UTF8String &mtl_name,const VertexShaderModule *vertex_shader_module,const ShaderModule *fragment_shader_module,MaterialDescriptorSets *mds)
|
Material *GPUDevice::CreateMaterial(const UTF8String &mtl_name,const VertexShaderModule *vertex_shader_module,const ShaderModule *fragment_shader_module,MaterialDescriptorSets *mds)
|
||||||
@ -63,4 +144,4 @@ Material *GPUDevice::CreateMaterial(const UTF8String &mtl_name,const VertexShade
|
|||||||
|
|
||||||
return CreateMaterial(mtl_name,smm,mds);
|
return CreateMaterial(mtl_name,smm,mds);
|
||||||
}
|
}
|
||||||
VK_NAMESPACE_END
|
VK_NAMESPACE_END
|
||||||
|
@ -159,7 +159,7 @@ void GPUDevice::Clear(TextureCreateInfo *tci)
|
|||||||
{
|
{
|
||||||
if(!tci)return;
|
if(!tci)return;
|
||||||
|
|
||||||
if(tci->image)DestoryImage(tci->image);
|
if(tci->image)DestroyImage(tci->image);
|
||||||
if(tci->image_view)delete tci->image_view;
|
if(tci->image_view)delete tci->image_view;
|
||||||
if(tci->memory)delete tci->memory;
|
if(tci->memory)delete tci->memory;
|
||||||
|
|
||||||
|
@ -1,58 +1,13 @@
|
|||||||
#include<hgl/graph/VKMaterial.h>
|
#include<hgl/graph/VKMaterial.h>
|
||||||
#include<hgl/graph/VKMaterialParameters.h>
|
#include<hgl/graph/VKMaterialParameters.h>
|
||||||
#include<hgl/graph/VKMaterialDescriptorSets.h>
|
#include<hgl/graph/VKMaterialDescriptorSets.h>
|
||||||
#include"VKDescriptorSetLayoutCreater.h"
|
#include"VKPipelineLayoutData.h"
|
||||||
VK_NAMESPACE_BEGIN
|
VK_NAMESPACE_BEGIN
|
||||||
Material::Material(const UTF8String &name,ShaderModuleMap *smm,MaterialDescriptorSets *_mds,DescriptorSetLayoutCreater *dslc)
|
MaterialData::~MaterialData()
|
||||||
{
|
{
|
||||||
mtl_name=name;
|
SAFE_CLEAR(mp.m);
|
||||||
shader_maps=smm;
|
SAFE_CLEAR(mp.r);
|
||||||
mds=_mds;
|
SAFE_CLEAR(mp.g);
|
||||||
dsl_creater=dslc;
|
|
||||||
|
|
||||||
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)->right;
|
|
||||||
hgl_cpy(p,sm->GetCreateInfo());
|
|
||||||
|
|
||||||
++p;
|
|
||||||
++itp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(smm->Get(VK_SHADER_STAGE_VERTEX_BIT,sm))
|
|
||||||
{
|
|
||||||
vertex_sm=(VertexShaderModule *)sm;
|
|
||||||
vab=vertex_sm->CreateVertexAttributeBinding();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//理论上不可能到达这里,前面CreateMaterial已经检测过了
|
|
||||||
vertex_sm=nullptr;
|
|
||||||
vab=nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
mp_m=CreateMP(DescriptorSetType::Material);
|
|
||||||
mp_r=CreateMP(DescriptorSetType::Renderable);
|
|
||||||
mp_g=CreateMP(DescriptorSetType::Global);
|
|
||||||
}
|
|
||||||
|
|
||||||
Material::~Material()
|
|
||||||
{
|
|
||||||
SAFE_CLEAR(mp_m);
|
|
||||||
SAFE_CLEAR(mp_r);
|
|
||||||
SAFE_CLEAR(mp_g);
|
|
||||||
|
|
||||||
delete dsl_creater;
|
|
||||||
|
|
||||||
if(vab)
|
if(vab)
|
||||||
{
|
{
|
||||||
@ -64,17 +19,14 @@ Material::~Material()
|
|||||||
SAFE_CLEAR(mds);
|
SAFE_CLEAR(mds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Material::~Material()
|
||||||
|
{
|
||||||
|
delete data->pipeline_layout_data;
|
||||||
|
delete data;
|
||||||
|
}
|
||||||
|
|
||||||
const VkPipelineLayout Material::GetPipelineLayout()const
|
const VkPipelineLayout Material::GetPipelineLayout()const
|
||||||
{
|
{
|
||||||
return dsl_creater->GetPipelineLayout();
|
return data->pipeline_layout_data->pipeline_layout;
|
||||||
}
|
|
||||||
|
|
||||||
MaterialParameters *Material::CreateMP(const DescriptorSetType &type)const
|
|
||||||
{
|
|
||||||
DescriptorSets *ds=dsl_creater->Create(type);
|
|
||||||
|
|
||||||
if(!ds)return(nullptr);
|
|
||||||
|
|
||||||
return(new MaterialParameters(mds,type,ds));
|
|
||||||
}
|
}
|
||||||
VK_NAMESPACE_END
|
VK_NAMESPACE_END
|
||||||
|
@ -19,7 +19,7 @@ MaterialDescriptorSets::MaterialDescriptorSets(ShaderDescriptor *sd,const uint c
|
|||||||
if(sd_count<=0)return;
|
if(sd_count<=0)return;
|
||||||
|
|
||||||
{
|
{
|
||||||
hgl_zero(sds);
|
hgl_zero(sds,size_t(DescriptorSetType::RANGE_SIZE));
|
||||||
|
|
||||||
{
|
{
|
||||||
ShaderDescriptor *sp=sd_list;
|
ShaderDescriptor *sp=sd_list;
|
||||||
@ -78,6 +78,8 @@ MaterialDescriptorSets::MaterialDescriptorSets(ShaderDescriptor *sd,const uint c
|
|||||||
{
|
{
|
||||||
binding_list[i]=nullptr;
|
binding_list[i]=nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
++sdl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,16 @@
|
|||||||
|
#include<hgl/graph/VKDevice.h>
|
||||||
#include<hgl/graph/VKMaterialInstance.h>
|
#include<hgl/graph/VKMaterialInstance.h>
|
||||||
#include<hgl/graph/VKMaterial.h>
|
#include<hgl/graph/VKMaterial.h>
|
||||||
#include<hgl/graph/VKMaterialParameters.h>
|
#include<hgl/graph/VKMaterialParameters.h>
|
||||||
|
|
||||||
VK_NAMESPACE_BEGIN
|
VK_NAMESPACE_BEGIN
|
||||||
MaterialInstance *Material::CreateInstance()
|
MaterialInstance *GPUDevice::CreateMI(Material *mtl)
|
||||||
{
|
{
|
||||||
MaterialParameters *mp=CreateMP(DescriptorSetType::Value);
|
if(!mtl)return(nullptr);
|
||||||
|
|
||||||
return(new MaterialInstance(this,mp));
|
MaterialParameters *mp=CreateMP(mtl,DescriptorSetType::Value);
|
||||||
|
|
||||||
|
return(new MaterialInstance(mtl,mp));
|
||||||
}
|
}
|
||||||
|
|
||||||
MaterialInstance::MaterialInstance(Material *mtl,MaterialParameters *p)
|
MaterialInstance::MaterialInstance(Material *mtl,MaterialParameters *p)
|
||||||
|
77
src/SceneGraph/Vulkan/VKPipelineLayoutData.cpp
Normal file
77
src/SceneGraph/Vulkan/VKPipelineLayoutData.cpp
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
#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
|
||||||
|
|
24
src/SceneGraph/Vulkan/VKPipelineLayoutData.h
Normal file
24
src/SceneGraph/Vulkan/VKPipelineLayoutData.h
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include<hgl/graph/VK.h>
|
||||||
|
#include<hgl/graph/VKShaderResource.h>
|
||||||
|
#include<hgl/type/Map.h>
|
||||||
|
#include<hgl/type/Sets.h>
|
||||||
|
VK_NAMESPACE_BEGIN
|
||||||
|
struct PipelineLayoutData
|
||||||
|
{
|
||||||
|
VkDevice device;
|
||||||
|
|
||||||
|
int binding_count[size_t(DescriptorSetType::RANGE_SIZE)];
|
||||||
|
VkDescriptorSetLayout layouts[size_t(DescriptorSetType::RANGE_SIZE)];
|
||||||
|
|
||||||
|
VkDescriptorSetLayout fin_dsl[size_t(DescriptorSetType::RANGE_SIZE)];
|
||||||
|
uint32_t fin_dsl_count;
|
||||||
|
|
||||||
|
VkPipelineLayout pipeline_layout;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
~PipelineLayoutData();
|
||||||
|
};//class PipelineLayoutData
|
||||||
|
VK_NAMESPACE_END
|
@ -54,7 +54,7 @@ MaterialInstance *RenderResource::CreateMaterialInstance(Material *mtl)
|
|||||||
{
|
{
|
||||||
if(!mtl)return(nullptr);
|
if(!mtl)return(nullptr);
|
||||||
|
|
||||||
MaterialInstance *mi=mtl->CreateInstance();
|
MaterialInstance *mi=device->CreateMI(mtl);
|
||||||
|
|
||||||
if(mi)
|
if(mi)
|
||||||
Add(mi);
|
Add(mi);
|
||||||
|
@ -145,7 +145,7 @@ Material *RenderResource::CreateMaterial(const OSString &filename)
|
|||||||
{
|
{
|
||||||
ShaderDescriptor *sd_list=hgl_zero_new<ShaderDescriptor>(count);
|
ShaderDescriptor *sd_list=hgl_zero_new<ShaderDescriptor>(count);
|
||||||
|
|
||||||
LoadShaderDescriptor(filedata,sd_list,count);
|
LoadShaderDescriptor(sp,sd_list,count);
|
||||||
|
|
||||||
mds=new MaterialDescriptorSets(sd_list,count);
|
mds=new MaterialDescriptorSets(sd_list,count);
|
||||||
}
|
}
|
||||||
@ -158,6 +158,7 @@ Material *RenderResource::CreateMaterial(const OSString &filename)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
SAFE_CLEAR(mds);
|
||||||
delete smm;
|
delete smm;
|
||||||
mtl=nullptr;
|
mtl=nullptr;
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ RenderTarget::RenderTarget(GPUDevice *dev,Framebuffer *_fb,const uint32_t fence_
|
|||||||
|
|
||||||
color_textures=nullptr;
|
color_textures=nullptr;
|
||||||
depth_texture=nullptr;
|
depth_texture=nullptr;
|
||||||
render_complete_semaphore=dev->CreateSemaphore();
|
render_complete_semaphore=dev->CreateGPUSemaphore();
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderTarget::RenderTarget(GPUDevice *dev,RenderPass *_rp,Framebuffer *_fb,Texture2D **ctl,const uint32_t cc,Texture2D *dt,const uint32_t fence_count):GPUQueue(dev,dev->GetGraphicsQueue(),fence_count)
|
RenderTarget::RenderTarget(GPUDevice *dev,RenderPass *_rp,Framebuffer *_fb,Texture2D **ctl,const uint32_t cc,Texture2D *dt,const uint32_t fence_count):GPUQueue(dev,dev->GetGraphicsQueue(),fence_count)
|
||||||
@ -48,7 +48,7 @@ RenderTarget::RenderTarget(GPUDevice *dev,RenderPass *_rp,Framebuffer *_fb,Textu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render_complete_semaphore=dev->CreateSemaphore();
|
render_complete_semaphore=dev->CreateGPUSemaphore();
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderTarget::~RenderTarget()
|
RenderTarget::~RenderTarget()
|
||||||
|
@ -35,7 +35,7 @@ SwapchainRenderTarget::SwapchainRenderTarget(GPUDevice *dev,Swapchain *sc):Rende
|
|||||||
|
|
||||||
current_frame=0;
|
current_frame=0;
|
||||||
|
|
||||||
present_complete_semaphore=dev->CreateSemaphore();
|
present_complete_semaphore=dev->CreateGPUSemaphore();
|
||||||
}
|
}
|
||||||
|
|
||||||
SwapchainRenderTarget::~SwapchainRenderTarget()
|
SwapchainRenderTarget::~SwapchainRenderTarget()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user