As per the code found at: Qt Triangle Example
Adding a bit of debug logic:
#include <QDateTime>
#include <QDebug>
#include <QGuiApplication>
#include <QLoggingCategory>
#include <QVulkanInstance>
int main(int argc, char** argv) {
QGuiApplication qt_gui_app(argc, argv);
QVulkanInstance qvk_instance;
// Set Layers
QByteArrayList curr_layers = qvk_instance.layers();
for (const std::string& layer : {"VK_LAYER_KHRONOS_validation"}) {
curr_layers << layer.c_str();
}
qvk_instance.setLayers(curr_layers);
const auto& supported_layers = qvk_instance.supportedLayers();
const auto& pre_layers = qvk_instance.layers();
qDebug() << "Supported layers are " << supported_layers;
qDebug() << "Pre .create() " << pre_layers;
// Set Extensions
QByteArrayList qt_vk_extensions = qvk_instance.extensions();
qt_vk_extensions.append(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
qvk_instance.setExtensions(qt_vk_extensions);
qvk_instance.setApiVersion(QVersionNumber(1, 2));
// Create
if (!qvk_instance.create()) {
qFatal("Failed to create Vulkan instance: %d",
qvk_instance.errorCode());
}
// Validate
const auto& post_layers = qvk_instance.layers();
qDebug() << "Post .create() " << post_layers;
exit(-1);
}
I get the following output:
Supported layers are QList(QVulkanLayer("VK_LAYER_MESA_device_select" 1 QVersionNumber(1.3.211) "Linux device selection layer"), QVulkanLayer("VK_LAYER_NV_optimus" 1 QVersionNumber(1.3.242) "NVIDIA Optimus layer"), QVulkanLayer("VK_LAYER_MESA_overlay" 1 QVersionNumber(1.3.211) "Mesa Overlay layer"), QVulkanLayer("VK_LAYER_INTEL_nullhw" 1 QVersionNumber(1.1.73) "INTEL NULL HW"))
Pre .create() QList("VK_LAYER_KHRONOS_validation")
Post .create() QList()
Why is it that after calling .create()
on the QVulkanInstance
, does the added layer disappear?
My goal is to add the validation and debug capabilities as described in vulkan tutorial -- Validation Layers.
For debugging and tooling related layers I'd suggest managing the layer from outside of the application using the LunarG Vulkan Configurator utility. This can inject the layer and the necessary configuration to enable the checks that you want, without needing source code modifications to your application to do it.
In general it's a much more convenient way to do it than having to rebuild whenever you want to change a debug configuration.