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