2019-04-16 02:23:03 +08:00
|
|
|
|
#ifndef HGL_GRAPH_VULKAN_VERTEX_INPUT_INCLUDE
|
|
|
|
|
#define HGL_GRAPH_VULKAN_VERTEX_INPUT_INCLUDE
|
|
|
|
|
|
|
|
|
|
#include"VK.h"
|
2019-04-26 03:03:21 +08:00
|
|
|
|
#include<hgl/type/BaseString.h>
|
|
|
|
|
#include<hgl/type/Map.h>
|
2019-04-16 02:23:03 +08:00
|
|
|
|
VK_NAMESPACE_BEGIN
|
2019-04-18 22:10:24 +08:00
|
|
|
|
class VertexBuffer;
|
2019-04-25 14:10:18 +08:00
|
|
|
|
class IndexBuffer;
|
2019-04-18 22:10:24 +08:00
|
|
|
|
|
2019-04-16 02:23:03 +08:00
|
|
|
|
/**
|
2019-04-25 16:02:13 +08:00
|
|
|
|
* 顶点输入状态<br>
|
|
|
|
|
* 顶点输入状态用于记录数据是如果传递给Pipeline的,并不包含具体数据
|
2019-04-16 02:23:03 +08:00
|
|
|
|
*/
|
2019-04-25 16:02:13 +08:00
|
|
|
|
class VertexInputState
|
2019-04-16 02:23:03 +08:00
|
|
|
|
{
|
2019-04-25 16:02:13 +08:00
|
|
|
|
List<VkVertexInputBindingDescription> binding_list;
|
|
|
|
|
List<VkVertexInputAttributeDescription> attribute_list;
|
2019-04-16 02:23:03 +08:00
|
|
|
|
|
2019-04-26 03:03:21 +08:00
|
|
|
|
struct StageInput
|
|
|
|
|
{
|
|
|
|
|
int binding;
|
|
|
|
|
VkFormat format;
|
|
|
|
|
|
|
|
|
|
uint32_t location;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
StageInput(){}
|
|
|
|
|
StageInput(const int b,const uint32_t l,const VkFormat f)
|
|
|
|
|
{
|
|
|
|
|
binding=b;
|
|
|
|
|
location=l;
|
|
|
|
|
format=f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CompOperatorMemcmp(const StageInput &);
|
|
|
|
|
};//struct StageInput
|
|
|
|
|
|
|
|
|
|
Map<UTF8String,StageInput> stage_input_locations;
|
2019-04-25 16:02:13 +08:00
|
|
|
|
public:
|
2019-04-16 02:23:03 +08:00
|
|
|
|
|
2019-04-25 16:02:13 +08:00
|
|
|
|
VertexInputState()=default;
|
|
|
|
|
~VertexInputState()=default;
|
2019-04-16 02:23:03 +08:00
|
|
|
|
|
2019-04-26 03:03:21 +08:00
|
|
|
|
int Add(const UTF8String &name,const uint32_t shader_location,const VkFormat format,uint32_t offset=0,bool instance=false);
|
2019-04-16 02:23:03 +08:00
|
|
|
|
|
2019-04-25 16:02:13 +08:00
|
|
|
|
public:
|
2019-04-16 02:23:03 +08:00
|
|
|
|
|
2019-04-26 03:03:21 +08:00
|
|
|
|
void Clear()
|
|
|
|
|
{
|
|
|
|
|
binding_list.Clear();
|
|
|
|
|
attribute_list.Clear();
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-25 16:02:13 +08:00
|
|
|
|
const uint32_t GetCount()const{return binding_list.GetCount();}
|
2019-04-18 16:37:59 +08:00
|
|
|
|
|
2019-04-26 03:03:21 +08:00
|
|
|
|
|
|
|
|
|
const int GetLocation (const UTF8String &)const;
|
|
|
|
|
const int GetBinding (const UTF8String &)const;
|
|
|
|
|
|
2019-04-25 16:02:13 +08:00
|
|
|
|
VkVertexInputBindingDescription * GetDesc(const int index){return (index<0||index>=binding_list.GetCount()?nullptr:binding_list.GetData()+index);}
|
|
|
|
|
VkVertexInputAttributeDescription * GetAttr(const int index){return (index<0||index>=attribute_list.GetCount()?nullptr:attribute_list.GetData()+index);}
|
|
|
|
|
|
|
|
|
|
void Write(VkPipelineVertexInputStateCreateInfo &vis)const;
|
|
|
|
|
};//class VertexInputStateCreater
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 顶点输入配置,类似于OpenGL的VAB<br>
|
|
|
|
|
* 注:本引擎不支持一个BUFFER中包括多种数据
|
|
|
|
|
*/
|
|
|
|
|
class VertexInput
|
|
|
|
|
{
|
|
|
|
|
VertexInputState *vis;
|
|
|
|
|
|
2019-04-26 03:03:21 +08:00
|
|
|
|
int buf_count=0;
|
2019-04-25 16:02:13 +08:00
|
|
|
|
VkBuffer *buf_list=nullptr;
|
|
|
|
|
VkDeviceSize *buf_offset=nullptr;
|
|
|
|
|
|
2019-04-25 14:10:18 +08:00
|
|
|
|
IndexBuffer *indices_buffer=nullptr;
|
|
|
|
|
VkDeviceSize indices_offset=0;
|
|
|
|
|
|
2019-04-16 02:23:03 +08:00
|
|
|
|
public:
|
|
|
|
|
|
2019-04-25 16:02:13 +08:00
|
|
|
|
VertexInput(VertexInputState *);
|
|
|
|
|
virtual ~VertexInput();
|
2019-04-17 02:26:58 +08:00
|
|
|
|
|
2019-04-26 03:03:21 +08:00
|
|
|
|
bool Set(int binding,VertexBuffer *,VkDeviceSize offset=0);
|
|
|
|
|
bool Set(const UTF8String &name,VertexBuffer *vb,VkDeviceSize offset=0){return Set(vis->GetBinding(name),vb,offset);}
|
|
|
|
|
|
2019-04-25 16:02:13 +08:00
|
|
|
|
bool Set(IndexBuffer *ib,VkDeviceSize offset=0)
|
2019-04-25 14:10:18 +08:00
|
|
|
|
{
|
|
|
|
|
if(!ib)return(false);
|
|
|
|
|
|
|
|
|
|
indices_buffer=ib;
|
|
|
|
|
indices_offset=offset;
|
2019-04-25 16:02:13 +08:00
|
|
|
|
return(true);
|
2019-04-25 14:10:18 +08:00
|
|
|
|
}
|
2019-04-16 02:23:03 +08:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2019-04-26 03:03:21 +08:00
|
|
|
|
const int GetCount ()const{return buf_count;}
|
2019-04-25 16:02:13 +08:00
|
|
|
|
const VkBuffer * GetBuffer ()const{return buf_list;}
|
|
|
|
|
const VkDeviceSize * GetOffset ()const{return buf_offset;}
|
2019-04-18 16:37:59 +08:00
|
|
|
|
|
2019-04-25 16:02:13 +08:00
|
|
|
|
IndexBuffer * GetIndexBuffer() {return indices_buffer;}
|
2019-04-25 14:10:18 +08:00
|
|
|
|
const VkDeviceSize GetIndexOffset()const{return indices_offset;}
|
2019-04-16 02:23:03 +08:00
|
|
|
|
};//class VertexInput
|
|
|
|
|
VK_NAMESPACE_END
|
|
|
|
|
#endif//HGL_GRAPH_VULKAN_VERTEX_INPUT_INCLUDE
|