• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 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()26 RENDER_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) before back-end processing.
44      * Needs to be overwritten by the inherit classes.
45      * Here (and only here with render data stores) one can access low level / back-end GPU resources.
46      * Process only backend related work here.
47      */
48     virtual void PreRenderBackend() = 0;
49 
50     /** Called automatically by the engine (renderer) after all rendering (front-end / back-end) has been completed.
51      * Needs to be overwritten by the inherit classes.
52      * Here one can place resets for buffers and data.
53      */
54     virtual void PostRender() = 0;
55 
56     /** Should be called when one starts to fill up the render data store.
57      * Needs to be overwritten by the inherit classes.
58      * This should clear all the buffers which are filled once a frame.
59      */
60     virtual void Clear() = 0;
61 
62     /** Get the type name of the render data store.
63      * @return Type name of the render data store.
64      */
65     virtual BASE_NS::string_view GetTypeName() const = 0;
66 
67     /** Get the unique instance name of the render data store.
68      * @return Unique name of the render data store.
69      */
70     virtual BASE_NS::string_view GetName() const = 0;
71 
72     /** Get the type UID of the render data store.
73      * @return Type UID of the render data store.
74      */
75     virtual const BASE_NS::Uid& GetUid() const = 0;
76 
77 protected:
78     IRenderDataStore() = default;
79     virtual ~IRenderDataStore() = default;
80 };
81 RENDER_END_NAMESPACE()
82 
83 #endif // API_RENDER_IRENDER_DATA_STORE_H
84