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 API_RENDER_IRENDER_NODE_POST_PROCESS_UTIL_H
17 #define API_RENDER_IRENDER_NODE_POST_PROCESS_UTIL_H
18 
19 #include <cstdint>
20 
21 #include <base/containers/vector.h>
22 #include <base/util/uid.h>
23 #include <core/plugin/intf_interface.h>
24 #include <render/device/pipeline_state_desc.h>
25 #include <render/render_data_structures.h>
26 
27 RENDER_BEGIN_NAMESPACE()
28 class IRenderNodeContextManager;
29 class IRenderCommandList;
30 
31 /**
32  * IRenderNodePostProcessUtil.
33  * Helper class for combined post process rendering.
34  * Creation:
35  * CORE_NS::CreateInstance<IRenderNodePostProcessUtil>(renderContext, UID_RENDER_NODE_POST_PROCESS_UTIL);
36  */
37 class IRenderNodePostProcessUtil : public CORE_NS::IInterface {
38 public:
39     static constexpr BASE_NS::Uid UID { "84057a3c-0e0f-4752-84af-55591f746ceb" };
40 
41     using Ptr = BASE_NS::refcnt_ptr<IRenderNodePostProcessUtil>;
42 
43     /**
44      * Image data is filled automatically by the class if data is not given and it's needed
45      * If parsing is true, the resources are parsed from render node inputs
46      */
47     struct ImageData {
48         /** Global input */
49         BindableImage input;
50         /** Global output */
51         BindableImage output;
52 
53         /** Depth */
54         BindableImage depth;
55         /** Velocity */
56         BindableImage velocity;
57 
58         /** History image */
59         BindableImage history;
60         /** History next image */
61         BindableImage historyNext;
62 
63         /** Dirtmask */
64         RenderHandle dirtMask;
65     };
66 
67     struct PostProcessInfo {
68         /** Parse render node resource inputs */
69         bool parseRenderNodeInputs { true };
70         /** Input image data */
71         ImageData imageData;
72     };
73 
74     /**
75      * Init method. Call in render node Init()
76      */
77     virtual void Init(IRenderNodeContextManager& renderNodeContextMgr, const PostProcessInfo& postProcessInfo) = 0;
78 
79     /**
80      * PreExecute method. Call in render node PreExecute()
81      */
82     virtual void PreExecute(const PostProcessInfo& postProcessInfo) = 0;
83 
84     /**
85      * Execute method. Call in render node Execute()
86      */
87     virtual void Execute(IRenderCommandList& cmdList) = 0;
88 
89 protected:
90     IRenderNodePostProcessUtil() = default;
91     virtual ~IRenderNodePostProcessUtil() = default;
92 };
93 
GetName(const IRenderNodePostProcessUtil *)94 inline constexpr BASE_NS::string_view GetName(const IRenderNodePostProcessUtil*)
95 {
96     return "IRenderNodePostProcessUtil";
97 }
98 RENDER_END_NAMESPACE()
99 
100 #endif // API_RENDER_IRENDER_NODE_POST_PROCESS_UTIL_H
101