VKALLOCATEMEMORY(3)

NAME
vkAllocateMemory - Allocate GPU memory.

C SPECIFICATION

    VkResult vkAllocateMemory(
        VkDevice                                    device,
        const VkMemoryAllocateInfo*                 pAllocateInfo,
        const VkAllocationCallbacks*                pAllocator,
        VkDeviceMemory*                             pMemory);

PARAMETERS

device
    The device from which to allocate memory.

pAllocateInfo
    Pointer to a VkMemoryAllocateInfo structure containing a description of the desired memory allocation.

pAllocator
    A pointer to a VkAllocationCallbacks structure containing the allocation callbacks to be used when allocating the object.

pMemory
    Pointer to a variable which will receive the newly allocated VkDeviceMemory object.

DESCRIPTION

vkAllocateMemory allocates memory using the device specified in device. The properties of the new allocation are specified in the structure pointed to by pAllocateInfo, which is an instance of VkMemoryAllocateInfo. The definition of VkMemoryAllocateInfo is:

    typedef struct VkMemoryAllocateInfo {
        VkStructureType    sType;
        const void*        pNext;
        VkDeviceSize       allocationSize;
        uint32_t           memoryTypeIndex;
    } VkMemoryAllocateInfo;

The sType member of the VkMemoryAllocateInfo structure must be set to VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO and the pNext member of the structure is reserved for use by extensions and should be set to NULL if none are in use.

The allocationSize member specifies the size in bytes of the requested allocation and the memoryTypeIndex member specifies the type of memory to allocate. The number of available memory types and their properties is a feature of the physical device and may be obtained by calling vkGetPhysicalDeviceMemoryProperties.

VALID USAGE

    • device must be a valid VkDevice handle

    • pAllocateInfo must be a pointer to a valid VkMemoryAllocateInfo structure

    • If pAllocator is not NULL, pAllocator must be a pointer to a valid VkAllocationCallbacks structure

    • pMemory must be a pointer to a VkDeviceMemory handle

    • The number of currently valid memory objects, allocated from device, must be less than VkPhysicalDeviceLimits::maxMemoryAllocationCount

RETURN CODES

On success, this command returns

        • VK_SUCCESS

On failure, this command returns

        • VK_ERROR_OUT_OF_HOST_MEMORY

        • VK_ERROR_OUT_OF_DEVICE_MEMORY

        • VK_ERROR_TOO_MANY_OBJECTS

If any host memory is required to create the memory object, the allocators passed in the structure pointed to by the pAllocator parameter are used and will be used to free the object when vkFreeMemory is called.

On success, a handle to the new memory object is placed in the variable pointed to by pMemory.

SEE ALSO

vkFreeMemory

COPYRIGHT

Copyright © 2014-2016 Khronos Group. This material may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1.0, 8 June 1999. http://opencontent.org/openpub/.

AUTHOR

Khronos Group
    Author.