1 #ifndef DALI_GRAPHICS_VULKAN_GPU_MEMORY_ALLOCATOR
2 #define DALI_GRAPHICS_VULKAN_GPU_MEMORY_ALLOCATOR
5 * Copyright (c) 2018 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.
20 #include <dali/graphics/vulkan/vulkan-types.h>
21 #include <dali/graphics/vulkan/gpu-memory/vulkan-gpu-memory-handle.h>
32 * Interface to Gpu memory allocation, must be overriden.
34 using GpuMemoryAllocationData = void*;
36 class GpuMemoryAllocator
40 GpuMemoryAllocator() = default;
45 virtual ~GpuMemoryAllocator() = default;
50 * @param memoryProperties
53 virtual GpuMemoryBlockHandle Allocate( const vk::MemoryRequirements& requirements, vk::MemoryPropertyFlags memoryProperties ) = 0;
58 * @param memoryProperties
61 virtual GpuMemoryBlockHandle Allocate( const Handle<Buffer>& buffer, vk::MemoryPropertyFlags memoryProperties ) = 0;
66 * @param memoryProperties
69 virtual GpuMemoryBlockHandle Allocate( Image& buffer, vk::MemoryPropertyFlags memoryProperties ) = 0;
71 // refcounting managed via allocator which ownes all the blocks, allocator may
72 // implement this feature any way ( or simply ignore it )
77 virtual void Retain( GpuMemoryBlock& allocationId ) {}
83 virtual void Release( GpuMemoryBlock& allocationId ) {}
89 virtual uint32_t GetRefCount( GpuMemoryBlock& allocationId )
99 virtual void GC( void* userdata ) = 0;
101 // Retrieve Vulkan object for this allocation
106 virtual vk::DeviceMemory GetVkDeviceMemory( GpuMemoryBlock& allocationId ) const = 0;
110 * @param allocationId
115 virtual void* Map( GpuMemoryBlock& allocationId, uint32_t offset, uint32_t size ) = 0;
119 * @param allocationId
124 virtual void Unmap( GpuMemoryBlock& allocationId ) = 0;
128 * @param allocationId
130 virtual void Flush( GpuMemoryBlock& allocationId ) = 0;
133 } // Namespace Vulkan
135 } // namespace Graphics
139 #endif // DALI_GRAPHICS_VULKAN_GPU_MEMORY_ALLOCATOR