use VAB instead of VBO
This commit is contained in:
@@ -32,11 +32,11 @@ namespace hgl
|
||||
|
||||
IndexBuffer * ibo;
|
||||
void * ibo_map;
|
||||
VBOAccessMap vbo_map;
|
||||
VABAccessMap vbo_map;
|
||||
|
||||
protected:
|
||||
|
||||
bool AcquirePVB(VBOAccessData *,const AnsiString &,const void *data); ///<请求一个顶点属性数据区
|
||||
bool AcquirePVB(VABAccess *,const AnsiString &,const void *data); ///<请求一个顶点属性数据区
|
||||
|
||||
void ClearAllData();
|
||||
|
||||
@@ -49,14 +49,14 @@ namespace hgl
|
||||
virtual bool Init(const uint32 vertices_count,const uint32 index_count,IndexType it=IndexType::AUTO); ///<初始化,参数为顶点数量
|
||||
|
||||
template<typename T>
|
||||
T * AccessVBO(const AnsiString &name) ///<创建一个顶点属性数据缓冲区以及访问器
|
||||
T * AccessVAB(const AnsiString &name) ///<创建一个顶点属性数据缓冲区以及访问器
|
||||
{
|
||||
const VkFormat format=vil->GetVulkanFormat(name);
|
||||
|
||||
if(format!=T::GetVulkanFormat())
|
||||
return(nullptr);
|
||||
|
||||
VBOAccessData vad;
|
||||
VABAccess vad;
|
||||
if(!this->AcquirePVB(&vad,name,nullptr))
|
||||
return(nullptr);
|
||||
|
||||
@@ -67,9 +67,10 @@ namespace hgl
|
||||
return access;
|
||||
}
|
||||
|
||||
bool WriteVBO(const AnsiString &name,const void *data,const uint32_t bytes); ///<直接写入顶点属性数据
|
||||
bool WriteVAB(const AnsiString &name,const void *data,const uint32_t bytes); ///<直接写入顶点属性数据
|
||||
|
||||
const IndexType GetIndexType()const{return ibo?ibo->GetType():IndexType::ERR;} ///<取得索引数据类型
|
||||
|
||||
template<typename T> T *AccessIBO()
|
||||
{
|
||||
if(!ibo)return(nullptr);
|
||||
|
@@ -55,7 +55,7 @@ class DeviceBuffer;
|
||||
struct DeviceBufferData;
|
||||
|
||||
class VertexAttribBuffer;
|
||||
using VBO=VertexAttribBuffer;
|
||||
using VAB=VertexAttribBuffer;
|
||||
|
||||
class IndexBuffer;
|
||||
|
||||
|
@@ -154,9 +154,9 @@ public:
|
||||
void PushConstants(const void *data,const uint32_t size) {vkCmdPushConstants(cmd_buf,pipeline_layout,VK_SHADER_STAGE_VERTEX_BIT,0, size,data);}
|
||||
void PushConstants(const void *data,const uint32_t offset,const uint32_t size) {vkCmdPushConstants(cmd_buf,pipeline_layout,VK_SHADER_STAGE_VERTEX_BIT,offset, size,data);}
|
||||
|
||||
void BindVBO(const uint32_t first,const uint32_t count,const VkBuffer *vbo,const VkDeviceSize *offsets)
|
||||
void BindVBO(const uint32_t first,const uint32_t count,const VkBuffer *vab,const VkDeviceSize *offsets)
|
||||
{
|
||||
vkCmdBindVertexBuffers(cmd_buf,first,count,vbo,offsets);
|
||||
vkCmdBindVertexBuffers(cmd_buf,first,count,vab,offsets);
|
||||
}
|
||||
|
||||
bool BindVBO(VBOList *vbo_list)
|
||||
|
@@ -114,8 +114,8 @@ public: //Buffer相关
|
||||
DeviceBuffer * CreateBuffer(VkBufferUsageFlags buf_usage, VkDeviceSize size,const void *data, SharingMode sm=SharingMode::Exclusive){return CreateBuffer(buf_usage,size,size,data,sm);}
|
||||
DeviceBuffer * CreateBuffer(VkBufferUsageFlags buf_usage, VkDeviceSize size, SharingMode sm=SharingMode::Exclusive){return CreateBuffer(buf_usage,size,size,nullptr,sm);}
|
||||
|
||||
VBO * CreateVBO (VkFormat format, uint32_t count,const void *data, SharingMode sm=SharingMode::Exclusive);
|
||||
VBO * CreateVBO (VkFormat format, uint32_t count, SharingMode sm=SharingMode::Exclusive){return CreateVBO(format,count,nullptr,sm);}
|
||||
VAB * CreateVAB (VkFormat format, uint32_t count,const void *data, SharingMode sm=SharingMode::Exclusive);
|
||||
VAB * CreateVAB (VkFormat format, uint32_t count, SharingMode sm=SharingMode::Exclusive){return CreateVAB(format,count,nullptr,sm);}
|
||||
|
||||
const IndexType ChooseIndexType (const VkDeviceSize &vertex_count)const; ///<求一个合适的索引类型
|
||||
const bool CheckIndexType (const IndexType,const VkDeviceSize &vertex_count)const; ///<检测一个索引类型是否合适
|
||||
|
@@ -58,7 +58,7 @@ struct VulkanHardwareRequirement
|
||||
// primitive topology
|
||||
// viewport
|
||||
// scissor
|
||||
// bind vbo
|
||||
// bind vab
|
||||
// depth test
|
||||
// depth write
|
||||
// depth compare op
|
||||
|
@@ -8,6 +8,22 @@
|
||||
#include<hgl/graph/AABB.h>
|
||||
#include<hgl/graph/VKVertexAttribBuffer.h>
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
struct PrimitiveData
|
||||
{
|
||||
uint32_t vertex_count;
|
||||
|
||||
uint32_t va_count;
|
||||
|
||||
|
||||
|
||||
VABAccess *vab_list;
|
||||
|
||||
IndexBufferData index_buffer_data;
|
||||
|
||||
AABB BoundingBox;
|
||||
};
|
||||
|
||||
/**
|
||||
* 单一图元数据
|
||||
*/
|
||||
@@ -16,15 +32,13 @@ class Primitive
|
||||
GPUDevice *device;
|
||||
AnsiString prim_name;
|
||||
|
||||
VBOAccessMap buffer_list;
|
||||
|
||||
protected:
|
||||
|
||||
uint32_t vertex_count;
|
||||
|
||||
IndexBufferData index_buffer_data;
|
||||
VABAccessMap buffer_list;
|
||||
|
||||
protected:
|
||||
IndexBufferData index_buffer_data;
|
||||
|
||||
AABB BoundingBox;
|
||||
|
||||
@@ -53,7 +67,7 @@ public:
|
||||
void SetBoundingBox(const AABB &aabb){BoundingBox=aabb;}
|
||||
const AABB & GetBoundingBox()const {return BoundingBox;}
|
||||
|
||||
bool Set(const AnsiString &name,VBO *vb,VkDeviceSize offset=0);
|
||||
bool Set(const AnsiString &name,VAB *vb,VkDeviceSize offset=0);
|
||||
|
||||
bool Set(IndexBuffer *ib,VkDeviceSize offset=0);
|
||||
|
||||
@@ -61,7 +75,7 @@ public:
|
||||
|
||||
const uint32_t GetVertexCount ()const {return vertex_count;}
|
||||
|
||||
bool GetVBOAccessData (const AnsiString &,VBOAccessData *);
|
||||
bool GetVBOAccessData (const AnsiString &,VABAccess *);
|
||||
const int GetBufferCount ()const {return buffer_list.GetCount();}
|
||||
|
||||
const IndexBufferData * GetIndexBufferData ()const {return &index_buffer_data;}
|
||||
|
@@ -105,8 +105,8 @@ public: //Add
|
||||
|
||||
public: // VBO/VAO
|
||||
|
||||
VBO *CreateVBO(VkFormat format,uint32_t count,const void *data, SharingMode sm=SharingMode::Exclusive);
|
||||
VBO *CreateVBO(VkFormat format,uint32_t count, SharingMode sm=SharingMode::Exclusive){return CreateVBO(format, count, nullptr, sm);}
|
||||
VAB *CreateVAB(VkFormat format,uint32_t count,const void *data, SharingMode sm=SharingMode::Exclusive);
|
||||
VAB *CreateVAB(VkFormat format,uint32_t count, SharingMode sm=SharingMode::Exclusive){return CreateVAB(format, count, nullptr, sm);}
|
||||
|
||||
#define SCENE_DB_CREATE_FUNC(name) DeviceBuffer *Create##name(const AnsiString &buf_name,VkDeviceSize size,void *data,SharingMode sm=SharingMode::Exclusive); \
|
||||
DeviceBuffer *Create##name(const AnsiString &buf_name,VkDeviceSize size,SharingMode sm=SharingMode::Exclusive){return Create##name(buf_name,size,nullptr,sm);}
|
||||
|
@@ -24,13 +24,13 @@ public:
|
||||
|
||||
VBO *SetVBO(const AnsiString &name,const VkFormat &fmt,const void *buf)
|
||||
{
|
||||
VBO *vbo=rr->CreateVBO(fmt,vertex_count,buf);
|
||||
VBO *vab=rr->CreateVAB(fmt,vertex_count,buf);
|
||||
|
||||
if(!vbo)
|
||||
if(!vab)
|
||||
return(nullptr);
|
||||
|
||||
prim->Set(name,vbo);
|
||||
return(vbo);
|
||||
prim->Set(name,vab);
|
||||
return(vab);
|
||||
}
|
||||
|
||||
IndexBuffer *SetIBO(const IndexType &it,const void *buf,const uint32_t index_count)
|
||||
|
@@ -35,11 +35,11 @@ namespace hgl
|
||||
const VkDeviceSize GetBytes()const { return stride*count; }
|
||||
};//class VertexAttribBuffer:public DeviceBuffer
|
||||
|
||||
using VBO=VertexAttribBuffer;
|
||||
using VAB=VertexAttribBuffer;
|
||||
|
||||
struct VBOAccessData
|
||||
struct VABAccess
|
||||
{
|
||||
VBO *vbo;
|
||||
VAB *vab;
|
||||
VkDeviceSize offset;
|
||||
VkDeviceSize size;
|
||||
|
||||
@@ -47,10 +47,10 @@ namespace hgl
|
||||
|
||||
public:
|
||||
|
||||
CompOperatorMemcmp(const VBOAccessData &);
|
||||
};//class VBOAccessData
|
||||
CompOperatorMemcmp(const VABAccess &);
|
||||
};//class VABAccess
|
||||
|
||||
using VBOAccessMap=Map<AnsiString,VBOAccessData>;
|
||||
using VABAccessMap=Map<AnsiString,VABAccess>;
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
#endif//HGL_GRAPH_VULKAN_VERTEX_ATTRIB_BUFFER_INCLUDE
|
||||
|
@@ -18,9 +18,9 @@ namespace hgl
|
||||
uint vi_count; ///<顶点输入流数量
|
||||
const VIF * vif_list; ///<顶点输入格式列表
|
||||
|
||||
VkDeviceSize vbo_max_size; ///<顶点缓冲区分配空间大小
|
||||
VkDeviceSize vbo_cur_size; ///<顶点缓冲区当前使用大小
|
||||
VBO ** vbo; ///<顶点缓冲区列表
|
||||
VkDeviceSize vab_max_size; ///<顶点缓冲区分配空间大小
|
||||
VkDeviceSize vab_cur_size; ///<顶点缓冲区当前使用大小
|
||||
VAB ** vab; ///<顶点缓冲区列表
|
||||
|
||||
VkDeviceSize ibo_cur_size; ///<索引缓冲区当前使用大小
|
||||
IndexBuffer * ibo; ///<索引缓冲区
|
||||
@@ -39,8 +39,8 @@ namespace hgl
|
||||
|
||||
const VIL * GetVIL ()const{return vil;} ///<取得顶点输入格式列表
|
||||
|
||||
const VkDeviceSize GetVBOMaxCount ()const{return vbo_max_size;} ///<取得顶点缓冲区分配的空间最大数量
|
||||
const VkDeviceSize GetVBOCurCount ()const{return vbo_cur_size;} ///<取得顶点缓冲区当前数量
|
||||
const VkDeviceSize GetVABMaxCount ()const{return vab_max_size;} ///<取得顶点属性缓冲区分配的空间最大数量
|
||||
const VkDeviceSize GetVABCurCount ()const{return vab_cur_size;} ///<取得顶点属性缓冲区当前数量
|
||||
|
||||
const IndexType GetIBOType ()const{return ibo?ibo->GetType():IndexType::ERR;} ///<取得索引缓冲区类型
|
||||
const VkDeviceSize GetIBOMaxCount ()const{return ibo?ibo->GetCount():-1;} ///<取得索引缓冲区分配的空间最大数量
|
||||
|
@@ -16,8 +16,8 @@ namespace hgl
|
||||
|
||||
uint max_count; ///<缓冲区最大容量
|
||||
|
||||
VBO * vbo_position;
|
||||
VBO * vbo_tex_coord;
|
||||
VAB * vab_position;
|
||||
VAB * vab_tex_coord;
|
||||
|
||||
protected:
|
||||
|
||||
|
Reference in New Issue
Block a user