ULRE/example/Vulkan/VKVertexInput.h

76 lines
2.2 KiB
C
Raw Normal View History

#ifndef HGL_GRAPH_VULKAN_VERTEX_INPUT_INCLUDE
#define HGL_GRAPH_VULKAN_VERTEX_INPUT_INCLUDE
#include"VK.h"
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
/**
* <br>
* Pipeline的
*/
class VertexInputState
{
List<VkVertexInputBindingDescription> binding_list;
List<VkVertexInputAttributeDescription> attribute_list;
public:
VertexInputState()=default;
~VertexInputState()=default;
void Add(const uint32_t shader_location,const VkFormat format,uint32_t offset=0,bool instance=false);
public:
const uint32_t GetCount()const{return binding_list.GetCount();}
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;
uint32_t buf_count=0;
VkBuffer *buf_list=nullptr;
VkDeviceSize *buf_offset=nullptr;
2019-04-25 14:10:18 +08:00
IndexBuffer *indices_buffer=nullptr;
VkDeviceSize indices_offset=0;
public:
VertexInput(VertexInputState *);
virtual ~VertexInput();
bool Set(uint32_t index,VertexBuffer *,VkDeviceSize offset=0);
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;
return(true);
2019-04-25 14:10:18 +08:00
}
public:
const uint32_t GetCount ()const{return buf_count;}
const VkBuffer * GetBuffer ()const{return buf_list;}
const VkDeviceSize * GetOffset ()const{return buf_offset;}
IndexBuffer * GetIndexBuffer() {return indices_buffer;}
2019-04-25 14:10:18 +08:00
const VkDeviceSize GetIndexOffset()const{return indices_offset;}
};//class VertexInput
VK_NAMESPACE_END
#endif//HGL_GRAPH_VULKAN_VERTEX_INPUT_INCLUDE