1 #ifndef DALI_INTERNAL_UNIFORM_BUFFER_MANAGER_H
2 #define DALI_INTERNAL_UNIFORM_BUFFER_MANAGER_H
5 * Copyright (c) 2022 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.
22 #include <dali/graphics-api/graphics-controller.h>
24 namespace Dali::Internal::Render
27 class UniformBufferView;
28 class UniformBufferViewPool;
31 * Class UniformBufferManager
33 * Manages the uniform buffers.
36 class UniformBufferManager
39 explicit UniformBufferManager(Dali::Graphics::Controller* controller);
41 ~UniformBufferManager();
44 * @brief Allocates uniform buffer with given size and alignment
45 * @param size Size of uniform buffer
46 * @param alignment Alignment
47 * @return new UniformBuffer
49 Graphics::UniquePtr<UniformBuffer> AllocateUniformBuffer(uint32_t size, uint32_t alignment = 256);
52 * @brief Creates a view on UniformBuffer
54 * @param uniformBuffer
56 * @return Uniform buffer view
58 Graphics::UniquePtr<UniformBufferView> CreateUniformBufferView(UniformBuffer* uniformBuffer, uint32_t offset, uint32_t size);
61 * @brief Creates uniform buffer pool view
65 Graphics::UniquePtr<UniformBufferViewPool> CreateUniformBufferViewPool();
68 * @brief Returns Controller object
69 * @return controller object
71 [[nodiscard]] Graphics::Controller& GetController() const
77 * @brief Returns embedded uniform buffer pool view for specified DAli buffer index
78 * @return Pointer to valid uniform buffer pool view
80 [[nodiscard]] UniformBufferViewPool* GetUniformBufferViewPool(uint32_t bufferIndex);
83 * @brief Prepare to lock the uniform buffer so we can write to the standalone uniform map directly.
84 * Uniform buffer will be locked at the first call of UniformBuffer::Write after call this API.
85 * @note After all write done, We should call UnlockUniformBuffer.
87 * @param bufferIndex current update/render buffer index
89 void ReadyToLockUniformBuffer(uint32_t bufferIndex);
92 * @brief Unlock the uniform buffer.
93 * @note We should call ReadyToLockUniformBuffer before call this.
95 * @param bufferIndex current update/render buffer index
97 void UnlockUniformBuffer(uint32_t bufferIndex);
100 Dali::Graphics::Controller* mController;
102 Graphics::UniquePtr<UniformBufferViewPool> mUniformBufferPoolStorage[2u]; ///< The pool view into UniformBuffer (double buffered)
105 } // namespace Dali::Internal::Render
107 #endif // DALI_INTERNAL_UNIFORM_BUFFER_MANAGER_H