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

org.lwjgl.vulkan.VkPhysicalDeviceMemoryProperties Maven / Gradle / Ivy

Go to download

A new generation graphics and compute API that provides high-efficiency, cross-platform access to modern GPUs used in a wide variety of devices from PCs and consoles to mobile phones and embedded platforms.

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.vulkan;

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 static org.lwjgl.vulkan.VK10.*;

/**
 * Structure specifying physical device memory properties.
 * 
 * 
Description
* *

The {@link VkPhysicalDeviceMemoryProperties} structure describes a number of memory heaps as well as a number of memory types that can be used to access memory allocated in those heaps. Each heap describes a memory resource of a particular size, and each memory type describes a set of memory properties (e.g. host cached vs uncached) that can be used with a given memory heap. Allocations using a particular memory type will consume resources from the heap indicated by that memory type's heap index. More than one memory type may share each heap, and the heaps and memory types provide a mechanism to advertise an accurate size of the physical memory resources while allowing the memory to be used with a variety of different properties.

* *

The number of memory heaps is given by {@code memoryHeapCount} and is less than or equal to {@link VK10#VK_MAX_MEMORY_HEAPS MAX_MEMORY_HEAPS}. Each heap is described by an element of the {@code memoryHeaps} array as a {@link VkMemoryHeap} structure. The number of memory types available across all memory heaps is given by {@code memoryTypeCount} and is less than or equal to {@link VK10#VK_MAX_MEMORY_TYPES MAX_MEMORY_TYPES}. Each memory type is described by an element of the {@code memoryTypes} array as a {@link VkMemoryType} structure.

* *

At least one heap must include {@link VK10#VK_MEMORY_HEAP_DEVICE_LOCAL_BIT MEMORY_HEAP_DEVICE_LOCAL_BIT} in {@link VkMemoryHeap}{@code ::flags}. If there are multiple heaps that all have similar performance characteristics, they may all include {@link VK10#VK_MEMORY_HEAP_DEVICE_LOCAL_BIT MEMORY_HEAP_DEVICE_LOCAL_BIT}. In a unified memory architecture (UMA) system there is often only a single memory heap which is considered to be equally "{@code local}" to the host and to the device, and such an implementation must advertise the heap as device-local.

* *

Each memory type returned by {@link VK10#vkGetPhysicalDeviceMemoryProperties GetPhysicalDeviceMemoryProperties} must have its {@code propertyFlags} set to one of the following values:

* *
    *
  • 0
  • *
  • {@link VK10#VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT MEMORY_PROPERTY_HOST_VISIBLE_BIT} | {@link VK10#VK_MEMORY_PROPERTY_HOST_COHERENT_BIT MEMORY_PROPERTY_HOST_COHERENT_BIT}
  • *
  • {@link VK10#VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT MEMORY_PROPERTY_HOST_VISIBLE_BIT} | {@link VK10#VK_MEMORY_PROPERTY_HOST_CACHED_BIT MEMORY_PROPERTY_HOST_CACHED_BIT}
  • *
  • {@link VK10#VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT MEMORY_PROPERTY_HOST_VISIBLE_BIT} | {@link VK10#VK_MEMORY_PROPERTY_HOST_CACHED_BIT MEMORY_PROPERTY_HOST_CACHED_BIT} | {@link VK10#VK_MEMORY_PROPERTY_HOST_COHERENT_BIT MEMORY_PROPERTY_HOST_COHERENT_BIT}
  • *
  • {@link VK10#VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT MEMORY_PROPERTY_DEVICE_LOCAL_BIT}
  • *
  • {@link VK10#VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT MEMORY_PROPERTY_DEVICE_LOCAL_BIT} | {@link VK10#VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT MEMORY_PROPERTY_HOST_VISIBLE_BIT} | {@link VK10#VK_MEMORY_PROPERTY_HOST_COHERENT_BIT MEMORY_PROPERTY_HOST_COHERENT_BIT}
  • *
  • {@link VK10#VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT MEMORY_PROPERTY_DEVICE_LOCAL_BIT} | {@link VK10#VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT MEMORY_PROPERTY_HOST_VISIBLE_BIT} | {@link VK10#VK_MEMORY_PROPERTY_HOST_CACHED_BIT MEMORY_PROPERTY_HOST_CACHED_BIT}
  • *
  • {@link VK10#VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT MEMORY_PROPERTY_DEVICE_LOCAL_BIT} | {@link VK10#VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT MEMORY_PROPERTY_HOST_VISIBLE_BIT} | {@link VK10#VK_MEMORY_PROPERTY_HOST_CACHED_BIT MEMORY_PROPERTY_HOST_CACHED_BIT} | {@link VK10#VK_MEMORY_PROPERTY_HOST_COHERENT_BIT MEMORY_PROPERTY_HOST_COHERENT_BIT}
  • *
  • {@link VK10#VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT MEMORY_PROPERTY_DEVICE_LOCAL_BIT} | {@link VK10#VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT}
  • *
* *

There must be at least one memory type with both the {@link VK10#VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT MEMORY_PROPERTY_HOST_VISIBLE_BIT} and {@link VK10#VK_MEMORY_PROPERTY_HOST_COHERENT_BIT MEMORY_PROPERTY_HOST_COHERENT_BIT} bits set in its {@code propertyFlags}. There must be at least one memory type with the {@link VK10#VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT MEMORY_PROPERTY_DEVICE_LOCAL_BIT} bit set in its {@code propertyFlags}.

* *

For each pair of elements X and Y returned in {@code memoryTypes}, X must be placed at a lower index position than Y if:

* *
    *
  • either the set of bit flags returned in the {@code propertyFlags} member of X is a strict subset of the set of bit flags returned in the {@code propertyFlags} member of Y.
  • *
  • or the {@code propertyFlags} members of X and Y are equal, and X belongs to a memory heap with greater performance (as determined in an implementation-specific manner).
  • *
* *
Note
* *

There is no ordering requirement between X and Y elements for the case their {@code propertyFlags} members are not in a subset relation. That potentially allows more than one possible way to order the same set of memory types. Notice that the list of all allowed memory property flag combinations is written in the required order. But if instead {@link VK10#VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT MEMORY_PROPERTY_DEVICE_LOCAL_BIT} was before {@link VK10#VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT MEMORY_PROPERTY_HOST_VISIBLE_BIT} | {@link VK10#VK_MEMORY_PROPERTY_HOST_COHERENT_BIT MEMORY_PROPERTY_HOST_COHERENT_BIT}, the list would still be in the required order.

*
* *

This ordering requirement enables applications to use a simple search loop to select the desired memory type along the lines of:

* *
 * // Find a memory in `memoryTypeBitsRequirement` that includes all of `requiredProperties`
 * int32_t findProperties(const VkPhysicalDeviceMemoryProperties* pMemoryProperties,
 *                        uint32_t memoryTypeBitsRequirement,
 *                        VkMemoryPropertyFlags requiredProperties) {
 *     const uint32_t memoryCount = pMemoryProperties->memoryTypeCount;
 *     for (uint32_t memoryIndex = 0; memoryIndex < memoryCount; ++memoryIndex) {
 *         const uint32_t memoryTypeBits = (1 << memoryIndex);
 *         const bool isRequiredMemoryType = memoryTypeBitsRequirement & memoryTypeBits;
 * 
 *         const VkMemoryPropertyFlags properties =
 *             pMemoryProperties->memoryTypes[memoryIndex].propertyFlags;
 *         const bool hasRequiredProperties =
 *             (properties & requiredProperties) == requiredProperties;
 * 
 *         if (isRequiredMemoryType && hasRequiredProperties)
 *             return static_cast(memoryIndex);
 *     }
 * 
 *     // failed to find memory type
 *     return -1;
 * }
 * 
 * // Try to find an optimal memory type, or if it does not exist try fallback memory type
 * // `device` is the VkDevice
 * // `image` is the VkImage that requires memory to be bound
 * // `memoryProperties` properties as returned by vkGetPhysicalDeviceMemoryProperties
 * // `requiredProperties` are the property flags that must be present
 * // `optimalProperties` are the property flags that are preferred by the application
 * VkMemoryRequirements memoryRequirements;
 * vkGetImageMemoryRequirements(device, image, &memoryRequirements);
 * int32_t memoryType =
 *     findProperties(&memoryProperties, memoryRequirements.memoryTypeBits, optimalProperties);
 * if (memoryType == -1) // not found; try fallback properties
 *     memoryType =
 *         findProperties(&memoryProperties, memoryRequirements.memoryTypeBits, requiredProperties);
* *
See Also
* *

{@link VkMemoryHeap}, {@link VkMemoryType}, {@link VkPhysicalDeviceMemoryProperties2KHR}, {@link VK10#vkGetPhysicalDeviceMemoryProperties GetPhysicalDeviceMemoryProperties}

* *

Member documentation

* *
    *
  • {@code memoryTypeCount} – the number of valid elements in the {@code memoryTypes} array.
  • *
  • {@code memoryTypes} – an array of {@link VkMemoryType} structures describing the memory types that can be used to access memory allocated from the heaps specified by {@code memoryHeaps}.
  • *
  • {@code memoryHeapCount} – the number of valid elements in the {@code memoryHeaps} array.
  • *
  • {@code memoryHeaps} – an array of {@link VkMemoryHeap} structures describing the memory heaps from which memory can be allocated.
  • *
* *

Layout

* *
 * struct VkPhysicalDeviceMemoryProperties {
 *     uint32_t memoryTypeCount;
 *     {@link VkMemoryType VkMemoryType} memoryTypes[VK_MAX_MEMORY_TYPES];
 *     uint32_t memoryHeapCount;
 *     {@link VkMemoryHeap VkMemoryHeap} memoryHeaps[VK_MAX_MEMORY_HEAPS];
 * }
*/ public class VkPhysicalDeviceMemoryProperties 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 MEMORYTYPECOUNT, MEMORYTYPES, MEMORYHEAPCOUNT, MEMORYHEAPS; static { Layout layout = __struct( __member(4), __array(VkMemoryType.SIZEOF, VkMemoryType.ALIGNOF, VK_MAX_MEMORY_TYPES), __member(4), __array(VkMemoryHeap.SIZEOF, VkMemoryHeap.ALIGNOF, VK_MAX_MEMORY_HEAPS) ); SIZEOF = layout.getSize(); ALIGNOF = layout.getAlignment(); MEMORYTYPECOUNT = layout.offsetof(0); MEMORYTYPES = layout.offsetof(1); MEMORYHEAPCOUNT = layout.offsetof(2); MEMORYHEAPS = layout.offsetof(3); } VkPhysicalDeviceMemoryProperties(long address, @Nullable ByteBuffer container) { super(address, container); } /** * Creates a {@link VkPhysicalDeviceMemoryProperties} 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 VkPhysicalDeviceMemoryProperties(ByteBuffer container) { this(memAddress(container), __checkContainer(container, SIZEOF)); } @Override public int sizeof() { return SIZEOF; } /** Returns the value of the {@code memoryTypeCount} field. */ @NativeType("uint32_t") public int memoryTypeCount() { return nmemoryTypeCount(address()); } /** Returns a {@link VkMemoryType}.Buffer view of the {@code memoryTypes} field. */ @NativeType("VkMemoryType[VK_MAX_MEMORY_TYPES]") public VkMemoryType.Buffer memoryTypes() { return nmemoryTypes(address()); } /** Returns a {@link VkMemoryType} view of the struct at the specified index of the {@code memoryTypes} field. */ public VkMemoryType memoryTypes(int index) { return nmemoryTypes(address(), index); } /** Returns the value of the {@code memoryHeapCount} field. */ @NativeType("uint32_t") public int memoryHeapCount() { return nmemoryHeapCount(address()); } /** Returns a {@link VkMemoryHeap}.Buffer view of the {@code memoryHeaps} field. */ @NativeType("VkMemoryHeap[VK_MAX_MEMORY_HEAPS]") public VkMemoryHeap.Buffer memoryHeaps() { return nmemoryHeaps(address()); } /** Returns a {@link VkMemoryHeap} view of the struct at the specified index of the {@code memoryHeaps} field. */ public VkMemoryHeap memoryHeaps(int index) { return nmemoryHeaps(address(), index); } // ----------------------------------- /** Returns a new {@link VkPhysicalDeviceMemoryProperties} instance allocated with {@link MemoryUtil#memAlloc memAlloc}. The instance must be explicitly freed. */ public static VkPhysicalDeviceMemoryProperties malloc() { return create(nmemAllocChecked(SIZEOF)); } /** Returns a new {@link VkPhysicalDeviceMemoryProperties} instance allocated with {@link MemoryUtil#memCalloc memCalloc}. The instance must be explicitly freed. */ public static VkPhysicalDeviceMemoryProperties calloc() { return create(nmemCallocChecked(1, SIZEOF)); } /** Returns a new {@link VkPhysicalDeviceMemoryProperties} instance allocated with {@link BufferUtils}. */ public static VkPhysicalDeviceMemoryProperties create() { return new VkPhysicalDeviceMemoryProperties(BufferUtils.createByteBuffer(SIZEOF)); } /** Returns a new {@link VkPhysicalDeviceMemoryProperties} instance for the specified memory address. */ public static VkPhysicalDeviceMemoryProperties create(long address) { return new VkPhysicalDeviceMemoryProperties(address, null); } /** Like {@link #create(long) create}, but returns {@code null} if {@code address} is {@code NULL}. */ @Nullable public static VkPhysicalDeviceMemoryProperties createSafe(long address) { return address == NULL ? null : create(address); } /** * Returns a new {@link VkPhysicalDeviceMemoryProperties.Buffer} instance allocated with {@link MemoryUtil#memAlloc memAlloc}. The instance must be explicitly freed. * * @param capacity the buffer capacity */ public static VkPhysicalDeviceMemoryProperties.Buffer malloc(int capacity) { return create(__malloc(capacity, SIZEOF), capacity); } /** * Returns a new {@link VkPhysicalDeviceMemoryProperties.Buffer} instance allocated with {@link MemoryUtil#memCalloc memCalloc}. The instance must be explicitly freed. * * @param capacity the buffer capacity */ public static VkPhysicalDeviceMemoryProperties.Buffer calloc(int capacity) { return create(nmemCallocChecked(capacity, SIZEOF), capacity); } /** * Returns a new {@link VkPhysicalDeviceMemoryProperties.Buffer} instance allocated with {@link BufferUtils}. * * @param capacity the buffer capacity */ public static VkPhysicalDeviceMemoryProperties.Buffer create(int capacity) { return new Buffer(__create(capacity, SIZEOF)); } /** * Create a {@link VkPhysicalDeviceMemoryProperties.Buffer} instance at the specified memory. * * @param address the memory address * @param capacity the buffer capacity */ public static VkPhysicalDeviceMemoryProperties.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 VkPhysicalDeviceMemoryProperties.Buffer createSafe(long address, int capacity) { return address == NULL ? null : create(address, capacity); } // ----------------------------------- /** Returns a new {@link VkPhysicalDeviceMemoryProperties} instance allocated on the thread-local {@link MemoryStack}. */ public static VkPhysicalDeviceMemoryProperties mallocStack() { return mallocStack(stackGet()); } /** Returns a new {@link VkPhysicalDeviceMemoryProperties} instance allocated on the thread-local {@link MemoryStack} and initializes all its bits to zero. */ public static VkPhysicalDeviceMemoryProperties callocStack() { return callocStack(stackGet()); } /** * Returns a new {@link VkPhysicalDeviceMemoryProperties} instance allocated on the specified {@link MemoryStack}. * * @param stack the stack from which to allocate */ public static VkPhysicalDeviceMemoryProperties mallocStack(MemoryStack stack) { return create(stack.nmalloc(ALIGNOF, SIZEOF)); } /** * Returns a new {@link VkPhysicalDeviceMemoryProperties} instance allocated on the specified {@link MemoryStack} and initializes all its bits to zero. * * @param stack the stack from which to allocate */ public static VkPhysicalDeviceMemoryProperties callocStack(MemoryStack stack) { return create(stack.ncalloc(ALIGNOF, 1, SIZEOF)); } /** * Returns a new {@link VkPhysicalDeviceMemoryProperties.Buffer} instance allocated on the thread-local {@link MemoryStack}. * * @param capacity the buffer capacity */ public static VkPhysicalDeviceMemoryProperties.Buffer mallocStack(int capacity) { return mallocStack(capacity, stackGet()); } /** * Returns a new {@link VkPhysicalDeviceMemoryProperties.Buffer} instance allocated on the thread-local {@link MemoryStack} and initializes all its bits to zero. * * @param capacity the buffer capacity */ public static VkPhysicalDeviceMemoryProperties.Buffer callocStack(int capacity) { return callocStack(capacity, stackGet()); } /** * Returns a new {@link VkPhysicalDeviceMemoryProperties.Buffer} instance allocated on the specified {@link MemoryStack}. * * @param stack the stack from which to allocate * @param capacity the buffer capacity */ public static VkPhysicalDeviceMemoryProperties.Buffer mallocStack(int capacity, MemoryStack stack) { return create(stack.nmalloc(ALIGNOF, capacity * SIZEOF), capacity); } /** * Returns a new {@link VkPhysicalDeviceMemoryProperties.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 VkPhysicalDeviceMemoryProperties.Buffer callocStack(int capacity, MemoryStack stack) { return create(stack.ncalloc(ALIGNOF, capacity, SIZEOF), capacity); } // ----------------------------------- /** Unsafe version of {@link #memoryTypeCount}. */ public static int nmemoryTypeCount(long struct) { return memGetInt(struct + VkPhysicalDeviceMemoryProperties.MEMORYTYPECOUNT); } /** Unsafe version of {@link #memoryTypes}. */ public static VkMemoryType.Buffer nmemoryTypes(long struct) { return VkMemoryType.create(struct + VkPhysicalDeviceMemoryProperties.MEMORYTYPES, nmemoryTypeCount(struct)); } /** Unsafe version of {@link #memoryTypes(int) memoryTypes}. */ public static VkMemoryType nmemoryTypes(long struct, int index) { if (CHECKS) { check(index, nmemoryTypeCount(struct)); } return VkMemoryType.create(struct + VkPhysicalDeviceMemoryProperties.MEMORYTYPES + index * VkMemoryType.SIZEOF); } /** Unsafe version of {@link #memoryHeapCount}. */ public static int nmemoryHeapCount(long struct) { return memGetInt(struct + VkPhysicalDeviceMemoryProperties.MEMORYHEAPCOUNT); } /** Unsafe version of {@link #memoryHeaps}. */ public static VkMemoryHeap.Buffer nmemoryHeaps(long struct) { return VkMemoryHeap.create(struct + VkPhysicalDeviceMemoryProperties.MEMORYHEAPS, nmemoryHeapCount(struct)); } /** Unsafe version of {@link #memoryHeaps(int) memoryHeaps}. */ public static VkMemoryHeap nmemoryHeaps(long struct, int index) { if (CHECKS) { check(index, nmemoryHeapCount(struct)); } return VkMemoryHeap.create(struct + VkPhysicalDeviceMemoryProperties.MEMORYHEAPS + index * VkMemoryHeap.SIZEOF); } // ----------------------------------- /** An array of {@link VkPhysicalDeviceMemoryProperties} structs. */ public static class Buffer extends StructBuffer implements NativeResource { /** * Creates a new {@link VkPhysicalDeviceMemoryProperties.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 VkPhysicalDeviceMemoryProperties#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 VkPhysicalDeviceMemoryProperties newInstance(long address) { return new VkPhysicalDeviceMemoryProperties(address, container); } @Override public int sizeof() { return SIZEOF; } /** Returns the value of the {@code memoryTypeCount} field. */ @NativeType("uint32_t") public int memoryTypeCount() { return VkPhysicalDeviceMemoryProperties.nmemoryTypeCount(address()); } /** Returns a {@link VkMemoryType}.Buffer view of the {@code memoryTypes} field. */ @NativeType("VkMemoryType[VK_MAX_MEMORY_TYPES]") public VkMemoryType.Buffer memoryTypes() { return VkPhysicalDeviceMemoryProperties.nmemoryTypes(address()); } /** Returns a {@link VkMemoryType} view of the struct at the specified index of the {@code memoryTypes} field. */ public VkMemoryType memoryTypes(int index) { return VkPhysicalDeviceMemoryProperties.nmemoryTypes(address(), index); } /** Returns the value of the {@code memoryHeapCount} field. */ @NativeType("uint32_t") public int memoryHeapCount() { return VkPhysicalDeviceMemoryProperties.nmemoryHeapCount(address()); } /** Returns a {@link VkMemoryHeap}.Buffer view of the {@code memoryHeaps} field. */ @NativeType("VkMemoryHeap[VK_MAX_MEMORY_HEAPS]") public VkMemoryHeap.Buffer memoryHeaps() { return VkPhysicalDeviceMemoryProperties.nmemoryHeaps(address()); } /** Returns a {@link VkMemoryHeap} view of the struct at the specified index of the {@code memoryHeaps} field. */ public VkMemoryHeap memoryHeaps(int index) { return VkPhysicalDeviceMemoryProperties.nmemoryHeaps(address(), index); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy