[WIP] comments VDM, preparing double PrimitiveCreater

This commit is contained in:
hyzboy 2024-05-23 13:15:47 +08:00
parent c49feac2e6
commit cfd67e1a42
7 changed files with 122 additions and 89 deletions

View File

@ -10,7 +10,7 @@
#include<hgl/graph/VKVertexAttribBuffer.h> #include<hgl/graph/VKVertexAttribBuffer.h>
#include<hgl/graph/mtl/Material3DCreateConfig.h> #include<hgl/graph/mtl/Material3DCreateConfig.h>
#include<hgl/graph/mtl/BlinnPhong.h> #include<hgl/graph/mtl/BlinnPhong.h>
#include<hgl/graph/VertexDataManager.h> //#include<hgl/graph/VertexDataManager.h>
using namespace hgl; using namespace hgl;
using namespace hgl::graph; using namespace hgl::graph;
@ -49,7 +49,7 @@ private:
private: //sphere private: //sphere
Material * mtl_blinnphong =nullptr; Material * mtl_blinnphong =nullptr;
VertexDataManager * vdm_blinnphong =nullptr; //VertexDataManager * vdm_blinnphong =nullptr;
MaterialInstance * mi_blinnphong[4]{}; MaterialInstance * mi_blinnphong[4]{};
Pipeline * p_blinnphong =nullptr; Pipeline * p_blinnphong =nullptr;
@ -100,7 +100,7 @@ private:
mtl_blinnphong->BindUBO(DescriptorSetType::Global,"sun",ubo_sun); mtl_blinnphong->BindUBO(DescriptorSetType::Global,"sun",ubo_sun);
mtl_blinnphong->Update(); mtl_blinnphong->Update();
vdm_blinnphong=new VertexDataManager(device,mtl_blinnphong->GetDefaultVIL()); //vdm_blinnphong=new VertexDataManager(device,mtl_blinnphong->GetDefaultVIL());
Color4f mi_data; Color4f mi_data;
for(uint i=0;i<4;i++) for(uint i=0;i<4;i++)

View File

