]> git.tdb.fi Git - libs/gl.git/blobdiff - source/backends/vulkan/memoryallocator.cpp
Implement textures and samplers for Vulkan
[libs/gl.git] / source / backends / vulkan / memoryallocator.cpp
index 6ffcc9fc5917bee515e46e7a8ce30da5f80a29a1..6ef5d2bd7a6b8714fb545997819abb11e1995fa9 100644 (file)
@@ -91,6 +91,20 @@ unsigned MemoryAllocator::allocate(VkBuffer buffer, MemoryType type)
        return id;
 }
 
+unsigned MemoryAllocator::allocate(VkImage image, MemoryType type)
+{
+       const VulkanFunctions &vk = device.get_functions();
+
+       VkMemoryRequirements requirements;
+       vk.GetImageMemoryRequirements(image, requirements);
+
+       unsigned id = allocate(requirements.size, requirements.memoryTypeBits, type);
+
+       vk.BindImageMemory(image, get_allocation(id).memory, 0);
+
+       return id;
+}
+
 void MemoryAllocator::release(unsigned id)
 {
        Allocation &alloc = get_allocation(id);