1// Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "vulkaninstance_p.h"
5
6#if QT_CONFIG(qt3d_vulkan)
7
8#include <QVulkanInstance>
9
10QT_BEGIN_NAMESPACE
11
12namespace Qt3DRender {
13
14QVulkanInstance &staticVulkanInstance() noexcept
15{
16 static QVulkanInstance* vkInstance = []
17 {
18 QVulkanInstance* v = new QVulkanInstance;
19#if defined(NDEBUG)
20 constexpr bool debug_mode = false;
21#else
22 constexpr bool debug_mode = true;
23#endif
24 if (debug_mode || qgetenv(varName: "QT3D_VULKAN_VALIDATION").toInt())
25 v->setLayers({ "VK_LAYER_KHRONOS_validation" });
26
27 if (!v->create())
28 qWarning(msg: "Failed to create Vulkan instance");
29
30 return v;
31 }();
32 return *vkInstance;
33}
34
35} // Qt3DRender
36
37QT_END_NAMESPACE
38
39#endif
40

source code of qt3d/src/render/surfaces/vulkaninstance.cpp