@ -38,7 +38,7 @@ protected:
public: public:
PrimitiveCreater(GPUDevice *,const VIL *,const AnsiString &name); PrimitiveCreater(GPUDevice *,const VIL *,const AnsiString &name);
//PrimitiveCreater(VertexDataManager *); PrimitiveCreater(VertexDataManager *);
virtual ~PrimitiveCreater() virtual ~PrimitiveCreater()
{ {
ClearAllData(); ClearAllData();

51
inc/hgl/graph/VDMAccess.h Normal file
View File

@ -0,0 +1,51 @@
#pragma once
#include<hgl/graph/VK.h>
#include<hgl/type/DataChain.h>
VK_NAMESPACE_BEGIN
class VDMAccess
{
protected:
VertexDataManager *vdm;
DataChain::UserNode *dc_node;
const VIL *vil;
public:
VDMAccess(VertexDataManager *_vdm,const VIL *_vil)
{
vdm=_vdm;
vil=_vil;
dc_node=nullptr;
}
virtual ~VDMAccess()=default;
const VIL * GetVIL ()const{ return vil; }
const DataChain::UserNode * GetDCNode ()const{ return dc_node; }
};//class VDMAccess
class VABAccessVDM:public VDMAccess
{
VABAccess **vab;
public:
~VABAccessVDM() override
{
vdm->ReleaseVAB(dc_node);
}
};//class VABAccessVDM:public VDMAccess
class IBAccessVDM:public VDMAccess
{
IBAccess *iba;
public:
};//class IBAccessVDM:public VDMAccess
VK_NAMESPACE_END

View File

@ -2,43 +2,9 @@
#include<hgl/graph/VK.h> #include<hgl/graph/VK.h>
#include<hgl/graph/VKIndexBuffer.h> #include<hgl/graph/VKIndexBuffer.h>
#include<hgl/type/DataChain.h> #include<hgl/graph/VDMAccess.h>
#include<hgl/type/Pair.h>
namespace hgl VK_NAMESPACE_BEGIN
{
namespace graph
{
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 class VertexDataManager
{ {
@ -64,8 +30,8 @@ namespace hgl
protected: protected:
friend struct IBAccessNode; friend struct IBAccessVDM;
friend struct VABAccessNode; friend struct VABAccessVDM;
bool ReleaseIB(DataChain::UserNode *); bool ReleaseIB(DataChain::UserNode *);
bool ReleaseVAB(DataChain::UserNode *); bool ReleaseVAB(DataChain::UserNode *);
@ -90,9 +56,10 @@ namespace hgl
bool Init(const VkDeviceSize vbo_size,const VkDeviceSize ibo_size,const IndexType index_type); bool Init(const VkDeviceSize vbo_size,const VkDeviceSize ibo_size,const IndexType index_type);
IBAccessNode *AcquireIB(const VkDeviceSize count); IBAccessVDM *AcquireIB(const VkDeviceSize count);
VABAccessVDM *AcquireVAB(const VkDeviceSize count);
VABAccessNode *AcquireVAB(const VkDeviceSize count); void Release(VABAccessVDM *);
void Release(IBAccessVDM *);
};//class VertexDataManager };//class VertexDataManager
}//namespace graph VK_NAMESPACE_END
}//namespace hgl

View File

@ -9,6 +9,7 @@ SOURCE_GROUP("Texture" FILES ${SG_TEXTURE_SOURCE})
SET(SG_VDM_SOURCE ${SG_INCLUDE_PATH}/VertexAttribDataAccess.h SET(SG_VDM_SOURCE ${SG_INCLUDE_PATH}/VertexAttribDataAccess.h
${SG_INCLUDE_PATH}/VertexDataManager.h ${SG_INCLUDE_PATH}/VertexDataManager.h
${SG_INCLUDE_PATH}/VDMAccess.h
VertexDataManager.cpp) VertexDataManager.cpp)
SOURCE_GROUP("VertexDataManager" FILES ${SG_VDM_SOURCE}) SOURCE_GROUP("VertexDataManager" FILES ${SG_VDM_SOURCE})
@ -307,7 +308,7 @@ add_cm_library(ULRE.SceneGraph "ULRE" ${SCENE_GRAPH_HEADER}
${SG_TEXTURE_SOURCE} ${SG_TEXTURE_SOURCE}
${TILE_SOURCE} ${TILE_SOURCE}
${SG_VDM_SOURCE} #${SG_VDM_SOURCE}
# ${FONT_MANAGE_SOURCE} # ${FONT_MANAGE_SOURCE}
# ${FONT_SOURCE} # ${FONT_SOURCE}

View File

@ -2,7 +2,7 @@
#include<hgl/graph/VKShaderModule.h> #include<hgl/graph/VKShaderModule.h>
#include<hgl/graph/VKVertexAttribBuffer.h> #include<hgl/graph/VKVertexAttribBuffer.h>
#include<hgl/graph/VKPrimitive.h> #include<hgl/graph/VKPrimitive.h>
#include<hgl/graph/VertexDataManager.h> //#include<hgl/graph/VertexDataManager.h>
VK_NAMESPACE_BEGIN VK_NAMESPACE_BEGIN

View File

@ -8,15 +8,29 @@ namespace hgl
{ {
namespace graph namespace graph
{ {
IBAccessNode::~IBAccessNode() class IBAccessVDM:public VDMAccess
{
IBAccess *iba;
public:
~IBAccessVDM() override
{ {
vdm->ReleaseIB(dc_node); vdm->ReleaseIB(dc_node);
} }
};//struct IBAccessVDM
VABAccessNode::~VABAccessNode() class VABAccessVDM:public VDMAccess
{
VABAccess **vab;
public:
~VABAccessVDM() override
{ {
vdm->ReleaseVAB(dc_node); vdm->ReleaseVAB(dc_node);
} }
};//struct VABAccessVDM
}//namespace graph }//namespace graph
namespace graph namespace graph
@ -84,7 +98,7 @@ namespace hgl
return(true); return(true);
} }
IBAccessNode *VertexDataManager::AcquireIB(const VkDeviceSize count) IBAccessVDM *VertexDataManager::AcquireIB(const VkDeviceSize count)
{ {
if(count<=0)return(false); if(count<=0)return(false);
@ -92,7 +106,7 @@ namespace hgl
if(!un)return(false); if(!un)return(false);
IBAccessNode *node=new IBAccessNode; IBAccessVDM *node=new IBAccessVDM;
node->vdm=this; node->vdm=this;
node->dc_node=un; node->dc_node=un;
@ -119,7 +133,7 @@ namespace hgl
return(true); return(true);
} }
VABAccessNode *VertexDataManager::AcquireVAB(const VkDeviceSize count) VABAccessVDM *VertexDataManager::AcquireVAB(const VkDeviceSize count)
{ {
if(count<=0)return(false); if(count<=0)return(false);
@ -127,7 +141,7 @@ namespace hgl
if(!un)return(false); if(!un)return(false);
VABAccessNode *node=new VABAccessNode; VABAccessVDM *node=new VABAccessVDM;
node->vdm=this; node->vdm=this;
node->dc_node=un; node->dc_node=un;