ULRE/inc/hgl/graph/vulkan/VKShaderModule.h

93 lines
3.2 KiB
C
Raw Normal View History

#ifndef HGL_GRAPH_VULKAN_SHADER_MODULE_INCLUDE
#define HGL_GRAPH_VULKAN_SHADER_MODULE_INCLUDE
2020-06-09 19:40:08 +08:00
#include<hgl/graph/shader/ShaderResource.h>
#include<hgl/type/Set.h>
VK_NAMESPACE_BEGIN
/**
* Shader模块<br>
* shader数据和信息ShaderModuleManage创建和删除
*/
class ShaderModule
{
VkDevice device;
int shader_id;
int ref_count;
private:
VkPipelineShaderStageCreateInfo *stage_create_info;
2020-06-09 19:40:08 +08:00
protected:
ShaderResource *shader_resource;
public:
2020-06-09 19:40:08 +08:00
ShaderModule(VkDevice dev,int id,VkPipelineShaderStageCreateInfo *pssci,ShaderResource *);
virtual ~ShaderModule();
const int GetID()const{return shader_id;}
const int IncRef(){return ++ref_count;}
const int DecRef(){return --ref_count;}
public:
const VkShaderStageFlagBits GetStage ()const{return stage_create_info->stage;}
const VkPipelineShaderStageCreateInfo * GetCreateInfo ()const{return stage_create_info;}
2020-07-07 19:16:23 +08:00
const int GetBinding (VkDescriptorType desc_type,const AnsiString &name)const
{
2020-06-09 19:40:08 +08:00
return shader_resource->GetBinding(desc_type,name);
}
2020-06-09 19:40:08 +08:00
const ShaderDescriptorList * GetDescriptorList()const{return shader_resource->GetDescriptorList();}
};//class ShaderModule
class VertexAttributeBinding;
/**
* Shader模块<br>
* shader在最前方执行shader多了VertexInput的数据
*/
class VertexShaderModule:public ShaderModule
{
uint32_t attr_count;
VkVertexInputBindingDescription *binding_list;
VkVertexInputAttributeDescription *attribute_list;
private:
Set<VertexAttributeBinding *> vab_sets;
public:
2020-06-09 19:40:08 +08:00
VertexShaderModule(VkDevice dev,int id,VkPipelineShaderStageCreateInfo *pssci,ShaderResource *sr);
virtual ~VertexShaderModule();
/**
* binding并非是shader中的binding/locationvkCmdBindVertexBuffer的缓冲区序列号
*/
2020-07-07 19:16:23 +08:00
const int GetStageInputBinding(const AnsiString &name)const{return shader_resource->GetStageInputBinding(name);}
2020-07-09 20:37:34 +08:00
const ShaderStage * GetStage(const AnsiString &name)const{return shader_resource->GetStage(name);}
const uint32_t GetAttrCount()const{return attr_count;}
const VkVertexInputBindingDescription * GetDescList ()const{return binding_list;}
const VkVertexInputAttributeDescription * GetAttrList ()const{return attribute_list;}
const VkVertexInputBindingDescription * GetDesc (const uint32_t index)const{return (index>=attr_count?nullptr:binding_list+index);}
const VkVertexInputAttributeDescription * GetAttr (const uint32_t index)const{return (index>=attr_count?nullptr:attribute_list+index);}
public:
VertexAttributeBinding * CreateVertexAttributeBinding();
bool Release(VertexAttributeBinding *);
const uint32_t GetInstanceCount()const{return vab_sets.GetCount();}
};//class VertexShaderModule:public ShaderModule
VK_NAMESPACE_END
#endif//HGL_GRAPH_VULKAN_SHADER_MODULE_INCLUDE