package org.lwjgl.util.vma;

import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import java.nio.LongBuffer;
import javax.annotation.Nullable;
import org.lwjgl.BufferUtils;
import org.lwjgl.system.Checks;
import org.lwjgl.system.MemoryStack;
import org.lwjgl.system.MemoryUtil;
import org.lwjgl.system.NativeResource;
import org.lwjgl.system.NativeType;
import org.lwjgl.system.Struct;
import org.lwjgl.vulkan.VkAllocationCallbacks;
import org.lwjgl.vulkan.VkDevice;
import org.lwjgl.vulkan.VkInstance;
import org.lwjgl.vulkan.VkPhysicalDevice;

public class VmaAllocatorCreateInfo extends Struct<VmaAllocatorCreateInfo> implements NativeResource {
   public static final int SIZEOF;
   public static final int ALIGNOF;
   public static final int FLAGS;
   public static final int PHYSICALDEVICE;
   public static final int DEVICE;
   public static final int PREFERREDLARGEHEAPBLOCKSIZE;
   public static final int PALLOCATIONCALLBACKS;
   public static final int PDEVICEMEMORYCALLBACKS;
   public static final int PHEAPSIZELIMIT;
   public static final int PVULKANFUNCTIONS;
   public static final int INSTANCE;
   public static final int VULKANAPIVERSION;
   public static final int PTYPEEXTERNALMEMORYHANDLETYPES;

   protected VmaAllocatorCreateInfo(long address, @Nullable ByteBuffer container) {
      super(address, container);
   }

   protected VmaAllocatorCreateInfo create(long address, @Nullable ByteBuffer container) {
      return new VmaAllocatorCreateInfo(address, container);
   }

   public VmaAllocatorCreateInfo(ByteBuffer container) {
      super(MemoryUtil.memAddress(container), __checkContainer(container, SIZEOF));
   }

   public int sizeof() {
      return SIZEOF;
   }

   @NativeType("VmaAllocatorCreateFlags")
   public int flags() {
      return nflags(this.address());
   }

   @NativeType("VkPhysicalDevice")
   public long physicalDevice() {
      return nphysicalDevice(this.address());
   }

   @NativeType("VkDevice")
   public long device() {
      return ndevice(this.address());
   }

   @NativeType("VkDeviceSize")
   public long preferredLargeHeapBlockSize() {
      return npreferredLargeHeapBlockSize(this.address());
   }

   @Nullable
   @NativeType("VkAllocationCallbacks const *")
   public VkAllocationCallbacks pAllocationCallbacks() {
      return npAllocationCallbacks(this.address());
   }

   @Nullable
   @NativeType("VmaDeviceMemoryCallbacks const *")
   public VmaDeviceMemoryCallbacks pDeviceMemoryCallbacks() {
      return npDeviceMemoryCallbacks(this.address());
   }

   @Nullable
   @NativeType("VkDeviceSize const *")
   public LongBuffer pHeapSizeLimit(int capacity) {
      return npHeapSizeLimit(this.address(), capacity);
   }

   @NativeType("VmaVulkanFunctions const *")
   public VmaVulkanFunctions pVulkanFunctions() {
      return npVulkanFunctions(this.address());
   }

   @NativeType("VkInstance")
   public long instance() {
      return ninstance(this.address());
   }

   @NativeType("uint32_t")
   public int vulkanApiVersion() {
      return nvulkanApiVersion(this.address());
   }

   @Nullable
   @NativeType("VkExternalMemoryHandleTypeFlagsKHR const *")
   public IntBuffer pTypeExternalMemoryHandleTypes(int capacity) {
      return npTypeExternalMemoryHandleTypes(this.address(), capacity);
   }

   public VmaAllocatorCreateInfo flags(@NativeType("VmaAllocatorCreateFlags") int value) {
      nflags(this.address(), value);
      return this;
   }

   public VmaAllocatorCreateInfo physicalDevice(VkPhysicalDevice value) {
      nphysicalDevice(this.address(), value);
      return this;
   }

   public VmaAllocatorCreateInfo device(VkDevice value) {
      ndevice(this.address(), value);
      return this;
   }

   public VmaAllocatorCreateInfo preferredLargeHeapBlockSize(@NativeType("VkDeviceSize") long value) {
      npreferredLargeHeapBlockSize(this.address(), value);
      return this;
   }

   public VmaAllocatorCreateInfo pAllocationCallbacks(@Nullable @NativeType("VkAllocationCallbacks const *") VkAllocationCallbacks value) {
      npAllocationCallbacks(this.address(), value);
      return this;
   }

   public VmaAllocatorCreateInfo pDeviceMemoryCallbacks(@Nullable @NativeType("VmaDeviceMemoryCallbacks const *") VmaDeviceMemoryCallbacks value) {
      npDeviceMemoryCallbacks(this.address(), value);
      return this;
   }

   public VmaAllocatorCreateInfo pHeapSizeLimit(@Nullable @NativeType("VkDeviceSize const *") LongBuffer value) {
      npHeapSizeLimit(this.address(), value);
      return this;
   }

