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_COPY_UTIL_H 17 #define API_RENDER_IRENDER_NODE_COPY_UTIL_H 18 19 #include <cstdint> 20 21 #include <base/util/uid.h> 22 #include <core/plugin/intf_interface.h> 23 #include <render/device/pipeline_layout_desc.h> 24 #include <render/namespace.h> 25 #include <render/render_data_structures.h> 26 27 RENDER_BEGIN_NAMESPACE() 28 class IRenderNodeContextManager; 29 class IRenderCommandList; 30 31 /** 32 * IRenderNodeCopyUtil. 33 * Helper class for copying images in render nodes. 34 * Creation: 35 * CORE_NS::CreateInstance<IRenderNodeCopyUtil>(renderContext, UID_RENDER_NODE_COPY_UTIL); 36 */ 37 class IRenderNodeCopyUtil : public CORE_NS::IInterface { 38 public: 39 static constexpr BASE_NS::Uid UID { "cf855681-2446-42fc-bc6b-8c439871f8db" }; 40 41 using Ptr = BASE_NS::refcnt_ptr<IRenderNodeCopyUtil>; 42 43 /** Copy type */ 44 enum class CopyType : uint32_t { 45 /** Basic copy the 2D image */ 46 BASIC_COPY = 0, 47 /** Layer copy */ 48 LAYER_COPY = 1, 49 }; 50 51 /** Copy info */ 52 struct CopyInfo { 53 /** Bindable input image */ 54 BindableImage input; 55 /** The output where to copy */ 56 BindableImage output; 57 /** Sampler (if not given linear clamp is used) */ 58 RenderHandle sampler; 59 /** Copy type to be used */ 60 CopyType copyType { CopyType::BASIC_COPY }; 61 }; 62 63 /** 64 * Init method. Call in render node Init() 65 */ 66 virtual void Init(IRenderNodeContextManager& renderNodeContextMgr) = 0; 67 68 /** 69 * PreExecute method. Call in render node PreExecute() 70 */ 71 virtual void PreExecute() = 0; 72 73 /** 74 * Execute method. Call in render node Execute() 75 */ 76 virtual void Execute(IRenderCommandList& cmdList, const CopyInfo& copyInfo) = 0; 77 78 /** 79 * Get render descriptor counts 80 */ 81 virtual DescriptorCounts GetRenderDescriptorCounts() const = 0; 82 83 protected: 84 IRenderNodeCopyUtil() = default; 85 virtual ~IRenderNodeCopyUtil() = default; 86 }; 87 GetName(const IRenderNodeCopyUtil *)88inline constexpr BASE_NS::string_view GetName(const IRenderNodeCopyUtil*) 89 { 90 return "IRenderNodeCopyUtil"; 91 } 92 RENDER_END_NAMESPACE() 93 94 #endif // API_RENDER_IRENDER_NODE_COPY_UTIL_H 95