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_RENDER__NODE__RENDER_NODE_BACK_BUFFER_H 17 #define RENDER_RENDER__NODE__RENDER_NODE_BACK_BUFFER_H 18 19 #include <base/containers/string.h> 20 #include <base/util/uid.h> 21 #include <render/datastore/render_data_store_render_pods.h> 22 #include <render/device/pipeline_state_desc.h> 23 #include <render/namespace.h> 24 #include <render/nodecontext/intf_pipeline_descriptor_set_binder.h> 25 #include <render/nodecontext/intf_render_node.h> 26 #include <render/render_data_structures.h> 27 #include <render/resource_handle.h> 28 29 RENDER_BEGIN_NAMESPACE() 30 class IRenderNodeRenderDataStoreManager; 31 32 class RenderNodeBackBuffer final : public IRenderNode { 33 public: 34 RenderNodeBackBuffer() = default; 35 ~RenderNodeBackBuffer() override = default; 36 37 void InitNode(IRenderNodeContextManager& renderNodeContextMgr) override; PreExecuteFrame()38 void PreExecuteFrame() override {}; 39 void ExecuteFrame(IRenderCommandList& cmdList) override; GetExecuteFlags()40 ExecuteFlags GetExecuteFlags() const override 41 { 42 return 0U; 43 } 44 45 // for plugin / factory interface 46 static constexpr BASE_NS::Uid UID { "f1dc030b-1081-4ca5-a195-1d8bfc1a036c" }; 47 static constexpr char const* TYPE_NAME = "RenderNodeBackBuffer"; 48 static constexpr IRenderNode::BackendFlags BACKEND_FLAGS = IRenderNode::BackendFlagBits::BACKEND_FLAG_BITS_DEFAULT; 49 static constexpr IRenderNode::ClassType CLASS_TYPE = IRenderNode::ClassType::CLASS_TYPE_NODE; 50 static IRenderNode* Create(); 51 static void Destroy(IRenderNode* instance); 52 53 private: 54 IRenderNodeContextManager* renderNodeContextMgr_ { nullptr }; 55 56 void CheckForPsoSpecilization(const PostProcessConfiguration& postProcessConfiguration); 57 PostProcessConfiguration GetPostProcessConfiguration(const IRenderNodeRenderDataStoreManager& dataStoreMgr); 58 RenderHandle UpdateColorAttachmentSize(); 59 void ParseRenderNodeInputs(); 60 61 // Json resources which might need re-fetching 62 struct JsonInputs { 63 RenderNodeGraphInputs::InputRenderPass renderPass; 64 RenderNodeGraphInputs::InputResources resources; 65 66 RenderNodeGraphInputs::RenderDataStore renderDataStore; 67 68 bool hasChangeableRenderPassHandles { false }; 69 bool hasChangeableResourceHandles { false }; 70 }; 71 JsonInputs jsonInputs_; 72 73 RenderNodeHandles::InputRenderPass inputRenderPass_; 74 RenderNodeHandles::InputResources inputResources_; 75 RenderHandle shader_; 76 RenderHandle psoHandle_; 77 RenderPass renderPass_; 78 79 struct BackBufferDefinition { 80 uint32_t width { 0 }; 81 uint32_t height { 0 }; 82 BASE_NS::Format format { BASE_NS::Format::BASE_FORMAT_UNDEFINED }; 83 }; 84 BackBufferDefinition currentBackBuffer_; 85 ViewportDesc currentViewportDesc_; 86 ScissorDesc currentScissorDesc_; 87 88 RenderPostProcessConfiguration currentRenderPostProcessConfiguration_; 89 PipelineLayout pipelineLayout_; 90 IPipelineDescriptorSetBinder::Ptr pipelineDescriptorSetBinder_; 91 }; 92 RENDER_END_NAMESPACE() 93 94 #endif // CORE__RENDER__NODE__RENDER_NODE_BACK_BUFFER_H 95