org.lwjgl.vulkan.NVExternalMemoryWin32 Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lwjgl-vulkan Show documentation
Show all versions of lwjgl-vulkan Show documentation
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.
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.vulkan;
import org.lwjgl.*;
import org.lwjgl.system.*;
import static org.lwjgl.system.Checks.*;
import static org.lwjgl.system.JNI.*;
import static org.lwjgl.system.MemoryUtil.*;
/**
* Applications may wish to export memory to other Vulkan instances or other APIs, or import memory from other Vulkan instances or other APIs to enable Vulkan workloads to be split up across application module, process, or API boundaries. This extension enables win32 applications to export win32 handles from Vulkan memory objects such that the underlying resources can be referenced outside the Vulkan instance that created them, and import win32 handles created in the Direct3D API to Vulkan memory objects.
*
* Examples
*
*
* //
* // Create an exportable memory object and export an external
* // handle from it.
* //
*
* // Pick an external format and handle type.
* static const VkFormat format = VK_FORMAT_R8G8B8A8_UNORM;
* static const VkExternalMemoryHandleTypeFlagsNV handleType =
* VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT_NV;
*
* extern VkPhysicalDevice physicalDevice;
* extern VkDevice device;
*
* VkPhysicalDeviceMemoryProperties memoryProperties;
* VkExternalImageFormatPropertiesNV properties;
* VkExternalMemoryImageCreateInfoNV externalMemoryImageCreateInfo;
* VkDedicatedAllocationImageCreateInfoNV dedicatedImageCreateInfo;
* VkImageCreateInfo imageCreateInfo;
* VkImage image;
* VkMemoryRequirements imageMemoryRequirements;
* uint32_t numMemoryTypes;
* uint32_t memoryType;
* VkExportMemoryAllocateInfoNV exportMemoryAllocateInfo;
* VkDedicatedAllocationMemoryAllocateInfoNV dedicatedAllocationInfo;
* VkMemoryAllocateInfo memoryAllocateInfo;
* VkDeviceMemory memory;
* VkResult result;
* HANDLE memoryHnd;
*
* // Figure out how many memory types the device supports
* vkGetPhysicalDeviceMemoryProperties(physicalDevice,
* &memoryProperties);
* numMemoryTypes = memoryProperties.memoryTypeCount;
*
* // Check the external handle type capabilities for the chosen format
* // Exportable 2D image support with at least 1 mip level, 1 array
* // layer, and VK_SAMPLE_COUNT_1_BIT using optimal tiling and supporting
* // texturing and color rendering is required.
* result = vkGetPhysicalDeviceExternalImageFormatPropertiesNV(
* physicalDevice,
* format,
* VK_IMAGE_TYPE_2D,
* VK_IMAGE_TILING_OPTIMAL,
* VK_IMAGE_USAGE_SAMPLED_BIT |
* VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
* 0,
* handleType,
* &properties);
*
* if ((result != VK_SUCCESS) ||
* !(properties.externalMemoryFeatures &
* VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT_NV)) {
* abort();
* }
*
* // Set up the external memory image creation info
* memset(&externalMemoryImageCreateInfo,
* 0, sizeof(externalMemoryImageCreateInfo));
* externalMemoryImageCreateInfo.sType =
* VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO_NV;
* externalMemoryImageCreateInfo.handleTypes = handleType;
* if (properties.externalMemoryFeatures &
* VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT_NV) {
* memset(&dedicatedImageCreateInfo, 0, sizeof(dedicatedImageCreateInfo));
* dedicatedImageCreateInfo.sType =
* VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_IMAGE_CREATE_INFO_NV;
* dedicatedImageCreateInfo.dedicatedAllocation = VK_TRUE;
* externalMemoryImageCreateInfo.pNext = &dedicatedImageCreateInfo;
* }
* // Set up the core image creation info
* memset(&imageCreateInfo, 0, sizeof(imageCreateInfo));
* imageCreateInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
* imageCreateInfo.pNext = &externalMemoryImageCreateInfo;
* imageCreateInfo.format = format;
* imageCreateInfo.extent.width = 64;
* imageCreateInfo.extent.height = 64;
* imageCreateInfo.extent.depth = 1;
* imageCreateInfo.mipLevels = 1;
* imageCreateInfo.arrayLayers = 1;
* imageCreateInfo.samples = VK_SAMPLE_COUNT_1_BIT;
* imageCreateInfo.tiling = VK_IMAGE_TILING_OPTIMAL;
* imageCreateInfo.usage = VK_IMAGE_USAGE_SAMPLED_BIT |
* VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
* imageCreateInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
* imageCreateInfo.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
*
* vkCreateImage(device, &imageCreateInfo, NULL, &image);
*
* vkGetImageMemoryRequirements(device,
* image,
* &imageMemoryRequirements);
*
* // For simplicity, just pick the first compatible memory type.
* for (memoryType = 0; memoryType < numMemoryTypes; memoryType++) {
* if ((1 << memoryType) & imageMemoryRequirements.memoryTypeBits) {
* break;
* }
* }
*
* // At least one memory type must be supported given the prior external
* // handle capability check.
* assert(memoryType < numMemoryTypes);
*
* // Allocate the external memory object.
* memset(&exportMemoryAllocateInfo, 0, sizeof(exportMemoryAllocateInfo));
* exportMemoryAllocateInfo.sType =
* VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO_NV;
* exportMemoryAllocateInfo.handleTypes = handleType;
* if (properties.externalMemoryFeatures &
* VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT_NV) {
* memset(&dedicatedAllocationInfo, 0, sizeof(dedicatedAllocationInfo));
* dedicatedAllocationInfo.sType =
* VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_MEMORY_ALLOCATE_INFO_NV;
* dedicatedAllocationInfo.image = image;
* exportMemoryAllocateInfo.pNext = &dedicatedAllocationInfo;
* }
* memset(&memoryAllocateInfo, 0, sizeof(memoryAllocateInfo));
* memoryAllocateInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
* memoryAllocateInfo.pNext = &exportMemoryAllocateInfo;
* memoryAllocateInfo.allocationSize = imageMemoryRequirements.size;
* memoryAllocateInfo.memoryTypeIndex = memoryType;
*
* vkAllocateMemory(device, &memoryAllocateInfo, NULL, &memory);
*
* if (!(properties.externalMemoryFeatures &
* VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT_NV)) {
* vkBindImageMemory(device, image, memory, 0);
* }
*
* // Get the external memory opaque FD handle
* vkGetMemoryWin32HandleNV(device, memory, &memoryHnd);
*
* VK_NV_external_memory_win32
*
*
* - Name String
* - {@code VK_NV_external_memory_win32}
* - Extension Type
* - Device extension
* - Registered Extension Number
* - 58
* - Revision
* - 1
* - Extension and Version Dependencies
*
* - Requires Vulkan 1.0
* - Requires {@link NVExternalMemory VK_NV_external_memory}
*
* - Deprecation state
*
* - Deprecated by {@link KHRExternalMemoryWin32 VK_KHR_external_memory_win32} extension
*
* - Contact
*
* - James Jones cubanismo
*
*
*
* Other Extension Metadata
*
*
* - Last Modified Date
* - 2016-08-19
* - IP Status
* - No known IP claims.
* - Contributors
*
* - James Jones, NVIDIA
* - Carsten Rohde, NVIDIA
*
*
*/
public class NVExternalMemoryWin32 {
/** The extension specification version. */
public static final int VK_NV_EXTERNAL_MEMORY_WIN32_SPEC_VERSION = 1;
/** The extension name. */
public static final String VK_NV_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME = "VK_NV_external_memory_win32";
/**
* Extends {@code VkStructureType}.
*
* Enum values:
*
*
* - {@link #VK_STRUCTURE_TYPE_IMPORT_MEMORY_WIN32_HANDLE_INFO_NV STRUCTURE_TYPE_IMPORT_MEMORY_WIN32_HANDLE_INFO_NV}
* - {@link #VK_STRUCTURE_TYPE_EXPORT_MEMORY_WIN32_HANDLE_INFO_NV STRUCTURE_TYPE_EXPORT_MEMORY_WIN32_HANDLE_INFO_NV}
*
*/
public static final int
VK_STRUCTURE_TYPE_IMPORT_MEMORY_WIN32_HANDLE_INFO_NV = 1000057000,
VK_STRUCTURE_TYPE_EXPORT_MEMORY_WIN32_HANDLE_INFO_NV = 1000057001;
protected NVExternalMemoryWin32() {
throw new UnsupportedOperationException();
}
// --- [ vkGetMemoryWin32HandleNV ] ---
/** Unsafe version of: {@link #vkGetMemoryWin32HandleNV GetMemoryWin32HandleNV} */
public static int nvkGetMemoryWin32HandleNV(VkDevice device, long memory, int handleType, long pHandle) {
long __functionAddress = device.getCapabilities().vkGetMemoryWin32HandleNV;
if (CHECKS) {
check(__functionAddress);
}
return callPJPI(device.address(), memory, handleType, pHandle, __functionAddress);
}
/**
* Retrieve Win32 handle to a device memory object.
*
* C Specification
*
* To retrieve the handle corresponding to a device memory object created with {@link VkExportMemoryAllocateInfoNV}{@code ::handleTypes} set to include {@link NVExternalMemoryCapabilities#VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT_NV EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT_NV} or {@link NVExternalMemoryCapabilities#VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT_NV EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT_NV}, call:
*
*
* VkResult vkGetMemoryWin32HandleNV(
* VkDevice device,
* VkDeviceMemory memory,
* VkExternalMemoryHandleTypeFlagsNV handleType,
* HANDLE* pHandle);
*
* Valid Usage
*
*
* - {@code handleType} must be a flag specified in {@link VkExportMemoryAllocateInfoNV}{@code ::handleTypes} when allocating {@code memory}
*
*
* Valid Usage (Implicit)
*
*
* - {@code device} must be a valid {@code VkDevice} handle
* - {@code memory} must be a valid {@code VkDeviceMemory} handle
* - {@code handleType} must be a valid combination of {@code VkExternalMemoryHandleTypeFlagBitsNV} values
* - {@code handleType} must not be 0
* - {@code pHandle} must be a valid pointer to a {@code HANDLE} value
* - {@code memory} must have been created, allocated, or retrieved from {@code device}
*
*
* Return Codes
*
*
* - On success, this command returns
*
* - {@link VK10#VK_SUCCESS SUCCESS}
*
* - On failure, this command returns
*
* - {@link VK10#VK_ERROR_TOO_MANY_OBJECTS ERROR_TOO_MANY_OBJECTS}
* - {@link VK10#VK_ERROR_OUT_OF_HOST_MEMORY ERROR_OUT_OF_HOST_MEMORY}
*
*
*
* @param device the logical device that owns the memory.
* @param memory the {@code VkDeviceMemory} object.
* @param handleType a bitmask of {@code VkExternalMemoryHandleTypeFlagBitsNV} containing a single bit specifying the type of handle requested.
*/
@NativeType("VkResult")
public static int vkGetMemoryWin32HandleNV(VkDevice device, @NativeType("VkDeviceMemory") long memory, @NativeType("VkExternalMemoryHandleTypeFlagsNV") int handleType, @NativeType("HANDLE *") PointerBuffer pHandle) {
if (CHECKS) {
check(pHandle, 1);
}
return nvkGetMemoryWin32HandleNV(device, memory, handleType, memAddress(pHandle));
}
}