   public VmaAllocatorCreateInfo pVulkanFunctions(@NativeType("VmaVulkanFunctions const *") VmaVulkanFunctions value) {
      npVulkanFunctions(this.address(), value);
      return this;
   }

   public VmaAllocatorCreateInfo instance(VkInstance value) {
      ninstance(this.address(), value);
      return this;
   }

   public VmaAllocatorCreateInfo vulkanApiVersion(@NativeType("uint32_t") int value) {
      nvulkanApiVersion(this.address(), value);
      return this;
   }

   public VmaAllocatorCreateInfo pTypeExternalMemoryHandleTypes(@Nullable @NativeType("VkExternalMemoryHandleTypeFlagsKHR const *") IntBuffer value) {
      npTypeExternalMemoryHandleTypes(this.address(), value);
      return this;
   }

   public VmaAllocatorCreateInfo set(int flags, VkPhysicalDevice physicalDevice, VkDevice device, long preferredLargeHeapBlockSize, @Nullable VkAllocationCallbacks pAllocationCallbacks, @Nullable VmaDeviceMemoryCallbacks pDeviceMemoryCallbacks, @Nullable LongBuffer pHeapSizeLimit, VmaVulkanFunctions pVulkanFunctions, VkInstance instance, int vulkanApiVersion, @Nullable IntBuffer pTypeExternalMemoryHandleTypes) {
      this.flags(flags);
      this.physicalDevice(physicalDevice);
      this.device(device);
      this.preferredLargeHeapBlockSize(preferredLargeHeapBlockSize);
      this.pAllocationCallbacks(pAllocationCallbacks);
      this.pDeviceMemoryCallbacks(pDeviceMemoryCallbacks);
      this.pHeapSizeLimit(pHeapSizeLimit);
      this.pVulkanFunctions(pVulkanFunctions);
      this.instance(instance);
      this.vulkanApiVersion(vulkanApiVersion);
      this.pTypeExternalMemoryHandleTypes(pTypeExternalMemoryHandleTypes);
      return this;
   }

   public VmaAllocatorCreateInfo set(VmaAllocatorCreateInfo src) {
      MemoryUtil.memCopy(src.address(), this.address(), (long)SIZEOF);
      return this;
   }

   public static VmaAllocatorCreateInfo malloc() {
      return new VmaAllocatorCreateInfo(MemoryUtil.nmemAllocChecked((long)SIZEOF), (ByteBuffer)null);
   }

   public static VmaAllocatorCreateInfo calloc() {
      return new VmaAllocatorCreateInfo(MemoryUtil.nmemCallocChecked(1L, (long)SIZEOF), (ByteBuffer)null);
   }

   public static VmaAllocatorCreateInfo create() {
      ByteBuffer container = BufferUtils.createByteBuffer(SIZEOF);
      return new VmaAllocatorCreateInfo(MemoryUtil.memAddress(container), container);
   }

   public static VmaAllocatorCreateInfo create(long address) {
      return new VmaAllocatorCreateInfo(address, (ByteBuffer)null);
   }

   @Nullable
   public static VmaAllocatorCreateInfo createSafe(long address) {
      return address == 0L ? null : new VmaAllocatorCreateInfo(address, (ByteBuffer)null);
   }

   /** @deprecated */
   @Deprecated
   public static VmaAllocatorCreateInfo mallocStack() {
      return malloc(MemoryStack.stackGet());
   }

   /** @deprecated */
   @Deprecated
   public static VmaAllocatorCreateInfo callocStack() {
      return calloc(MemoryStack.stackGet());
   }

   /** @deprecated */
   @Deprecated
   public static VmaAllocatorCreateInfo mallocStack(MemoryStack stack) {
      return malloc(stack);
   }

   /** @deprecated */
   @Deprecated
   public static VmaAllocatorCreateInfo callocStack(MemoryStack stack) {
      return calloc(stack);
   }

   public static VmaAllocatorCreateInfo malloc(MemoryStack stack) {
      return new VmaAllocatorCreateInfo(stack.nmalloc(ALIGNOF, SIZEOF), (ByteBuffer)null);
   }

   public static VmaAllocatorCreateInfo calloc(MemoryStack stack) {
      return new VmaAllocatorCreateInfo(stack.ncalloc(ALIGNOF, 1, SIZEOF), (ByteBuffer)null);
   }

   public static int nflags(long struct) {
      return UNSAFE.getInt((Object)null, struct + (long)FLAGS);
   }

   public static long nphysicalDevice(long struct) {
      return MemoryUtil.memGetAddress(struct + (long)PHYSICALDEVICE);
   }

   public static long ndevice(long struct) {
      return MemoryUtil.memGetAddress(struct + (long)DEVICE);
   }

   public static long npreferredLargeHeapBlockSize(long struct) {
      return UNSAFE.getLong((Object)null, struct + (long)PREFERREDLARGEHEAPBLOCKSIZE);
   }

