Top Description Inners Constructors Methods
org.lwjgl.vulkan

public abstract Class VkAllocationFunction

extends Callback
implements VkAllocationFunctionI
Class Inheritance
All Implemented Interfaces
org.lwjgl.vulkan.VkAllocationFunctionI, org.lwjgl.system.CallbackI, org.lwjgl.system.Pointer
Known Direct Subclasses
org.lwjgl.vulkan.VkAllocationFunction.Container
Imports
javax.annotation.*, org.lwjgl.system.*

Application-defined memory allocation function.
C Specification

The type of pfnAllocation is:


typedef void* (VKAPI_PTR *PFN_vkAllocationFunction)(
    void*                                       pUserData,
    size_t                                      size,
    size_t                                      alignment,
    VkSystemAllocationScope                     allocationScope);
Description

If pfnAllocation is unable to allocate the requested memory, it must return NULL. If the allocation was successful, it must return a valid pointer to memory allocation containing at least size bytes, and with the pointer value being a multiple of alignment.

Note

Correct Vulkan operation cannot be assumed if the application does not follow these rules.

For example, pfnAllocation (or pfnReallocation) could cause termination of running Vulkan instance(s) on a failed allocation for debugging purposes, either directly or indirectly. In these circumstances, it cannot be assumed that any part of any affected VkInstance objects are going to operate correctly (even DestroyInstance), and the application must ensure it cleans up properly via other means (e.g. process termination).

If pfnAllocation returns NULL, and if the implementation is unable to continue correct processing of the current command without the requested allocation, it must treat this as a runtime error, and generate ERROR_OUT_OF_HOST_MEMORY at the appropriate time for the command in which the condition was detected, as described in Return Codes.

If the implementation is able to continue correct processing of the current command without the requested allocation, then it may do so, and must not generate ERROR_OUT_OF_HOST_MEMORY as a result of this failed allocation.

See Also

VkAllocationCallbacks

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Constructor Summary

AccessConstructor and Description
protected
pack-priv
VkAllocationFunction(long functionPointer)

Method Summary

Modifier and TypeMethod and Description
public static VkAllocationFunction

Returns:

the new VkAllocationFunction
create
(long functionPointer)

Creates a VkAllocationFunction instance from the specified function pointer.

public static VkAllocationFunction
create(VkAllocationFunctionI instance)

Creates a VkAllocationFunction instance that delegates to the specified VkAllocationFunctionI instance.

public static VkAllocationFunction
createSafe(long functionPointer)

Like create, but returns null if functionPointer is NULL.

Inherited from org.lwjgl.system.Callback:
addressequalsfreefreegetgetSafehashCodetoString

Constructor Detail

VkAllocationFunctionback to summary
protected VkAllocationFunction()
VkAllocationFunctionback to summary
pack-priv VkAllocationFunction(long functionPointer)

Method Detail

createback to summary
public static VkAllocationFunction create(long functionPointer)

Creates a VkAllocationFunction instance from the specified function pointer.

Returns:VkAllocationFunction

the new VkAllocationFunction

createback to summary
public static VkAllocationFunction create(VkAllocationFunctionI instance)

Creates a VkAllocationFunction instance that delegates to the specified VkAllocationFunctionI instance.

createSafeback to summary
public static VkAllocationFunction createSafe(long functionPointer)

Like create, but returns null if functionPointer is NULL.

Annotations
@Nullable
org.lwjgl.vulkan back to summary

private final Class VkAllocationFunction.Container

extends VkAllocationFunction
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final VkAllocationFunctionI

Constructor Summary

AccessConstructor and Description
pack-priv
Container(long functionPointer, VkAllocationFunctionI delegate)

Method Summary

Modifier and TypeMethod and Description
public long
invoke(long
the value specified for VkAllocationCallbacks::pUserData in the allocator specified by the application.
pUserData
,
long
the size in bytes of the requested allocation.
size
,
long
the requested alignment of the allocation in bytes and must be a power of two.
alignment
,
int
a VkSystemAllocationScope value specifying the allocation scope of the lifetime of the allocation, as described here.
allocationScope
)

Implements org.lwjgl.vulkan.VkAllocationFunctionI.invoke.

Application-defined memory allocation function.
Inherited from org.lwjgl.vulkan.VkAllocationFunction:
createcreatecreateSafe

Field Detail

delegateback to summary
private final VkAllocationFunctionI delegate

Constructor Detail

Containerback to summary
pack-priv Container(long functionPointer, VkAllocationFunctionI delegate)

Method Detail

invokeback to summary
public long invoke(long pUserData, long size, long alignment, int allocationScope)

Implements org.lwjgl.vulkan.VkAllocationFunctionI.invoke.

Doc from org.lwjgl.vulkan.VkAllocationFunctionI.invoke.

Application-defined memory allocation function.

Parameters
pUserData:long

the value specified for VkAllocationCallbacks::pUserData in the allocator specified by the application.

size:long

the size in bytes of the requested allocation.

alignment:long

the requested alignment of the allocation in bytes and must be a power of two.

allocationScope:int

a VkSystemAllocationScope value specifying the allocation scope of the lifetime of the allocation, as described here.

Annotations
@Override