2019-05-06 21:01:28 +08:00
|
|
|
|
#ifndef HGL_GRAPH_VULKAN_SHADER_MODULE_INCLUDE
|
2019-04-27 21:23:57 +08:00
|
|
|
|
#define HGL_GRAPH_VULKAN_SHADER_MODULE_INCLUDE
|
|
|
|
|
|
2021-09-13 20:39:25 +08:00
|
|
|
|
#include<hgl/graph/VKShaderResource.h>
|
2022-02-08 11:12:17 +08:00
|
|
|
|
#include<hgl/type/SortedSets.h>
|
2019-04-28 16:06:53 +08:00
|
|
|
|
|
2019-04-27 21:23:57 +08:00
|
|
|
|
VK_NAMESPACE_BEGIN
|
2019-04-28 16:06:53 +08:00
|
|
|
|
|
2019-04-27 21:23:57 +08:00
|
|
|
|
/**
|
2019-05-06 21:01:28 +08:00
|
|
|
|
* Shader模块<br>
|
|
|
|
|
* 该模块提供的是原始的shader数据和信息,不可被修改,只能通过ShaderModuleManage创建和删除
|
2019-04-27 21:23:57 +08:00
|
|
|
|
*/
|
|
|
|
|
class ShaderModule
|
|
|
|
|
{
|
2019-05-05 21:30:55 +08:00
|
|
|
|
VkDevice device;
|
2019-04-27 21:23:57 +08:00
|
|
|
|
int ref_count;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
VkPipelineShaderStageCreateInfo *stage_create_info;
|
|
|
|
|
|
2020-06-09 19:40:08 +08:00
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
ShaderResource *shader_resource;
|
2019-04-27 21:23:57 +08:00
|
|
|
|
|
|
|
|
|
public:
|
2019-05-05 14:22:58 +08:00
|
|
|
|
|
2020-09-19 23:49:32 +08:00
|
|
|
|
ShaderModule(VkDevice dev,VkPipelineShaderStageCreateInfo *pssci,ShaderResource *);
|
2019-04-28 16:06:53 +08:00
|
|
|
|
virtual ~ShaderModule();
|
2019-04-27 21:23:57 +08:00
|
|
|
|
|
|
|
|
|
const int IncRef(){return ++ref_count;}
|
|
|
|
|
const int DecRef(){return --ref_count;}
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
const VkShaderStageFlagBits GetStage ()const{return stage_create_info->stage;}
|
2020-09-05 18:36:18 +08:00
|
|
|
|
|
|
|
|
|
const bool IsVertex ()const{return stage_create_info->stage==VK_SHADER_STAGE_VERTEX_BIT;}
|
|
|
|
|
const bool IsTessControl ()const{return stage_create_info->stage==VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT;}
|
|
|
|
|
const bool IsTessEval ()const{return stage_create_info->stage==VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT;}
|
|
|
|
|
const bool IsGeometry ()const{return stage_create_info->stage==VK_SHADER_STAGE_GEOMETRY_BIT;}
|
|
|
|
|
const bool IsFragment ()const{return stage_create_info->stage==VK_SHADER_STAGE_FRAGMENT_BIT;}
|
|
|
|
|
const bool IsCompute ()const{return stage_create_info->stage==VK_SHADER_STAGE_COMPUTE_BIT;}
|
|
|
|
|
const bool IsTask ()const{return stage_create_info->stage==VK_SHADER_STAGE_TASK_BIT_NV;}
|
|
|
|
|
const bool IsMesh ()const{return stage_create_info->stage==VK_SHADER_STAGE_MESH_BIT_NV;}
|
|
|
|
|
|
2019-04-27 21:23:57 +08:00
|
|
|
|
const VkPipelineShaderStageCreateInfo * GetCreateInfo ()const{return stage_create_info;}
|
2022-09-29 18:29:21 +08:00
|
|
|
|
|
|
|
|
|
operator VkShaderModule ()const{return stage_create_info->module;}
|
2019-04-28 16:06:53 +08:00
|
|
|
|
};//class ShaderModule
|
|
|
|
|
|
|
|
|
|
/**
|
2019-05-06 21:01:28 +08:00
|
|
|
|
* 顶点Shader模块<br>
|
|
|
|
|
* 由于顶点shader在最前方执行,所以它比其它shader多了VertexInput的数据
|
2019-04-28 16:06:53 +08:00
|
|
|
|
*/
|
|
|
|
|
class VertexShaderModule:public ShaderModule
|
|
|
|
|
{
|
|
|
|
|
uint32_t attr_count;
|
2021-11-29 20:12:10 +08:00
|
|
|
|
VertexAttribType *type_list;
|
|
|
|
|
const AnsiString **name_list;
|
|
|
|
|
ShaderStage **ssi_list;
|
2019-04-28 16:06:53 +08:00
|
|
|
|
|
|
|
|
|
private:
|
2021-11-29 20:12:10 +08:00
|
|
|
|
|
2022-10-11 19:16:06 +08:00
|
|
|
|
SortedSets<VIL *> vil_sets;
|
2019-04-28 16:06:53 +08:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2020-09-19 23:49:32 +08:00
|
|
|
|
VertexShaderModule(VkDevice dev,VkPipelineShaderStageCreateInfo *pssci,ShaderResource *sr);
|
2019-04-28 16:06:53 +08:00
|
|
|
|
virtual ~VertexShaderModule();
|
2019-04-27 21:23:57 +08:00
|
|
|
|
|
2019-05-06 21:01:28 +08:00
|
|
|
|
/**
|
|
|
|
|
* 获取输入流绑定点,需要注意的时,这里获取的binding并非是shader中的binding/location,而是绑定顺序的序列号。对应vkCmdBindVertexBuffer的缓冲区序列号
|
|
|
|
|
*/
|
2020-07-07 19:16:23 +08:00
|
|
|
|
const int GetStageInputBinding(const AnsiString &name)const{return shader_resource->GetStageInputBinding(name);}
|
2020-08-04 01:27:35 +08:00
|
|
|
|
const ShaderStage * GetStageInput (const AnsiString &name)const{return shader_resource->GetStageInput(name);}
|
2020-09-21 19:05:25 +08:00
|
|
|
|
const uint GetStageInputCount () const{return shader_resource->GetStageInputCount();}
|
|
|
|
|
const ShaderStageList & GetStageInputs () const{return shader_resource->GetStageInputs();}
|
2019-04-27 21:23:57 +08:00
|
|
|
|
|
2021-11-29 20:12:10 +08:00
|
|
|
|
//const uint32_t GetAttrCount()const{return attr_count;}
|
2019-04-28 16:06:53 +08:00
|
|
|
|
|
2023-02-21 22:32:03 +08:00
|
|
|
|
//const VkVertexInputBindingDescription * GetBindList ()const{return binding_list;}
|
2021-11-29 20:12:10 +08:00
|
|
|
|
//const VkVertexInputAttributeDescription * GetAttrList ()const{return attribute_list;}
|
2019-04-27 21:23:57 +08:00
|
|
|
|
|
2023-02-21 22:32:03 +08:00
|
|
|
|
//const VkVertexInputBindingDescription * GetBind (const uint32_t index)const{return (index>=attr_count?nullptr:binding_list+index);}
|
2021-11-29 20:12:10 +08:00
|
|
|
|
//const VkVertexInputAttributeDescription * GetAttr (const uint32_t index)const{return (index>=attr_count?nullptr:attribute_list+index);}
|
2019-04-28 16:06:53 +08:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2022-10-11 19:16:06 +08:00
|
|
|
|
VIL * CreateVIL(const VILConfig *format_map=nullptr);
|
|
|
|
|
bool Release(VIL *);
|
|
|
|
|
const uint32_t GetInstanceCount()const{return vil_sets.GetCount();}
|
2019-04-28 16:06:53 +08:00
|
|
|
|
};//class VertexShaderModule:public ShaderModule
|
2019-04-27 21:23:57 +08:00
|
|
|
|
VK_NAMESPACE_END
|
|
|
|
|
#endif//HGL_GRAPH_VULKAN_SHADER_MODULE_INCLUDE
|