org.lwjgl.vulkan.VkImageSubresourceRange 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 java.nio.*;
import org.lwjgl.*;
import org.lwjgl.system.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.system.MemoryStack.*;
/**
* Structure specifying a image subresource range.
*
* Description
*
* The number of mipmap levels and array layers must be a subset of the image subresources in the image. If an application wants to use all mip levels or layers in an image after the {@code baseMipLevel} or {@code baseArrayLayer}, it can set {@code levelCount} and {@code layerCount} to the special values {@link VK10#VK_REMAINING_MIP_LEVELS REMAINING_MIP_LEVELS} and {@link VK10#VK_REMAINING_ARRAY_LAYERS REMAINING_ARRAY_LAYERS} without knowing the exact number of mip levels or layers.
*
* For cube and cube array image views, the layers of the image view starting at {@code baseArrayLayer} correspond to faces in the order +X, -X, +Y, -Y, +Z, -Z. For cube arrays, each set of six sequential layers is a single cube, so the number of cube maps in a cube map array view is {@code layerCount} / 6, and image array layer (baseArrayLayer {plus} i)
is face index (i mod 6)
of cube i / 6. If the number of layers in the view, whether set explicitly in {@code layerCount} or implied by {@link VK10#VK_REMAINING_ARRAY_LAYERS REMAINING_ARRAY_LAYERS}, is not a multiple of 6, behavior when indexing the last cube is undefined.
*
* {@code aspectMask} must be only {@link VK10#VK_IMAGE_ASPECT_COLOR_BIT IMAGE_ASPECT_COLOR_BIT}, {@link VK10#VK_IMAGE_ASPECT_DEPTH_BIT IMAGE_ASPECT_DEPTH_BIT} or {@link VK10#VK_IMAGE_ASPECT_STENCIL_BIT IMAGE_ASPECT_STENCIL_BIT} if {@code format} is a color, depth-only or stencil-only format, respectively, except if {@code format} is a multi-planar format. If using a depth/stencil format with both depth and stencil components, {@code aspectMask} must include at least one of {@link VK10#VK_IMAGE_ASPECT_DEPTH_BIT IMAGE_ASPECT_DEPTH_BIT} and {@link VK10#VK_IMAGE_ASPECT_STENCIL_BIT IMAGE_ASPECT_STENCIL_BIT}, and can include both.
*
* When the {@link VkImageSubresourceRange} structure is used to select a subset of the slices of a 3D image's mip level in order to create a 2D or 2D array image view of a 3D image created with {@link #IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT}, {@code baseArrayLayer} and {@code layerCount} specify the first slice index and the number of slices to include in the created image view. Such an image view can be used as a framebuffer attachment that refers only to the specified range of slices of the selected mip level. However, any layout transitions performed on such an attachment view during a render pass instance still apply to the entire subresource referenced which includes all the slices of the selected mip level.
*
* When using an imageView of a depth/stencil image to populate a descriptor set (e.g. for sampling in the shader, or for use as an input attachment), the {@code aspectMask} must only include one bit and selects whether the imageView is used for depth reads (i.e. using a floating-point sampler or input attachment in the shader) or stencil reads (i.e. using an unsigned integer sampler or input attachment in the shader). When an imageView of a depth/stencil image is used as a depth/stencil framebuffer attachment, the {@code aspectMask} is ignored and both depth and stencil image subresources are used.
*
* The {@code components} member is of type {@link VkComponentMapping}, and describes a remapping from components of the image to components of the vector returned by shader image instructions. This remapping must be identity for storage image descriptors, input attachment descriptors, framebuffer attachments, and any {@code VkImageView} used with a combined image sampler that enables sampler Y'CBCR conversion.
*
* If sampler Y'CBCR conversion is enabled in the sampler, the {@code aspectMask} used by a {@code VkImageView} must be {@link VK10#VK_IMAGE_ASPECT_COLOR_BIT IMAGE_ASPECT_COLOR_BIT}.
*
* If sampler Y'CBCR conversion is not enabled in the sampler and the format is multi-planar, the image must have been created with {@link VK10#VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT IMAGE_CREATE_MUTABLE_FORMAT_BIT}, and the {@code aspectMask} of the {@code VkImageView}'s {@link VkImageSubresourceRange} must be {@link KHRSamplerYcbcrConversion#VK_IMAGE_ASPECT_PLANE_0_BIT_KHR IMAGE_ASPECT_PLANE_0_BIT_KHR}, {@link KHRSamplerYcbcrConversion#VK_IMAGE_ASPECT_PLANE_1_BIT_KHR IMAGE_ASPECT_PLANE_1_BIT_KHR} or {@link KHRSamplerYcbcrConversion#VK_IMAGE_ASPECT_PLANE_2_BIT_KHR IMAGE_ASPECT_PLANE_2_BIT_KHR}.
*
* Valid Usage (Implicit)
*
*
* - {@code aspectMask} must be a valid combination of {@code VkImageAspectFlagBits} values
* - {@code aspectMask} must not be 0
*
*
* See Also
*
* {@link VkImageMemoryBarrier}, {@link VkImageViewCreateInfo}, {@link VK10#vkCmdClearColorImage CmdClearColorImage}, {@link VK10#vkCmdClearDepthStencilImage CmdClearDepthStencilImage}
*
* Member documentation
*
*
* - {@code aspectMask} – a bitmask of {@code VkImageAspectFlagBits} specifying which aspect(s) of the image are included in the view.
* - {@code baseMipLevel} – the first mipmap level accessible to the view.
* - {@code levelCount} – the number of mipmap levels (starting from {@code baseMipLevel}) accessible to the view.
* - {@code baseArrayLayer} – the first array layer accessible to the view.
* - {@code layerCount} – the number of array layers (starting from {@code baseArrayLayer}) accessible to the view.
*
*
* Layout
*
*
* struct VkImageSubresourceRange {
* VkImageAspectFlags aspectMask;
* uint32_t baseMipLevel;
* uint32_t levelCount;
* uint32_t baseArrayLayer;
* uint32_t layerCount;
* }
*/
public class VkImageSubresourceRange 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
ASPECTMASK,
BASEMIPLEVEL,
LEVELCOUNT,
BASEARRAYLAYER,
LAYERCOUNT;
static {
Layout layout = __struct(
__member(4),
__member(4),
__member(4),
__member(4),
__member(4)
);
SIZEOF = layout.getSize();
ALIGNOF = layout.getAlignment();
ASPECTMASK = layout.offsetof(0);
BASEMIPLEVEL = layout.offsetof(1);
LEVELCOUNT = layout.offsetof(2);
BASEARRAYLAYER = layout.offsetof(3);
LAYERCOUNT = layout.offsetof(4);
}
VkImageSubresourceRange(long address, ByteBuffer container) {
super(address, container);
}
/**
* Creates a {@link VkImageSubresourceRange} 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 VkImageSubresourceRange(ByteBuffer container) {
this(memAddress(container), checkContainer(container, SIZEOF));
}
@Override
public int sizeof() { return SIZEOF; }
/** Returns the value of the {@code aspectMask} field. */
@NativeType("VkImageAspectFlags")
public int aspectMask() { return naspectMask(address()); }
/** Returns the value of the {@code baseMipLevel} field. */
@NativeType("uint32_t")
public int baseMipLevel() { return nbaseMipLevel(address()); }
/** Returns the value of the {@code levelCount} field. */
@NativeType("uint32_t")
public int levelCount() { return nlevelCount(address()); }
/** Returns the value of the {@code baseArrayLayer} field. */
@NativeType("uint32_t")
public int baseArrayLayer() { return nbaseArrayLayer(address()); }
/** Returns the value of the {@code layerCount} field. */
@NativeType("uint32_t")
public int layerCount() { return nlayerCount(address()); }
/** Sets the specified value to the {@code aspectMask} field. */
public VkImageSubresourceRange aspectMask(@NativeType("VkImageAspectFlags") int value) { naspectMask(address(), value); return this; }
/** Sets the specified value to the {@code baseMipLevel} field. */
public VkImageSubresourceRange baseMipLevel(@NativeType("uint32_t") int value) { nbaseMipLevel(address(), value); return this; }
/** Sets the specified value to the {@code levelCount} field. */
public VkImageSubresourceRange levelCount(@NativeType("uint32_t") int value) { nlevelCount(address(), value); return this; }
/** Sets the specified value to the {@code baseArrayLayer} field. */
public VkImageSubresourceRange baseArrayLayer(@NativeType("uint32_t") int value) { nbaseArrayLayer(address(), value); return this; }
/** Sets the specified value to the {@code layerCount} field. */
public VkImageSubresourceRange layerCount(@NativeType("uint32_t") int value) { nlayerCount(address(), value); return this; }
/** Initializes this struct with the specified values. */
public VkImageSubresourceRange set(
int aspectMask,
int baseMipLevel,
int levelCount,
int baseArrayLayer,
int layerCount
) {
aspectMask(aspectMask);
baseMipLevel(baseMipLevel);
levelCount(levelCount);
baseArrayLayer(baseArrayLayer);
layerCount(layerCount);
return this;
}
/**
* Copies the specified struct data to this struct.
*
* @param src the source struct
*
* @return this struct
*/
public VkImageSubresourceRange set(VkImageSubresourceRange src) {
memCopy(src.address(), address(), SIZEOF);
return this;
}
// -----------------------------------
/** Returns a new {@link VkImageSubresourceRange} instance allocated with {@link MemoryUtil#memAlloc memAlloc}. The instance must be explicitly freed. */
public static VkImageSubresourceRange malloc() {
return create(nmemAlloc(SIZEOF));
}
/** Returns a new {@link VkImageSubresourceRange} instance allocated with {@link MemoryUtil#memCalloc memCalloc}. The instance must be explicitly freed. */
public static VkImageSubresourceRange calloc() {
return create(nmemCalloc(1, SIZEOF));
}
/** Returns a new {@link VkImageSubresourceRange} instance allocated with {@link BufferUtils}. */
public static VkImageSubresourceRange create() {
return new VkImageSubresourceRange(BufferUtils.createByteBuffer(SIZEOF));
}
/** Returns a new {@link VkImageSubresourceRange} instance for the specified memory address or {@code null} if the address is {@code NULL}. */
public static VkImageSubresourceRange create(long address) {
return address == NULL ? null : new VkImageSubresourceRange(address, null);
}
/**
* Returns a new {@link VkImageSubresourceRange.Buffer} instance allocated with {@link MemoryUtil#memAlloc memAlloc}. The instance must be explicitly freed.
*
* @param capacity the buffer capacity
*/
public static Buffer malloc(int capacity) {
return create(__malloc(capacity, SIZEOF), capacity);
}
/**
* Returns a new {@link VkImageSubresourceRange.Buffer} instance allocated with {@link MemoryUtil#memCalloc memCalloc}. The instance must be explicitly freed.
*
* @param capacity the buffer capacity
*/
public static Buffer calloc(int capacity) {
return create(nmemCalloc(capacity, SIZEOF), capacity);
}
/**
* Returns a new {@link VkImageSubresourceRange.Buffer} instance allocated with {@link BufferUtils}.
*
* @param capacity the buffer capacity
*/
public static Buffer create(int capacity) {
return new Buffer(__create(capacity, SIZEOF));
}
/**
* Create a {@link VkImageSubresourceRange.Buffer} instance at the specified memory.
*
* @param address the memory address
* @param capacity the buffer capacity
*/
public static Buffer create(long address, int capacity) {
return address == NULL ? null : new Buffer(address, null, -1, 0, capacity, capacity);
}
// -----------------------------------
/** Returns a new {@link VkImageSubresourceRange} instance allocated on the thread-local {@link MemoryStack}. */
public static VkImageSubresourceRange mallocStack() {
return mallocStack(stackGet());
}
/** Returns a new {@link VkImageSubresourceRange} instance allocated on the thread-local {@link MemoryStack} and initializes all its bits to zero. */
public static VkImageSubresourceRange callocStack() {
return callocStack(stackGet());
}
/**
* Returns a new {@link VkImageSubresourceRange} instance allocated on the specified {@link MemoryStack}.
*
* @param stack the stack from which to allocate
*/
public static VkImageSubresourceRange mallocStack(MemoryStack stack) {
return create(stack.nmalloc(ALIGNOF, SIZEOF));
}
/**
* Returns a new {@link VkImageSubresourceRange} instance allocated on the specified {@link MemoryStack} and initializes all its bits to zero.
*
* @param stack the stack from which to allocate
*/
public static VkImageSubresourceRange callocStack(MemoryStack stack) {
return create(stack.ncalloc(ALIGNOF, 1, SIZEOF));
}
/**
* Returns a new {@link VkImageSubresourceRange.Buffer} instance allocated on the thread-local {@link MemoryStack}.
*
* @param capacity the buffer capacity
*/
public static Buffer mallocStack(int capacity) {
return mallocStack(capacity, stackGet());
}
/**
* Returns a new {@link VkImageSubresourceRange.Buffer} instance allocated on the thread-local {@link MemoryStack} and initializes all its bits to zero.
*
* @param capacity the buffer capacity
*/
public static Buffer callocStack(int capacity) {
return callocStack(capacity, stackGet());
}
/**
* Returns a new {@link VkImageSubresourceRange.Buffer} instance allocated on the specified {@link MemoryStack}.
*
* @param stack the stack from which to allocate
* @param capacity the buffer capacity
*/
public static Buffer mallocStack(int capacity, MemoryStack stack) {
return create(stack.nmalloc(ALIGNOF, capacity * SIZEOF), capacity);
}
/**
* Returns a new {@link VkImageSubresourceRange.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 Buffer callocStack(int capacity, MemoryStack stack) {
return create(stack.ncalloc(ALIGNOF, capacity, SIZEOF), capacity);
}
// -----------------------------------
/** Unsafe version of {@link #aspectMask}. */
public static int naspectMask(long struct) { return memGetInt(struct + VkImageSubresourceRange.ASPECTMASK); }
/** Unsafe version of {@link #baseMipLevel}. */
public static int nbaseMipLevel(long struct) { return memGetInt(struct + VkImageSubresourceRange.BASEMIPLEVEL); }
/** Unsafe version of {@link #levelCount}. */
public static int nlevelCount(long struct) { return memGetInt(struct + VkImageSubresourceRange.LEVELCOUNT); }
/** Unsafe version of {@link #baseArrayLayer}. */
public static int nbaseArrayLayer(long struct) { return memGetInt(struct + VkImageSubresourceRange.BASEARRAYLAYER); }
/** Unsafe version of {@link #layerCount}. */
public static int nlayerCount(long struct) { return memGetInt(struct + VkImageSubresourceRange.LAYERCOUNT); }
/** Unsafe version of {@link #aspectMask(int) aspectMask}. */
public static void naspectMask(long struct, int value) { memPutInt(struct + VkImageSubresourceRange.ASPECTMASK, value); }
/** Unsafe version of {@link #baseMipLevel(int) baseMipLevel}. */
public static void nbaseMipLevel(long struct, int value) { memPutInt(struct + VkImageSubresourceRange.BASEMIPLEVEL, value); }
/** Unsafe version of {@link #levelCount(int) levelCount}. */
public static void nlevelCount(long struct, int value) { memPutInt(struct + VkImageSubresourceRange.LEVELCOUNT, value); }
/** Unsafe version of {@link #baseArrayLayer(int) baseArrayLayer}. */
public static void nbaseArrayLayer(long struct, int value) { memPutInt(struct + VkImageSubresourceRange.BASEARRAYLAYER, value); }
/** Unsafe version of {@link #layerCount(int) layerCount}. */
public static void nlayerCount(long struct, int value) { memPutInt(struct + VkImageSubresourceRange.LAYERCOUNT, value); }
// -----------------------------------
/** An array of {@link VkImageSubresourceRange} structs. */
public static class Buffer extends StructBuffer implements NativeResource {
/**
* Creates a new {@link VkImageSubresourceRange.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 VkImageSubresourceRange#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);
}
Buffer(long address, 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, ByteBuffer container, int mark, int pos, int lim, int cap) {
return new Buffer(address, container, mark, pos, lim, cap);
}
@Override
protected VkImageSubresourceRange newInstance(long address) {
return new VkImageSubresourceRange(address, container);
}
@Override
public int sizeof() {
return SIZEOF;
}
/** Returns the value of the {@code aspectMask} field. */
@NativeType("VkImageAspectFlags")
public int aspectMask() { return VkImageSubresourceRange.naspectMask(address()); }
/** Returns the value of the {@code baseMipLevel} field. */
@NativeType("uint32_t")
public int baseMipLevel() { return VkImageSubresourceRange.nbaseMipLevel(address()); }
/** Returns the value of the {@code levelCount} field. */
@NativeType("uint32_t")
public int levelCount() { return VkImageSubresourceRange.nlevelCount(address()); }
/** Returns the value of the {@code baseArrayLayer} field. */
@NativeType("uint32_t")
public int baseArrayLayer() { return VkImageSubresourceRange.nbaseArrayLayer(address()); }
/** Returns the value of the {@code layerCount} field. */
@NativeType("uint32_t")
public int layerCount() { return VkImageSubresourceRange.nlayerCount(address()); }
/** Sets the specified value to the {@code aspectMask} field. */
public VkImageSubresourceRange.Buffer aspectMask(@NativeType("VkImageAspectFlags") int value) { VkImageSubresourceRange.naspectMask(address(), value); return this; }
/** Sets the specified value to the {@code baseMipLevel} field. */
public VkImageSubresourceRange.Buffer baseMipLevel(@NativeType("uint32_t") int value) { VkImageSubresourceRange.nbaseMipLevel(address(), value); return this; }
/** Sets the specified value to the {@code levelCount} field. */
public VkImageSubresourceRange.Buffer levelCount(@NativeType("uint32_t") int value) { VkImageSubresourceRange.nlevelCount(address(), value); return this; }
/** Sets the specified value to the {@code baseArrayLayer} field. */
public VkImageSubresourceRange.Buffer baseArrayLayer(@NativeType("uint32_t") int value) { VkImageSubresourceRange.nbaseArrayLayer(address(), value); return this; }
/** Sets the specified value to the {@code layerCount} field. */
public VkImageSubresourceRange.Buffer layerCount(@NativeType("uint32_t") int value) { VkImageSubresourceRange.nlayerCount(address(), value); return this; }
}
}