1 #ifndef DALI_INTERNAL_UNIFORM_BUFFER_VIEW_POOL_H
2 #define DALI_INTERNAL_UNIFORM_BUFFER_VIEW_POOL_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-types.h>
28 namespace Dali::Internal::Render
30 class UniformBufferManager;
31 class UniformBufferView;
35 * Class UniformBufferPoolView
37 * The class is responsible for managing the UniformBuffer memory.
38 * It is stack-based pool allocator. It doesn't own the UniformBuffer but
39 * it's mere view into the memory.
41 * The view may however request UniformBuffer to resize if there is a need
42 * to allocate memory beyond its current size.
44 * The UniformBuffer may be trimmed on Rollback().
46 * Rollback() operation moves allocation pointer to the very beginning
47 * of the UniformBuffer. The data stored in the UniformBuffer after
48 * Rollback() is considered invalid and shouldn't be used by the client side.
50 class UniformBufferViewPool
52 friend class UniformBufferManager;
55 UniformBufferViewPool(UniformBufferManager& manager, uint32_t alignment);
58 ~UniformBufferViewPool();
61 * @brief Rolls back allocation to the beginning of pool
66 * @brief Creates view for next free chunk of UBO memory of specified size.
68 Graphics::UniquePtr<UniformBufferView> CreateUniformBufferView(size_t size);
71 * @copydoc Dali::Internal::Render::UniformBufferManager::ReadyToLockUniformBuffer
73 void ReadyToLockUniformBuffer();
76 * @copydoc Dali::Internal::Render::UniformBufferManager::UnlockUniformBuffer
78 void UnlockUniformBuffer();
81 UniformBufferManager& mUboManager;
82 Graphics::UniquePtr<UniformBuffer> mUniformBufferStorage;
84 uint32_t mAlignment; // 1 for tightly packed emulated UBO
85 uint32_t mCurrentOffset;
88 } // namespace Dali::Internal::Render
89 #endif //DALI_INTERNAL_UNIFORM_BUFFER_VIEW_POOL_H