1.removed VertexShaderModule
2.added VertexInput at MaterialData 3.newly CreateShaderModule/CreateMaterial functions at GPUDevice/RenderResource class.
This commit is contained in:
@@ -75,7 +75,6 @@ struct ShaderAttribute;
|
||||
|
||||
class ShaderResource;
|
||||
class ShaderModule;
|
||||
class VertexShaderModule;
|
||||
class ShaderModuleMap;
|
||||
class MaterialDescriptorSets;
|
||||
|
||||
@@ -86,39 +85,9 @@ struct PipelineData;
|
||||
enum class InlinePipeline;
|
||||
class Pipeline;
|
||||
|
||||
struct VAConfig
|
||||
{
|
||||
VkFormat format;
|
||||
bool instance;
|
||||
|
||||
public:
|
||||
|
||||
VAConfig()
|
||||
{
|
||||
format=PF_UNDEFINED;
|
||||
instance=false;
|
||||
}
|
||||
|
||||
VAConfig(const VkFormat fmt,bool inst=false)
|
||||
{
|
||||
format=fmt;
|
||||
instance=inst;
|
||||
}
|
||||
|
||||
CompOperatorMemcmp(const VAConfig &);
|
||||
};
|
||||
|
||||
class VILConfig:public Map<AnsiString,VAConfig>
|
||||
{
|
||||
public:
|
||||
|
||||
using Map<AnsiString,VAConfig>::Map;
|
||||
|
||||
bool Add(const AnsiString &name,const VkFormat fmt,const bool inst=false)
|
||||
{
|
||||
return Map<AnsiString,VAConfig>::Add(name,VAConfig(fmt,inst));
|
||||
}
|
||||
};
|
||||
struct VAConfig;
|
||||
class VILConfig;
|
||||
class VertexInput;
|
||||
|
||||
class VertexInputLayout;
|
||||
using VIL=VertexInputLayout;
|
||||
|
@@ -224,11 +224,9 @@ public: //shader & material
|
||||
MaterialParameters *CreateMP(const MaterialDescriptorSets *,const PipelineLayoutData *,const DescriptorSetType &);
|
||||
MaterialParameters *CreateMP(Material *,const DescriptorSetType &);
|
||||
|
||||
ShaderModule *CreateShaderModule(ShaderResource *);
|
||||
ShaderModule *CreateShaderModule(VkShaderStageFlagBits,const void *,const size_t);
|
||||
|
||||
Material *CreateMaterial(const UTF8String &mtl_name,ShaderModuleMap *shader_maps,MaterialDescriptorSets *);
|
||||
Material *CreateMaterial(const UTF8String &mtl_name,const VertexShaderModule *vertex_shader_module,const ShaderModule *fragment_shader_module,MaterialDescriptorSets *);
|
||||
Material *CreateMaterial(const UTF8String &mtl_name,const VertexShaderModule *vertex_shader_module,const ShaderModule *geometry_shader_module,const ShaderModule *fragment_shader_module,MaterialDescriptorSets *);
|
||||
Material *CreateMaterial(const UTF8String &mtl_name,ShaderModuleMap *shader_maps,MaterialDescriptorSets *,VertexInput *);
|
||||
|
||||
MaterialInstance *CreateMI(Material *,const VILConfig *vil_cfg=nullptr);
|
||||
|
||||
|
@@ -15,10 +15,11 @@ struct MaterialData
|
||||
{
|
||||
UTF8String name;
|
||||
|
||||
ShaderModuleMap *shader_maps;
|
||||
MaterialDescriptorSets *mds;
|
||||
VertexInput *vertex_input;
|
||||
|
||||
VertexShaderModule *vertex_sm;
|
||||
ShaderModuleMap *shader_maps;
|
||||
|
||||
MaterialDescriptorSets *mds;
|
||||
|
||||
ShaderStageCreateInfoList shader_stage_list;
|
||||
|
||||
@@ -54,7 +55,7 @@ public:
|
||||
|
||||
const UTF8String & GetName ()const{return data->name;}
|
||||
|
||||
VertexShaderModule * GetVertexShaderModule () {return data->vertex_sm;}
|
||||
const VertexInput * GetVertexInput ()const{return data->vertex_input;}
|
||||
|
||||
const ShaderStageCreateInfoList & GetStageList ()const{return data->shader_stage_list;}
|
||||
|
||||
@@ -72,6 +73,10 @@ public:
|
||||
}
|
||||
|
||||
const bool hasSet (const DescriptorSetType &type)const;
|
||||
|
||||
VIL * CreateVIL(const VILConfig *format_map=nullptr);
|
||||
bool Release(VIL *);
|
||||
const uint GetVILCount();
|
||||
};//class Material
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_MATERIAL_INCLUDE
|
||||
|
@@ -88,7 +88,7 @@ public: // VBO/VAO
|
||||
|
||||
public: //Material
|
||||
|
||||
const ShaderModule *CreateShaderModule(const OSString &filename,ShaderResource *shader_resource);
|
||||
const ShaderModule *CreateShaderModule(const OSString &filename,VkShaderStageFlagBits shader_stage,const void *spv_data,const size_t spv_size);
|
||||
|
||||
Material * CreateMaterial(const OSString &);
|
||||
Material * CreateMaterial(const hgl::shadergen::MaterialCreateInfo *);
|
||||
|
@@ -2,7 +2,6 @@
|
||||
#define HGL_GRAPH_VULKAN_SHADER_MODULE_INCLUDE
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/graph/VKShaderResource.h>
|
||||
#include<hgl/graph/VKVertexInputLayout.h>
|
||||
#include<hgl/type/SortedSets.h>
|
||||
|
||||
@@ -21,13 +20,9 @@ private:
|
||||
|
||||
VkPipelineShaderStageCreateInfo *stage_create_info;
|
||||
|
||||
protected:
|
||||
|
||||
ShaderResource *shader_resource;
|
||||
|
||||
public:
|
||||
|
||||
ShaderModule(VkDevice dev,VkPipelineShaderStageCreateInfo *pssci,ShaderResource *);
|
||||
ShaderModule(VkDevice dev,VkPipelineShaderStageCreateInfo *pssci);
|
||||
virtual ~ShaderModule();
|
||||
|
||||
const int IncRef(){return ++ref_count;}
|
||||
@@ -50,48 +45,5 @@ public:
|
||||
|
||||
operator VkShaderModule ()const{return stage_create_info->module;}
|
||||
};//class ShaderModule
|
||||
|
||||
/**
|
||||
* 顶点Shader模块<br>
|
||||
* 由于顶点shader在最前方执行,所以它比其它shader多了VertexInput的数据
|
||||
*/
|
||||
class VertexShaderModule:public ShaderModule
|
||||
{
|
||||
uint32_t attr_count;
|
||||
VAT *type_list;
|
||||
const char **name_list;
|
||||
ShaderAttribute *shader_attr_list;
|
||||
|
||||
private:
|
||||
|
||||
SortedSets<VIL *> vil_sets;
|
||||
|
||||
public:
|
||||
|
||||
VertexShaderModule(VkDevice dev,VkPipelineShaderStageCreateInfo *pssci,ShaderResource *sr);
|
||||
virtual ~VertexShaderModule();
|
||||
|
||||
/**
|
||||
* 获取输入流绑定点,需要注意的时,这里获取的binding并非是shader中的binding/location,而是绑定顺序的序列号。对应vkCmdBindVertexBuffer的缓冲区序列号
|
||||
*/
|
||||
const int GetInputBinding(const AnsiString &name)const{return shader_resource->GetInputBinding(name);}
|
||||
const ShaderAttribute * GetInput (const AnsiString &name)const{return shader_resource->GetInput(name);}
|
||||
const uint GetInputCount () const{return shader_resource->GetInputCount();}
|
||||
const ShaderAttributeArray & GetInputs () const{return shader_resource->GetInputs();}
|
||||
|
||||
//const uint32_t GetAttrCount()const{return attr_count;}
|
||||
|
||||
//const VkVertexInputBindingDescription * GetBindList ()const{return binding_list;}
|
||||
//const VkVertexInputAttributeDescription * GetAttrList ()const{return attribute_list;}
|
||||
|
||||
//const VkVertexInputBindingDescription * GetBind (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:
|
||||
|
||||
VIL * CreateVIL(const VILConfig *format_map=nullptr);
|
||||
bool Release(VIL *);
|
||||
const uint32_t GetInstanceCount()const{return vil_sets.GetCount();}
|
||||
};//class VertexShaderModule:public ShaderModule
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_SHADER_MODULE_INCLUDE
|
||||
|
@@ -38,16 +38,5 @@ public:
|
||||
const ShaderAttribute * GetInput (const AnsiString &)const;
|
||||
const int GetInputBinding (const AnsiString &)const;
|
||||
};//class ShaderResource
|
||||
|
||||
struct ShaderModuleCreateInfo:public vkstruct_flag<VkShaderModuleCreateInfo,VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO>
|
||||
{
|
||||
public:
|
||||
|
||||
ShaderModuleCreateInfo(ShaderResource *sr)
|
||||
{
|
||||
codeSize=sr->GetCodeSize();
|
||||
pCode =sr->GetCode();
|
||||
}
|
||||
};//struct ShaderModuleCreateInfo
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_SHADER_RESOURCE_INCLUDE
|
||||
|
Reference in New Issue
Block a user