CVulkan 1.0 released
Since Vulkan was released, everyone talks about it and wants to try it BUT the API is very low level and close to the metal.
You can now be happy because CVulkan is working ! But what is CVulkan ?
You can find CVulkan here: CVulkan
CVulkan is a Python binding to the Vulkan API. When you import
module, the Vulkan SDK is loaded (check my first post to understand
what is SDK) and all Vulkan functions inside it.
It means you can develop with the simplicity and power of the amazing Python language something as low-level as Vulkan. It’s a great news for you… or not…
Although this Python binding will simplify your development, it stills the so complex Vulkan API. So if you want a high level of developpment with Vulkan, checkout my other project vulk. It’s a 3D engine working with Vulkan, but more on this later.
Let’s see how CVulkan works, how you must use it and its features.
CVulkan gives access to all the Vulkan API, including extension functions.
All structs must be initialized at first call and are immutable, you shouldn’t need to update values after creation. Here’s an exemple:
import vulkan as vk createInfo = vk.VkInstanceCreateInfo( sType=vk.VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, flags=0, pApplicationInfo=appInfo, enabledExtensionCount=len(extensions), ppEnabledExtensionNames=extensions, enabledLayerCount=len(layers), ppEnabledLayerNames=layers )
It will be one of the first struct you will call. Like you can see, to
create the struct, you must pass all parameters at creation time. You
can see that I provide Python
list, indeed, the wrapper converts everything
for us into native Vulkan types.
CVulkan will help you a lot when calling function. In Vulkan, there are three types of function:
- functions that create nothing
- functions that create one object
- functions that create several objects
CVulkan takes care of you and guesses when it has to return
None, an object
list. Here an exemple:
# Create one object instance = vk.vkCreateInstance(pCreateInfo=createInfo) # Create a list of object extensions = vk.vkEnumerateDeviceExtensionProperties( physicalDevice=physical_device, pLayerName=None) # Return None vk.vkQueuePresentKHR(presentation_queue, present_create)
Vulkan functions usually return a
VkResult. CVulkan is pythonic and
converts it to exception: if the result is not
VK_SUCCESS, an exception is
raised and is named
VkErrorExtensionNotPresent for example.
All Vulkan constants are available in CVulkan and it provides some fancy
In the end
I think it’s a new area of possibilities which is offered to us! Let’s enjoy Vulkan.
Let me know what you think of this article on twitter @realitix!