ULRE/inc/hgl/graph/VertexAttribData.h

58 lines
2.2 KiB
C
Raw Normal View History

#ifndef HGL_GRAPH_VERTEX_ATTRIB_DATA_INCLUDE
#define HGL_GRAPH_VERTEX_ATTRIB_DATA_INCLUDE
2019-05-22 18:10:13 +08:00
#include<hgl/graph/VK.h>
2019-05-22 18:10:13 +08:00
namespace hgl
{
namespace graph
{
/**
*
*/
class VertexAttribData ///顶点属性数据
2019-05-22 18:10:13 +08:00
{
void *mem_data; ///<内存中的数据
protected:
2023-05-04 19:35:09 +08:00
VkFormat format;
2019-05-22 18:10:13 +08:00
2023-05-04 19:35:09 +08:00
uint32_t count; ///<数据个数
uint32_t total_bytes; ///<字节数
2019-05-22 18:10:13 +08:00
public:
2023-05-04 19:35:09 +08:00
VertexAttribData(uint32_t c,const VkFormat vf,const uint32_t t)
2019-05-22 18:10:13 +08:00
{
2023-05-04 19:35:09 +08:00
count=c;
format=vf;
total_bytes=t;
2019-05-22 18:10:13 +08:00
mem_data = hgl_malloc(total_bytes); //在很多情况下hgl_malloc分配的内存是对齐的这样有效率上的提升
}
virtual ~VertexAttribData()
2019-05-22 18:10:13 +08:00
{
if(mem_data)
hgl_free(mem_data);
}
2023-05-04 19:35:09 +08:00
const VkFormat GetFormat ()const{return format;} ///<取得数据类型
const uint32_t GetCount ()const{return count;} ///<取得数据数量
2019-05-22 18:10:13 +08:00
void * GetData ()const{return mem_data;} ///<取得数据指针
const uint32_t GetTotalBytes ()const{return total_bytes;} ///<取得数据字节数
};//class VertexAttribData
using VAD=VertexAttribData;
/**
* (VAD)
* @param vertex_count
2023-05-04 19:35:09 +08:00
* @param vif
*/
2023-05-04 19:35:09 +08:00
VAD *CreateVertexAttribData(const uint32_t vertex_count,const VertexInputFormat *vif);
//这个函数比较重要就不搞成CreateVAD的简写了
2019-05-22 18:10:13 +08:00
}//namespace graph
}//namespace hgl
#endif//HGL_GRAPH_VERTEX_ATTRIB_DATA_INCLUDE