optimized VertexAttribData class
This commit is contained in:
@@ -15,18 +15,19 @@ namespace hgl
|
||||
|
||||
protected:
|
||||
|
||||
const uint32_t vec_size; ///<每个数据成员数(比如二维坐标为2、三维坐标为3)
|
||||
uint32_t count; ///<数据个数
|
||||
VkFormat format;
|
||||
|
||||
const uint32_t stride; ///<每组数据字节数
|
||||
const uint32_t total_bytes; ///<字节数
|
||||
|
||||
VkFormat vk_format; ///<在Vulkan中的数据类型
|
||||
uint32_t count; ///<数据个数
|
||||
uint32_t total_bytes; ///<字节数
|
||||
|
||||
public:
|
||||
|
||||
VertexAttribData(uint32_t c,uint32_t dc,uint32_t cs,VkFormat fmt):count(c),vec_size(dc),stride(cs),total_bytes(cs*c),vk_format(fmt)
|
||||
VertexAttribData(uint32_t c,const VkFormat vf,const uint32_t t)
|
||||
{
|
||||
count=c;
|
||||
format=vf;
|
||||
total_bytes=t;
|
||||
|
||||
mem_data = hgl_malloc(total_bytes); //在很多情况下,hgl_malloc分配的内存是对齐的,这样有效率上的提升
|
||||
}
|
||||
|
||||
@@ -36,7 +37,7 @@ namespace hgl
|
||||
hgl_free(mem_data);
|
||||
}
|
||||
|
||||
const VkFormat GetVulkanFormat ()const{return vk_format;} ///<取得数据类型
|
||||
const VkFormat GetFormat ()const{return format;} ///<取得数据类型
|
||||
// const uint32_t GetVecSize ()const{return vec_size;} ///<取数缓冲区元数据成份数量
|
||||
const uint32_t GetCount ()const{return count;} ///<取得数据数量
|
||||
// const uint32_t GetStride ()const{return stride;} ///<取得每一组数据字节数
|
||||
@@ -49,11 +50,9 @@ namespace hgl
|
||||
/**
|
||||
* 根据格式要求,创建对应的顶点属性数据区(VAD)
|
||||
* @param vertex_count 顶点数量
|
||||
* @param fmt Vulkan格式
|
||||
* @param vec_size vec数量
|
||||
* @param stride 单个数据字节数
|
||||
* @param vif 格式
|
||||
*/
|
||||
VAD *CreateVertexAttribData(const uint32_t vertex_count,const VkFormat fmt,const int vec_size,const uint stride);
|
||||
VAD *CreateVertexAttribData(const uint32_t vertex_count,const VertexInputFormat *vif);
|
||||
//这个函数比较重要,就不搞成CreateVAD的简写了
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
|
Reference in New Issue
Block a user