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 API_RENDER_IRENDER_DATA_STORE_H 17 #define API_RENDER_IRENDER_DATA_STORE_H 18 19 #include <base/containers/string_view.h> 20 #include <render/namespace.h> 21 22 BASE_BEGIN_NAMESPACE() 23 struct Uid; 24 BASE_END_NAMESPACE() 25 RENDER_BEGIN_NAMESPACE()26RENDER_BEGIN_NAMESPACE() 27 /** @ingroup group_render_irenderdatastore */ 28 /** Base class for render data management. 29 * Inherit to create a new data manager. 30 */ 31 class IRenderDataStore { 32 public: 33 IRenderDataStore(const IRenderDataStore&) = delete; 34 IRenderDataStore& operator=(const IRenderDataStore&) = delete; 35 36 /** Called automatically by the engine (renderer) before render node front-end processing. 37 * Needs to be overwritten by the inherit classes. 38 * Here one could e.g. allocate GPU resources for current counts or do some specific management 39 * for all this frame's data. 40 */ 41 virtual void PreRender() = 0; 42 43 /** Called automatically by the engine (renderer) after rendering front-end has been completed. 44 * This happens before PreRenderBackend. For example clear render data store data which has been processed in render 45 * nodes. Needs to be overwritten by the inherit classes. Here one can place resets for buffers and data. 46 */ 47 virtual void PostRender() = 0; 48 49 /** Called automatically by the engine (renderer) before back-end processing. 50 * Here (and only here with render data stores) one can access low level / back-end GPU resources. 51 * Needs to be overwritten by the inherit classes. 52 * Process only backend related work here. 53 */ 54 virtual void PreRenderBackend() = 0; 55 56 /** Called automatically by the engine (renderer) after back-end processing (full rendering). 57 * Needs to be overwritten by the inherit classes. 58 * Process only post full render here. (Clear data store content already in PostRender()) 59 */ 60 virtual void PostRenderBackend() = 0; 61 62 /** Should be called when one starts to fill up the render data store. 63 * Needs to be overwritten by the inherit classes. 64 * This should clear all the buffers which are filled once a frame. 65 */ 66 virtual void Clear() = 0; 67 68 /** Should return IRenderDataStoreManager::RenderDataStoreFlags which are implemented by the data store. 69 * Do not print flags which are not supported by the data store. 70 * Needs to be overwritten by the inherit classes. 71 * Used by the renderer for e.g. validation. (Can print warnings when correct flags are not returned.) 72 */ 73 virtual uint32_t GetFlags() const = 0; 74 75 /** Get the type name of the render data store. 76 * @return Type name of the render data store. 77 */ 78 virtual BASE_NS::string_view GetTypeName() const = 0; 79 80 /** Get the unique instance name of the render data store. 81 * @return Unique name of the render data store. 82 */ 83 virtual BASE_NS::string_view GetName() const = 0; 84 85 /** Get the type UID of the render data store. 86 * @return Type UID of the render data store. 87 */ 88 virtual const BASE_NS::Uid& GetUid() const = 0; 89 90 /** Take a new reference of the object. 91 */ 92 virtual void Ref() = 0; 93 94 /** Releases one reference of the object. 95 * No methods of the class shall be called after unref. 96 * The object could be destroyed, if last reference 97 */ 98 virtual void Unref() = 0; 99 100 virtual int32_t GetRefCount() = 0; 101 102 protected: 103 IRenderDataStore() = default; 104 virtual ~IRenderDataStore() = default; 105 }; 106 RENDER_END_NAMESPACE() 107 108 #endif // API_RENDER_IRENDER_DATA_STORE_H 109