1 /* 2 * Copyright (c) 2022 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_POSTPROCESS_RENDER_POST_PROCESS_TAA_NODE_H 17 #define RENDER_POSTPROCESS_RENDER_POST_PROCESS_TAA_NODE_H 18 19 #include <array> 20 21 #include <base/containers/string.h> 22 #include <base/containers/string_view.h> 23 #include <base/containers/unique_ptr.h> 24 #include <base/math/vector.h> 25 #include <base/util/uid.h> 26 #include <core/plugin/intf_interface.h> 27 #include <core/plugin/intf_interface_helper.h> 28 #include <core/property/intf_property_api.h> 29 #include <core/property/intf_property_handle.h> 30 #include <core/property/property_types.h> 31 #include <core/property_tools/property_api_impl.h> 32 #include <core/property_tools/property_macros.h> 33 #include <render/datastore/render_data_store_render_pods.h> 34 #include <render/device/intf_shader_manager.h> 35 #include <render/namespace.h> 36 #include <render/nodecontext/intf_pipeline_descriptor_set_binder.h> 37 #include <render/nodecontext/intf_render_node.h> 38 #include <render/nodecontext/intf_render_node_post_process_util.h> 39 #include <render/nodecontext/intf_render_post_process.h> 40 #include <render/nodecontext/intf_render_post_process_node.h> 41 #include <render/render_data_structures.h> 42 43 RENDER_BEGIN_NAMESPACE() 44 class IRenderCommandList; 45 class IRenderNodeRenderDataStoreManager; 46 struct RenderNodeGraphInputs; 47 48 class RenderPostProcessTaaNode final : public CORE_NS::IInterfaceHelper<IRenderPostProcessNode> { 49 public: 50 static constexpr auto UID = BASE_NS::Uid("8589eded-49de-4128-852a-f3e521561f93"); 51 52 using Ptr = BASE_NS::refcnt_ptr<RenderPostProcessTaaNode>; 53 54 RenderPostProcessTaaNode(); 55 ~RenderPostProcessTaaNode() = default; 56 57 CORE_NS::IPropertyHandle* GetRenderInputProperties() override; 58 CORE_NS::IPropertyHandle* GetRenderOutputProperties() override; 59 DescriptorCounts GetRenderDescriptorCounts() const override; 60 void SetRenderAreaRequest(const RenderAreaRequest& renderAreaRequest) override; 61 IRenderNode::ExecuteFlags GetExecuteFlags() const override; 62 63 struct EffectProperties { 64 bool enabled { false }; 65 TaaConfiguration taaConfiguration; 66 }; 67 68 void Init(const IRenderPostProcess::Ptr& postProcess, IRenderNodeContextManager& renderNodeContextMgr) override; 69 void PreExecute() override; 70 void Execute(IRenderCommandList& cmdList) override; 71 72 struct NodeInputs { 73 BindableImage input; 74 BindableImage depth; 75 BindableImage velocity; 76 BindableImage history; 77 }; 78 struct NodeOutputs { 79 BindableImage output; 80 }; 81 82 NodeInputs nodeInputsData; 83 NodeOutputs nodeOutputsData; 84 85 private: 86 IRenderNodeContextManager* renderNodeContextMgr_ { nullptr }; 87 IRenderPostProcess::Ptr postProcess_; 88 89 RenderPass CreateRenderPass(const RenderHandle input) const; 90 BASE_NS::Math::Vec4 GetFactorTaa() const; 91 void CheckDescriptorSetNeed(); 92 93 IShaderManager::ShaderData shaderData_; 94 RenderHandle pso_; 95 IDescriptorSetBinder::Ptr taaBinder_; 96 97 RenderHandle samplerHandle_; 98 99 RenderAreaRequest renderAreaRequest_; 100 bool useRequestedRenderArea_ { false }; 101 102 CORE_NS::PropertyApiImpl<NodeInputs> inputProperties_; 103 CORE_NS::PropertyApiImpl<NodeOutputs> outputProperties_; 104 105 RENDER_NS::DescriptorCounts descriptorCounts_; 106 bool valid_ { false }; 107 108 EffectProperties effectProperties_; 109 }; 110 RENDER_END_NAMESPACE() 111 112 #endif // RENDER_POSTPROCESS_RENDER_POST_PROCESS_TAA_NODE_H 113