Auto-generated D bindings for Vulkan
To use this package, run the following command in your project's root directory:
This package provides sub packages which can be used individually:
d-vulkan:devices - Simple Vulkan example
d-vulkan:layers - Simple Vulkan example
Automatically-generated D bindings for Vulkan.
Usage with Function Pointers Struct
D-Vulkan, at its core, does not load functions into global variables, like similar bindings do.
Instead, functions are loaded into a
VulkanFunctions structure. This is because Vulkan functions
are inherently tied to the instance, or device, that they were loaded from. For example, global
variables would make using the device-specific functions impossible to use with multiple devices.
To use the
- Import via
- Get a pointer to the
vkGetInstanceProcAddr, through platform-specific means (ex. loading the Vulkan shared library, using the Derelict loader, or
glfwGetInstanceProcAddressif using GLFW).
- Define a
VulkanFunctionsstructure somewhere (ex. on the stack via
getProcAddris the address of the loaded
vkGetInstanceProcAddrfunction, to load the following functions:
vkGetInstanceProcAddr(sets the function from the passed value)
- Create a
VkInstanceusing the above functions.
VulkanFunctions.loadInstanceFunctions(instance)to load the rest of the functions.
- (Optional) Call
VulkanFunctions.loadDeviceFunctions(device)once you have a
VkDeviceto load specific functions for a device.
For your convenience, the
VulkanFunctions structure includes the fields
that are set whenever
loadDeviceFunctions are called, respectively.
Note that the
VulkanFunctions struct is fairly large; be sure, if you are passing it around, to
pass by reference or pointer.
Usage with Global Functions
For convenience, when the
DVulkanGlobalFunctions version is set (it is set in the default
configuration), D-Vulkan will generate global variables holding Vulkan functions.
To use the global functions, follow the steps for using the
VulkanFunctions struct, but instead of
VulkanFunctions.load*Functions member functions, use the
global functions instead.
Differences from C Vulkan
VK_NULL_HANDLEwill not work. The C Vulkan headers rely on the fact that 0 in C is implicitly convertible to the null pointer, but that is not the case in D. Instead, use the
VK_NULL_[NON_]DISPATCHABLE_HANDLEconstants (as approprate for the type) or
Typeis the type to get a null handle for).
- All structures have their
sTypefield set to the appropriate value upon initialization; explicit initialization is not needed.
- Without the
DVulkanGlobalEnumsversion (on by default), Vulkan enums must be prefixed by their type, as they are defined as D enums (ex.
VkPipelineShaderStageCreateInfo.modulehas been renamed to
moduleis a D keyword.
VK_KHR_*_surfaceextensions are not yet implemented, as they require types from external libraries (X11, XCB, ...). They can be manually loaded with
D-Vulkan has two configurations, settable via the
subConfigurations dub option
- default: The default. Sets the versions
DVulkanGlobalFunctions(see below), and includes
- bare: No versions are set, you must specify what you want manually (usually at least
D-Vulkan has several versions, settable via the
versions dub option.
DVulkanGlobalEnums: Defines global aliases for all enumerations.
DVulkanGlobalFunctions: Generates global function pointers for Vulkan functions.
DVulkanDerelict: Includes a small loader for the Vulkan shared library using
derelict-util. When using this version with the
bareconfig, you must add
derelict-utilto your dependencies.
(EXT)is an Vulkan version or extension name (ex.
VK_KHR_swapchain), generates bindings
Examples can be found in the
examples directory, and ran with
dub run d-vulkan:examplename.
D-Vulkan includes a small loader using
derelict-util to load the Vulkan shared library when the
DVulkanDerelict version is defined.
To use it, call
DVulkanDerelict.load(), then either
which returns a
VulkanFunctions struct containing the initialization functions loaded by
VulkanFunctions.getInitializationFunctions, or, if
DVulkanGlobalFunctions is also specified,
DVulkanDerelict.loadInitializationFunctions() to load the same functions to the global variables.
Two examples can be found in the
examples directory, and can be ran with
dub run d-vulkan:examplename.
devices: Lists devices. Uses the derelict loader.
layers: Lists available layers. Uses the derelict loader, global enums, and whitelisted extension loading.
To generate bindings, download the Vulkan-Docs repo,
cd there, and execute it, passing in an output
folder to place the D files. Requires Python 3.
- Registered by Alex Parrill
- ~master released 4 years ago
- BSD 2-clause
- Copyright 2015-2016 The Khronos Group Inc.; Copyright 2016, Alex Parrill
- Sub packages:
- d-vulkan:devices, d-vulkan:layers
0.3.1 2016-May-19 0.3.0 2016-May-19 0.2.0 2016-Mar-26 0.1.0 2016-Mar-19 ~master 2016-May-27
- Download Stats:
0 downloads today
0 downloads this week
0 downloads this month
169 downloads total
- Short URL: