Autogenerated low level Vulkan c# binding. This project starts as a fork of the work of https://github.com/mellinoe. I made a new generator limiting the number of overrides and trying to avoid use of unsafe raw pointers. The nuget package is available under the name Vulkan.
Port of the gltfPBR from Sacha Willems
The second project included in this repository is a set of classes encapsulating vulkan objects with IDispose
model and reference counting. GLFW handles the windowing system.
Developping exclusively on linux, I would be glad to have some feedback from window experiences.
- GLFW
- libstb, on debian install libstb-dev.
- Vulkan Sdk, glslc has to be in the path.
- optionaly for ui, you will need vkvg.
- physicaly based rendering, direct and deferred
- glTF 2.0
- ktx image loading.
To create a new vulkan application, derrive your application from VkWindow
.
class Program : VkWindow {
static void Main (string[] args) {
Instance.VALIDATION = true;
using (Program vke = new Program ()) {
vke.Run ();
}
}
}
Override the configureEnabledFeatures
method of VkWindow
to enable features.
protected override void configureEnabledFeatures (VkPhysicalDeviceFeatures available_features, ref VkPhysicalDeviceFeatures enabled_features) {
enabled_features.samplerAnisotropy = available_features.samplerAnisotropy;
}
To create queues, override the createQueues
method of VkWindow
. This function is called before the logical device creation and will take care of physically available queues, creating duplicates if count exceed availability. The base
method will create a default presentable queue.
protected override void createQueues () {
base.createQueues ();
transferQ = new Queue (dev, VkQueueFlags.Transfer);
}
The constructor of the VkWIndow
will finish the vulkan initialisation, so that you may create pipelines, buffers, and so on in your constructor.
VkWindow will provide the default swapchain, but it's up to you to create the frame buffers. For the triangle example, create them in the OnResize
override.
Framebuffer[] frameBuffers;
protected override void OnResize () {
if (frameBuffers != null)
for (int i = 0; i < swapChain.ImageCount; ++i)
frameBuffers[i]?.Dispose ();
frameBuffers = new Framebuffer[swapChain.ImageCount];
for (int i = 0; i < swapChain.ImageCount; ++i)
frameBuffers[i] = new Framebuffer (pipeline.RenderPass, swapChain.Width, swapChain.Height,
(pipeline.Samples == VkSampleCountFlags.SampleCount1) ? new Image[] {
swapChain.images[i],
null
} : new Image[] {
null,
null,
swapChain.images[i]
});
buildCommandBuffers ();
}