2019-04-25 10:09:56 +08:00
|
|
|
|
#ifndef HGL_GRAPH_VULKAN_MATERIAL_INCLUDE
|
|
|
|
|
#define HGL_GRAPH_VULKAN_MATERIAL_INCLUDE
|
|
|
|
|
|
2020-10-21 11:43:18 +08:00
|
|
|
|
#include<hgl/graph/VK.h>
|
2019-04-28 16:06:53 +08:00
|
|
|
|
#include<hgl/type/Map.h>
|
2020-09-05 17:54:21 +08:00
|
|
|
|
#include<hgl/type/String.h>
|
2020-10-21 11:43:18 +08:00
|
|
|
|
#include<hgl/graph/VKShaderModuleMap.h>
|
|
|
|
|
#include<hgl/graph/VKVertexAttributeBinding.h>
|
2019-04-25 10:09:56 +08:00
|
|
|
|
VK_NAMESPACE_BEGIN
|
2021-09-14 20:31:15 +08:00
|
|
|
|
struct MaterialData
|
2019-04-25 10:09:56 +08:00
|
|
|
|
{
|
2021-09-14 20:31:15 +08:00
|
|
|
|
UTF8String name;
|
2021-05-10 15:19:16 +08:00
|
|
|
|
|
2019-04-28 16:06:53 +08:00
|
|
|
|
ShaderModuleMap *shader_maps;
|
2021-09-13 20:39:25 +08:00
|
|
|
|
MaterialDescriptorSets *mds;
|
|
|
|
|
|
2019-04-28 16:06:53 +08:00
|
|
|
|
VertexShaderModule *vertex_sm;
|
2021-09-14 20:31:15 +08:00
|
|
|
|
VertexAttributeBinding *vab;
|
|
|
|
|
|
2021-09-13 20:39:25 +08:00
|
|
|
|
List<VkPipelineShaderStageCreateInfo> shader_stage_list;
|
2019-05-05 21:30:55 +08:00
|
|
|
|
|
2021-09-14 20:31:15 +08:00
|
|
|
|
PipelineLayoutData *pipeline_layout_data;
|
2019-05-05 21:30:55 +08:00
|
|
|
|
|
2021-09-14 20:31:15 +08:00
|
|
|
|
struct
|
|
|
|
|
{
|
|
|
|
|
MaterialParameters *m,*g,*r;
|
|
|
|
|
}mp;
|
2021-06-15 21:20:57 +08:00
|
|
|
|
|
2021-09-14 20:31:15 +08:00
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
friend class Material;
|
|
|
|
|
|
|
|
|
|
~MaterialData();
|
|
|
|
|
};//struct MaterialData
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 材质类<br>
|
|
|
|
|
* 用于管理shader,提供DescriptorSetLayoutCreater
|
|
|
|
|
*/
|
|
|
|
|
class Material
|
|
|
|
|
{
|
|
|
|
|
MaterialData *data;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
friend GPUDevice;
|
|
|
|
|
|
|
|
|
|
MaterialData *GetMaterialData(){return data;}
|
2019-04-25 10:09:56 +08:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2021-09-14 20:31:15 +08:00
|
|
|
|
Material(MaterialData *md):data(md){}
|
2019-04-25 10:09:56 +08:00
|
|
|
|
~Material();
|
|
|
|
|
|
2021-09-14 20:31:15 +08:00
|
|
|
|
const UTF8String & GetName ()const{return data->name;}
|
2021-05-10 15:19:16 +08:00
|
|
|
|
|
2021-09-14 20:31:15 +08:00
|
|
|
|
const VertexShaderModule * GetVertexShaderModule ()const{return data->vertex_sm;}
|
2019-04-28 16:06:53 +08:00
|
|
|
|
|
2021-09-14 20:31:15 +08:00
|
|
|
|
const uint32_t GetStageCount ()const{return data->shader_stage_list.GetCount();}
|
|
|
|
|
const VkPipelineShaderStageCreateInfo * GetStages ()const{return data->shader_stage_list.GetData();}
|
2019-04-28 16:06:53 +08:00
|
|
|
|
|
2021-09-14 20:31:15 +08:00
|
|
|
|
const MaterialDescriptorSets * GetDescriptorSets ()const{return data->mds;}
|
2020-09-20 03:15:50 +08:00
|
|
|
|
const VkPipelineLayout GetPipelineLayout ()const;
|
2021-09-14 20:31:15 +08:00
|
|
|
|
const PipelineLayoutData * GetPipelineLayoutData ()const{return data->pipeline_layout_data;}
|
2021-06-16 11:43:19 +08:00
|
|
|
|
|
2021-09-14 20:31:15 +08:00
|
|
|
|
const VertexAttributeBinding * GetVAB ()const{return data->vab;}
|
2019-04-28 17:02:38 +08:00
|
|
|
|
|
2020-09-20 03:15:50 +08:00
|
|
|
|
public:
|
2019-04-28 16:06:53 +08:00
|
|
|
|
|
2021-09-27 21:20:22 +08:00
|
|
|
|
MaterialParameters * GetMP (const DescriptorSetsType &type)
|
2021-06-16 11:43:19 +08:00
|
|
|
|
{
|
2021-09-27 21:20:22 +08:00
|
|
|
|
if(type==DescriptorSetsType::Material )return data->mp.m;else
|
|
|
|
|
if(type==DescriptorSetsType::Renderable )return data->mp.r;else
|
|
|
|
|
if(type==DescriptorSetsType::Global )return data->mp.g;else
|
2021-06-16 11:43:19 +08:00
|
|
|
|
return(nullptr);
|
|
|
|
|
}
|
2019-04-28 21:25:52 +08:00
|
|
|
|
};//class Material
|
2019-04-25 10:09:56 +08:00
|
|
|
|
VK_NAMESPACE_END
|
|
|
|
|
#endif//HGL_GRAPH_VULKAN_MATERIAL_INCLUDE
|