1 #ifndef DALI_INTERNAL_UNIFORM_BUFFER_VIEW_POOL_H
2 #define DALI_INTERNAL_UNIFORM_BUFFER_VIEW_POOL_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.
22 #include <dali/graphics-api/graphics-types.h>
28 namespace Dali::Internal::Render
31 class UniformBufferManager;
32 class UniformBufferView;
36 * Class UniformBufferPoolView
38 * The class is responsible for managing the UniformBuffer memory.
39 * It is stack-based pool allocator. It doesn't own the UniformBuffer but
40 * it's mere view into the memory.
42 * The view may however request UniformBuffer to resize if there is a need
43 * to allocate memory beyond its current size.
45 * The UniformBuffer may be trimmed on Rollback().
47 * Rollback() operation moves allocation pointer to the very beginning
48 * of the UniformBuffer. The data stored in the UniformBuffer after
49 * Rollback() is considered invalid and shouldn't be used by the client side.
51 class UniformBufferViewPool
53 friend class UniformBufferManager;
57 UniformBufferViewPool( UniformBufferManager& manager, uint32_t alignment );
61 ~UniformBufferViewPool();
64 * Rolls back allocation to the beginning of pool
69 * Creates view for next free chunk of UBO memory of specified size.
71 Graphics::UniquePtr<UniformBufferView> CreateUniformBufferView( size_t size );
75 UniformBufferManager& mUboManager;
76 Graphics::UniquePtr<UniformBuffer> mUniformBufferStorage;
78 uint32_t mAlignment; // 1 for tightly packed emulated UBO
79 uint32_t mCurrentOffset;
82 } // namespace Dali::Internal::Render
83 #endif //DALI_INTERNAL_UNIFORM_BUFFER_VIEW_POOL_H