Tanagra is a binding generator and (eventually) support library for Vulkan. Currently approximately half of all commands have been tested.
The example project should run on any Windows platform that can support Vulkan. More platform examples comming soon. The example uses SharpDX to quickly establish a render window and uses the OpenTK Math library for matrix and vector math.
You can also check the Wiki for a basic introduction to Vulkan (Comming soon!)
If you're looking for the LUNARG validation layer (VK_LAYER_LUNARG_standard_validation
) you can downloaded it from lunarG here
Coming soon!
using Vulkan; // Core Vulkan classes
using Vulkan.Managed; // Interface to unmanaged interop
using Vulkan.Managed.ObjectModel; // Extensions to vulkan handle objects
// Create a Vulkan instance
var instanceCreateInfo = new InstanceCreateInfo();
Instance vulkanInstance = Vk.CreateInstance(instanceCreateInfo);
// Enumerate Physical Devices
PhysicalDevice[] physicalDevices = instance.EnumeratePhysicalDevices();
// Create a Vulkan device
var queueCreateInfo = new DeviceQueueCreateInfo(0, new[]{ 0f });
var deviceCreateInfo = new DeviceCreateInfo(queueCreateInfo, null, null);
Device vulkanDevice = physicalDevices[0].CreateDevice(deviceCreateInfo);
// The 'CreateInfo' structures implement IDisposable, so make sure
// to either use a `using` block or dispose of these objects correctly
deviceCreateInfo.Dispose();
queueCreateInfo.Dispose();
instanceCreateInfo.Dispose();
The managed layer is reccomended in almost all cases. If you'd rather work with the interop layer directly (if you want total control over memory, for example) you can do that as well. You will need to compile with unsafe
in order to work with unmanaged classes.
using Vulkan; // Core Vulkan classes
using Vulkan.Unmanaged; // Unmanaged structs and callbacks
// The vulkan functions are in the `VulkanBinding` class. It's designed to be used
// with C# 6.0's 'using static' feature to replicate the Vulkan C api.
using static Unmanaged.VulkanBinding;
/* Allocate pointers to objects */
// `vkCreateInstance` is a member of `VulkanBinding`. We can call it like this
// because of the 'using static' statement above.
var result = vkCreateInstance(...)
if(result != Result.Success)
throw new VulkanCommandException(nameof(vkCreateInstance), result);
// Commands that return an array use the C 'call twice' convention:
// First call determines the length of the array to be retrieved
UInt32 listLength;
vkEnumeratePhysicalDevices(instancePtr, &listLength, null);
// Second call actually retrives the array
var arrayPhysicalDevice = new IntPtr[listLength];
fixed(IntPtr* resultPtr = &arrayPhysicalDevice[0])
vkEnumeratePhysicalDevices(instancePtr, &listLength, resultPtr);
vkCreateDevice(...);
./Vulkan/ - Generated Vulkan API as a standalone DLL
./Tanagra.Generator/ - Generates the Vulkan API from vk.xml
./Tanagra/ - Extended managed support for Vulkan
./TanagraExample/ - Example code
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
You hoped that something like this would happen, didn't you? You knew there was a dangerous creature on this planet, and you knew from the tale of Darmok that a danger shared might sometimes bring two people together. Darmok and Jalad at Tanagra. You and me, here, at El-Adrel.