1 #ifndef DALI_INTERNAL_UNIFORM_BUFFER_MANAGER_H
2 #define DALI_INTERNAL_UNIFORM_BUFFER_MANAGER_H
5 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 #include <dali/graphics-api/graphics-controller.h>
33 friend class UniformBufferManager;
37 * Constructor of UniformBuffer
39 * @param[in] mController Pointer of the graphics controller
40 * @param[in] sizeInBytes initial size of allocated buffer
41 * @param[in] alignment memory alignment in bytes
42 * @param[in] persistentMappingEnabled if true, buffer is mapped persistently
43 * @param[in] usageFlags type of usage ( Graphics::BufferUsage )
45 UniformBuffer(Dali::Graphics::Controller* mController,
48 bool persistentMappingEnabled,
49 Graphics::BufferUsageFlags usageFlags);
53 * Destructor of UniformBuffer
58 * Writes data into the buffer
60 * @param[in] data pointer to the source data
61 * @param[in] size size of source data
62 * @param[in] offset destination offset
64 void Write(const void* data, uint32_t size, uint32_t offset);
67 * Flushes whole buffer range
72 * Returns allocated ( requested ) size
73 * @return size of buffer
75 uint32_t GetSize() const
81 * Return Graphics API buffer
82 * @return pointer to the buffer object
84 Dali::Graphics::Buffer* GetBuffer() const
90 * Returns memory alignment
91 * @return memory alignment
93 uint32_t GetAlignment() const
99 * Reserves buffer memory
101 * @param size requested size
103 void Reserve(uint32_t size);
111 * Unmaps buffer memory
116 * Fills the buffer from the given offset with given data ( single 8bit value )
117 * @param data char type data
118 * @param offset start offset
119 * @param size size to write, 0 if whole size
121 void Fill(char data, uint32_t offset, uint32_t size);
124 Graphics::UniquePtr<Graphics::Buffer> mBuffer;
125 Dali::Graphics::Controller* mController;
126 Graphics::UniquePtr<Graphics::Memory> mMemory{nullptr};
128 Graphics::MapBufferInfo mMapBufferInfo{};
130 uint32_t mCapacity{0}; ///< buffer capacity
131 uint32_t mSize; ///< buffer size
132 uint32_t mAlignment{0};
133 bool mPersistentMappedEnabled;
135 Graphics::BufferUsageFlags mUsageFlags;
138 class UniformBufferManager
141 UniformBufferManager(Dali::Graphics::Controller* controller);
143 ~UniformBufferManager();
146 * Allocates uniform buffer with given size
150 Graphics::UniquePtr<UniformBuffer> AllocateUniformBuffer(uint32_t size);
153 Dali::Graphics::Controller* mController;
156 } // namespace Render
157 } // namespace Internal
160 #endif // DALI_INTERNAL_UNIFORM_BUFFER_MANAGER_H