added VDM in Primitive/Renderable/PrimitiveDataBuffer

This commit is contained in:
hyzboy 2024-05-28 23:33:15 +08:00
parent ca8e36687f
commit 8cdf88e2fd
6 changed files with 21 additions and 3 deletions

View File

@ -42,6 +42,8 @@ public:
IndexBuffer * GetIBO ();
const uint32_t GetFirstIndex ()const; ///<取得第一个索引
VertexDataManager * GetVDM (); ///<取得顶点数据管理器
const AABB & GetBoundingBox ()const{return BoundingBox;}
};//class Primitive
VK_NAMESPACE_END

View File

@ -29,9 +29,11 @@ struct PrimitiveDataBuffer
IndexBuffer * ibo;
VertexDataManager *vdm; //只是用来区分和比较的,不实际使用
public:
PrimitiveDataBuffer(const uint32_t,IndexBuffer *);
PrimitiveDataBuffer(const uint32_t,IndexBuffer *,VertexDataManager *_v=nullptr);
~PrimitiveDataBuffer();
const bool Comp(const PrimitiveDataBuffer *pdb)const;

View File

@ -80,4 +80,9 @@ const uint32_t Primitive::GetFirstIndex()const
{
return prim_data->GetFirstIndex();
}
VertexDataManager *Primitive::GetVDM()
{
return prim_data->GetVDM();
}
VK_NAMESPACE_END

View File

@ -56,6 +56,8 @@ namespace
int32_t GetVertexOffset ()const override{return 0;}
uint32_t GetFirstIndex ()const override{return 0;}
VertexDataManager * GetVDM()const override{return nullptr;} ///<取得顶点数据管理器
public:
PrimitiveDataPrivateBuffer(GPUDevice *dev,const VIL *_vil,const uint32_t vc):PrimitiveData(_vil,vc)
@ -141,6 +143,9 @@ namespace
int32_t GetVertexOffset()const override { return vab_node->GetStart(); }
uint32_t GetFirstIndex ()const override { return ib_node->GetStart(); }
VertexDataManager * GetVDM()const override{return vdm;} ///<取得顶点数据管理器
public:
PrimitiveDataVDM(VertexDataManager *_vdm,const uint32_t vc):PrimitiveData(_vdm->GetVIL(),vc)
{

View File

@ -46,6 +46,8 @@ public:
virtual int32_t GetVertexOffset ()const=0; ///<取得顶点偏移(注意是顶点不是字节)
virtual uint32_t GetFirstIndex ()const=0; ///<取得第一个索引
virtual VertexDataManager * GetVDM()const=0; ///<取得顶点数据管理器
public:
virtual IndexBuffer * InitIBO(const uint32_t index_count,IndexType it)=0;

View File

@ -7,12 +7,14 @@
#include<hgl/log/LogInfo.h>
VK_NAMESPACE_BEGIN
PrimitiveDataBuffer::PrimitiveDataBuffer(const uint32_t c,IndexBuffer *ib)
PrimitiveDataBuffer::PrimitiveDataBuffer(const uint32_t c,IndexBuffer *ib,VertexDataManager *_vdm)
{
vab_count=c;
vab_list=hgl_zero_new<VkBuffer>(vab_count);
ibo=ib;
vdm=_vdm;
}
PrimitiveDataBuffer::~PrimitiveDataBuffer()
@ -62,7 +64,7 @@ Renderable *CreateRenderable(Primitive *prim,MaterialInstance *mi,Pipeline *p)
return(nullptr);
}
PrimitiveDataBuffer *pdb=new PrimitiveDataBuffer(input_count,prim->GetIBO());
PrimitiveDataBuffer *pdb=new PrimitiveDataBuffer(input_count,prim->GetIBO(),prim->GetVDM());
PrimitiveRenderData *prd=new PrimitiveRenderData(prim->GetVertexCount(),prim->GetIndexCount(),prim->GetVertexOffset(),prim->GetFirstIndex());
const VertexInputFormat *vif=vil->GetVIFList(VertexInputGroup::Basic);