• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_RENDER_MOTION_BLUR_H
17 #define RENDER_NODE_RENDER_MOTION_BLUR_H
18 
19 #include <base/containers/string.h>
20 #include <base/containers/vector.h>
21 #include <base/math/vector.h>
22 #include <render/datastore/render_data_store_render_pods.h>
23 #include <render/namespace.h>
24 #include <render/nodecontext/intf_pipeline_descriptor_set_binder.h>
25 #include <render/nodecontext/intf_render_node.h>
26 #include <render/render_data_structures.h>
27 #include <render/resource_handle.h>
28 
29 RENDER_BEGIN_NAMESPACE()
30 class IRenderCommandList;
31 
32 class RenderMotionBlur final {
33 public:
34     RenderMotionBlur() = default;
35     ~RenderMotionBlur() = default;
36 
37     struct MotionBlurInfo {
38         RenderHandle input;
39         RenderHandle output;
40         RenderHandle velocity;
41         RenderHandle depth;
42         RenderHandle globalUbo;
43         uint32_t globalUboByteOffset { 0U };
44         BASE_NS::Math::UVec2 size { 0U, 0U };
45     };
46     void Init(IRenderNodeContextManager& renderNodeContextMgr, const MotionBlurInfo& blurInfo);
47     void PreExecute(IRenderNodeContextManager& renderNodeContextMgr, const MotionBlurInfo& blurInfo,
48         const PostProcessConfiguration& ppConfig);
49     void Execute(IRenderNodeContextManager& renderNodeContextMgr, IRenderCommandList& cmdList,
50         const MotionBlurInfo& blurInfo, const PostProcessConfiguration& ppConfig);
51 
52     static DescriptorCounts GetDescriptorCounts();
53 
54 private:
55     void ExecuteTileVelocity(
56         IRenderNodeContextManager& renderNodeContextMgr, IRenderCommandList& cmdList, const MotionBlurInfo& blurInfo);
57     void UpdateDescriptorSet0(IRenderCommandList& cmdList, const MotionBlurInfo& blurInfo);
58     RenderHandle GetTileVelocityForMotionBlur() const;
59 
60     struct RenderDataHandles {
61         RenderHandle shader;
62         RenderHandle pso;
63         PipelineLayout pipelineLayout;
64     };
65     RenderDataHandles renderData_;
66     RenderDataHandles renderTileMaxData_;
67     struct RenderDataHandlesTileNeighborhood {
68         RenderHandle shader;
69         PipelineLayout pipelineLayout;
70         RenderHandle psoNeighborhood;
71         RenderHandle psoHorizontal;
72         RenderHandle psoVertical;
73         bool doublePass { true };
74     };
75     RenderDataHandlesTileNeighborhood renderTileNeighborData_;
76 
77     IDescriptorSetBinder::Ptr globalSet0_;
78     IDescriptorSetBinder::Ptr localSet1_;
79     IDescriptorSetBinder::Ptr localTileMaxSet1_;
80     IDescriptorSetBinder::Ptr localTileNeighborhoodSet1_[2U];
81     RenderHandle samplerHandle_;
82     RenderHandle samplerNearestHandle_;
83     MotionBlurInfo motionBlurInfo_;
84 
85     RenderHandleReference tileVelocityImages_[2U];
86     BASE_NS::Math::UVec2 tileImageSize_ { 0U, 0U };
87 };
88 RENDER_END_NAMESPACE()
89 
90 #endif // CORE__RENDER__NODE__RENDER_MOTION_BLUR_H
91