diff --git a/CMCore b/CMCore index 5e081538..8f184a87 160000 --- a/CMCore +++ b/CMCore @@ -1 +1 @@ -Subproject commit 5e08153800ef4b0f46b9cad44b1e7e05415befef +Subproject commit 8f184a87fbd630da45b6708ee0fcfcb8372fdef1 diff --git a/inc/hgl/graph/VK.h b/inc/hgl/graph/VK.h index e256e831..7d95d310 100644 --- a/inc/hgl/graph/VK.h +++ b/inc/hgl/graph/VK.h @@ -73,6 +73,8 @@ public: using VABAccessMap=Map; +class VABView; + class IndexBuffer; struct IndexBufferAccess diff --git a/inc/hgl/graph/VKVertexAttribBuffer.h b/inc/hgl/graph/VKVertexAttribBuffer.h index 2958e8f3..25d28c47 100644 --- a/inc/hgl/graph/VKVertexAttribBuffer.h +++ b/inc/hgl/graph/VKVertexAttribBuffer.h @@ -36,6 +36,21 @@ namespace hgl };//class VertexAttribBuffer:public DeviceBuffer using VAB=VertexAttribBuffer; + + class VABView + { + public: + + VABView()=default; + virtual ~VABView()=default; + + virtual VAB *GetVAB()=0; + virtual VkDeviceSize GetStart()const=0; + virtual VkDeviceSize GetSize()const=0; + + virtual void *Map()=0; + virtual void Unmap()=0; + };//class VABView }//namespace graph }//namespace hgl #endif//HGL_GRAPH_VULKAN_VERTEX_ATTRIB_BUFFER_INCLUDE diff --git a/inc/hgl/graph/VertexDataManager.h b/inc/hgl/graph/VertexDataManager.h index 8e28809e..db773529 100644 --- a/inc/hgl/graph/VertexDataManager.h +++ b/inc/hgl/graph/VertexDataManager.h @@ -3,11 +3,45 @@ #include #include #include +#include namespace hgl { namespace graph { + class VertexDataManager; + + struct IBAccessNode:public IBAccess + { + private: + + VertexDataManager *vdm; + DataChain::UserNode *dc_node; + + public: + + friend class VertexDataManager; + + ~IBAccessNode(); + }; + + struct VABAccessNode + { + private: + + VertexDataManager *vdm; + DataChain::UserNode *dc_node; + const VIL *vil; + + VABAccess **vab; + + public: + + friend class VertexDataManager; + + ~VABAccessNode(); + }; + class VertexDataManager { GPUDevice *device; @@ -30,6 +64,14 @@ namespace hgl DataChain vbo_data_chain; ///<数据链 DataChain ibo_data_chain; ///<数据链 + protected: + + friend struct IBAccessNode; + friend struct VABAccessNode; + + bool ReleaseIB(DataChain::UserNode *); + bool ReleaseVAB(DataChain::UserNode *); + public: VertexDataManager(GPUDevice *dev,const VIL *_vil); @@ -49,6 +91,10 @@ namespace hgl public: bool Init(const VkDeviceSize vbo_size,const VkDeviceSize ibo_size,const IndexType index_type); + + IBAccessNode *AcquireIB(const VkDeviceSize count); + + VABAccessNode *AcquireVAB(const VkDeviceSize count); };//class VertexDataManager }//namespace graph }//namespace hgl diff --git a/src/SceneGraph/VertexDataManager.cpp b/src/SceneGraph/VertexDataManager.cpp index b736c767..175ac1c0 100644 --- a/src/SceneGraph/VertexDataManager.cpp +++ b/src/SceneGraph/VertexDataManager.cpp @@ -6,6 +6,19 @@ namespace hgl { + namespace graph + { + IBAccessNode::~IBAccessNode() + { + vdm->ReleaseIB(dc_node); + } + + VABAccessNode::~VABAccessNode() + { + vdm->ReleaseVAB(dc_node); + } + }//namespace graph + namespace graph { VertexDataManager::VertexDataManager(GPUDevice *dev,const VIL *_vil) @@ -70,5 +83,76 @@ namespace hgl return(true); } + + IBAccessNode *VertexDataManager::AcquireIB(const VkDeviceSize count) + { + if(count<=0)return(false); + + DataChain::UserNode *un=ibo_data_chain.Acquire(count); + + if(!un)return(false); + + IBAccessNode *node=new IBAccessNode; + + node->vdm=this; + node->dc_node=un; + + node->buffer=ibo; + node->start=un->GetStart(); + node->count=un->GetCount(); + + ibo_cur_size+=count; + + return(node); + } + + bool VertexDataManager::ReleaseIB(DataChain::UserNode *un) + { + if(!un)return(false); + + const auto count=un->GetCount(); + + if(!ibo_data_chain.Release(un)) + return(false); + + ibo_cur_size-=count; + return(true); + } + + VABAccessNode *VertexDataManager::AcquireVAB(const VkDeviceSize count) + { + if(count<=0)return(false); + + DataChain::UserNode *un=vbo_data_chain.Acquire(count); + + if(!un)return(false); + + VABAccessNode *node=new VABAccessNode; + + node->vdm=this; + node->dc_node=un; + node->vil=vil; + + //node->buffer=vab[0]; + //node->start=un->GetStart(); + //node->count=un->GetCount(); + + vab_cur_size+=count; + + return(node); + } + + bool VertexDataManager::ReleaseVAB(DataChain::UserNode *un) + { + if(!un)return(false); + + const auto count=un->GetCount(); + + if(!vbo_data_chain.Release(un)) + return(false); + + vab_cur_size-=count; + return(true); + } }//namespace graph }//namespace hgl