From 01bf8b3dd2b85f63d13329453f99342525334ecf Mon Sep 17 00:00:00 2001 From: hyzboy Date: Mon, 1 Apr 2024 23:32:18 +0800 Subject: [PATCH] updated VertexDataManager --- CMCore | 2 +- CMSceneGraph | 2 +- .../LightBasic/BlinnPhongDirectionLight.cpp | 23 ++++++++----------- inc/hgl/graph/VK.h | 1 + 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/CMCore b/CMCore index cf13064c..71d198a3 160000 --- a/CMCore +++ b/CMCore @@ -1 +1 @@ -Subproject commit cf13064ceada8814ced7aac89eaac3dd2d681d45 +Subproject commit 71d198a3356cb8958003753339abf4eb8599d7c7 diff --git a/CMSceneGraph b/CMSceneGraph index d395ee15..0f9713fb 160000 --- a/CMSceneGraph +++ b/CMSceneGraph @@ -1 +1 @@ -Subproject commit d395ee152f64b1eb7d058c355767f25c44ed8dcb +Subproject commit 0f9713fb95f4bf1e23a46d3d256db2fb416dbdc3 diff --git a/example/LightBasic/BlinnPhongDirectionLight.cpp b/example/LightBasic/BlinnPhongDirectionLight.cpp index 864a7732..d7644d7e 100644 --- a/example/LightBasic/BlinnPhongDirectionLight.cpp +++ b/example/LightBasic/BlinnPhongDirectionLight.cpp @@ -11,6 +11,8 @@ #include #include #include +#include +#include using namespace hgl; using namespace hgl::graph; @@ -35,17 +37,6 @@ constexpr const COLOR AxisColor[4]= class VertexDataManager { -public: - - struct DataOffset - { - VkDeviceSize vbo_start; - VkDeviceSize vbo_size; - - VkDeviceSize ibo_start; - VkDeviceSize ibo_size; - }; - protected: uint vi_count; ///<顶点输入流数量 @@ -60,14 +51,14 @@ protected: protected: - //List 我们可能需要一个数据块链表管理器,并且支持最小数据分块。以方便支持数据块回收。 + DataChain data_chain; ///<数据链 public: VertexDataManager(const VIL &_vil) { vi_count=_vil.GetCount(); - vif_list=_vil.GetVIFList(); + vif_list=_vil.GetVIFList(); //来自于Material,不会被释放,所以指针有效 vbo_max_size=0; vbo_cur_size=0; @@ -77,6 +68,12 @@ public: ibo=nullptr; } + ~VertexDataManager() + { + SAFE_CLEAR_OBJECT_ARRAY(vbo,vi_count); + SAFE_CLEAR(ibo); + } + const VkDeviceSize GetVBOMaxCount ()const{return vbo_max_size;} ///<取得顶点缓冲区分配的空间最大数量 const VkDeviceSize GetVBOCurCount ()const{return vbo_cur_size;} ///<取得顶点缓冲区当前数量 diff --git a/inc/hgl/graph/VK.h b/inc/hgl/graph/VK.h index 931c704e..78cf3b3e 100644 --- a/inc/hgl/graph/VK.h +++ b/inc/hgl/graph/VK.h @@ -99,6 +99,7 @@ class VILConfig; class VertexInput; struct VertexInputFormat; +using VIF=VertexInputFormat; class VertexInputLayout; using VIL=VertexInputLayout;