prepare support VDM for PrimitiveCreater

This commit is contained in:
hyzboy 2024-04-17 01:38:35 +08:00
parent f00cb0b815
commit 4fc74d38ba
4 changed files with 25 additions and 7 deletions

View File

@ -8,6 +8,8 @@ namespace hgl
{ {
namespace graph namespace graph
{ {
class VertexDataManager;
/** /**
* *
*/ */
@ -23,6 +25,7 @@ namespace hgl
protected: protected:
VertexDataManager *vdm;
RenderResource *db; RenderResource *db;
const VIL *vil; const VIL *vil;
@ -43,6 +46,7 @@ namespace hgl
public: public:
PrimitiveCreater(RenderResource *sdb,const VIL *); PrimitiveCreater(RenderResource *sdb,const VIL *);
PrimitiveCreater(VertexDataManager *);
virtual ~PrimitiveCreater()=default; virtual ~PrimitiveCreater()=default;
virtual bool Init(const uint32 vertices_count); ///<初始化,参数为顶点数量 virtual bool Init(const uint32 vertices_count); ///<初始化,参数为顶点数量

View File

@ -14,6 +14,7 @@ namespace hgl
protected: protected:
VIL * vil; ///<顶点输入格式列表
uint vi_count; ///<顶点输入流数量 uint vi_count; ///<顶点输入流数量
const VIF * vif_list; ///<顶点输入格式列表 const VIF * vif_list; ///<顶点输入格式列表
@ -34,6 +35,8 @@ namespace hgl
VertexDataManager(GPUDevice *dev,const VIL *_vil); VertexDataManager(GPUDevice *dev,const VIL *_vil);
~VertexDataManager(); ~VertexDataManager();
const VIL * GetVIL ()const{return vil;} ///<取得顶点输入格式列表
const VkDeviceSize GetVBOMaxCount ()const{return vbo_max_size;} ///<取得顶点缓冲区分配的空间最大数量 const VkDeviceSize GetVBOMaxCount ()const{return vbo_max_size;} ///<取得顶点缓冲区分配的空间最大数量
const VkDeviceSize GetVBOCurCount ()const{return vbo_cur_size;} ///<取得顶点缓冲区当前数量 const VkDeviceSize GetVBOCurCount ()const{return vbo_cur_size;} ///<取得顶点缓冲区当前数量

View File

@ -1,6 +1,7 @@
#include<hgl/graph/PrimitiveCreater.h> #include<hgl/graph/PrimitiveCreater.h>
#include<hgl/graph/VKShaderModule.h> #include<hgl/graph/VKShaderModule.h>
#include<hgl/graph/VKVertexAttribBuffer.h> #include<hgl/graph/VKVertexAttribBuffer.h>
#include<hgl/graph/VertexDataManager.h>
namespace hgl namespace hgl
{ {
@ -15,6 +16,15 @@ namespace hgl
ibo =nullptr; ibo =nullptr;
} }
PrimitiveCreater::PrimitiveCreater(VertexDataManager *_vdm)
{
vdm=_vdm;
vil=vdm->GetVIL();
vertices_number =0;
ibo =nullptr;
}
bool PrimitiveCreater::Init(const uint32 count) bool PrimitiveCreater::Init(const uint32 count)
{ {
if(count<=0)return(false); if(count<=0)return(false);

View File

@ -1,4 +1,4 @@
#include<hgl/graph/VertexDataManager.h> #include<hgl/graph/VertexDataManager.h>
#include<hgl/graph/VKVertexAttribBuffer.h> #include<hgl/graph/VKVertexAttribBuffer.h>
#include<hgl/graph/VKVertexInputFormat.h> #include<hgl/graph/VKVertexInputFormat.h>
#include<hgl/graph/VKVertexInputLayout.h> #include<hgl/graph/VKVertexInputLayout.h>
@ -12,8 +12,9 @@ namespace hgl
{ {
device=dev; device=dev;
vil=_vil;
vi_count=_vil->GetCount(); vi_count=_vil->GetCount();
vif_list=_vil->GetVIFList(); //来自于Material不会被释放所以指针有效 vif_list=_vil->GetVIFList(); //来自于Material不会被释放所以指针有效
vbo_max_size=0; vbo_max_size=0;
vbo_cur_size=0; vbo_cur_size=0;
@ -30,14 +31,14 @@ namespace hgl
} }
/** /**
* *
* @param vbo_size VBO大小 * @param vbo_size VBO大小
* @param ibo_size IBO大小 * @param ibo_size IBO大小
* @param index_type * @param index_type
*/ */
bool VertexDataManager::Init(const VkDeviceSize vbo_size,const VkDeviceSize ibo_size,const IndexType index_type) bool VertexDataManager::Init(const VkDeviceSize vbo_size,const VkDeviceSize ibo_size,const IndexType index_type)
{ {
if(vbo[0]||ibo) //已经初始化过了 if(vbo[0]||ibo) //已经初始化过了
return(false); return(false);
if(vbo_size<=0) if(vbo_size<=0)