All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.lwjgl.util.vma.VmaAllocatorCreateInfo Maven / Gradle / Ivy

There is a newer version: 3.3.4
Show newest version
/*
 * Copyright LWJGL. All rights reserved.
 * License terms: https://www.lwjgl.org/license
 * MACHINE GENERATED FILE, DO NOT EDIT
 */
package org.lwjgl.util.vma;

import javax.annotation.*;

import java.nio.*;

import org.lwjgl.*;
import org.lwjgl.system.*;

import static org.lwjgl.system.Checks.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.system.MemoryStack.*;

import org.lwjgl.vulkan.*;

/**
 * Description of an Allocator to be created.
 * 
 * 

Member documentation

* *
    *
  • {@code flags} – flags for created allocator. Use {@code VmaAllocatorCreateFlagBits} enum. One of:
    {@link Vma#VMA_ALLOCATOR_CREATE_EXTERNALLY_SYNCHRONIZED_BIT ALLOCATOR_CREATE_EXTERNALLY_SYNCHRONIZED_BIT}
    {@link Vma#VMA_ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT}
  • *
  • {@code physicalDevice} – Vulkan physical device. It must be valid throughout whole lifetime of created allocator.
  • *
  • {@code device} – Vulkan device. It must be valid throughout whole lifetime of created allocator.
  • *
  • {@code preferredLargeHeapBlockSize} – * preferred size of a single {@code VkDeviceMemory} block to be allocated from large heaps > 1 GiB. Set to 0 to use default, which is currently 256 * MiB. Optional.
  • *
  • {@code pAllocationCallbacks} – custom CPU memory allocation callbacks. Optional, can be null. When specified, will also be used for all CPU-side memory allocations. Optional.
  • *
  • {@code pDeviceMemoryCallbacks} – informative callbacks for {@code vkAllocateMemory}, {@code vkFreeMemory}. Optional.
  • *
  • {@code frameInUseCount} – * Maximum number of additional frames that are in use at the same time as current frame. * *

    This value is used only when you make allocations with {@link Vma#VMA_ALLOCATION_CREATE_CAN_BECOME_LOST_BIT ALLOCATION_CREATE_CAN_BECOME_LOST_BIT} flag. Such allocation cannot become lost if * {@code allocation.lastUseFrameIndex >= allocator.currentFrameIndex - frameInUseCount}.

    * *

    For example, if you double-buffer your command buffers, so resources used for rendering in previous frame may still be in use by the GPU at the moment * you allocate resources needed for the current frame, set this value to 1.

    * *

    If you want to allow any allocations other than used in the current frame to become lost, set this value to 0.

  • *
  • {@code pHeapSizeLimit} – * Either {@code NULL} or a pointer to an array of limits on maximum number of bytes that can be allocated out of particular Vulkan memory heap. * *

    If not {@code NULL}, it must be a pointer to an array of {@code VkPhysicalDeviceMemoryProperties::memoryHeapCount} elements, defining limit on maximum number * of bytes that can be allocated out of particular Vulkan memory heap.

    * *

    Any of the elements may be equal to {@code VK_WHOLE_SIZE}, which means no limit on that heap. This is also the default in case of * {@code pHeapSizeLimit = NULL}.

    * *

    If there is a limit defined for a heap:

    * *
      *
    • If user tries to allocate more memory from that heap using this allocator, the allocation fails with {@code VK_ERROR_OUT_OF_DEVICE_MEMORY}.
    • *
    • If the limit is smaller than heap size reported in {@code VkMemoryHeap::size}, the value of this limit will be reported instead when using * {@link Vma#vmaGetMemoryProperties GetMemoryProperties}.
    • *
    * *

    Warning! Using this feature may not be equivalent to installing a GPU with smaller amount of memory, because graphics driver doesn't necessary fail new * allocations with {@code VK_ERROR_OUT_OF_DEVICE_MEMORY} result when memory capacity is exceeded. It may return success and just silently migrate some * device memory blocks to system RAM.

  • *
  • {@code pVulkanFunctions} – pointers to Vulkan functions
  • *
* *

Layout

* *

 * struct VmaAllocatorCreateInfo {
 *     VmaAllocatorCreateFlags flags;
 *     VkPhysicalDevice physicalDevice;
 *     VkDevice device;
 *     VkDeviceSize preferredLargeHeapBlockSize;
 *     {@link VkAllocationCallbacks VkAllocationCallbacks const} * pAllocationCallbacks;
 *     {@link VmaDeviceMemoryCallbacks VmaDeviceMemoryCallbacks const} * pDeviceMemoryCallbacks;
 *     uint32_t frameInUseCount;
 *     VkDeviceSize const * pHeapSizeLimit;
 *     {@link VmaVulkanFunctions VmaVulkanFunctions const} * pVulkanFunctions;
 * }
*/ public class VmaAllocatorCreateInfo extends Struct implements NativeResource { /** The struct size in bytes. */ public static final int SIZEOF; /** The struct alignment in bytes. */ public static final int ALIGNOF; /** The struct member offsets. */ public static final int FLAGS, PHYSICALDEVICE, DEVICE, PREFERREDLARGEHEAPBLOCKSIZE, PALLOCATIONCALLBACKS, PDEVICEMEMORYCALLBACKS, FRAMEINUSECOUNT, PHEAPSIZELIMIT, PVULKANFUNCTIONS; static { Layout layout = __struct( __member(4), __member(POINTER_SIZE), __member(POINTER_SIZE), __member(8), __member(POINTER_SIZE), __member(POINTER_SIZE), __member(4), __member(POINTER_SIZE), __member(POINTER_SIZE) ); SIZEOF = layout.getSize(); ALIGNOF = layout.getAlignment(); FLAGS = layout.offsetof(0); PHYSICALDEVICE = layout.offsetof(1); DEVICE = layout.offsetof(2); PREFERREDLARGEHEAPBLOCKSIZE = layout.offsetof(3); PALLOCATIONCALLBACKS = layout.offsetof(4); PDEVICEMEMORYCALLBACKS = layout.offsetof(5); FRAMEINUSECOUNT = layout.offsetof(6); PHEAPSIZELIMIT = layout.offsetof(7); PVULKANFUNCTIONS = layout.offsetof(8); } VmaAllocatorCreateInfo(long address, @Nullable ByteBuffer container) { super(address, container); } /** * Creates a {@link VmaAllocatorCreateInfo} instance at the current position of the specified {@link ByteBuffer} container. Changes to the buffer's content will be * visible to the struct instance and vice versa. * *

The created instance holds a strong reference to the container object.

*/ public VmaAllocatorCreateInfo(ByteBuffer container) { this(memAddress(container), __checkContainer(container, SIZEOF)); } @Override public int sizeof() { return SIZEOF; } /** Returns the value of the {@code flags} field. */ @NativeType("VmaAllocatorCreateFlags") public int flags() { return nflags(address()); } /** Returns the value of the {@code physicalDevice} field. */ @NativeType("VkPhysicalDevice") public long physicalDevice() { return nphysicalDevice(address()); } /** Returns the value of the {@code device} field. */ @NativeType("VkDevice") public long device() { return ndevice(address()); } /** Returns the value of the {@code preferredLargeHeapBlockSize} field. */ @NativeType("VkDeviceSize") public long preferredLargeHeapBlockSize() { return npreferredLargeHeapBlockSize(address()); } /** Returns a {@link VkAllocationCallbacks} view of the struct pointed to by the {@code pAllocationCallbacks} field. */ @Nullable @NativeType("VkAllocationCallbacks const *") public VkAllocationCallbacks pAllocationCallbacks() { return npAllocationCallbacks(address()); } /** Returns a {@link VmaDeviceMemoryCallbacks} view of the struct pointed to by the {@code pDeviceMemoryCallbacks} field. */ @Nullable @NativeType("VmaDeviceMemoryCallbacks const *") public VmaDeviceMemoryCallbacks pDeviceMemoryCallbacks() { return npDeviceMemoryCallbacks(address()); } /** Returns the value of the {@code frameInUseCount} field. */ @NativeType("uint32_t") public int frameInUseCount() { return nframeInUseCount(address()); } /** * Returns a {@link LongBuffer} view of the data pointed to by the {@code pHeapSizeLimit} field. * * @param capacity the number of elements in the returned buffer */ @Nullable @NativeType("VkDeviceSize const *") public LongBuffer pHeapSizeLimit(int capacity) { return npHeapSizeLimit(address(), capacity); } /** Returns a {@link VmaVulkanFunctions} view of the struct pointed to by the {@code pVulkanFunctions} field. */ @NativeType("VmaVulkanFunctions const *") public VmaVulkanFunctions pVulkanFunctions() { return npVulkanFunctions(address()); } /** Sets the specified value to the {@code flags} field. */ public VmaAllocatorCreateInfo flags(@NativeType("VmaAllocatorCreateFlags") int value) { nflags(address(), value); return this; } /** Sets the specified value to the {@code physicalDevice} field. */ public VmaAllocatorCreateInfo physicalDevice(VkPhysicalDevice value) { nphysicalDevice(address(), value); return this; } /** Sets the specified value to the {@code device} field. */ public VmaAllocatorCreateInfo device(VkDevice value) { ndevice(address(), value); return this; } /** Sets the specified value to the {@code preferredLargeHeapBlockSize} field. */ public VmaAllocatorCreateInfo preferredLargeHeapBlockSize(@NativeType("VkDeviceSize") long value) { npreferredLargeHeapBlockSize(address(), value); return this; } /** Sets the address of the specified {@link VkAllocationCallbacks} to the {@code pAllocationCallbacks} field. */ public VmaAllocatorCreateInfo pAllocationCallbacks(@Nullable @NativeType("VkAllocationCallbacks const *") VkAllocationCallbacks value) { npAllocationCallbacks(address(), value); return this; } /** Sets the address of the specified {@link VmaDeviceMemoryCallbacks} to the {@code pDeviceMemoryCallbacks} field. */ public VmaAllocatorCreateInfo pDeviceMemoryCallbacks(@Nullable @NativeType("VmaDeviceMemoryCallbacks const *") VmaDeviceMemoryCallbacks value) { npDeviceMemoryCallbacks(address(), value); return this; } /** Sets the specified value to the {@code frameInUseCount} field. */ public VmaAllocatorCreateInfo frameInUseCount(@NativeType("uint32_t") int value) { nframeInUseCount(address(), value); return this; } /** Sets the address of the specified {@link LongBuffer} to the {@code pHeapSizeLimit} field. */ public VmaAllocatorCreateInfo pHeapSizeLimit(@Nullable @NativeType("VkDeviceSize const *") LongBuffer value) { npHeapSizeLimit(address(), value); return this; } /** Sets the address of the specified {@link VmaVulkanFunctions} to the {@code pVulkanFunctions} field. */ public VmaAllocatorCreateInfo pVulkanFunctions(@NativeType("VmaVulkanFunctions const *") VmaVulkanFunctions value) { npVulkanFunctions(address(), value); return this; } /** Initializes this struct with the specified values. */ public VmaAllocatorCreateInfo set( int flags, VkPhysicalDevice physicalDevice, VkDevice device, long preferredLargeHeapBlockSize, @Nullable VkAllocationCallbacks pAllocationCallbacks, @Nullable VmaDeviceMemoryCallbacks pDeviceMemoryCallbacks, int frameInUseCount, @Nullable LongBuffer pHeapSizeLimit, VmaVulkanFunctions pVulkanFunctions ) { flags(flags); physicalDevice(physicalDevice); device(device); preferredLargeHeapBlockSize(preferredLargeHeapBlockSize); pAllocationCallbacks(pAllocationCallbacks); pDeviceMemoryCallbacks(pDeviceMemoryCallbacks); frameInUseCount(frameInUseCount); pHeapSizeLimit(pHeapSizeLimit); pVulkanFunctions(pVulkanFunctions); return this; } /** * Copies the specified struct data to this struct. * * @param src the source struct * * @return this struct */ public VmaAllocatorCreateInfo set(VmaAllocatorCreateInfo src) { memCopy(src.address(), address(), SIZEOF); return this; } // ----------------------------------- /** Returns a new {@link VmaAllocatorCreateInfo} instance allocated with {@link MemoryUtil#memAlloc memAlloc}. The instance must be explicitly freed. */ public static VmaAllocatorCreateInfo malloc() { return create(nmemAllocChecked(SIZEOF)); } /** Returns a new {@link VmaAllocatorCreateInfo} instance allocated with {@link MemoryUtil#memCalloc memCalloc}. The instance must be explicitly freed. */ public static VmaAllocatorCreateInfo calloc() { return create(nmemCallocChecked(1, SIZEOF)); } /** Returns a new {@link VmaAllocatorCreateInfo} instance allocated with {@link BufferUtils}. */ public static VmaAllocatorCreateInfo create() { return new VmaAllocatorCreateInfo(BufferUtils.createByteBuffer(SIZEOF)); } /** Returns a new {@link VmaAllocatorCreateInfo} instance for the specified memory address. */ public static VmaAllocatorCreateInfo create(long address) { return new VmaAllocatorCreateInfo(address, null); } /** Like {@link #create(long) create}, but returns {@code null} if {@code address} is {@code NULL}. */ @Nullable public static VmaAllocatorCreateInfo createSafe(long address) { return address == NULL ? null : create(address); } // ----------------------------------- /** Returns a new {@link VmaAllocatorCreateInfo} instance allocated on the thread-local {@link MemoryStack}. */ public static VmaAllocatorCreateInfo mallocStack() { return mallocStack(stackGet()); } /** Returns a new {@link VmaAllocatorCreateInfo} instance allocated on the thread-local {@link MemoryStack} and initializes all its bits to zero. */ public static VmaAllocatorCreateInfo callocStack() { return callocStack(stackGet()); } /** * Returns a new {@link VmaAllocatorCreateInfo} instance allocated on the specified {@link MemoryStack}. * * @param stack the stack from which to allocate */ public static VmaAllocatorCreateInfo mallocStack(MemoryStack stack) { return create(stack.nmalloc(ALIGNOF, SIZEOF)); } /** * Returns a new {@link VmaAllocatorCreateInfo} instance allocated on the specified {@link MemoryStack} and initializes all its bits to zero. * * @param stack the stack from which to allocate */ public static VmaAllocatorCreateInfo callocStack(MemoryStack stack) { return create(stack.ncalloc(ALIGNOF, 1, SIZEOF)); } // ----------------------------------- /** Unsafe version of {@link #flags}. */ public static int nflags(long struct) { return memGetInt(struct + VmaAllocatorCreateInfo.FLAGS); } /** Unsafe version of {@link #physicalDevice}. */ public static long nphysicalDevice(long struct) { return memGetAddress(struct + VmaAllocatorCreateInfo.PHYSICALDEVICE); } /** Unsafe version of {@link #device}. */ public static long ndevice(long struct) { return memGetAddress(struct + VmaAllocatorCreateInfo.DEVICE); } /** Unsafe version of {@link #preferredLargeHeapBlockSize}. */ public static long npreferredLargeHeapBlockSize(long struct) { return memGetLong(struct + VmaAllocatorCreateInfo.PREFERREDLARGEHEAPBLOCKSIZE); } /** Unsafe version of {@link #pAllocationCallbacks}. */ @Nullable public static VkAllocationCallbacks npAllocationCallbacks(long struct) { return VkAllocationCallbacks.createSafe(memGetAddress(struct + VmaAllocatorCreateInfo.PALLOCATIONCALLBACKS)); } /** Unsafe version of {@link #pDeviceMemoryCallbacks}. */ @Nullable public static VmaDeviceMemoryCallbacks npDeviceMemoryCallbacks(long struct) { return VmaDeviceMemoryCallbacks.createSafe(memGetAddress(struct + VmaAllocatorCreateInfo.PDEVICEMEMORYCALLBACKS)); } /** Unsafe version of {@link #frameInUseCount}. */ public static int nframeInUseCount(long struct) { return memGetInt(struct + VmaAllocatorCreateInfo.FRAMEINUSECOUNT); } /** Unsafe version of {@link #pHeapSizeLimit(int) pHeapSizeLimit}. */ @Nullable public static LongBuffer npHeapSizeLimit(long struct, int capacity) { return memLongBufferSafe(memGetAddress(struct + VmaAllocatorCreateInfo.PHEAPSIZELIMIT), capacity); } /** Unsafe version of {@link #pVulkanFunctions}. */ public static VmaVulkanFunctions npVulkanFunctions(long struct) { return VmaVulkanFunctions.create(memGetAddress(struct + VmaAllocatorCreateInfo.PVULKANFUNCTIONS)); } /** Unsafe version of {@link #flags(int) flags}. */ public static void nflags(long struct, int value) { memPutInt(struct + VmaAllocatorCreateInfo.FLAGS, value); } /** Unsafe version of {@link #physicalDevice(VkPhysicalDevice) physicalDevice}. */ public static void nphysicalDevice(long struct, VkPhysicalDevice value) { memPutAddress(struct + VmaAllocatorCreateInfo.PHYSICALDEVICE, value.address()); } /** Unsafe version of {@link #device(VkDevice) device}. */ public static void ndevice(long struct, VkDevice value) { memPutAddress(struct + VmaAllocatorCreateInfo.DEVICE, value.address()); } /** Unsafe version of {@link #preferredLargeHeapBlockSize(long) preferredLargeHeapBlockSize}. */ public static void npreferredLargeHeapBlockSize(long struct, long value) { memPutLong(struct + VmaAllocatorCreateInfo.PREFERREDLARGEHEAPBLOCKSIZE, value); } /** Unsafe version of {@link #pAllocationCallbacks(VkAllocationCallbacks) pAllocationCallbacks}. */ public static void npAllocationCallbacks(long struct, @Nullable VkAllocationCallbacks value) { memPutAddress(struct + VmaAllocatorCreateInfo.PALLOCATIONCALLBACKS, memAddressSafe(value)); } /** Unsafe version of {@link #pDeviceMemoryCallbacks(VmaDeviceMemoryCallbacks) pDeviceMemoryCallbacks}. */ public static void npDeviceMemoryCallbacks(long struct, @Nullable VmaDeviceMemoryCallbacks value) { memPutAddress(struct + VmaAllocatorCreateInfo.PDEVICEMEMORYCALLBACKS, memAddressSafe(value)); } /** Unsafe version of {@link #frameInUseCount(int) frameInUseCount}. */ public static void nframeInUseCount(long struct, int value) { memPutInt(struct + VmaAllocatorCreateInfo.FRAMEINUSECOUNT, value); } /** Unsafe version of {@link #pHeapSizeLimit(LongBuffer) pHeapSizeLimit}. */ public static void npHeapSizeLimit(long struct, @Nullable LongBuffer value) { memPutAddress(struct + VmaAllocatorCreateInfo.PHEAPSIZELIMIT, memAddressSafe(value)); } /** Unsafe version of {@link #pVulkanFunctions(VmaVulkanFunctions) pVulkanFunctions}. */ public static void npVulkanFunctions(long struct, VmaVulkanFunctions value) { memPutAddress(struct + VmaAllocatorCreateInfo.PVULKANFUNCTIONS, value.address()); } /** * Validates pointer members that should not be {@code NULL}. * * @param struct the struct to validate */ public static void validate(long struct) { check(memGetAddress(struct + VmaAllocatorCreateInfo.PHYSICALDEVICE)); check(memGetAddress(struct + VmaAllocatorCreateInfo.DEVICE)); long pAllocationCallbacks = memGetAddress(struct + VmaAllocatorCreateInfo.PALLOCATIONCALLBACKS); if (pAllocationCallbacks != NULL) { VkAllocationCallbacks.validate(pAllocationCallbacks); } long pVulkanFunctions = memGetAddress(struct + VmaAllocatorCreateInfo.PVULKANFUNCTIONS); check(pVulkanFunctions); VmaVulkanFunctions.validate(pVulkanFunctions); } /** * Calls {@link #validate(long)} for each struct contained in the specified struct array. * * @param array the struct array to validate * @param count the number of structs in {@code array} */ public static void validate(long array, int count) { for (int i = 0; i < count; i++) { validate(array + i * SIZEOF); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy