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_POSTPROCESS_RENDER_POSTPROCESS_FLARE_NODE_H 17 #define RENDER_POSTPROCESS_RENDER_POSTPROCESS_FLARE_NODE_H 18 19 #include <base/containers/unique_ptr.h> 20 #include <base/util/uid.h> 21 #include <core/plugin/intf_interface.h> 22 #include <core/plugin/intf_interface_helper.h> 23 #include <core/property/intf_property_api.h> 24 #include <core/property/intf_property_handle.h> 25 #include <core/property/property_types.h> 26 #include <core/property_tools/property_api_impl.h> 27 #include <core/property_tools/property_macros.h> 28 #include <render/device/intf_shader_manager.h> 29 #include <render/namespace.h> 30 #include <render/nodecontext/intf_render_node.h> 31 #include <render/nodecontext/intf_render_post_process.h> 32 #include <render/nodecontext/intf_render_post_process_node.h> 33 #include <render/property/property_types.h> 34 #include <render/render_data_structures.h> 35 RENDER_BEGIN_NAMESPACE()36RENDER_BEGIN_NAMESPACE() 37 class RenderPostProcessFlareNode : public CORE_NS::IInterfaceHelper<RENDER_NS::IRenderPostProcessNode> { 38 public: 39 static constexpr auto UID = BASE_NS::Uid("eeea01ce-c094-4559-a909-ea44172c7d43"); 40 41 using Ptr = BASE_NS::refcnt_ptr<RenderPostProcessFlareNode>; 42 43 RenderPostProcessFlareNode(); 44 45 CORE_NS::IPropertyHandle* GetRenderInputProperties() override; 46 CORE_NS::IPropertyHandle* GetRenderOutputProperties() override; 47 RENDER_NS::DescriptorCounts GetRenderDescriptorCounts() const override; 48 void SetRenderAreaRequest(const RenderAreaRequest& renderAreaRequest) override; 49 50 RENDER_NS::IRenderNode::ExecuteFlags GetExecuteFlags() const override; 51 void Init(const RENDER_NS::IRenderPostProcess::Ptr& postProcess, 52 RENDER_NS::IRenderNodeContextManager& renderNodeContextMgr) override; 53 void PreExecute() override; 54 void Execute(RENDER_NS::IRenderCommandList& cmdList) override; 55 56 struct NodeInputs { 57 RENDER_NS::BindableImage input; 58 }; 59 struct NodeOutputs { 60 RENDER_NS::BindableImage output; 61 }; 62 63 private: 64 RENDER_NS::IRenderNodeContextManager* renderNodeContextMgr_ { nullptr }; 65 RENDER_NS::IRenderPostProcess::Ptr postProcess_; 66 67 static constexpr uint64_t INVALID_CAM_ID { 0xFFFFFFFFffffffff }; 68 struct JsonInputs { 69 BASE_NS::string customCameraName; 70 uint64_t customCameraId { INVALID_CAM_ID }; 71 }; 72 JsonInputs jsonInputs_; 73 74 struct PushConstantStruct { 75 BASE_NS::Math::Vec4 texSizeInvTexSize; 76 BASE_NS::Math::Vec4 rt; 77 }; 78 79 void EvaluateOutput(); 80 PushConstantStruct GetPushDataStruct(uint32_t width, uint32_t height) const; 81 82 RenderAreaRequest renderAreaRequest_; 83 bool useRequestedRenderArea_ { false }; 84 85 struct PipelineData { 86 RENDER_NS::IShaderManager::GraphicsShaderData gsd; 87 RENDER_NS::RenderHandle pso; 88 }; 89 PipelineData pipelineData_; 90 91 RENDER_NS::RenderHandleReference tempTarget_; 92 93 NodeInputs nodeInputsData_; 94 NodeOutputs nodeOutputsData_; 95 CORE_NS::PropertyApiImpl<NodeInputs> inputProperties_; 96 CORE_NS::PropertyApiImpl<NodeOutputs> outputProperties_; 97 98 RENDER_NS::BindableImage defaultInput_; 99 100 RENDER_NS::DescriptorCounts descriptorCounts_; 101 bool valid_ { false }; 102 bool enabled_ { false }; 103 }; 104 RENDER_END_NAMESPACE() 105 106 #endif // RENDER_POSTPROCESS_RENDER_POSTPROCESS_FLARE_NODE_H 107