diff --git a/inc/hgl/graph/VKMaterial.h b/inc/hgl/graph/VKMaterial.h index 47d41fb4..2f181abd 100644 --- a/inc/hgl/graph/VKMaterial.h +++ b/inc/hgl/graph/VKMaterial.h @@ -76,8 +76,9 @@ public: public: - const uint32_t GetMIDataBytes ()const{return mi_data_bytes;} - const uint32_t GetMIMaxCount ()const{return mi_max_count;} + const bool HasMI ()const{return !mi_data_bytes;} + const uint32_t GetMIDataBytes ()const{return mi_data_bytes;} + const uint32_t GetMIMaxCount ()const{return mi_max_count;} void ReleaseMI(int); ///<释放材质实例 void *GetMIData(int); ///<取得指定ID号的材质实例数据访问指针 diff --git a/src/SceneGraph/MaterialRenderList.cpp b/src/SceneGraph/MaterialRenderList.cpp index b4b43d72..33bb0911 100644 --- a/src/SceneGraph/MaterialRenderList.cpp +++ b/src/SceneGraph/MaterialRenderList.cpp @@ -91,7 +91,9 @@ void MaterialRenderList::End() if(node_count<=0)return; - StatMI(); + if(mtl->HasMI()) + StatMI(); + Stat(); //写入LocalToWorld数据 @@ -116,6 +118,8 @@ void MaterialRenderList::StatMI() { //超出最大数量了怎么办??? } + + } void MaterialRenderList::Stat() diff --git a/src/SceneGraph/RenderAssignBuffer.cpp b/src/SceneGraph/RenderAssignBuffer.cpp index f3d46aa2..ad0d1e94 100644 --- a/src/SceneGraph/RenderAssignBuffer.cpp +++ b/src/SceneGraph/RenderAssignBuffer.cpp @@ -8,6 +8,18 @@ VK_NAMESPACE_BEGIN +RenderAssignBuffer::RenderAssignBuffer(GPUDevice *dev,const uint mi_total_bytes) +{ + hgl_zero(*this); + + device=dev; + + if(mi_total_bytes>0) + ubo_mi=device->CreateUBO(mi_total_bytes); + else + ubo_mi=nullptr; +} + VkBuffer RenderAssignBuffer::GetAssignVBO()const { return vbo_assigns->GetBuffer(); @@ -44,15 +56,16 @@ void RenderAssignBuffer::Alloc(const uint nc,const uint mc) ubo_l2w=device->CreateUBO(node_count*sizeof(Matrix4f)); } - { - mi_count=power_to_2(mc); - - ubo_mi=device->CreateUBO(mi_count*mi_data_bytes); - } - vbo_assigns=device->CreateVBO(ASSIGN_VBO_FMT,node_count); } +bool RenderAssignBuffer::WriteMIData(void *mi_data,const uint bytes) +{ + if(!mi_data||!bytes||!ubo_mi)return(false); + + return ubo_mi->Write(mi_data,bytes); +} + void RenderAssignBuffer::WriteNode(RenderNode *render_node,const uint count,const MaterialInstanceSets &mi_set) { RenderNode *rn; diff --git a/src/SceneGraph/RenderAssignBuffer.h b/src/SceneGraph/RenderAssignBuffer.h index da9c785f..949247a6 100644 --- a/src/SceneGraph/RenderAssignBuffer.h +++ b/src/SceneGraph/RenderAssignBuffer.h @@ -37,8 +37,6 @@ private: uint node_count; ///<渲染节点数量 DeviceBuffer *ubo_l2w; ///