v0.0.1
dragiyski-vulkan-binding
Python bindings for the Vulkan graphics and compute API, generated on-demand from the official Vulkan XML registry.
Overview
The binding is lazy: the module structure is set up at import time, but individual symbols (types, constants, functions, macros) are resolved and bound only when first accessed. This keeps startup overhead minimal regardless of how large the registry is.
Bindings are derived from dragiyski-vulkan-registry, which parses the official Vulkan XML registry and exposes its taxonomy. The binding layer translates that taxonomy into Python-callable objects backed by ctypes, including:
- Macros — version utility macros such as
VK_MAKE_VERSION,VK_MAKE_API_VERSION, and their corresponding accessors, exposed as plain Python callables with matching signatures. - Constants — scalar values such as
VK_HEADER_VERSION, exposed as Pythonintorfloat. - Types — Vulkan structs, unions, handles, and enums, mapped to
ctypesequivalents. - Commands — Vulkan API commands, loadable via the standard
vkGetInstanceProcAddr/vkGetDeviceProcAddrmechanism. - Callbacks — Vulkan callback function pointer types, wrapped as
ctypes.CFUNCTYPEfactories.
Requirements
- Python 3.12 or later
pycparser≥ 2.23dragiyski-vulkan-registry
Installation
pip install dragiyski-vulkan-binding
Usage
import ctypes
import dragiyski.vulkan.binding as vulkan
version = vulkan.VK_MAKE_API_VERSION(0, 1, 3, 0)
print(vulkan.VK_HEADER_VERSION)
vulkan_version = ctypes.c_uint32()
vulkan.vkEnumerateInstanceVersion(ctypes.byref(vulkan_version))
print('.'.join([
str(vulkan.VK_API_VERSION_MAJOR(vulkan_version.value)),
str(vulkan.VK_API_VERSION_MINOR(vulkan_version.value)),
str(vulkan.VK_API_VERSION_PATCH(vulkan_version.value)),
]))
Symbols are resolved lazily on first attribute access, so importing the module itself is fast.
Description
Languages
Python
100%