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_COPY_H
17 #define RENDER_RENDER__NODE__RENDER_COPY_H
18 
19 #include <render/namespace.h>
20 #include <render/nodecontext/intf_pipeline_descriptor_set_binder.h>
21 #include <render/nodecontext/intf_render_node.h>
22 #include <render/render_data_structures.h>
23 #include <render/resource_handle.h>
24 
25 RENDER_BEGIN_NAMESPACE()
26 class IRenderCommandList;
27 
28 class RenderCopy final {
29 public:
30     RenderCopy() = default;
31     ~RenderCopy() = default;
32 
33     enum class CopyType : uint32_t {
34         BASIC_COPY = 0,
35         LAYER_COPY = 1,
36     };
37 
38     struct CopyInfo {
39         BindableImage input;
40         BindableImage output;
41         RenderHandle sampler; // if not given linear clamp is used
42         CopyType copyType { CopyType::BASIC_COPY };
43     };
44     void Init(IRenderNodeContextManager& renderNodeContextMgr, const CopyInfo& copyInfo);
45     void PreExecute(IRenderNodeContextManager& renderNodeContextMgr, const CopyInfo& copyInfo);
46     void Execute(IRenderNodeContextManager& renderNodeContextMgr, IRenderCommandList& cmdList);
47 
48     DescriptorCounts GetDescriptorCounts() const;
49 
50 private:
51     CopyInfo copyInfo_;
52     struct RenderDataHandles {
53         RenderHandle shader;
54         PipelineLayout pipelineLayout;
55         RenderHandle pso;
56         RenderHandle sampler;
57 
58         RenderHandle shaderLayer;
59         PipelineLayout pipelineLayoutLayer;
60         RenderHandle psoLayer;
61     };
62     RenderDataHandles renderData_;
63 
64     IDescriptorSetBinder::Ptr binder_;
65 };
66 RENDER_END_NAMESPACE()
67 
68 #endif // CORE__RENDER__NODE__RENDER_COPY_H
69