1 #ifndef DALI_GRAPHICS_MEMORY_H
2 #define DALI_GRAPHICS_MEMORY_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.
29 * @brief Memory object represents a GPU memory that can be
30 * read and/or written.
32 * It depends on the usage when creating objects such as
33 * buffers and textures.
35 * The Memory must be mapped first, however, to obtain the direct
36 * pointer the memory must be locked. Locking mechanism enables
37 * synchronisation and prevents driver from using the memory
38 * until the client unlocks it. The memory may be still used
39 * while being mapped (it's ok to keep memory mapped persistently).
46 virtual ~Memory() = default;
49 Memory(const Memory&) = delete;
50 Memory& operator=(const Memory&) = delete;
53 * @brief Locks region of memory for client-side operation
55 * @param[in] offset Offset of mapped memory
56 * @param[in] size Size of the region to be locked
57 * @return returns valid memory pointer or nullptr on failure
59 virtual void* LockRegion(uint32_t offset, uint32_t size) = 0;
62 * @brief Unlocks previously locked memory region
64 * @param[in] flush If true, region will be flushed immediately and visible to GPU
66 virtual void Unlock(bool flush) = 0;
69 * @brief Flushes memory
71 * Flushing makes a memory object instantly visible by the GPU.
74 * Large Buffer object divided in two halves. Every frame only one half
75 * is being updated (permanently mapped, locked, written, unlocked). Calling
76 * FlushMemory() we can update the GPU without unmapping the Buffer object.
78 * In the scenario when the Memory is being unmapped, flushing is redundant.
80 virtual void Flush() = 0;
83 Memory(Memory&&) = default;
84 Memory& operator=(Memory&&) = default;
87 } // Namespace Graphics