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 CORE3D_NODE_RENDER_NODE_WEATHER_SIMULATION_H 17 #define CORE3D_NODE_RENDER_NODE_WEATHER_SIMULATION_H 18 19 #include <3d/namespace.h> 20 #include <base/util/uid.h> 21 #include <render/device/pipeline_layout_desc.h> 22 #include <render/nodecontext/intf_pipeline_descriptor_set_binder.h> 23 #include <render/nodecontext/intf_render_node.h> 24 #include <render/render_data_structures.h> 25 #include <render/resource_handle.h> 26 27 #include "render/datastore/render_data_store_weather.h" 28 29 RENDER_BEGIN_NAMESPACE() 30 class IRenderCommandList; 31 class IRenderNodeContextManager; 32 RENDER_END_NAMESPACE() 33 CORE3D_BEGIN_NAMESPACE()34CORE3D_BEGIN_NAMESPACE() 35 class RenderNodeWeatherSimulation final : public RENDER_NS::IRenderNode { 36 public: 37 RenderNodeWeatherSimulation() = default; 38 ~RenderNodeWeatherSimulation() override = default; 39 40 void InitNode(RENDER_NS::IRenderNodeContextManager& renderNodeContextMgr) override; 41 void PreExecuteFrame() override; 42 void ExecuteFrame(RENDER_NS::IRenderCommandList& cmdList) override; 43 ExecuteFlags GetExecuteFlags() const override 44 { 45 return 0U; 46 } 47 48 // for plugin / factory interface 49 static constexpr BASE_NS::Uid UID { "6722cfd9-ff0c-4b8c-bdc1-1ecbd9ae11e1" }; 50 static constexpr char const* TYPE_NAME = "RenderNodeWeatherSimulation"; 51 static constexpr RENDER_NS::IRenderNode::BackendFlags BACKEND_FLAGS = 52 IRenderNode::BackendFlagBits::BACKEND_FLAG_BITS_DEFAULT; 53 static constexpr RENDER_NS::IRenderNode::ClassType CLASS_TYPE = RENDER_NS::IRenderNode::ClassType::CLASS_TYPE_NODE; 54 static RENDER_NS::IRenderNode* Create(); 55 static void Destroy(RENDER_NS::IRenderNode* instance); 56 57 private: 58 RENDER_NS::IRenderNodeContextManager* renderNodeContextMgr_ { nullptr }; 59 60 void InitializeRippleBuffers(RENDER_NS::IRenderCommandList& cmdList); 61 62 void ParseRenderNodeInputs(); 63 64 // Json resources which might need re-fetching 65 struct JsonInputs { 66 RENDER_NS::RenderNodeGraphInputs::InputResources resources; 67 RENDER_NS::RenderNodeGraphInputs::InputResources dispatchResources; 68 RENDER_NS::RenderNodeGraphInputs::RenderDataStore renderDataStore; 69 RENDER_NS::RenderNodeGraphInputs::RenderDataStore renderDataStoreSpecialization; 70 71 bool hasChangeableResourceHandles { false }; 72 bool hasChangeableDispatchHandles { false }; 73 }; 74 JsonInputs jsonInputs_; 75 76 RENDER_NS::RenderHandle initShader_; 77 RENDER_NS::RenderHandle shader_; 78 79 RENDER_NS::IPipelineDescriptorSetBinder::Ptr pipelineDescriptorSetBinder_; 80 RENDER_NS::PipelineLayout pipelineLayout_; 81 RENDER_NS::RenderHandle psoHandle_; 82 83 RENDER_NS::IPipelineDescriptorSetBinder::Ptr initPipelineDescriptorSetBinder_; 84 RENDER_NS::PipelineLayout initPipelineLayout_; 85 RENDER_NS::RenderHandle initPsoHandle_; 86 87 RENDER_NS::RenderHandle defaultMaterialSam_; 88 RENDER_NS::RenderHandle rippleTextureHandle_; 89 RENDER_NS::RenderHandle rippleTextureHandle1_; 90 RENDER_NS::RenderHandle rippleInputArgsBuffer_; 91 92 RenderDataStoreWeather* dataStoreWeather_ { nullptr }; 93 94 uint32_t pingPongIdx { 0 }; 95 bool areTextureInit { false }; 96 }; 97 CORE3D_END_NAMESPACE() 98 99 #endif // CORE3D_NODE_RENDER_NODE_WEATHER_SIMULATION_H 100