• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 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 API_RENDER_IRENDER_NODE_GRAPH_SHARE_MANAGER_H
17 #define API_RENDER_IRENDER_NODE_GRAPH_SHARE_MANAGER_H
18 
19 #include <base/containers/string_view.h>
20 #include <base/util/uid.h>
21 #include <render/namespace.h>
22 #include <render/nodecontext/intf_render_node_interface.h>
23 #include <render/render_data_structures.h>
24 #include <render/resource_handle.h>
25 
RENDER_BEGIN_NAMESPACE()26 RENDER_BEGIN_NAMESPACE()
27 /** @ingroup group_render_IRenderNodeGraphShareManager */
28 /**
29  * Share input / output and other resources with current render node graph.
30  * Resources might change during the run and new RenderNodes might come in between.
31  *
32  * Methods with PreExecuteFrame -prefix are only valid to be called in RenderNode::PreExecuteFrame().
33  * Methods with ExecuteFrame -prefix are only valid to be called in RenderNode::ExecuteFrame().
34  */
35 class IRenderNodeGraphShareManager : public IRenderNodeInterface {
36 public:
37     static constexpr auto UID = BASE_NS::Uid("1c573502-0e25-481b-bf20-b1d1f09af37f");
38 
39     /** Get render node graph input resource handles.
40      * Set globally through render node graph manager or in render node graph description.
41      */
42     virtual BASE_NS::array_view<const RenderHandle> GetRenderNodeGraphInputs() const = 0;
43 
44     /** Get render node graph output resource handles.
45      * Set globally through render node graph manager or in render node graph description.
46      */
47     virtual BASE_NS::array_view<const RenderHandle> GetRenderNodeGraphOutputs() const = 0;
48 
49     /** Get render node graph input resource handle with index.
50      * Set globally through render node graph manager or in render node graph description.
51      */
52     virtual RenderHandle GetRenderNodeGraphInput(const uint32_t index) const = 0;
53 
54     /** Get render node graph output resource handle with index.
55      * Set globally through render node graph manager or in render node graph description.
56      */
57     virtual RenderHandle GetRenderNodeGraphOutput(const uint32_t index) const = 0;
58 
59     /** Register render node graph output resource handles. (I.e. the output of this render node graph)
60      * Often these should be set from the outside, but a controller render node can handle this as well.
61      * Should be called every frame in PreExecuteFrame() (and initially in InitNode()).
62      * @param outputHandles Output handles to be registered.
63      */
64     virtual void RegisterRenderNodeGraphOutputs(const BASE_NS::array_view<const RenderHandle> outputs) = 0;
65 
66     /** Register render node output resource handles. (I.e. the output of this render node)
67      * Should be called every frame in PreExecuteFrame() (and initially in InitNode()).
68      * @param outputs Output handles to be registered.
69      */
70     virtual void RegisterRenderNodeOutputs(const BASE_NS::array_view<const RenderHandle> outputs) = 0;
71 
72     /** Register render node output one-by-one.
73      * Should be called every frame in PreExecuteFrame() (and initially in InitNode()).
74      * @param name Named output handle to be registered.
75      * @param handle Output handle to be registered.
76      */
77     virtual void RegisterRenderNodeOutput(const BASE_NS::string_view name, const RenderHandle& handle) = 0;
78 
79     /** Get registered output from a named render node with index.
80      */
81     virtual RenderHandle GetRegisteredRenderNodeOutput(
82         const BASE_NS::string_view renderNodeName, const uint32_t index) const = 0;
83 
84     /** Get registered output from a named render node with name.
85      * @param renderNodeName Render node name of the output.
86      * @param resourceName Name of the output resource.
87      */
88     virtual RenderHandle GetRegisteredRenderNodeOutput(
89         const BASE_NS::string_view renderNodeName, const BASE_NS::string_view resourceName) const = 0;
90 
91     /** Get registered output from previous render node with index.
92      * @param index Index of the output.
93      */
94     virtual RenderHandle GetRegisteredPrevRenderNodeOutput(const uint32_t index) const = 0;
95 
96 protected:
97     IRenderNodeGraphShareManager() = default;
98     virtual ~IRenderNodeGraphShareManager() = default;
99 
100     IRenderNodeGraphShareManager(const IRenderNodeGraphShareManager&) = delete;
101     IRenderNodeGraphShareManager& operator=(const IRenderNodeGraphShareManager&) = delete;
102     IRenderNodeGraphShareManager(IRenderNodeGraphShareManager&&) = delete;
103     IRenderNodeGraphShareManager& operator=(IRenderNodeGraphShareManager&&) = delete;
104 };
105 RENDER_END_NAMESPACE()
106 
107 #endif // API_RENDER_IRENDER_NODE_GRAPH_SHARE_H
108