Looked into it. First experience so far:
Wow, Vulkan is insanely specific. Before you can do anything you have to specify everything! It’s a lot of setup code, most of the stuff was previously hidden by drivers. But there is a good thing about that. There are no secrets. Everything you do ultimately makes sense and there are no surprises or deprecated and outdated burdens.
The SDK size of ~250MB is surprisingly small. Install it, test if the basic cube demo runs on your system. Link some libs, set the header path and you’re ready to go.
Trying to understand every step in the tutorial takes a while, but there are some good references and examples. Although the majority of demos use the C API, I highly recommend to look into the C++ API too. It’s a bit different and confusing at first, but it nicely abstracts some of the steps.
Initialization code like…
const VkApplicationInfo app = {
.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,
.pNext = NULL,
.pApplicationName = APP_SHORT_NAME,
.applicationVersion = 0,
.pEngineName = APP_SHORT_NAME,
.engineVersion = 0,
.apiVersion = VK_API_VERSION_1_0,
};
… which is mainly done with structs. will become a bit cleaner in C++.
There are also methods for automatic memory managment. And since a lot of functionality is done by extensions, the dynamic loader for functions seems very helpful in C++.
auto const app = vk::ApplicationInfo()
.setPApplicationName(APP_SHORT_NAME)
.setApplicationVersion(0)
.setPEngineName(APP_SHORT_NAME)
.setEngineVersion(0)
.setApiVersion(VK_API_VERSION_1_0);
Now for the C interface the best example resource is probably by Sascha Willems at:
Vulkan (C API) examples and demos
Luckily someone ported these to the C++ API here:
Vulkan (C++ API) examples and demos
Another more concrete and realistic scenario is this project
Animate - Interesting minimalist animations.
As initial reference for how to setup the instance and devices.
Vulkan Context Example
Unfortunately most of the demos drag in GLFW as dependency. Since we probably don’t want that in JUCE, it’s necessary to setup the surfaces manually together with the native JUCE handles.
Looking at the overall picture, it seems a lot of the heavy context stuff in juce_opengl can be avoided in Vulkan, which will probably give a big performance boost in plugins. Moreover the idea of offscreen rendering and compute shaders that work multithreaded are ideally suited for heavy processing stuff audio visualisation. Vulkan is the future!