qt: disable Vulkan early if not available
This commit is contained in:
@@ -75,6 +75,10 @@ extern "C" {
|
|||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#if QT_CONFIG(vulkan)
|
||||||
|
#include <QVulkanInstance>
|
||||||
|
#include <QVulkanFunctions>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
@@ -325,10 +329,25 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
ui->actionVNC->setVisible(false);
|
ui->actionVNC->setVisible(false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !QT_CONFIG(vulkan)
|
#if QT_CONFIG(vulkan)
|
||||||
if (vid_api == 4) vid_api = 0;
|
bool vulkanAvailable = false;
|
||||||
ui->actionVulkan->setVisible(false);
|
{
|
||||||
|
QVulkanInstance instance;
|
||||||
|
instance.setApiVersion(QVersionNumber(1, 0));
|
||||||
|
if (instance.create()) {
|
||||||
|
uint32_t physicalDevices = 0;
|
||||||
|
instance.functions()->vkEnumeratePhysicalDevices(instance.vkInstance(), &physicalDevices, nullptr);
|
||||||
|
if (physicalDevices != 0) {
|
||||||
|
vulkanAvailable = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!vulkanAvailable)
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
|
if (vid_api == 4) vid_api = 0;
|
||||||
|
ui->actionVulkan->setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
QActionGroup* actGroup = nullptr;
|
QActionGroup* actGroup = nullptr;
|
||||||
|
|
||||||
|
@@ -795,18 +795,8 @@ VulkanWindowRenderer::VulkanWindowRenderer(QWidget* parent)
|
|||||||
: QVulkanWindow(parent->windowHandle())
|
: QVulkanWindow(parent->windowHandle())
|
||||||
{
|
{
|
||||||
parentWidget = parent;
|
parentWidget = parent;
|
||||||
instance.setLayers(QByteArrayList() << "VK_LAYER_KHRONOS_validation");
|
|
||||||
instance.setExtensions(QByteArrayList() << "VK_EXT_debug_report");
|
|
||||||
instance.setApiVersion(QVersionNumber(1, 0));
|
instance.setApiVersion(QVersionNumber(1, 0));
|
||||||
if (!instance.create()) {
|
instance.create();
|
||||||
throw std::runtime_error("Could not create Vulkan instance");
|
|
||||||
}
|
|
||||||
uint32_t physicalDevices = 0;
|
|
||||||
instance.functions()->vkEnumeratePhysicalDevices(instance.vkInstance(), &physicalDevices, nullptr);
|
|
||||||
if (physicalDevices == 0) {
|
|
||||||
throw std::runtime_error("No physical devices available.");
|
|
||||||
}
|
|
||||||
qDebug() << instance.layers();
|
|
||||||
setVulkanInstance(&instance);
|
setVulkanInstance(&instance);
|
||||||
setPhysicalDeviceIndex(0);
|
setPhysicalDeviceIndex(0);
|
||||||
setPreferredColorFormats({VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_A8B8G8R8_UNORM_PACK32});
|
setPreferredColorFormats({VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_A8B8G8R8_UNORM_PACK32});
|
||||||
|
Reference in New Issue
Block a user