1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef CORE__RENDER__NODE__RENDER_NODE_DEFAULT_MATERIAL_OBJECTS_H 17 #define CORE__RENDER__NODE__RENDER_NODE_DEFAULT_MATERIAL_OBJECTS_H 18 19 #include <base/util/uid.h> 20 #include <core/namespace.h> 21 #include <render/nodecontext/intf_render_node.h> 22 #include <render/resource_handle.h> 23 24 #include "render/render_node_scene_util.h" 25 26 CORE3D_BEGIN_NAMESPACE() 27 class IRenderDataStoreDefaultMaterial; 28 29 class RenderNodeDefaultMaterialObjects final : public RENDER_NS::IRenderNode { 30 public: 31 RenderNodeDefaultMaterialObjects() = default; 32 ~RenderNodeDefaultMaterialObjects() override = default; 33 34 void InitNode(RENDER_NS::IRenderNodeContextManager& renderNodeContextMgr) override; 35 void PreExecuteFrame() override; 36 void ExecuteFrame(RENDER_NS::IRenderCommandList& cmdList) override; GetExecuteFlags()37 ExecuteFlags GetExecuteFlags() const override 38 { 39 return 0U; 40 } 41 42 // for plugin / factory interface 43 static constexpr BASE_NS::Uid UID { "a25b27ea-a4ff-4b64-87c7-a7865cccfd92" }; 44 static constexpr char const* const TYPE_NAME = "RenderNodeDefaultMaterialObjects"; 45 static constexpr IRenderNode::BackendFlags BACKEND_FLAGS = IRenderNode::BackendFlagBits::BACKEND_FLAG_BITS_DEFAULT; 46 static constexpr IRenderNode::ClassType CLASS_TYPE = IRenderNode::ClassType::CLASS_TYPE_NODE; 47 static IRenderNode* Create(); 48 static void Destroy(IRenderNode* instance); 49 50 private: 51 struct ObjectCounts { 52 uint32_t maxMeshCount { 0u }; 53 uint32_t maxSubmeshCount { 0u }; 54 uint32_t maxSkinCount { 0u }; 55 uint32_t maxMaterialCount { 0u }; 56 }; 57 struct UboHandles { 58 RENDER_NS::RenderHandleReference mat; 59 RENDER_NS::RenderHandleReference matTransform; 60 RENDER_NS::RenderHandleReference userMat; 61 RENDER_NS::RenderHandleReference mesh; 62 RENDER_NS::RenderHandleReference submeshSkin; 63 }; 64 65 void UpdateBuffers(const IRenderDataStoreDefaultMaterial& dataStoreMaterial); 66 void UpdateMeshBuffer(const IRenderDataStoreDefaultMaterial& dataStoreMaterial); 67 void UpdateSkinBuffer(const IRenderDataStoreDefaultMaterial& dataStoreMaterial); 68 void UpdateMaterialBuffers(const IRenderDataStoreDefaultMaterial& dataStoreMaterial); 69 void ProcessBuffers(const ObjectCounts& objectCounts); 70 71 RENDER_NS::IRenderNodeContextManager* renderNodeContextMgr_ { nullptr }; 72 73 SceneRenderDataStores stores_; 74 ObjectCounts objectCounts_; 75 UboHandles ubos_; 76 }; 77 CORE3D_END_NAMESPACE() 78 79 #endif // CORE__RENDER__NODE__RENDER_NODE_DEFAULT_MATERIAL_OBJECTS_H 80