libstd/vulkan
Bindings to Vulkan and helpers for the first steps of a Vulkan program: instance, physical and logical device, graphics queue, window surface and swapchain. It links libvulkan.so on Linux and vulkan-1.dll on Windows (installed with the GPU driver); the instance enables the surface extension of the system it runs on. Vulkan structs are declared as classes with explicit padding; handles are long.
#include <libstd/vulkan>
Includes libstd/stdio, libstd/dict. Links the shared library vulkan-1.dll, libvulkan.so (FFI).
Example
#include <libstd/vulkan>
app = create_vulkan_instance("Hello World")
instance = vk_create_instance(app)
gpu = vk_get_first_physical_device(instance)
if gpu == (0 as long):
print("no Vulkan device\n")
exit(1)
family = vk_find_graphics_queue_family(gpu)
device = vk_create_logical_device(gpu, family)
queue = 0 as long
vkGetDeviceQueue(device, family, 0, &queue)
vkDestroyDevice(device, 0 as long)
vk_destroy_instance(instance)
Constants
| Name | Value | Meaning |
|---|---|---|
VK_STRUCTURE_TYPE_APPLICATION_INFO | 0 | |
VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO | 1 | |
VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO | 2 | |
VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO | 3 | |
VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR | 1000004000 | |
VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR | 1000009000 | |
VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR | 1000001000 | |
VK_QUEUE_GRAPHICS_BIT | 1 | |
VK_FORMAT_B8G8R8A8_UNORM | 44 | |
VK_COLOR_SPACE_SRGB_NONLINEAR_KHR | 0 | |
VK_PRESENT_MODE_FIFO_KHR | 2 | |
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | 16 | |
VK_IMAGE_USAGE_TRANSFER_DST_BIT | 2 | |
VK_SHARING_MODE_EXCLUSIVE | 0 | |
VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR | 1 | |
VK_PHYSICAL_DEVICE_PROPERTIES_SIZE | 824 | |
VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO | 39 | |
VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO | 40 | |
VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO | 42 | |
VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER | 45 | |
VK_STRUCTURE_TYPE_FENCE_CREATE_INFO | 8 | |
VK_STRUCTURE_TYPE_SUBMIT_INFO | 4 | |
VK_STRUCTURE_TYPE_PRESENT_INFO_KHR | 1000001001 | |
VK_IMAGE_ASPECT_COLOR_BIT | 1 | |
VK_IMAGE_LAYOUT_UNDEFINED | 0 | |
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL | 7 | |
VK_IMAGE_LAYOUT_PRESENT_SRC_KHR | 1000001002 | |
VK_ACCESS_TRANSFER_WRITE_BIT | 4096 | |
VK_ACCESS_MEMORY_READ_BIT | 32768 | |
VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT | 1 | |
VK_PIPELINE_STAGE_TRANSFER_BIT | 4096 | |
VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT | 8192 | |
VK_QUEUE_FAMILY_IGNORED | -1 | |
VK_COMMAND_BUFFER_LEVEL_PRIMARY | 0 |
Classes
sType int
_pad0 int
pNext long
pApplicationName str
applicationVersion int
_pad1 int
pEngineName str
engineVersion int
apiVersion int sType int
_pad0 int
pNext long
flags int
_pad1 int
pApplicationInfo long
enabledLayerCount int
_pad2 int
ppEnabledLayerNames long
enabledExtensionCount int
_pad3 int
ppEnabledExtensionNames long pUserData long
pfnAllocation long
pfnReallocation long
pfnFree long
pfnInternalAllocation long
pfnInternalFree long queueFlags int
queueCount int
timestampValidBits int
minImageTransferGranularityWidth int
minImageTransferGranularityHeight int
minImageTransferGranularityDepth int sType int
_pad0 int
pNext long
flags int
queueFamilyIndex int
queueCount int
_pad1 int
pQueuePriorities long sType int
_pad0 int
pNext long
flags int
queueCreateInfoCount int
pQueueCreateInfos long
enabledLayerCount int
_pad1 int
ppEnabledLayerNames long
enabledExtensionCount int
_pad2 int
ppEnabledExtensionNames long
pEnabledFeatures long sType int
_pad0 int
pNext long
flags int
_pad1 int
dpy long
window long sType int
_pad0 int
pNext long
flags int
_pad1 int
hinstance long
hwnd long minImageCount int
maxImageCount int
currentExtentWidth int
currentExtentHeight int
minImageExtentWidth int
minImageExtentHeight int
maxImageExtentWidth int
maxImageExtentHeight int
maxImageArrayLayers int
supportedTransforms int
currentTransform int
supportedCompositeAlpha int
supportedUsageFlags int format int
colorSpace int sType int
_pad0 int
pNext long
flags int
_pad1 int
surface long
minImageCount int
imageFormat int
imageColorSpace int
imageExtentWidth int
imageExtentHeight int
imageArrayLayers int
imageUsage int
imageSharingMode int
queueFamilyIndexCount int
_pad2 int
pQueueFamilyIndices long
preTransform int
compositeAlpha int
presentMode int
clipped int
oldSwapchain long sType int
_pad0 int
pNext long
flags int
queueFamilyIndex int sType int
_pad0 int
pNext long
commandPool long
level int
commandBufferCount int sType int
_pad0 int
pNext long
flags int
_pad1 int
pInheritanceInfo long aspectMask int
baseMipLevel int
levelCount int
baseArrayLayer int
layerCount int sType int
_pad0 int
pNext long
srcAccessMask int
dstAccessMask int
oldLayout int
newLayout int
srcQueueFamilyIndex int
dstQueueFamilyIndex int
image long
subresourceAspectMask int
subresourceBaseMipLevel int
subresourceLevelCount int
subresourceBaseArrayLayer int
subresourceLayerCount int
_pad2 int sType int
_pad0 int
pNext long
flags int
_pad1 int sType int
_pad0 int
pNext long
waitSemaphoreCount int
_pad1 int
pWaitSemaphores long
pWaitDstStageMask long
commandBufferCount int
_pad2 int
pCommandBuffers long
signalSemaphoreCount int
_pad3 int
pSignalSemaphores long sType int
_pad0 int
pNext long
waitSemaphoreCount int
_pad1 int
pWaitSemaphores long
swapchainCount int
_pad2 int
pSwapchains long
pImageIndices long
pResults longFunctions
C library function, called as declared in the library's own documentation.
C library function, called as declared in the library's own documentation.
C library function, called as declared in the library's own documentation.
C library function, called as declared in the library's own documentation.
C library function, called as declared in the library's own documentation.
C library function, called as declared in the library's own documentation.
C library function, called as declared in the library's own documentation.
C library function, called as declared in the library's own documentation.
C library function, called as declared in the library's own documentation.
C library function, called as declared in the library's own documentation.
C library function, called as declared in the library's own documentation.
C library function, called as declared in the library's own documentation.
C library function, called as declared in the library's own documentation.
C library function, called as declared in the library's own documentation.
C library function, called as declared in the library's own documentation.
C library function, called as declared in the library's own documentation.
C library function, called as declared in the library's own documentation.
C library function, called as declared in the library's own documentation.
Packs major/minor/patch into a Vulkan version number.
Allocates a VkPhysicalDeviceProperties buffer (824 bytes, raw_alloc); free with raw_free.
The device type field of a properties buffer.
The device name of a properties buffer.
The first physical device of an instance, 0 if none.
Index of the first queue family with VK_QUEUE_GRAPHICS_BIT, -1 if none.
Creates a logical device with one queue of the given family.
Linux: creates a VkSurfaceKHR for an X11 window.
Windows: creates a VkSurfaceKHR for a window of user32 (vkCreateWin32SurfaceKHR, from its HINSTANCE and HWND).
Creates the VkSurfaceKHR for a window of libstd/window, from the display, window that window_open returned: an X11 surface on Linux, a Win32 one on Windows. The portable choice.
Surface capabilities (extent, image counts, transforms).
Picks a (format, colorSpace) pair supported by the surface.
Creates a swapchain with the given format, size and image count.
The swapchain images as (pointer to handles, count).
Fills a VkApplicationInfo for vk_create_instance.
Creates the instance (with the Xlib surface extensions enabled).
Destroys the instance.
C library function, called as declared in the library's own documentation.
C library function, called as declared in the library's own documentation.
C library function, called as declared in the library's own documentation.
C library function, called as declared in the library's own documentation.
C library function, called as declared in the library's own documentation.
C library function, called as declared in the library's own documentation.
C library function, called as declared in the library's own documentation.
C library function, called as declared in the library's own documentation.
C library function, called as declared in the library's own documentation.
C library function, called as declared in the library's own documentation.
C library function, called as declared in the library's own documentation.
C library function, called as declared in the library's own documentation.
C library function, called as declared in the library's own documentation.
C library function, called as declared in the library's own documentation.
C library function, called as declared in the library's own documentation.
C library function, called as declared in the library's own documentation.
A command pool for a queue family.
Allocates count primary command buffers; returns a pointer to their handles.
A VkClearColorValue buffer.
A colour subresource range covering one mip level and layer.
Records a clear of a swapchain image into a command buffer.
Creates a fence, optionally signalled.
Acquires the next image, submits the matching command buffer, presents, waits for the fence.