package org.lwjgl.util.vma;

import java.nio.ByteBuffer;
import javax.annotation.Nullable;
import org.lwjgl.BufferUtils;
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.system.StructBuffer;

public class VmaDetailedStatistics extends Struct<VmaDetailedStatistics> implements NativeResource {
   public static final int SIZEOF;
   public static final int ALIGNOF;
   public static final int STATISTICS;
   public static final int UNUSEDRANGECOUNT;
   public static final int ALLOCATIONSIZEMIN;
   public static final int ALLOCATIONSIZEMAX;
   public static final int UNUSEDRANGESIZEMIN;
   public static final int UNUSEDRANGESIZEMAX;

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

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

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

   public int sizeof() {
      return SIZEOF;
   }

   public VmaStatistics statistics() {
      return nstatistics(this.address());
   }

   @NativeType("uint32_t")
   public int unusedRangeCount() {
      return nunusedRangeCount(this.address());
   }

   @NativeType("VkDeviceSize")
   public long allocationSizeMin() {
      return nallocationSizeMin(this.address());
   }

   @NativeType("VkDeviceSize")
   public long allocationSizeMax() {
      return nallocationSizeMax(this.address());
   }

   @NativeType("VkDeviceSize")
   public long unusedRangeSizeMin() {
      return nunusedRangeSizeMin(this.address());
   }

   @NativeType("VkDeviceSize")
   public long unusedRangeSizeMax() {
      return nunusedRangeSizeMax(this.address());
   }

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

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

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

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

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

   public static Buffer malloc(int capacity) {
      return new Buffer(MemoryUtil.nmemAllocChecked(__checkMalloc(capacity, SIZEOF)), capacity);
   }

   public static Buffer calloc(int capacity) {
      return new Buffer(MemoryUtil.nmemCallocChecked((long)capacity, (long)SIZEOF), capacity);
   }

   public static Buffer create(int capacity) {
      ByteBuffer container = __create(capacity, SIZEOF);
      return new Buffer(MemoryUtil.memAddress(container), container, -1, 0, capacity, capacity);
   }

   public static Buffer create(long address, int capacity) {
      return new Buffer(address, capacity);
   }

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

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

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

   public static Buffer malloc(int capacity, MemoryStack stack) {
      return new Buffer(stack.nmalloc(ALIGNOF, capacity * SIZEOF), capacity);
   }

   public static Buffer calloc(int capacity, MemoryStack stack) {
      return new Buffer(stack.ncalloc(ALIGNOF, capacity, SIZEOF), capacity);
   }

   public static VmaStatistics nstatistics(long struct) {
      return VmaStatistics.create(struct + (long)STATISTICS);
   }

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

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

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

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

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

   static {
      Struct.Layout layout = __struct(new Struct.Member[]{__member(VmaStatistics.SIZEOF, VmaStatistics.ALIGNOF), __member(4), __member(8), __member(8), __member(8), __member(8)});
      SIZEOF = layout.getSize();
      ALIGNOF = layout.getAlignment();
      STATISTICS = layout.offsetof(0);
      UNUSEDRANGECOUNT = layout.offsetof(1);
      ALLOCATIONSIZEMIN = layout.offsetof(2);
      ALLOCATIONSIZEMAX = layout.offsetof(3);
      UNUSEDRANGESIZEMIN = layout.offsetof(4);
      UNUSEDRANGESIZEMAX = layout.offsetof(5);
   }

   public static class Buffer extends StructBuffer<VmaDetailedStatistics, Buffer> implements NativeResource {
      private static final VmaDetailedStatistics ELEMENT_FACTORY = VmaDetailedStatistics.create(-1L);

      public Buffer(ByteBuffer container) {
         super(container, container.remaining() / VmaDetailedStatistics.SIZEOF);
      }

      public Buffer(long address, int cap) {
         super(address, (ByteBuffer)null, -1, 0, cap, cap);
      }

      Buffer(long address, @Nullable ByteBuffer container, int mark, int pos, int lim, int cap) {
         super(address, container, mark, pos, lim, cap);
      }

      protected Buffer self() {
         return this;
      }

      protected VmaDetailedStatistics getElementFactory() {
         return ELEMENT_FACTORY;
      }

      public VmaStatistics statistics() {
         return VmaDetailedStatistics.nstatistics(this.address());
      }

      @NativeType("uint32_t")
      public int unusedRangeCount() {
         return VmaDetailedStatistics.nunusedRangeCount(this.address());
      }

      @NativeType("VkDeviceSize")
      public long allocationSizeMin() {
         return VmaDetailedStatistics.nallocationSizeMin(this.address());
      }

      @NativeType("VkDeviceSize")
      public long allocationSizeMax() {
         return VmaDetailedStatistics.nallocationSizeMax(this.address());
      }

      @NativeType("VkDeviceSize")
      public long unusedRangeSizeMin() {
         return VmaDetailedStatistics.nunusedRangeSizeMin(this.address());
      }

      @NativeType("VkDeviceSize")
      public long unusedRangeSizeMax() {
         return VmaDetailedStatistics.nunusedRangeSizeMax(this.address());
      }
   }
}
