Allocating and binding a memory object for a buffer
In Vulkan, buffers don't have their own memory. To be able to use buffers in our application and to store any data inside them, we need to allocate a memory object and bind it to a buffer.
How to do it...
- Take the handle of a physical device from which the logical device was created. Store it in a variable of type
VkPhysicalDevice
namedphysical_device
. - Create a variable of type
VkPhysicalDeviceMemoryProperties
namedphysical_device_memory_properties
. - Call
vkGetPhysicalDeviceMemoryProperties( physical_device, &physical_device_memory_properties )
, for which provide the handle of a physical device and a pointer to thephysical_device_memory_properties
variable. This call will store memory parameters (number of heaps, their size, and types) of the physical device used for processing. - Take the handle of a logical device created from the physical device, represented by the
physical_device
variable. Store the handle in a variable of typeVkDevice...