Files
vulkan-binding/README.md
Plamen Dragiyski a8740d88dd
Some checks failed
CI / Code Style (autopep8) (push) Failing after 16s
CI / Tests (Python 3.12) (push) Successful in 20s
CI / Tests (Python 3.13) (push) Successful in 20s
CI / Tests (Python 3.14) (push) Successful in 19s
CI / Coverage (Python 3.12) (push) Failing after 7s
main: initial library
2026-05-10 01:05:56 +03:00

2.1 KiB

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 Python int or float.
  • Types — Vulkan structs, unions, handles, and enums, mapped to ctypes equivalents.
  • Commands — Vulkan API commands, loadable via the standard vkGetInstanceProcAddr / vkGetDeviceProcAddr mechanism.
  • Callbacks — Vulkan callback function pointer types, wrapped as ctypes.CFUNCTYPE factories.

Requirements

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.