split VertexDataManager.h/.cpp
This commit is contained in:
parent
e1d45a7c83
commit
f00cb0b815
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/graph/VKIndexBuffer.h>
|
||||
#include<hgl/type/DataChain.h>
|
||||
|
||||
namespace hgl
|
||||
@ -25,30 +26,13 @@ namespace hgl
|
||||
|
||||
protected:
|
||||
|
||||
DataChain data_chain; ///<数据链
|
||||
DataChain vbo_data_chain; ///<数据链
|
||||
DataChain ibo_data_chain; ///<数据链
|
||||
|
||||
public:
|
||||
|
||||
VertexDataManager(GPUDevice *dev,const VIL *_vil)
|
||||
{
|
||||
device=dev;
|
||||
|
||||
vi_count=_vil->GetCount();
|
||||
vif_list=_vil->GetVIFList(); //来自于Material,不会被释放,所以指针有效
|
||||
|
||||
vbo_max_size=0;
|
||||
vbo_cur_size=0;
|
||||
vbo=hgl_zero_new<VBO *>(vi_count);
|
||||
|
||||
ibo_cur_size=0;
|
||||
ibo=nullptr;
|
||||
}
|
||||
|
||||
~VertexDataManager()
|
||||
{
|
||||
SAFE_CLEAR_OBJECT_ARRAY(vbo,vi_count);
|
||||
SAFE_CLEAR(ibo);
|
||||
}
|
||||
VertexDataManager(GPUDevice *dev,const VIL *_vil);
|
||||
~VertexDataManager();
|
||||
|
||||
const VkDeviceSize GetVBOMaxCount ()const{return vbo_max_size;} ///<取得顶点缓冲区分配的空间最大数量
|
||||
const VkDeviceSize GetVBOCurCount ()const{return vbo_cur_size;} ///<取得顶点缓冲区当前数量
|
||||
@ -59,36 +43,7 @@ namespace hgl
|
||||
|
||||
public:
|
||||
|
||||
bool Init(const VkDeviceSize vbo_size,const VkDeviceSize ibo_size,const IndexType index_type)
|
||||
{
|
||||
if(vbo[0]||ibo) //已经初始化过了
|
||||
return(false);
|
||||
|
||||
if(vbo_size<=0)
|
||||
return(false);
|
||||
|
||||
vbo_max_size=vbo_size;
|
||||
ibo_cur_size=ibo_size;
|
||||
|
||||
vbo_cur_size=0;
|
||||
ibo_cur_size=0;
|
||||
|
||||
for(uint i=0;i<vi_count;i++)
|
||||
{
|
||||
vbo[i]=device->CreateVBO(vif_list[i].format,vbo_max_size);
|
||||
if(!vbo[i])
|
||||
return(false);
|
||||
}
|
||||
|
||||
if(ibo_size>0)
|
||||
{
|
||||
ibo=device->CreateIBO(index_type,ibo_size);
|
||||
if(!ibo)
|
||||
return(false);
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
bool Init(const VkDeviceSize vbo_size,const VkDeviceSize ibo_size,const IndexType index_type);
|
||||
};//class VertexDataManager
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
|
@ -8,7 +8,8 @@ SET(SG_TEXTURE_SOURCE ${SG_INCLUDE_PATH}/TextureLoader.h
|
||||
SOURCE_GROUP("Texture" FILES ${SG_TEXTURE_SOURCE})
|
||||
|
||||
SET(SG_VDM_SOURCE ${SG_INCLUDE_PATH}/VertexAttribDataAccess.h
|
||||
${SG_INCLUDE_PATH}/VertexDataManager.h)
|
||||
${SG_INCLUDE_PATH}/VertexDataManager.h
|
||||
VertexDataManager.cpp)
|
||||
|
||||
SOURCE_GROUP("VertexDataManager" FILES ${SG_VDM_SOURCE})
|
||||
|
||||
|
73
src/SceneGraph/VertexDataManager.cpp
Normal file
73
src/SceneGraph/VertexDataManager.cpp
Normal file
@ -0,0 +1,73 @@
|
||||
#include<hgl/graph/VertexDataManager.h>
|
||||
#include<hgl/graph/VKVertexAttribBuffer.h>
|
||||
#include<hgl/graph/VKVertexInputFormat.h>
|
||||
#include<hgl/graph/VKVertexInputLayout.h>
|
||||
#include<hgl/graph/VKDevice.h>
|
||||
|
||||
namespace hgl
|
||||
{
|
||||
namespace graph
|
||||
{
|
||||
VertexDataManager::VertexDataManager(GPUDevice *dev,const VIL *_vil)
|
||||
{
|
||||
device=dev;
|
||||
|
||||
vi_count=_vil->GetCount();
|
||||
vif_list=_vil->GetVIFList(); //来自于Material,不会被释放,所以指针有效
|
||||
|
||||
vbo_max_size=0;
|
||||
vbo_cur_size=0;
|
||||
vbo=hgl_zero_new<VBO *>(vi_count);
|
||||
|
||||
ibo_cur_size=0;
|
||||
ibo=nullptr;
|
||||
}
|
||||
|
||||
VertexDataManager::~VertexDataManager()
|
||||
{
|
||||
SAFE_CLEAR_OBJECT_ARRAY(vbo,vi_count);
|
||||
SAFE_CLEAR(ibo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化顶点数据管理器
|
||||
* @param vbo_size VBO大小
|
||||
* @param ibo_size IBO大小
|
||||
* @param index_type 索引类型
|
||||
*/
|
||||
bool VertexDataManager::Init(const VkDeviceSize vbo_size,const VkDeviceSize ibo_size,const IndexType index_type)
|
||||
{
|
||||
if(vbo[0]||ibo) //已经初始化过了
|
||||
return(false);
|
||||
|
||||
if(vbo_size<=0)
|
||||
return(false);
|
||||
|
||||
vbo_max_size=vbo_size;
|
||||
ibo_cur_size=ibo_size;
|
||||
|
||||
vbo_cur_size=0;
|
||||
ibo_cur_size=0;
|
||||
|
||||
for(uint i=0;i<vi_count;i++)
|
||||
{
|
||||
vbo[i]=device->CreateVBO(vif_list[i].format,vbo_max_size);
|
||||
if(!vbo[i])
|
||||
return(false);
|
||||
}
|
||||
|
||||
vbo_data_chain.Init(vbo_max_size);
|
||||
|
||||
if(ibo_size>0)
|
||||
{
|
||||
ibo=device->CreateIBO(index_type,ibo_size);
|
||||
if(!ibo)
|
||||
return(false);
|
||||
|
||||
ibo_data_chain.Init(ibo_size);
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
Loading…
x
Reference in New Issue
Block a user