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_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 struct EffectProperties { 44 bool enabled { true }; 45 BASE_NS::Math::Vec3 flarePos { 0.0f, 0.0f, 0.0f }; 46 float intensity { 1.0f }; 47 }; 48 49 RenderPostProcessFlareNode(); 50 51 CORE_NS::IPropertyHandle* GetRenderInputProperties() override; 52 CORE_NS::IPropertyHandle* GetRenderOutputProperties() override; 53 RENDER_NS::DescriptorCounts GetRenderDescriptorCounts() const override; 54 void SetRenderAreaRequest(const RenderAreaRequest& renderAreaRequest) override; 55 56 RENDER_NS::IRenderNode::ExecuteFlags GetExecuteFlags() const override; 57 void Init(const RENDER_NS::IRenderPostProcess::Ptr& postProcess, 58 RENDER_NS::IRenderNodeContextManager& renderNodeContextMgr) override; 59 void PreExecute() override; 60 void Execute(RENDER_NS::IRenderCommandList& cmdList) override; 61 62 struct NodeInputs { 63 RENDER_NS::BindableImage input; 64 }; 65 struct NodeOutputs { 66 RENDER_NS::BindableImage output; 67 }; 68 69 NodeInputs nodeInputsData; 70 NodeOutputs nodeOutputsData; 71 72 private: 73 RENDER_NS::IRenderNodeContextManager* renderNodeContextMgr_ { nullptr }; 74 RENDER_NS::IRenderPostProcess::Ptr postProcess_; 75 76 static constexpr uint64_t INVALID_CAM_ID { 0xFFFFFFFFffffffff }; 77 struct JsonInputs { 78 BASE_NS::string customCameraName; 79 uint64_t customCameraId { INVALID_CAM_ID }; 80 }; 81 JsonInputs jsonInputs_; 82 83 struct PushConstantStruct { 84 BASE_NS::Math::Vec4 texSizeInvTexSize; 85 BASE_NS::Math::Vec4 rt; 86 }; 87 88 void EvaluateOutput(); 89 PushConstantStruct GetPushDataStruct(uint32_t width, uint32_t height) const; 90 91 RenderAreaRequest renderAreaRequest_; 92 bool useRequestedRenderArea_ { false }; 93 94 struct PipelineData { 95 RENDER_NS::IShaderManager::GraphicsShaderData gsd; 96 RENDER_NS::RenderHandle pso; 97 }; 98 PipelineData pipelineData_; 99 100 RENDER_NS::RenderHandleReference tempTarget_; 101 102 CORE_NS::PropertyApiImpl<NodeInputs> inputProperties_; 103 CORE_NS::PropertyApiImpl<NodeOutputs> outputProperties_; 104 105 RENDER_NS::BindableImage defaultInput_; 106 107 RENDER_NS::DescriptorCounts descriptorCounts_; 108 bool valid_ { false }; 109 110 EffectProperties effectProperties_; 111 }; 112 RENDER_END_NAMESPACE() 113 114 #endif // RENDER_POSTPROCESS_RENDER_POSTPROCESS_FLARE_NODE_H 115