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_FXAA_NODE_H 17 #define RENDER_POSTPROCESS_RENDER_POST_PROCESS_FXAA_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 RenderPostProcessFxaaNode final : public CORE_NS::IInterfaceHelper<IRenderPostProcessNode> { 49 public: 50 static constexpr auto UID = BASE_NS::Uid("7ae334d0-4da8-4e17-842a-d4fe3a4ef61d"); 51 52 using Ptr = BASE_NS::refcnt_ptr<RenderPostProcessFxaaNode>; 53 54 RenderPostProcessFxaaNode(); 55 ~RenderPostProcessFxaaNode() = 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 BASE_NS::Math::Vec4 targetSize { 0.0f, 0.0f, 0.0f, 0.0f }; 66 FxaaConfiguration fxaaConfiguration; 67 }; 68 69 void Init(const IRenderPostProcess::Ptr& postProcess, IRenderNodeContextManager& renderNodeContextMgr) override; 70 void PreExecute() override; 71 void Execute(IRenderCommandList& cmdList) override; 72 73 // for plugin / factory interface 74 static constexpr const char* TYPE_NAME = "RenderPostProcessFxaaNode"; 75 76 struct NodeInputs { 77 BindableImage input; 78 }; 79 struct NodeOutputs { 80 BindableImage output; 81 }; 82 83 NodeInputs nodeInputsData; 84 NodeOutputs nodeOutputsData; 85 86 private: 87 IRenderNodeContextManager* renderNodeContextMgr_ { nullptr }; 88 IRenderPostProcess::Ptr postProcess_; 89 90 RenderPass CreateRenderPass(const RenderHandle input) const; 91 BASE_NS::Math::Vec4 GetFactorFxaa() const; 92 void CheckDescriptorSetNeed(); 93 94 IShaderManager::ShaderData shaderData_; 95 RenderHandle pso_; 96 IDescriptorSetBinder::Ptr fxaaBinder_; 97 98 RenderHandle samplerHandle_; 99 100 RenderAreaRequest renderAreaRequest_; 101 bool useRequestedRenderArea_ { false }; 102 103 CORE_NS::PropertyApiImpl<NodeInputs> inputProperties_; 104 CORE_NS::PropertyApiImpl<NodeOutputs> outputProperties_; 105 106 RENDER_NS::DescriptorCounts descriptorCounts_; 107 bool valid_ { false }; 108 109 EffectProperties effectProperties_; 110 }; 111 RENDER_END_NAMESPACE() 112 113 #endif // RENDER_POSTPROCESS_RENDER_POST_PROCESS_FXAA_NODE_H 114