Automatically-generated D bindings for Vulkan.
The bindings have two configurations: the default
configuration, where the bindings load all functions from the vkGetInstanceProcAddr
, which you supply when loading; and the with-derelict-loader
configuration, which uses the Derelict library to load vkGetInstanceProcAddr
for you.
To use in the default
configuration:
- Import via
import dvulkan;
. - Get a pointer to the
vkGetInstanceProcAddr
, through platform-specific means (ex. loading the Vulkan shared library, orglfwGetInstanceProcAddress
if using GLFW). - Call
DVulkanLoader.loadInstanceFunctions(getProcAddr)
, wheregetProcAddr
is the address of the loadedvkGetInstanceProcAddr
function, to load the following functions:vkGetInstanceProcAddr
(sets the global variable from the passed value)vkCreateInstance
vkEnumerateInstanceExtensionProperties
vkEnumerateInstanceLayerProperties
- Create a
VkInstance
using the above functions. - Call
DVulkanLoader.loadAllFunctions(instance)
to load the rest of the functions. - (Optional) Call
DVulkanLoader.loadAllFunctions(device)
once you have aVkDevice
to load specific functions for a device.
To use in the with-derelict-loader
configuration, follow the above steps, but call DVulkanDerelict.load()
instead of performing steps two and three.
The API is similar to the C Vulkan API, but with some differences:
- Since enums in D are not global, you need to specify the enum type. Ex:
VkResult.VK_SUCCESS
instead of justVK_SUCCESS
. - All structures have their
sType
field set to the appropriate value upon initialization; explicit initialization is not needed. VkPipelineShaderStageCreateInfo.module
has been renamed toVkPipelineShaderStageCreateInfo._module
, sincemodule
is a D keyword.
Examples can be found in the examples
directory, and ran with dub run dvulkan:examplename
.
Bindings for all extensions are available, except for the VK_KHR_*_surface
extensions, which require types from external libraries (X11, XCB, ...). They can be manually loaded with vkGetInstanceProcAddr
if needed.
To generate bindings, download the Vulkan-Docs repo, copy/move/symlink vkdgen.py
into src/spec/
, cd
there, and execute it, passing in an output folder to place the D files. Requires Python 3.