1 /* 2 * Copyright (C) 2023 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; 40 41 // for plugin / factory interface 42 static constexpr BASE_NS::Uid UID { "6b15f334-872b-4963-acc8-691b30de7501" }; 43 static constexpr char const* TYPE_NAME = "RenderNodeBackBuffer"; 44 static constexpr IRenderNode::BackendFlags BACKEND_FLAGS = IRenderNode::BackendFlagBits::BACKEND_FLAG_BITS_DEFAULT; 45 static constexpr IRenderNode::ClassType CLASS_TYPE = IRenderNode::ClassType::CLASS_TYPE_NODE; 46 static IRenderNode* Create(); 47 static void Destroy(IRenderNode* instance); 48 49 private: 50 IRenderNodeContextManager* renderNodeContextMgr_ { nullptr }; 51 52 void CheckForPsoSpecilization(const PostProcessConfiguration& postProcessConfiguration); 53 PostProcessConfiguration GetPostProcessConfiguration(const IRenderNodeRenderDataStoreManager& dataStoreMgr); 54 RenderHandle UpdateColorAttachmentSize(); 55 void ParseRenderNodeInputs(); 56 57 // Json resources which might need re-fetching 58 struct JsonInputs { 59 RenderNodeGraphInputs::InputRenderPass renderPass; 60 RenderNodeGraphInputs::InputResources resources; 61 62 RenderNodeGraphInputs::RenderDataStore renderDataStore; 63 64 bool hasChangeableRenderPassHandles { false }; 65 bool hasChangeableResourceHandles { false }; 66 }; 67 JsonInputs jsonInputs_; 68 69 RenderNodeHandles::InputRenderPass inputRenderPass_; 70 RenderNodeHandles::InputResources inputResources_; 71 RenderHandle shader_; 72 RenderHandle psoHandle_; 73 RenderPass renderPass_; 74 75 struct BackBufferDefinition { 76 uint32_t width { 0 }; 77 uint32_t height { 0 }; 78 BASE_NS::Format format { BASE_NS::Format::BASE_FORMAT_UNDEFINED }; 79 }; 80 BackBufferDefinition currentBackBuffer_; 81 ViewportDesc currentViewportDesc_; 82 ScissorDesc currentScissorDesc_; 83 84 RenderPostProcessConfiguration currentRenderPostProcessConfiguration_; 85 PipelineLayout pipelineLayout_; 86 IPipelineDescriptorSetBinder::Ptr pipelineDescriptorSetBinder_; 87 }; 88 RENDER_END_NAMESPACE() 89 90 #endif // CORE__RENDER__NODE__RENDER_NODE_BACK_BUFFER_H 91