From 4208e47534b92c0dfeff6960f808318b1a65637f Mon Sep 17 00:00:00 2001 From: "HuYingzhuo(hugo/hyzboy)" Date: Tue, 19 Sep 2023 21:45:54 +0800 Subject: [PATCH] newly material instance stat,but can't run. --- inc/hgl/graph/MaterialRenderList.h | 3 ++- inc/hgl/graph/RenderNode.h | 2 -- src/SceneGraph/MaterialRenderList.cpp | 18 +++++++++++++++--- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/inc/hgl/graph/MaterialRenderList.h b/inc/hgl/graph/MaterialRenderList.h index 4fd0db66..9c4a33a9 100644 --- a/inc/hgl/graph/MaterialRenderList.h +++ b/inc/hgl/graph/MaterialRenderList.h @@ -35,10 +35,11 @@ private: void Set(Renderable *); }; - MaterialInstanceSets mi_set; + SortedSets mi_id_set; DataArray ri_array; uint ri_count; + void StatMI(); void Stat(); protected: diff --git a/inc/hgl/graph/RenderNode.h b/inc/hgl/graph/RenderNode.h index 9e42d2b7..d164c8b3 100644 --- a/inc/hgl/graph/RenderNode.h +++ b/inc/hgl/graph/RenderNode.h @@ -22,8 +22,6 @@ namespace hgl }; using RenderNodeList=List; - - using MaterialInstanceSets=SortedSets; }//namespace graph }//namespace hgl #endif//HGL_GRAPH_RENDER_NODE_INCLUDE diff --git a/src/SceneGraph/MaterialRenderList.cpp b/src/SceneGraph/MaterialRenderList.cpp index 417fe4d9..b4b43d72 100644 --- a/src/SceneGraph/MaterialRenderList.cpp +++ b/src/SceneGraph/MaterialRenderList.cpp @@ -91,6 +91,7 @@ void MaterialRenderList::End() if(node_count<=0)return; + StatMI(); Stat(); //写入LocalToWorld数据 @@ -104,6 +105,19 @@ void MaterialRenderList::RenderItem::Set(Renderable *ri) vid =ri->GetVertexInputData(); } +void MaterialRenderList::StatMI() +{ + mi_id_set.Clear(); + + for(RenderNode &rn:rn_list) + mi_id_set.Add(rn.ri->GetMaterialInstance()->GetMIID()); + + if(mi_id_set.GetCount()>mtl->GetMIMaxCount()) + { + //超出最大数量了怎么办??? + } +} + void MaterialRenderList::Stat() { const uint count=rn_list.GetCount(); @@ -112,8 +126,6 @@ void MaterialRenderList::Stat() ri_array.Clear(); ri_array.Alloc(count); - mi_set.Clear(); - RenderItem *ri=ri_array.GetData(); ri_count=1; @@ -131,7 +143,7 @@ void MaterialRenderList::Stat() ++rn; for(uint i=1;iri->GetPipeline()) if(last_mi==rn->ri->GetMaterialInstance()) if(last_vid==rn->ri->GetVertexInputData())