moved to VKPrimitiveData.cpp from VKPrimitiveData.h
This commit is contained in:
parent
6892a64393
commit
ecb47dae4d
@ -4,9 +4,11 @@
|
|||||||
#include<hgl/graph/VertexAttribDataAccess.h>
|
#include<hgl/graph/VertexAttribDataAccess.h>
|
||||||
#include<hgl/graph/VKShaderModule.h>
|
#include<hgl/graph/VKShaderModule.h>
|
||||||
#include<hgl/graph/VKIndexBuffer.h>
|
#include<hgl/graph/VKIndexBuffer.h>
|
||||||
|
#include<hgl/graph/VKPrimitiveData.h>
|
||||||
|
|
||||||
VK_NAMESPACE_BEGIN
|
VK_NAMESPACE_BEGIN
|
||||||
class VertexDataManager;
|
class VertexDataManager;
|
||||||
|
struct PrimitiveData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 可绘制图元创建器
|
* 可绘制图元创建器
|
||||||
@ -18,12 +20,13 @@ protected:
|
|||||||
GPUDevice *device;
|
GPUDevice *device;
|
||||||
const GPUPhysicalDevice *phy_device;
|
const GPUPhysicalDevice *phy_device;
|
||||||
|
|
||||||
VertexDataManager *vdm;
|
|
||||||
|
|
||||||
const VIL *vil;
|
const VIL *vil;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
PrimitiveData * prim_data;
|
||||||
|
|
||||||
|
|
||||||
VkDeviceSize vertices_number;
|
VkDeviceSize vertices_number;
|
||||||
VkDeviceSize index_number;
|
VkDeviceSize index_number;
|
||||||
|
|
||||||
|
@ -23,48 +23,32 @@ VK_NAMESPACE_BEGIN
|
|||||||
*/
|
*/
|
||||||
class Primitive
|
class Primitive
|
||||||
{
|
{
|
||||||
GPUDevice *device;
|
protected:
|
||||||
|
|
||||||
AnsiString prim_name;
|
AnsiString prim_name;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
VkDeviceSize vertex_count;
|
|
||||||
|
|
||||||
VABAccessMap buffer_list;
|
|
||||||
|
|
||||||
IBAccess ib_access;
|
|
||||||
|
|
||||||
AABB BoundingBox;
|
AABB BoundingBox;
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
bool SetVAB(const AnsiString &name,VAB *vb,VkDeviceSize start=0);
|
|
||||||
|
|
||||||
bool SetIndex(IndexBuffer *ib,VkDeviceSize start,const VkDeviceSize index_count);
|
|
||||||
|
|
||||||
void SetBoundingBox(const AABB &aabb){BoundingBox=aabb;}
|
|
||||||
|
|
||||||
friend class PrimitiveCreater;
|
|
||||||
friend class RenderablePrimitiveCreater;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Primitive(GPUDevice *dev,const AnsiString &n,const VkDeviceSize vc=0)
|
Primitive(const AnsiString &n)
|
||||||
{
|
{
|
||||||
device=dev;
|
|
||||||
prim_name=n;
|
prim_name=n;
|
||||||
vertex_count=vc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~Primitive()=default;
|
virtual ~Primitive()=0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
const VkDeviceSize GetVertexCount ()const{return vertex_count;}
|
virtual const VkDeviceSize GetVertexCount ()const=0;
|
||||||
const int GetVACount ()const{return buffer_list.GetCount();}
|
virtual const int GetVACount ()const=0;
|
||||||
const bool GetVABAccess (const AnsiString &,VABAccess *);
|
virtual const bool GetVABAccess (const AnsiString &,VABAccess *)=0;
|
||||||
const IBAccess * GetIBAccess ()const{return ib_access.buffer?&ib_access:nullptr;}
|
virtual const IBAccess * GetIBAccess ()const=0;
|
||||||
|
|
||||||
const AABB & GetBoundingBox ()const{return BoundingBox;}
|
const AABB & GetBoundingBox ()const{return BoundingBox;}
|
||||||
};//class Primitive
|
};//class Primitive
|
||||||
|
|
||||||
|
Primitive *CreatePrimitive(const PrimitiveData *);
|
||||||
VK_NAMESPACE_END
|
VK_NAMESPACE_END
|
||||||
|
@ -31,71 +31,11 @@ struct PrimitiveData
|
|||||||
|
|
||||||
VABAccess vab_access[HGL_MAX_VERTEX_ATTRIB_COUNT];
|
VABAccess vab_access[HGL_MAX_VERTEX_ATTRIB_COUNT];
|
||||||
IBAccess ib_access;
|
IBAccess ib_access;
|
||||||
};
|
};//struct PrimitiveData
|
||||||
|
|
||||||
inline bool Init(PrimitiveData *pd,const VIL *_vil,const VkDeviceSize vc,const VkDeviceSize ic=0)
|
bool Init( PrimitiveData *pd,const VIL *_vil,const VkDeviceSize vc,const VkDeviceSize ic=0);
|
||||||
{
|
int GetVABIndex(const PrimitiveData *pd,const AnsiString &name);
|
||||||
if(!pd)return(false);
|
const VABAccess * GetVAB(const PrimitiveData *pd,const AnsiString &name);
|
||||||
if(!_vil)return(false);
|
VABAccess * SetVAB( PrimitiveData *pd,const AnsiString &name,VAB *vab,VkDeviceSize start=0);
|
||||||
if(vc<=0)return(false);
|
|
||||||
|
|
||||||
hgl_zero(*pd);
|
|
||||||
|
|
||||||
pd->vil=_vil;
|
|
||||||
pd->vertex_count=vc;
|
|
||||||
pd->ib_access.count=ic;
|
|
||||||
|
|
||||||
return(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int GetVABIndex(const PrimitiveData *pd,const AnsiString &name)
|
|
||||||
{
|
|
||||||
if(!pd)return(-1);
|
|
||||||
if(!pd->vil)return(-1);
|
|
||||||
if(name.IsEmpty())return(-1);
|
|
||||||
|
|
||||||
return pd->vil->GetIndex(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const VABAccess *GetVAB(const PrimitiveData *pd,const AnsiString &name)
|
|
||||||
{
|
|
||||||
if(!pd)return(nullptr);
|
|
||||||
if(name.IsEmpty())return(nullptr);
|
|
||||||
|
|
||||||
const int index=GetVABIndex(pd,name);
|
|
||||||
|
|
||||||
if(index==-1)
|
|
||||||
return(nullptr);
|
|
||||||
|
|
||||||
return pd->vab_access+index;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VABAccess *SetVAB(PrimitiveData *pd,const AnsiString &name,VAB *vab,VkDeviceSize start=0)
|
|
||||||
{
|
|
||||||
if(!pd)return(nullptr);
|
|
||||||
if(name.IsEmpty())return(nullptr);
|
|
||||||
|
|
||||||
const int index=GetVABIndex(pd,name);
|
|
||||||
|
|
||||||
if(index==-1)
|
|
||||||
return(nullptr);
|
|
||||||
|
|
||||||
VABAccess *vaba=pd->vab_access+index;
|
|
||||||
|
|
||||||
vaba->vab=vab;
|
|
||||||
vaba->start=start;
|
|
||||||
|
|
||||||
//#ifdef _DEBUG
|
|
||||||
// DebugUtils *du=device->GetDebugUtils();
|
|
||||||
|
|
||||||
// if(du)
|
|
||||||
// {
|
|
||||||
// du->SetBuffer(vab->GetBuffer(),prim_name+":VAB:Buffer:"+name);
|
|
||||||
// du->SetDeviceMemory(vab->GetVkMemory(),prim_name+":VAB:Memory:"+name);
|
|
||||||
// }
|
|
||||||
//#endif//_DEBUG
|
|
||||||
|
|
||||||
return vaba;
|
|
||||||
}
|
|
||||||
|
|
||||||
VK_NAMESPACE_END
|
VK_NAMESPACE_END
|
||||||
|
@ -16,6 +16,7 @@ SOURCE_GROUP("VertexDataManager" FILES ${SG_VDM_SOURCE})
|
|||||||
SET(SG_PRIMITIVE_SOURCE ${SG_INCLUDE_PATH}/VKPrimitiveData.h
|
SET(SG_PRIMITIVE_SOURCE ${SG_INCLUDE_PATH}/VKPrimitiveData.h
|
||||||
${SG_INCLUDE_PATH}/VKPrimitive.h
|
${SG_INCLUDE_PATH}/VKPrimitive.h
|
||||||
Vulkan/VKPrimitive.cpp
|
Vulkan/VKPrimitive.cpp
|
||||||
|
Vulkan/VKPrimitiveData.cpp
|
||||||
${SG_INCLUDE_PATH}/VKRenderablePrimitiveCreater.h
|
${SG_INCLUDE_PATH}/VKRenderablePrimitiveCreater.h
|
||||||
${SG_INCLUDE_PATH}/PrimitiveCreater.h
|
${SG_INCLUDE_PATH}/PrimitiveCreater.h
|
||||||
PrimitiveCreater.cpp)
|
PrimitiveCreater.cpp)
|
||||||
|
@ -31,14 +31,14 @@ VK_NAMESPACE_BEGIN
|
|||||||
bool Primitive::SetVAB(const AnsiString &name,VAB *vab,VkDeviceSize start)
|
bool Primitive::SetVAB(const AnsiString &name,VAB *vab,VkDeviceSize start)
|
||||||
{
|
{
|
||||||
if(!vab)return(false);
|
if(!vab)return(false);
|
||||||
if(buffer_list.KeyExist(name))return(false);
|
if(vab_access_map.KeyExist(name))return(false);
|
||||||
|
|
||||||
VABAccess vad;
|
VABAccess vad;
|
||||||
|
|
||||||
vad.vab=vab;
|
vad.vab=vab;
|
||||||
vad.start=start;
|
vad.start=start;
|
||||||
|
|
||||||
buffer_list.Add(name,vad);
|
vab_access_map.Add(name,vad);
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
DebugUtils *du=device->GetDebugUtils();
|
DebugUtils *du=device->GetDebugUtils();
|
||||||
@ -58,7 +58,7 @@ const bool Primitive::GetVABAccess(const AnsiString &name,VABAccess *vad)
|
|||||||
if(name.IsEmpty())return(false);
|
if(name.IsEmpty())return(false);
|
||||||
if(!vad)return(false);
|
if(!vad)return(false);
|
||||||
|
|
||||||
return buffer_list.Get(name,*vad);
|
return vab_access_map.Get(name,*vad);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Primitive::SetIndex(IndexBuffer *ib,VkDeviceSize start,const VkDeviceSize index_count)
|
bool Primitive::SetIndex(IndexBuffer *ib,VkDeviceSize start,const VkDeviceSize index_count)
|
||||||
|
69
src/SceneGraph/Vulkan/VKPrimitiveData.cpp
Normal file
69
src/SceneGraph/Vulkan/VKPrimitiveData.cpp
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
#include<hgl/graph/VKPrimitiveData.h>
|
||||||
|
|
||||||
|
VK_NAMESPACE_BEGIN
|
||||||
|
bool Init(PrimitiveData *pd,const VIL *_vil,const VkDeviceSize vc,const VkDeviceSize ic=0)
|
||||||
|
{
|
||||||
|
if(!pd)return(false);
|
||||||
|
if(!_vil)return(false);
|
||||||
|
if(vc<=0)return(false);
|
||||||
|
|
||||||
|
hgl_zero(*pd);
|
||||||
|
|
||||||
|
pd->vil=_vil;
|
||||||
|
pd->vertex_count=vc;
|
||||||
|
pd->ib_access.count=ic;
|
||||||
|
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
int GetVABIndex(const PrimitiveData *pd,const AnsiString &name)
|
||||||
|
{
|
||||||
|
if(!pd)return(-1);
|
||||||
|
if(!pd->vil)return(-1);
|
||||||
|
if(name.IsEmpty())return(-1);
|
||||||
|
|
||||||
|
return pd->vil->GetIndex(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
const VABAccess *GetVAB(const PrimitiveData *pd,const AnsiString &name)
|
||||||
|
{
|
||||||
|
if(!pd)return(nullptr);
|
||||||
|
if(name.IsEmpty())return(nullptr);
|
||||||
|
|
||||||
|
const int index=GetVABIndex(pd,name);
|
||||||
|
|
||||||
|
if(index==-1)
|
||||||
|
return(nullptr);
|
||||||
|
|
||||||
|
return pd->vab_access+index;
|
||||||
|
}
|
||||||
|
|
||||||
|
VABAccess *SetVAB(PrimitiveData *pd,const AnsiString &name,VAB *vab,VkDeviceSize start=0)
|
||||||
|
{
|
||||||
|
if(!pd)return(nullptr);
|
||||||
|
if(name.IsEmpty())return(nullptr);
|
||||||
|
|
||||||
|
const int index=GetVABIndex(pd,name);
|
||||||
|
|
||||||
|
if(index==-1)
|
||||||
|
return(nullptr);
|
||||||
|
|
||||||
|
VABAccess *vaba=pd->vab_access+index;
|
||||||
|
|
||||||
|
vaba->vab=vab;
|
||||||
|
vaba->start=start;
|
||||||
|
|
||||||
|
//#ifdef _DEBUG
|
||||||
|
// DebugUtils *du=device->GetDebugUtils();
|
||||||
|
|
||||||
|
// if(du)
|
||||||
|
// {
|
||||||
|
// du->SetBuffer(vab->GetBuffer(),prim_name+":VAB:Buffer:"+name);
|
||||||
|
// du->SetDeviceMemory(vab->GetVkMemory(),prim_name+":VAB:Memory:"+name);
|
||||||
|
// }
|
||||||
|
//#endif//_DEBUG
|
||||||
|
|
||||||
|
return vaba;
|
||||||
|
}
|
||||||
|
|
||||||
|
VK_NAMESPACE_END
|
Loading…
x
Reference in New Issue
Block a user