cfcaac617b631a14dd4a670d596af9cf9d17e8db
[platform/core/uifw/dali-core.git] / dali / internal / render / renderers / uniform-buffer-manager.h
1 #ifndef DALI_INTERNAL_UNIFORM_BUFFER_MANAGER_H
2 #define DALI_INTERNAL_UNIFORM_BUFFER_MANAGER_H
3
4 /*
5  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/graphics-api/graphics-controller.h>
23
24 namespace Dali::Internal::Render
25 {
26 class UniformBuffer;
27 class UniformBufferView;
28 class UniformBufferViewPool;
29
30 /**
31  * Class UniformBufferManager
32  *
33  * Manages the uniform buffers.
34  *
35  */
36 class UniformBufferManager
37 {
38 public:
39
40   explicit UniformBufferManager(Dali::Graphics::Controller* controller);
41
42   ~UniformBufferManager();
43
44   /**
45    * Allocates uniform buffer with given size and alignment
46    * @param size Size of uniform buffer
47    * @param alignment Alignment
48    * @return new UniformBuffer
49    */
50   Graphics::UniquePtr<UniformBuffer> AllocateUniformBuffer(uint32_t size, uint32_t alignment = 256);
51
52   /**
53    * Creates a view on UniformBuffer
54    *
55    * @param uniformBuffer
56    * @param size
57    * @return Uniform buffer view
58    */
59   Graphics::UniquePtr<UniformBufferView> CreateUniformBufferView( UniformBuffer* uniformBuffer, uint32_t offset, uint32_t size);
60
61   /**
62    * Creates uniform buffer pool view
63    * @param size
64    * @return
65    */
66   Graphics::UniquePtr<UniformBufferViewPool> CreateUniformBufferViewPool();
67
68   /**
69    * Returns Controller object
70    * @return controller object
71    */
72   [[nodiscard]] Graphics::Controller& GetController() const
73   {
74     return *mController;
75   }
76
77   /**
78    * Returns embedded uniform buffer pool view for specified DAli buffer index
79    * @return Pointer to valid uniform buffer pool view
80    */
81   [[nodiscard]] UniformBufferViewPool* GetUniformBufferViewPool( uint32_t bufferIndex );
82
83 private:
84
85   Dali::Graphics::Controller* mController;
86
87   Graphics::UniquePtr<UniformBufferViewPool> mUniformBufferPoolStorage[2u]; ///< The pool view into UniformBuffer (double buffered)
88 };
89
90 } // namespace Dali
91
92 #endif // DALI_INTERNAL_UNIFORM_BUFFER_MANAGER_H