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
|
2020-01-20 15:39:39 +08:00
|
|
|
|
class DescriptorSetLayoutCreater;
|
2019-04-25 10:09:56 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 材质类<br>
|
|
|
|
|
* 用于管理shader,提供DescriptorSetLayoutCreater
|
|
|
|
|
*/
|
|
|
|
|
class Material
|
|
|
|
|
{
|
2021-05-10 15:19:16 +08:00
|
|
|
|
UTF8String mtl_name;
|
|
|
|
|
|
2019-04-28 16:06:53 +08:00
|
|
|
|
ShaderModuleMap *shader_maps;
|
|
|
|
|
VertexShaderModule *vertex_sm;
|
2019-04-28 21:25:52 +08:00
|
|
|
|
List<VkPipelineShaderStageCreateInfo> *shader_stage_list;
|
2019-05-05 21:30:55 +08:00
|
|
|
|
|
2019-04-27 02:07:06 +08:00
|
|
|
|
DescriptorSetLayoutCreater *dsl_creater;
|
2019-05-05 21:30:55 +08:00
|
|
|
|
|
2021-06-15 21:20:57 +08:00
|
|
|
|
DescriptorSets *g_desc_sets;
|
|
|
|
|
DescriptorSets *ri_desc_sets;
|
|
|
|
|
|
2019-04-28 21:25:52 +08:00
|
|
|
|
VertexAttributeBinding *vab;
|
2019-04-25 10:09:56 +08:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2021-05-10 15:19:16 +08:00
|
|
|
|
Material(const UTF8String &name,ShaderModuleMap *smm,List<VkPipelineShaderStageCreateInfo> *,DescriptorSetLayoutCreater *dslc);
|
2019-04-25 10:09:56 +08:00
|
|
|
|
~Material();
|
|
|
|
|
|
2021-05-10 15:19:16 +08:00
|
|
|
|
const UTF8String & GetName()const{return mtl_name;}
|
|
|
|
|
|
|
|
|
|
const VertexShaderModule * GetVertexShaderModule()const{return vertex_sm;}
|
2019-05-22 18:10:13 +08:00
|
|
|
|
|
2021-05-10 15:19:16 +08:00
|
|
|
|
const int GetBinding(VkDescriptorType,const AnsiString &)const;
|
2019-05-06 22:33:21 +08:00
|
|
|
|
|
2020-07-07 19:16:23 +08:00
|
|
|
|
#define GET_BO_BINDING(name,vk_name) const int Get##name(const AnsiString &obj_name)const{return GetBinding(VK_DESCRIPTOR_TYPE_##vk_name,obj_name);}
|
2019-05-21 00:11:50 +08:00
|
|
|
|
// GET_BO_BINDING(Sampler, SAMPLER)
|
2019-05-06 22:33:21 +08:00
|
|
|
|
|
2019-05-21 00:11:50 +08:00
|
|
|
|
GET_BO_BINDING(Sampler, COMBINED_IMAGE_SAMPLER)
|
|
|
|
|
// GET_BO_BINDING(SampledImage, SAMPLED_IMAGE)
|
2019-05-06 22:33:21 +08:00
|
|
|
|
GET_BO_BINDING(StorageImage, STORAGE_IMAGE)
|
|
|
|
|
|
|
|
|
|
GET_BO_BINDING(UTBO, UNIFORM_TEXEL_BUFFER)
|
|
|
|
|
GET_BO_BINDING(SSTBO, STORAGE_TEXEL_BUFFER)
|
|
|
|
|
GET_BO_BINDING(UBO, UNIFORM_BUFFER)
|
|
|
|
|
GET_BO_BINDING(SSBO, STORAGE_BUFFER)
|
2020-12-18 15:59:42 +08:00
|
|
|
|
|
|
|
|
|
//shader中并不区分普通UBO和动态UBO,所以Material/ShaderResource中的数据,只有UBO
|
|
|
|
|
|
|
|
|
|
// GET_BO_BINDING(UBODynamic, UNIFORM_BUFFER_DYNAMIC)
|
|
|
|
|
// GET_BO_BINDING(SSBODynamic, STORAGE_BUFFER_DYNAMIC)
|
2019-05-06 22:33:21 +08:00
|
|
|
|
|
|
|
|
|
GET_BO_BINDING(InputAttachment, INPUT_ATTACHMENT)
|
|
|
|
|
#undef GET_BO_BINDING
|
2019-04-28 16:06:53 +08:00
|
|
|
|
|
2020-09-20 03:15:50 +08:00
|
|
|
|
const uint32_t GetStageCount ()const{return shader_stage_list->GetCount();}
|
|
|
|
|
const VkPipelineShaderStageCreateInfo * GetStages ()const{return shader_stage_list->GetData();}
|
2019-04-28 16:06:53 +08:00
|
|
|
|
|
2020-09-20 03:15:50 +08:00
|
|
|
|
const VkPipelineLayout GetPipelineLayout ()const;
|
2021-06-15 21:20:57 +08:00
|
|
|
|
DescriptorSets * CreateMIDescriptorSets ()const;
|
|
|
|
|
|
|
|
|
|
DescriptorSets * GetGlobalDescriptorSets (){return g_desc_sets;}
|
|
|
|
|
DescriptorSets * GetRIDescriptorSets (){return ri_desc_sets;}
|
2020-09-20 03:15:50 +08:00
|
|
|
|
|
|
|
|
|
const VertexAttributeBinding * GetVAB ()const{return vab;}
|
|
|
|
|
const uint32_t GetVertexAttrCount ()const{return vab->GetVertexAttrCount();}
|
|
|
|
|
const VkVertexInputBindingDescription * GetVertexBindingList ()const{return vab->GetVertexBindingList();}
|
|
|
|
|
const VkVertexInputAttributeDescription * GetVertexAttributeList ()const{return vab->GetVertexAttributeList();}
|
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-06-16 10:41:04 +08:00
|
|
|
|
MaterialParameters * CreateInstance ();
|
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
|