newly RenderNode2D/List

This commit is contained in:
HuYingzhuo(hugo/hyzboy) 2023-04-26 20:52:31 +08:00
parent cd03ee8211
commit b26e25df61
5 changed files with 43 additions and 25 deletions

2
CMCore

@ -1 +1 @@
Subproject commit a377fe8d05d9486379c1da6007a940a90898e956 Subproject commit d4d8af1bdcba53acc70fb6b2edf3b21a3a7245d9

View File

@ -23,6 +23,8 @@ namespace hgl
private: private:
uint renderable_count; ///<可渲染对象数量
MaterialRenderMap2D mrl_map; ///<按材质分类的渲染列表 MaterialRenderMap2D mrl_map; ///<按材质分类的渲染列表
RenderNode2DComparator render_node_comparator; RenderNode2DComparator render_node_comparator;
@ -38,12 +40,8 @@ namespace hgl
virtual bool ExpendNode(SceneNode *); virtual bool ExpendNode(SceneNode *);
virtual void End(); virtual void End();
bool BindPerFrameDescriptor();
bool BindPerMaterialDescriptor();
private: private:
Material * last_mtl;
Pipeline * last_pipeline; Pipeline * last_pipeline;
MaterialParameters *last_mp[DESCRIPTOR_SET_TYPE_COUNT]; MaterialParameters *last_mp[DESCRIPTOR_SET_TYPE_COUNT];
uint32_t last_vbo; uint32_t last_vbo;

View File

@ -17,16 +17,32 @@ namespace hgl
Renderable *ri; Renderable *ri;
}; };
using RenderNode2DList=List<RenderNode2D *>; using RenderNode2DList=List<RenderNode2D>;
/** /**
* *
*/ */
struct MaterialRenderList2D class MaterialRenderList2D
{ {
Material *mtl; Material *mtl;
RenderNode2DList rn_list; RenderNode2DList rn_list;
public:
MaterialRenderList2D(Material *m)
{
mtl=m;
}
void Add(Renderable *ri,const Matrix3x4f &mat);
void ClearData()
{
rn_list.ClearData();
}
void End();
}; };
class MaterialRenderMap2D:public ObjectMap<Material *,MaterialRenderList2D> class MaterialRenderMap2D:public ObjectMap<Material *,MaterialRenderList2D>
@ -36,15 +52,18 @@ namespace hgl
MaterialRenderMap2D()=default; MaterialRenderMap2D()=default;
virtual ~MaterialRenderMap2D()=default; virtual ~MaterialRenderMap2D()=default;
void ClearData() void Begin()
{ {
for(auto *it:data_list) for(auto *it:data_list)
it->value->rn_list.ClearData(); it->value->ClearData();
}
void End()
{
for(auto *it:data_list)
it->value->End();
} }
}; };
}//namespace graph }//namespace graph
}//namespace hgl }//namespace hgl
using RenderNode2DPointer=hgl::graph::RenderNode2D *;
using RenderNode2DComparator=Comparator<RenderNode2DPointer>;
#endif//HGL_GRAPH_RENDER_NODE_2D_INCLUDE #endif//HGL_GRAPH_RENDER_NODE_2D_INCLUDE

View File

@ -23,11 +23,6 @@ class DescriptorSet
bool is_dirty; bool is_dirty;
protected: //动态UBO/SSBO记录
private: private:
friend class GPUDevice; friend class GPUDevice;

View File

@ -1,10 +1,10 @@
#include<hgl/graph/RenderNode2D.h> #include<hgl/graph/RenderNode2D.h>
#include<hgl/graph/VKRenderable.h> #include<hgl/graph/VKRenderable.h>
#include<hgl/util/sort/Sort.h> #include<hgl/util/sort/Sort.h>
/** /**
* *
* *
* *
* for(material) * for(material)
* for(pipeline) * for(pipeline)
@ -20,7 +20,7 @@ int Comparator<hgl::graph::RenderNode2D>::compare(const hgl::graph::RenderNode2D
hgl::graph::Renderable *ri_one=obj_one.ri; hgl::graph::Renderable *ri_one=obj_one.ri;
hgl::graph::Renderable *ri_two=obj_two.ri; hgl::graph::Renderable *ri_two=obj_two.ri;
//比较管线 //比较管线
{ {
off=ri_one->GetPipeline() off=ri_one->GetPipeline()
-ri_two->GetPipeline(); -ri_two->GetPipeline();
@ -29,7 +29,7 @@ int Comparator<hgl::graph::RenderNode2D>::compare(const hgl::graph::RenderNode2D
return off; return off;
} }
//比较材质实例 //比较材质实例
//{ //{
// for(int i =(int)hgl::graph::DescriptorSetType::BEGIN_RANGE; // for(int i =(int)hgl::graph::DescriptorSetType::BEGIN_RANGE;
// i<=(int)hgl::graph::DescriptorSetType::END_RANGE; // i<=(int)hgl::graph::DescriptorSetType::END_RANGE;
@ -43,7 +43,7 @@ int Comparator<hgl::graph::RenderNode2D>::compare(const hgl::graph::RenderNode2D
// } // }
//} //}
//比较vbo+ebo //比较vbo+ebo
{ {
off=ri_one->GetBufferHash() off=ri_one->GetBufferHash()
-ri_two->GetBufferHash(); -ri_two->GetBufferHash();
@ -70,12 +70,18 @@ namespace hgl
} }
void MaterialRenderList2D::End() void MaterialRenderList2D::End()
{
//排序
{ {
Comparator<hgl::graph::RenderNode2D> rnc; Comparator<hgl::graph::RenderNode2D> rnc;
Sort(rn_list,&rnc); Sort(rn_list,&rnc);
}
//创建UBO/SSBO绑定数据
{
mtl->
}
} }
}//namespace graph }//namespace graph
}//namespace hgl }//namespace hgl