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 RENDER_NODE_DOTFIELD_RENDER_H 17 #define RENDER_NODE_DOTFIELD_RENDER_H 18 #include <3d/render/intf_render_node_scene_util.h> 19 #include <base/containers/unordered_map.h> 20 #include <base/math/vector.h> 21 #include <base/util/uid.h> 22 #include <core/namespace.h> 23 #include <render/nodecontext/intf_pipeline_descriptor_set_binder.h> 24 #include <render/nodecontext/intf_render_node.h> 25 #include <render/render_data_structures.h> 26 #include <render/resource_handle.h> 27 28 namespace RENDER_NS { 29 class IRenderCommandList; 30 class IRenderNodeContextManager; 31 class IPipelineDescriptorSetBinder; 32 } // namespace RENDER_NS 33 34 namespace Dotfield { 35 class RenderNodeDotfieldRender final : public RENDER_NS::IRenderNode { 36 public: 37 RenderNodeDotfieldRender() = default; 38 ~RenderNodeDotfieldRender() override = default; 39 40 void InitNode(RENDER_NS::IRenderNodeContextManager& renderNodeContextMgr) override; 41 void PreExecuteFrame() override; 42 void ExecuteFrame(RENDER_NS::IRenderCommandList& cmdList) override; 43 ExecuteFlags GetExecuteFlags() const override 44 { 45 return 0U; 46 } 47 48 static constexpr BASE_NS::Uid UID { "4ce00e60-68c9-46c8-aea8-87c4e7994d27" }; 49 static constexpr char const* TYPE_NAME = "RenderNodeDotfieldRender"; 50 static constexpr RENDER_NS::IRenderNode::BackendFlags BACKEND_FLAGS = 51 RENDER_NS::IRenderNode::BackendFlagBits::BACKEND_FLAG_BITS_DEFAULT; 52 static constexpr RENDER_NS::IRenderNode::ClassType CLASS_TYPE = RENDER_NS::IRenderNode::ClassType::CLASS_TYPE_NODE; 53 static RENDER_NS::IRenderNode* Create(); 54 static void Destroy(RENDER_NS::IRenderNode* instance); 55 56 private: 57 void ParseRenderNodeInputs(); 58 59 RENDER_NS::IRenderNodeContextManager* renderNodeContextMgr_ { nullptr }; 60 CORE3D_NS::SceneRenderDataStores stores_; 61 62 struct PsoData { 63 RENDER_NS::RenderHandle psoHandle; 64 RENDER_NS::PushConstant pushConstant; 65 }; 66 67 struct RenderBinders { 68 RENDER_NS::IDescriptorSetBinder::Ptr set0; 69 RENDER_NS::IDescriptorSetBinder::Ptr set1; 70 }; 71 72 void RenderData(RENDER_NS::IRenderNodeContextManager& renderNodeContextMgr, RENDER_NS::IRenderCommandList& cmdList); 73 PsoData GetPsoData( 74 RENDER_NS::IRenderNodeContextManager& renderNodeContextMgr, const RENDER_NS::RenderHandle& shaderHandle); 75 76 BASE_NS::unordered_map<uint64_t, PsoData> shaderToPsoData_; 77 RenderBinders binders_; 78 RENDER_NS::RenderNodeHandles::InputRenderPass inputRenderPass_; 79 RENDER_NS::RenderPass renderPass_; 80 RENDER_NS::RenderHandle cameraUniformBufferHandle_; 81 RENDER_NS::RenderHandle shaderHandle_; 82 struct JsonInputs { 83 RENDER_NS::RenderNodeGraphInputs::InputRenderPass renderPass; 84 }; 85 JsonInputs jsonInputs_; 86 }; 87 } // namespace Dotfield 88 89 #endif // RENDER_NODE_DOTFIELD_SIMULATION_H 90