2019-04-25 10:09:56 +08:00
|
|
|
|
#ifndef HGL_GRAPH_VULKAN_MATERIAL_INCLUDE
|
|
|
|
|
#define HGL_GRAPH_VULKAN_MATERIAL_INCLUDE
|
|
|
|
|
|
|
|
|
|
#include"VK.h"
|
2019-04-28 16:06:53 +08:00
|
|
|
|
#include<hgl/type/Map.h>
|
|
|
|
|
#include<hgl/type/BaseString.h>
|
2019-04-25 10:09:56 +08:00
|
|
|
|
VK_NAMESPACE_BEGIN
|
2019-04-27 01:36:58 +08:00
|
|
|
|
class Device;
|
2019-04-28 16:06:53 +08:00
|
|
|
|
class ShaderModule;
|
|
|
|
|
class VertexShaderModule;
|
2019-04-25 10:09:56 +08:00
|
|
|
|
class DescriptorSetLayoutCreater;
|
2019-04-27 02:07:06 +08:00
|
|
|
|
class DescriptorSetLayout;
|
2019-04-26 22:34:51 +08:00
|
|
|
|
class VertexAttributeBinding;
|
2019-04-28 17:02:38 +08:00
|
|
|
|
class VertexBuffer;
|
|
|
|
|
class Renderable;
|
2019-04-28 17:47:58 +08:00
|
|
|
|
class PipelineLayout;
|
2019-04-28 16:06:53 +08:00
|
|
|
|
|
|
|
|
|
using ShaderModuleMap=hgl::Map<VkShaderStageFlagBits,const ShaderModule *>;
|
2019-04-25 10:09:56 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 材质类<br>
|
|
|
|
|
* 用于管理shader,提供DescriptorSetLayoutCreater
|
|
|
|
|
*/
|
|
|
|
|
class Material
|
|
|
|
|
{
|
2019-04-28 16:06:53 +08:00
|
|
|
|
VkDevice device;
|
|
|
|
|
ShaderModuleMap *shader_maps;
|
|
|
|
|
VertexShaderModule *vertex_sm;
|
2019-04-28 21:25:52 +08:00
|
|
|
|
List<VkPipelineShaderStageCreateInfo> *shader_stage_list;
|
2019-04-27 02:07:06 +08:00
|
|
|
|
DescriptorSetLayoutCreater *dsl_creater;
|
2019-04-28 21:25:52 +08:00
|
|
|
|
DescriptorSetLayout *desc_set_layout;
|
|
|
|
|
VkPipelineLayout pipeline_layout;
|
|
|
|
|
VertexAttributeBinding *vab;
|
2019-04-25 10:09:56 +08:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2019-04-28 21:25:52 +08:00
|
|
|
|
Material(Device *dev,ShaderModuleMap *smm,VertexShaderModule *vsm,List<VkPipelineShaderStageCreateInfo> *,DescriptorSetLayoutCreater *dslc,DescriptorSetLayout *dsl,VkPipelineLayout pl,VertexAttributeBinding *v);
|
2019-04-25 10:09:56 +08:00
|
|
|
|
~Material();
|
|
|
|
|
|
2019-04-28 16:06:53 +08:00
|
|
|
|
const int GetUBOBinding(const UTF8String &)const;
|
2019-04-28 17:02:38 +08:00
|
|
|
|
const int GetVBOBinding(const UTF8String &)const;
|
2019-04-28 16:06:53 +08:00
|
|
|
|
|
2019-04-28 21:25:52 +08:00
|
|
|
|
const VkPipelineLayout GetPipelineLayout ()const{return pipeline_layout;}
|
|
|
|
|
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
|
|
|
|
|
2019-04-28 21:25:52 +08:00
|
|
|
|
const uint32_t GetDescriptorSetCount ()const;
|
|
|
|
|
const VkDescriptorSet * GetDescriptorSets ()const;
|
2019-04-28 16:06:53 +08:00
|
|
|
|
|
|
|
|
|
bool UpdateUBO(const uint32_t binding,const VkDescriptorBufferInfo *buf_info);
|
|
|
|
|
bool UpdateUBO(const UTF8String &name,const VkDescriptorBufferInfo *buf_info)
|
|
|
|
|
{
|
|
|
|
|
if(name.IsEmpty()||!buf_info)
|
|
|
|
|
return(false);
|
|
|
|
|
|
2019-04-28 21:25:52 +08:00
|
|
|
|
return UpdateUBO(GetUBOBinding(name),buf_info);
|
2019-04-28 16:06:53 +08:00
|
|
|
|
}
|
2019-04-28 17:02:38 +08:00
|
|
|
|
|
2019-04-28 16:06:53 +08:00
|
|
|
|
void Write(VkPipelineVertexInputStateCreateInfo &vis)const;
|
|
|
|
|
|
2019-04-28 17:02:38 +08:00
|
|
|
|
Renderable *CreateRenderable();
|
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
|