vulkan-api
vulkan-api copied to clipboard
The exomia/vulkan-api repository contains .NET bindings providing low-level and cross-platform access to the Vulkan API.
Information
The exomia/vulkan-api repository contains .NET bindings providing low-level and cross-platform access to the Vulkan API.
The bindings and documentation are generated using the KhronosGroup/Vulkan-Docs repository.
It is meant to be as close as possible to the original Vulkan API written in C. see example
Features
- Vulkan 1.0, 1.1, 1.2, 1.3, 0.0
- All platforms except provisional, sci
- All extensions including vk_video
- Raw low level bindings using unsafe C# code
- cross platform
Example
With Exomia.Vulkan.Api you can create a Vulkan instance like this:
C#
using Exomia.Vulkan.Api.Core;
using static Exomia.Vulkan.Api.Core.Vk;
// ...
VkApplicationInfo applicationInfo;
applicationInfo.sType = VkApplicationInfo.STYPE;
applicationInfo.pNext = null;
applicationInfo.pApplicationName = Allocator.AllocateNtString("my app"); // "Allocator" not included in the Exomia.Vulkan.Api
applicationInfo.applicationVersion = new VkVersion(0, 1, 0, 0);
applicationInfo.pEngineName = Allocator.AllocateNtString("my engine"); // "Allocator" not included in the Exomia.Vulkan.Api
applicationInfo.engineVersion = new VkVersion(0, 1, 0, 0);
applicationInfo.apiVersion = VkVersion.VulkanApiVersion13;
VkInstanceCreateInfo instanceCreateInfo;
instanceCreateInfo.sType = VkInstanceCreateInfo.STYPE;
instanceCreateInfo.pNext = null;
instanceCreateInfo.flags = 0;
instanceCreateInfo.pApplicationInfo = &applicationInfo;
instanceCreateInfo.enabledLayerCount = 0u;
instanceCreateInfo.ppEnabledLayerNames = null;
instanceCreateInfo.enabledExtensionCount = 0u;
instanceCreateInfo.ppEnabledExtensionNames = null;
VkInstance instance;
VkResult result = vkCreateInstance(&instanceCreateInfo, null, &instance);
C/C++ comparison
VkApplicationInfo applicationInfo = {};
applicationInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
applicationInfo.pApplicationName = "my app";
applicationInfo.applicationVersion = VK_MAKE_VERSION(0, 1, 0, 0);
applicationInfo.pEngineName = "my engine";
applicationInfo.engineVersion = VK_MAKE_VERSION(0, 1, 0, 0);
applicationInfo.apiVersion = VK_API_VERSION_1_3;
VkInstanceCreateInfo instanceCreateInfo = {};
instanceCreateInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
instanceCreateInfo.pApplicationInfo = &applicationInfo;
instanceCreateInfo.enabledLayerCount = 0;
instanceCreateInfo.enabledExtensionCount = 0;
VkInstance instance;
VkResult result = vkCreateInstance(&instanceCreateInfo, nullptr, &instance)
Extensions
loading extensions is also possible (do not forget to enable them first):
// <extension name>.Load(instance[, device]);
VkExtDebugUtils.Load(instance);
after loading the extension functions can be used:
using static Exomia.Vulkan.Api.Core.VkExtDebugUtils;
// ...
VkDebugUtilsMessengerCreateInfoEXT debugUtilsMessengerCreateInfoExt;
debugUtilsMessengerCreateInfoExt.sType = VkDebugUtilsMessengerCreateInfoEXT.STYPE;
debugUtilsMessengerCreateInfoExt.pNext = null;
debugUtilsMessengerCreateInfoExt.flags = 0u;
// ...
VkDebugUtilsMessengerEXT debugUtilsMessengerExt;
VkResult result = vkCreateDebugUtilsMessengerEXT(instance, &debugUtilsMessengerCreateInfoExt, null, &debugUtilsMessengerExt);
// ...
Installing
Core
[Package Manager]
PM> Install-Package Exomia.Vulkan.Api.Core
Platform
[Package Manager]
PM> Install-Package Exomia.Vulkan.Api.<Platform>
replace <Platform> with a platform name of the following table
platform name | comment |
---|---|
Xlib | X Window System, Xlib client library |
Xlib_xrandr | X Window System, Xlib client library, XRandR extension |
Xcb | X Window System, Xcb client library |
Wayland | Wayland display server protocol |
Directfb | DirectFB library |
Android | Android OS |
Win32 | Microsoft Win32 API (also refers to Win64 apps) |
Vi | Nintendo Vi |
Ios | Apple IOS |
Macos | Apple MacOS |
Metal | Metal on CoreAnimation on Apple platforms |
Fuchsia | Fuchsia |
Ggp | Google Games Platform |
Screen | QNX Screen Graphics Subsystem |
see Exomia.Vulkan.Api packages on nuget
Changelog
can be found here
Building
Core
To build Exomia.Vulkan.Api.Core, open Exomia.Vulkan.Api.Core.sln in Visual Studio 2022 and build the solution.
Alternatively you can also build it on the command line, run the dotnet build Exomia.Vulkan.Api.Core.sln
command.
Platforms
In order to be able to build Exomia.Vulkan.Api.Platforms, make sure that the core package is available in one of your nuget feeds.
To build Exomia.Vulkan.Api.Platforms, open Exomia.Vulkan.Api.Platforms.sln in Visual Studio 2022 and build the solution.
Alternatively you can also build it on the command line, run the dotnet build Exomia.Vulkan.Api.Platforms.sln
command.
Q&A, Ideas or Show & tell us
You have questions, ideas or want to show or tell us something?
Open a new discussion or join an existing one!