org.lwjgl.vulkan.VkDescriptorBufferInfo Maven / Gradle / Ivy
Show all versions of lwjgl-vulkan Show documentation
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.vulkan;
import javax.annotation.*;
import java.nio.*;
import org.lwjgl.*;
import org.lwjgl.system.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.system.MemoryStack.*;
/**
* Structure specifying descriptor buffer info.
*
* Description
*
* Note
*
* When setting {@code range} to {@link VK10#VK_WHOLE_SIZE WHOLE_SIZE}, the effective range must not be larger than the maximum range for the descriptor type (maxUniformBufferRange or maxStorageBufferRange). This means that {@link VK10#VK_WHOLE_SIZE WHOLE_SIZE} is not typically useful in the common case where uniform buffer descriptors are suballocated from a buffer that is much larger than {@code maxUniformBufferRange}.
*
*
* For {@link VK10#VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC} and {@link VK10#VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC} descriptor types, {@code offset} is the base offset from which the dynamic offset is applied and {@code range} is the static size used for all dynamic offsets.
*
* Valid Usage
*
*
* - {@code offset} must be less than the size of {@code buffer}
* - If {@code range} is not equal to {@link VK10#VK_WHOLE_SIZE WHOLE_SIZE}, {@code range} must be greater than 0
* - If {@code range} is not equal to {@link VK10#VK_WHOLE_SIZE WHOLE_SIZE}, {@code range} must be less than or equal to the size of {@code buffer} minus {@code offset}
*
*
* Valid Usage (Implicit)
*
*
* - {@code buffer} must be a valid {@code VkBuffer} handle
*
*
* See Also
*
* {@link VkWriteDescriptorSet}
*
* Member documentation
*
*
* - {@code buffer} – the buffer resource.
* - {@code offset} – the offset in bytes from the start of {@code buffer}. Access to buffer memory via this descriptor uses addressing that is relative to this starting offset.
* - {@code range} – the size in bytes that is used for this descriptor update, or {@link VK10#VK_WHOLE_SIZE WHOLE_SIZE} to use the range from {@code offset} to the end of the buffer.
*
*
* Layout
*
*
* struct VkDescriptorBufferInfo {
* VkBuffer buffer;
* VkDeviceSize offset;
* VkDeviceSize range;
* }
*/
public class VkDescriptorBufferInfo extends Struct implements NativeResource {
/** The struct size in bytes. */
public static final int SIZEOF;
public static final int ALIGNOF;
/** The struct member offsets. */
public static final int
BUFFER,
OFFSET,
RANGE;
static {
Layout layout = __struct(
__member(8),
__member(8),
__member(8)
);
SIZEOF = layout.getSize();
ALIGNOF = layout.getAlignment();
BUFFER = layout.offsetof(0);
OFFSET = layout.offsetof(1);
RANGE = layout.offsetof(2);
}
VkDescriptorBufferInfo(long address, @Nullable ByteBuffer container) {
super(address, container);
}
/**
* Creates a {@link VkDescriptorBufferInfo} 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 VkDescriptorBufferInfo(ByteBuffer container) {
this(memAddress(container), __checkContainer(container, SIZEOF));
}
@Override
public int sizeof() { return SIZEOF; }
/** Returns the value of the {@code buffer} field. */
@NativeType("VkBuffer")
public long buffer() { return nbuffer(address()); }
/** Returns the value of the {@code offset} field. */
@NativeType("VkDeviceSize")
public long offset() { return noffset(address()); }
/** Returns the value of the {@code range} field. */
@NativeType("VkDeviceSize")
public long range() { return nrange(address()); }
/** Sets the specified value to the {@code buffer} field. */
public VkDescriptorBufferInfo buffer(@NativeType("VkBuffer") long value) { nbuffer(address(), value); return this; }
/** Sets the specified value to the {@code offset} field. */
public VkDescriptorBufferInfo offset(@NativeType("VkDeviceSize") long value) { noffset(address(), value); return this; }
/** Sets the specified value to the {@code range} field. */
public VkDescriptorBufferInfo range(@NativeType("VkDeviceSize") long value) { nrange(address(), value); return this; }
/** Initializes this struct with the specified values. */
public VkDescriptorBufferInfo set(
long buffer,
long offset,
long range
) {
buffer(buffer);
offset(offset);
range(range);
return this;
}
/**
* Copies the specified struct data to this struct.
*
* @param src the source struct
*
* @return this struct
*/
public VkDescriptorBufferInfo set(VkDescriptorBufferInfo src) {
memCopy(src.address(), address(), SIZEOF);
return this;
}
// -----------------------------------
/** Returns a new {@link VkDescriptorBufferInfo} instance allocated with {@link MemoryUtil#memAlloc memAlloc}. The instance must be explicitly freed. */
public static VkDescriptorBufferInfo malloc() {
return create(nmemAllocChecked(SIZEOF));
}
/** Returns a new {@link VkDescriptorBufferInfo} instance allocated with {@link MemoryUtil#memCalloc memCalloc}. The instance must be explicitly freed. */
public static VkDescriptorBufferInfo calloc() {
return create(nmemCallocChecked(1, SIZEOF));
}
/** Returns a new {@link VkDescriptorBufferInfo} instance allocated with {@link BufferUtils}. */
public static VkDescriptorBufferInfo create() {
return new VkDescriptorBufferInfo(BufferUtils.createByteBuffer(SIZEOF));
}
/** Returns a new {@link VkDescriptorBufferInfo} instance for the specified memory address. */
public static VkDescriptorBufferInfo create(long address) {
return new VkDescriptorBufferInfo(address, null);
}
/** Like {@link #create(long) create}, but returns {@code null} if {@code address} is {@code NULL}. */
@Nullable
public static VkDescriptorBufferInfo createSafe(long address) {
return address == NULL ? null : create(address);
}
/**
* Returns a new {@link VkDescriptorBufferInfo.Buffer} instance allocated with {@link MemoryUtil#memAlloc memAlloc}. The instance must be explicitly freed.
*
* @param capacity the buffer capacity
*/
public static VkDescriptorBufferInfo.Buffer malloc(int capacity) {
return create(__malloc(capacity, SIZEOF), capacity);
}
/**
* Returns a new {@link VkDescriptorBufferInfo.Buffer} instance allocated with {@link MemoryUtil#memCalloc memCalloc}. The instance must be explicitly freed.
*
* @param capacity the buffer capacity
*/
public static VkDescriptorBufferInfo.Buffer calloc(int capacity) {
return create(nmemCallocChecked(capacity, SIZEOF), capacity);
}
/**
* Returns a new {@link VkDescriptorBufferInfo.Buffer} instance allocated with {@link BufferUtils}.
*
* @param capacity the buffer capacity
*/
public static VkDescriptorBufferInfo.Buffer create(int capacity) {
return new Buffer(__create(capacity, SIZEOF));
}
/**
* Create a {@link VkDescriptorBufferInfo.Buffer} instance at the specified memory.
*
* @param address the memory address
* @param capacity the buffer capacity
*/
public static VkDescriptorBufferInfo.Buffer create(long address, int capacity) {
return new Buffer(address, capacity);
}
/** Like {@link #create(long, int) create}, but returns {@code null} if {@code address} is {@code NULL}. */
@Nullable
public static VkDescriptorBufferInfo.Buffer createSafe(long address, int capacity) {
return address == NULL ? null : create(address, capacity);
}
// -----------------------------------
/** Returns a new {@link VkDescriptorBufferInfo} instance allocated on the thread-local {@link MemoryStack}. */
public static VkDescriptorBufferInfo mallocStack() {
return mallocStack(stackGet());
}
/** Returns a new {@link VkDescriptorBufferInfo} instance allocated on the thread-local {@link MemoryStack} and initializes all its bits to zero. */
public static VkDescriptorBufferInfo callocStack() {
return callocStack(stackGet());
}
/**
* Returns a new {@link VkDescriptorBufferInfo} instance allocated on the specified {@link MemoryStack}.
*
* @param stack the stack from which to allocate
*/
public static VkDescriptorBufferInfo mallocStack(MemoryStack stack) {
return create(stack.nmalloc(ALIGNOF, SIZEOF));
}
/**
* Returns a new {@link VkDescriptorBufferInfo} instance allocated on the specified {@link MemoryStack} and initializes all its bits to zero.
*
* @param stack the stack from which to allocate
*/
public static VkDescriptorBufferInfo callocStack(MemoryStack stack) {
return create(stack.ncalloc(ALIGNOF, 1, SIZEOF));
}
/**
* Returns a new {@link VkDescriptorBufferInfo.Buffer} instance allocated on the thread-local {@link MemoryStack}.
*
* @param capacity the buffer capacity
*/
public static VkDescriptorBufferInfo.Buffer mallocStack(int capacity) {
return mallocStack(capacity, stackGet());
}
/**
* Returns a new {@link VkDescriptorBufferInfo.Buffer} instance allocated on the thread-local {@link MemoryStack} and initializes all its bits to zero.
*
* @param capacity the buffer capacity
*/
public static VkDescriptorBufferInfo.Buffer callocStack(int capacity) {
return callocStack(capacity, stackGet());
}
/**
* Returns a new {@link VkDescriptorBufferInfo.Buffer} instance allocated on the specified {@link MemoryStack}.
*
* @param stack the stack from which to allocate
* @param capacity the buffer capacity
*/
public static VkDescriptorBufferInfo.Buffer mallocStack(int capacity, MemoryStack stack) {
return create(stack.nmalloc(ALIGNOF, capacity * SIZEOF), capacity);
}
/**
* Returns a new {@link VkDescriptorBufferInfo.Buffer} instance allocated on the specified {@link MemoryStack} and initializes all its bits to zero.
*
* @param stack the stack from which to allocate
* @param capacity the buffer capacity
*/
public static VkDescriptorBufferInfo.Buffer callocStack(int capacity, MemoryStack stack) {
return create(stack.ncalloc(ALIGNOF, capacity, SIZEOF), capacity);
}
// -----------------------------------
/** Unsafe version of {@link #buffer}. */
public static long nbuffer(long struct) { return memGetLong(struct + VkDescriptorBufferInfo.BUFFER); }
/** Unsafe version of {@link #offset}. */
public static long noffset(long struct) { return memGetLong(struct + VkDescriptorBufferInfo.OFFSET); }
/** Unsafe version of {@link #range}. */
public static long nrange(long struct) { return memGetLong(struct + VkDescriptorBufferInfo.RANGE); }
/** Unsafe version of {@link #buffer(long) buffer}. */
public static void nbuffer(long struct, long value) { memPutLong(struct + VkDescriptorBufferInfo.BUFFER, value); }
/** Unsafe version of {@link #offset(long) offset}. */
public static void noffset(long struct, long value) { memPutLong(struct + VkDescriptorBufferInfo.OFFSET, value); }
/** Unsafe version of {@link #range(long) range}. */
public static void nrange(long struct, long value) { memPutLong(struct + VkDescriptorBufferInfo.RANGE, value); }
// -----------------------------------
/** An array of {@link VkDescriptorBufferInfo} structs. */
public static class Buffer extends StructBuffer implements NativeResource {
/**
* Creates a new {@link VkDescriptorBufferInfo.Buffer} instance backed by the specified container.
*
* Changes to the container's content will be visible to the struct buffer instance and vice versa. The two buffers' position, limit, and mark values
* will be independent. The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided
* by {@link VkDescriptorBufferInfo#SIZEOF}, and its mark will be undefined.
*
* The created buffer instance holds a strong reference to the container object.
*/
public Buffer(ByteBuffer container) {
super(container, container.remaining() / SIZEOF);
}
public Buffer(long address, int cap) {
super(address, 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);
}
@Override
protected Buffer self() {
return this;
}
@Override
protected Buffer newBufferInstance(long address, @Nullable ByteBuffer container, int mark, int pos, int lim, int cap) {
return new Buffer(address, container, mark, pos, lim, cap);
}
@Override
protected VkDescriptorBufferInfo newInstance(long address) {
return new VkDescriptorBufferInfo(address, container);
}
@Override
public int sizeof() {
return SIZEOF;
}
/** Returns the value of the {@code buffer} field. */
@NativeType("VkBuffer")
public long buffer() { return VkDescriptorBufferInfo.nbuffer(address()); }
/** Returns the value of the {@code offset} field. */
@NativeType("VkDeviceSize")
public long offset() { return VkDescriptorBufferInfo.noffset(address()); }
/** Returns the value of the {@code range} field. */
@NativeType("VkDeviceSize")
public long range() { return VkDescriptorBufferInfo.nrange(address()); }
/** Sets the specified value to the {@code buffer} field. */
public VkDescriptorBufferInfo.Buffer buffer(@NativeType("VkBuffer") long value) { VkDescriptorBufferInfo.nbuffer(address(), value); return this; }
/** Sets the specified value to the {@code offset} field. */
public VkDescriptorBufferInfo.Buffer offset(@NativeType("VkDeviceSize") long value) { VkDescriptorBufferInfo.noffset(address(), value); return this; }
/** Sets the specified value to the {@code range} field. */
public VkDescriptorBufferInfo.Buffer range(@NativeType("VkDeviceSize") long value) { VkDescriptorBufferInfo.nrange(address(), value); return this; }
}
}