diff --git a/CMCore b/CMCore index a377fe8d..d4d8af1b 160000 --- a/CMCore +++ b/CMCore @@ -1 +1 @@ -Subproject commit a377fe8d05d9486379c1da6007a940a90898e956 +Subproject commit d4d8af1bdcba53acc70fb6b2edf3b21a3a7245d9 diff --git a/inc/hgl/graph/RenderList2D.h b/inc/hgl/graph/RenderList2D.h index 5b441135..571e9d1f 100644 --- a/inc/hgl/graph/RenderList2D.h +++ b/inc/hgl/graph/RenderList2D.h @@ -23,6 +23,8 @@ namespace hgl private: + uint renderable_count; ///<可渲染对象数量 + MaterialRenderMap2D mrl_map; ///<按材质分类的渲染列表 RenderNode2DComparator render_node_comparator; @@ -38,12 +40,8 @@ namespace hgl virtual bool ExpendNode(SceneNode *); virtual void End(); - bool BindPerFrameDescriptor(); - bool BindPerMaterialDescriptor(); - private: - Material * last_mtl; Pipeline * last_pipeline; MaterialParameters *last_mp[DESCRIPTOR_SET_TYPE_COUNT]; uint32_t last_vbo; diff --git a/inc/hgl/graph/RenderNode2D.h b/inc/hgl/graph/RenderNode2D.h index f4de6737..4d62deb3 100644 --- a/inc/hgl/graph/RenderNode2D.h +++ b/inc/hgl/graph/RenderNode2D.h @@ -17,16 +17,32 @@ namespace hgl Renderable *ri; }; - using RenderNode2DList=List; + using RenderNode2DList=List; /** * 同一材质的对象渲染列表 */ - struct MaterialRenderList2D + class MaterialRenderList2D { Material *mtl; 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 @@ -36,15 +52,18 @@ namespace hgl MaterialRenderMap2D()=default; virtual ~MaterialRenderMap2D()=default; - void ClearData() + void Begin() { 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 hgl - -using RenderNode2DPointer=hgl::graph::RenderNode2D *; -using RenderNode2DComparator=Comparator; #endif//HGL_GRAPH_RENDER_NODE_2D_INCLUDE diff --git a/inc/hgl/graph/VKDescriptorSet.h b/inc/hgl/graph/VKDescriptorSet.h index dca2db64..4d0d3d9f 100644 --- a/inc/hgl/graph/VKDescriptorSet.h +++ b/inc/hgl/graph/VKDescriptorSet.h @@ -23,11 +23,6 @@ class DescriptorSet bool is_dirty; -protected: //动态UBO/SSBO记录 - - - - private: friend class GPUDevice; diff --git a/src/SceneGraph/RenderNode2D.cpp b/src/SceneGraph/RenderNode2D.cpp index a8bee3cd..dd88a180 100644 --- a/src/SceneGraph/RenderNode2D.cpp +++ b/src/SceneGraph/RenderNode2D.cpp @@ -1,10 +1,10 @@ -#include +#include #include #include /** * -* ϽҪ˳ +* 理论上讲,我们需要按以下顺序排序 * * for(material) * for(pipeline) @@ -20,7 +20,7 @@ int Comparator::compare(const hgl::graph::RenderNode2D hgl::graph::Renderable *ri_one=obj_one.ri; hgl::graph::Renderable *ri_two=obj_two.ri; - //ȽϹ + //比较管线 { off=ri_one->GetPipeline() -ri_two->GetPipeline(); @@ -29,7 +29,7 @@ int Comparator::compare(const hgl::graph::RenderNode2D return off; } - //Ƚϲʵ + //比较材质实例 //{ // for(int i =(int)hgl::graph::DescriptorSetType::BEGIN_RANGE; // i<=(int)hgl::graph::DescriptorSetType::END_RANGE; @@ -43,7 +43,7 @@ int Comparator::compare(const hgl::graph::RenderNode2D // } //} - //Ƚvbo+ebo + //比较vbo+ebo { off=ri_one->GetBufferHash() -ri_two->GetBufferHash(); @@ -71,11 +71,17 @@ namespace hgl void MaterialRenderList2D::End() { - Comparator rnc; + //排序 + { + Comparator rnc; - Sort(rn_list,&rnc); + Sort(rn_list,&rnc); + } - + //创建UBO/SSBO绑定数据 + { + mtl-> + } } }//namespace graph }//namespace hgl