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_RENDER__NODE__RENDER_NODE_COMPUTE_GENERIC_H 17 #define RENDER_RENDER__NODE__RENDER_NODE_COMPUTE_GENERIC_H 18 19 #include <base/math/vector.h> 20 #include <base/util/uid.h> 21 #include <render/namespace.h> 22 #include <render/nodecontext/intf_pipeline_descriptor_set_binder.h> 23 #include <render/nodecontext/intf_render_node.h> 24 #include <render/render_data_structures.h> 25 #include <render/resource_handle.h> 26 27 RENDER_BEGIN_NAMESPACE() 28 class IRenderCommandList; 29 class IRenderNodeContextManager; 30 struct RenderNodeGraphInputs; 31 32 class RenderNodeComputeGeneric final : public IRenderNode { 33 public: 34 RenderNodeComputeGeneric() = default; 35 ~RenderNodeComputeGeneric() override = default; 36 37 void InitNode(IRenderNodeContextManager& renderNodeContextMgr) override; 38 void PreExecuteFrame() override; 39 void ExecuteFrame(IRenderCommandList& cmdList) override; GetExecuteFlags()40 ExecuteFlags GetExecuteFlags() const override 41 { 42 return 0U; 43 } 44 45 // for plugin / factory interface 46 static constexpr BASE_NS::Uid UID { "dc5da6df-0234-4275-b7a3-d68421e76313" }; 47 static constexpr char const* TYPE_NAME = "RenderNodeComputeGeneric"; 48 static constexpr IRenderNode::BackendFlags BACKEND_FLAGS = IRenderNode::BackendFlagBits::BACKEND_FLAG_BITS_DEFAULT; 49 static constexpr IRenderNode::ClassType CLASS_TYPE = IRenderNode::ClassType::CLASS_TYPE_NODE; 50 static IRenderNode* Create(); 51 static void Destroy(IRenderNode* instance); 52 53 private: 54 IRenderNodeContextManager* renderNodeContextMgr_ { nullptr }; 55 56 void ParseRenderNodeInputs(); 57 RenderHandle GetPsoHandle(IRenderNodeContextManager& renderNodeContextMgr); 58 59 // Json resources which might need re-fetching 60 struct JsonInputs { 61 RenderNodeGraphInputs::InputResources resources; 62 RenderNodeGraphInputs::InputResources dispatchResources; 63 64 RenderNodeGraphInputs::RenderDataStore renderDataStore; 65 RenderNodeGraphInputs::RenderDataStore renderDataStoreSpecialization; 66 67 bool hasChangeableResourceHandles { false }; 68 bool hasChangeableDispatchHandles { false }; 69 }; 70 JsonInputs jsonInputs_; 71 72 RenderNodeHandles::InputResources inputResources_; 73 RenderNodeHandles::InputResources dispatchResources_; 74 RenderHandle shader_; 75 76 IPipelineDescriptorSetBinder::Ptr pipelineDescriptorSetBinder_; 77 PipelineLayout pipelineLayout_; 78 RenderHandle psoHandle_; 79 80 // data store push constant 81 bool useDataStorePushConstant_ { false }; 82 83 // data store shader specialization 84 bool useDataStoreShaderSpecialization_ { false }; 85 struct ShaderSpecilizationData { 86 BASE_NS::vector<ShaderSpecialization::Constant> constants; 87 BASE_NS::vector<uint32_t> data; 88 }; 89 ShaderSpecilizationData shaderSpecializationData_; 90 91 ShaderThreadGroup threadGroupSize_ { 1u, 1u, 1u }; 92 }; 93 RENDER_END_NAMESPACE() 94 95 #endif // CORE__RENDER__NODE__RENDER_NODE_COMPUTE_GENERIC_H 96