   @Nullable
   public static VkAllocationCallbacks npAllocationCallbacks(long struct) {
      return VkAllocationCallbacks.createSafe(MemoryUtil.memGetAddress(struct + (long)PALLOCATIONCALLBACKS));
   }

   @Nullable
   public static VmaDeviceMemoryCallbacks npDeviceMemoryCallbacks(long struct) {
      return VmaDeviceMemoryCallbacks.createSafe(MemoryUtil.memGetAddress(struct + (long)PDEVICEMEMORYCALLBACKS));
   }

   @Nullable
   public static LongBuffer npHeapSizeLimit(long struct, int capacity) {
      return MemoryUtil.memLongBufferSafe(MemoryUtil.memGetAddress(struct + (long)PHEAPSIZELIMIT), capacity);
   }

   public static VmaVulkanFunctions npVulkanFunctions(long struct) {
      return VmaVulkanFunctions.create(MemoryUtil.memGetAddress(struct + (long)PVULKANFUNCTIONS));
   }

   public static long ninstance(long struct) {
      return MemoryUtil.memGetAddress(struct + (long)INSTANCE);
   }

   public static int nvulkanApiVersion(long struct) {
      return UNSAFE.getInt((Object)null, struct + (long)VULKANAPIVERSION);
   }

   @Nullable
   public static IntBuffer npTypeExternalMemoryHandleTypes(long struct, int capacity) {
      return MemoryUtil.memIntBufferSafe(MemoryUtil.memGetAddress(struct + (long)PTYPEEXTERNALMEMORYHANDLETYPES), capacity);
   }

   public static void nflags(long struct, int value) {
      UNSAFE.putInt((Object)null, struct + (long)FLAGS, value);
   }

   public static void nphysicalDevice(long struct, VkPhysicalDevice value) {
      MemoryUtil.memPutAddress(struct + (long)PHYSICALDEVICE, value.address());
   }

   public static void ndevice(long struct, VkDevice value) {
      MemoryUtil.memPutAddress(struct + (long)DEVICE, value.address());
   }

   public static void npreferredLargeHeapBlockSize(long struct, long value) {
      UNSAFE.putLong((Object)null, struct + (long)PREFERREDLARGEHEAPBLOCKSIZE, value);
   }

   public static void npAllocationCallbacks(long struct, @Nullable VkAllocationCallbacks value) {
      MemoryUtil.memPutAddress(struct + (long)PALLOCATIONCALLBACKS, MemoryUtil.memAddressSafe(value));
   }

   public static void npDeviceMemoryCallbacks(long struct, @Nullable VmaDeviceMemoryCallbacks value) {
      MemoryUtil.memPutAddress(struct + (long)PDEVICEMEMORYCALLBACKS, MemoryUtil.memAddressSafe(value));
   }

   public static void npHeapSizeLimit(long struct, @Nullable LongBuffer value) {
      MemoryUtil.memPutAddress(struct + (long)PHEAPSIZELIMIT, MemoryUtil.memAddressSafe(value));
   }

   public static void npVulkanFunctions(long struct, VmaVulkanFunctions value) {
      MemoryUtil.memPutAddress(struct + (long)PVULKANFUNCTIONS, value.address());
   }

   public static void ninstance(long struct, VkInstance value) {
      MemoryUtil.memPutAddress(struct + (long)INSTANCE, value.address());
   }

   public static void nvulkanApiVersion(long struct, int value) {
      UNSAFE.putInt((Object)null, struct + (long)VULKANAPIVERSION, value);
   }

   public static void npTypeExternalMemoryHandleTypes(long struct, @Nullable IntBuffer value) {
      MemoryUtil.memPutAddress(struct + (long)PTYPEEXTERNALMEMORYHANDLETYPES, MemoryUtil.memAddressSafe(value));
   }

   public static void validate(long struct) {
      Checks.check(MemoryUtil.memGetAddress(struct + (long)PHYSICALDEVICE));
      Checks.check(MemoryUtil.memGetAddress(struct + (long)DEVICE));
      long pVulkanFunctions = MemoryUtil.memGetAddress(struct + (long)PVULKANFUNCTIONS);
      Checks.check(pVulkanFunctions);
      VmaVulkanFunctions.validate(pVulkanFunctions);
      Checks.check(MemoryUtil.memGetAddress(struct + (long)INSTANCE));
   }

   static {
      Struct.Layout layout = __struct(new Struct.Member[]{__member(4), __member(POINTER_SIZE), __member(POINTER_SIZE), __member(8), __member(POINTER_SIZE), __member(POINTER_SIZE), __member(POINTER_SIZE), __member(POINTER_SIZE), __member(POINTER_SIZE), __member(4), __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);
      PHEAPSIZELIMIT = layout.offsetof(6);
      PVULKANFUNCTIONS = layout.offsetof(7);
      INSTANCE = layout.offsetof(8);
      VULKANAPIVERSION = layout.offsetof(9);
      PTYPEEXTERNALMEMORYHANDLETYPES = layout.offsetof(10);
   }
}
