From 7a1650e34331f87bab5a9372087d2a1135f9f63a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 31 Mar 2020 12:25:43 +0200 Subject: Move QtVulkanSupport into QtGui and QtOpenGL Task-number: QTBUG-83255 Change-Id: Ib021cecebda89fa2ab9332752124a8cec0a51a10 Reviewed-by: Laszlo Agocs --- src/gui/CMakeLists.txt | 1 + src/gui/vulkan/qbasicvulkanplatforminstance.cpp | 405 +++++++++++++++++++++ src/gui/vulkan/qbasicvulkanplatforminstance_p.h | 118 ++++++ src/gui/vulkan/qvulkanwindow_p.h | 2 +- src/gui/vulkan/vulkan.pri | 6 +- src/opengl/CMakeLists.txt | 8 + src/opengl/opengl.pro | 10 + src/opengl/qvkconvenience.cpp | 219 +++++++++++ src/opengl/qvkconvenience_p.h | 69 ++++ src/platformsupport/CMakeLists.txt | 3 - src/platformsupport/platformsupport.pro | 3 - .../vkconvenience/.prev_CMakeLists.txt | 31 -- src/platformsupport/vkconvenience/CMakeLists.txt | 33 -- .../vkconvenience/qbasicvulkanplatforminstance.cpp | 405 --------------------- .../vkconvenience/qbasicvulkanplatforminstance_p.h | 116 ------ .../vkconvenience/qvkconvenience.cpp | 219 ----------- .../vkconvenience/qvkconvenience_p.h | 69 ---- .../vkconvenience/vkconvenience.pro | 20 - src/plugins/platforms/android/CMakeLists.txt | 2 - src/plugins/platforms/android/android.pro | 2 - .../android/qandroidplatformvulkaninstance.h | 2 +- src/plugins/platforms/cocoa/CMakeLists.txt | 2 - src/plugins/platforms/cocoa/cocoa.pro | 2 - src/plugins/platforms/cocoa/qcocoavulkaninstance.h | 2 +- src/plugins/platforms/direct2d/direct2d.pro | 1 - src/plugins/platforms/eglfs/CMakeLists.txt | 2 - .../eglfs/api/vulkan/qeglfsvulkaninstance_p.h | 2 +- .../platforms/eglfs/eglfsdeviceintegration.pro | 3 - src/plugins/platforms/windows/CMakeLists.txt | 2 - .../platforms/windows/qwindowsvulkaninstance.h | 2 +- src/plugins/platforms/windows/windows.pro | 1 - src/plugins/platforms/xcb/CMakeLists.txt | 2 - src/plugins/platforms/xcb/qxcbvulkaninstance.h | 2 +- src/plugins/platforms/xcb/xcb_qpa_lib.pro | 2 - 34 files changed, 840 insertions(+), 928 deletions(-) create mode 100644 src/gui/vulkan/qbasicvulkanplatforminstance.cpp create mode 100644 src/gui/vulkan/qbasicvulkanplatforminstance_p.h create mode 100644 src/opengl/qvkconvenience.cpp create mode 100644 src/opengl/qvkconvenience_p.h delete mode 100644 src/platformsupport/vkconvenience/.prev_CMakeLists.txt delete mode 100644 src/platformsupport/vkconvenience/CMakeLists.txt delete mode 100644 src/platformsupport/vkconvenience/qbasicvulkanplatforminstance.cpp delete mode 100644 src/platformsupport/vkconvenience/qbasicvulkanplatforminstance_p.h delete mode 100644 src/platformsupport/vkconvenience/qvkconvenience.cpp delete mode 100644 src/platformsupport/vkconvenience/qvkconvenience_p.h delete mode 100644 src/platformsupport/vkconvenience/vkconvenience.pro (limited to 'src') diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 2448f36e5f..d9067bb4b8 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -695,6 +695,7 @@ qt_extend_target(Gui CONDITION QT_FEATURE_vulkan vulkan/qvulkanfunctions.cpp vulkan/qvulkaninstance.cpp vulkan/qvulkaninstance.h vulkan/qvulkanwindow.cpp vulkan/qvulkanwindow.h vulkan/qvulkanwindow_p.h + vulkan/qbasicvulkanplatforminstance.cpp vulkan/qbasicvulkanplatforminstance_p.h PUBLIC_LIBRARIES Vulkan::Vulkan_nolink ) diff --git a/src/gui/vulkan/qbasicvulkanplatforminstance.cpp b/src/gui/vulkan/qbasicvulkanplatforminstance.cpp new file mode 100644 index 0000000000..6f6ba58319 --- /dev/null +++ b/src/gui/vulkan/qbasicvulkanplatforminstance.cpp @@ -0,0 +1,405 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qbasicvulkanplatforminstance_p.h" +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +Q_LOGGING_CATEGORY(lcPlatVk, "qt.vulkan") + +/*! + \class QBasicPlatformVulkanInstance + \brief A generic platform Vulkan instance implementation. + \since 5.10 + \internal + \ingroup qpa + + Implements QPlatformVulkanInstance, serving as a base for platform-specific + implementations. The library loading and any WSI-specifics are excluded. + + Subclasses are expected to call init() from their constructor and + initInstance() from their createOrAdoptInstance() implementation. + */ + +QBasicPlatformVulkanInstance::QBasicPlatformVulkanInstance() + : m_vkInst(VK_NULL_HANDLE), + m_vkGetInstanceProcAddr(nullptr), + m_ownsVkInst(false), + m_errorCode(VK_SUCCESS), + m_debugCallback(0) +{ +} + +QBasicPlatformVulkanInstance::~QBasicPlatformVulkanInstance() +{ + if (!m_vkInst) + return; + + if (m_debugCallback && m_vkDestroyDebugReportCallbackEXT) + m_vkDestroyDebugReportCallbackEXT(m_vkInst, m_debugCallback, nullptr); + + if (m_ownsVkInst) + m_vkDestroyInstance(m_vkInst, nullptr); +} + +void QBasicPlatformVulkanInstance::loadVulkanLibrary(const QString &defaultLibraryName) +{ + if (qEnvironmentVariableIsSet("QT_VULKAN_LIB")) + m_vulkanLib.setFileName(QString::fromUtf8(qgetenv("QT_VULKAN_LIB"))); + else + m_vulkanLib.setFileName(defaultLibraryName); + + if (!m_vulkanLib.load()) { + qWarning("Failed to load %s: %s", qPrintable(m_vulkanLib.fileName()), qPrintable(m_vulkanLib.errorString())); + return; + } + + init(&m_vulkanLib); +} + +void QBasicPlatformVulkanInstance::init(QLibrary *lib) +{ + if (m_vkGetInstanceProcAddr) + return; + + qCDebug(lcPlatVk, "Vulkan init (%s)", qPrintable(lib->fileName())); + + // While not strictly required with every implementation, try to follow the spec + // and do not rely on core functions being exported. + // + // 1. dlsym vkGetInstanceProcAddr + // 2. with a special null instance resolve vkCreateInstance and vkEnumerateInstance* + // 3. all other core functions are resolved with the created instance + + m_vkGetInstanceProcAddr = reinterpret_cast(lib->resolve("vkGetInstanceProcAddr")); + if (!m_vkGetInstanceProcAddr) { + qWarning("Failed to find vkGetInstanceProcAddr"); + return; + } + + m_vkCreateInstance = reinterpret_cast(m_vkGetInstanceProcAddr(VK_NULL_HANDLE, "vkCreateInstance")); + if (!m_vkCreateInstance) { + qWarning("Failed to find vkCreateInstance"); + return; + } + m_vkEnumerateInstanceLayerProperties = reinterpret_cast( + m_vkGetInstanceProcAddr(VK_NULL_HANDLE, "vkEnumerateInstanceLayerProperties")); + if (!m_vkEnumerateInstanceLayerProperties) { + qWarning("Failed to find vkEnumerateInstanceLayerProperties"); + return; + } + m_vkEnumerateInstanceExtensionProperties = reinterpret_cast( + m_vkGetInstanceProcAddr(VK_NULL_HANDLE, "vkEnumerateInstanceExtensionProperties")); + if (!m_vkEnumerateInstanceExtensionProperties) { + qWarning("Failed to find vkEnumerateInstanceExtensionProperties"); + return; + } + + uint32_t layerCount = 0; + m_vkEnumerateInstanceLayerProperties(&layerCount, nullptr); + if (layerCount) { + QVector layerProps(layerCount); + m_vkEnumerateInstanceLayerProperties(&layerCount, layerProps.data()); + m_supportedLayers.reserve(layerCount); + for (const VkLayerProperties &p : qAsConst(layerProps)) { + QVulkanLayer layer; + layer.name = p.layerName; + layer.version = p.implementationVersion; + layer.specVersion = QVersionNumber(VK_VERSION_MAJOR(p.specVersion), + VK_VERSION_MINOR(p.specVersion), + VK_VERSION_PATCH(p.specVersion)); + layer.description = p.description; + m_supportedLayers.append(layer); + } + } + qCDebug(lcPlatVk) << "Supported Vulkan instance layers:" << m_supportedLayers; + + uint32_t extCount = 0; + m_vkEnumerateInstanceExtensionProperties(nullptr, &extCount, nullptr); + if (extCount) { + QVector extProps(extCount); + m_vkEnumerateInstanceExtensionProperties(nullptr, &extCount, extProps.data()); + m_supportedExtensions.reserve(extCount); + for (const VkExtensionProperties &p : qAsConst(extProps)) { + QVulkanExtension ext; + ext.name = p.extensionName; + ext.version = p.specVersion; + m_supportedExtensions.append(ext); + } + } + qDebug(lcPlatVk) << "Supported Vulkan instance extensions:" << m_supportedExtensions; +} + +QVulkanInfoVector QBasicPlatformVulkanInstance::supportedLayers() const +{ + return m_supportedLayers; +} + +QVulkanInfoVector QBasicPlatformVulkanInstance::supportedExtensions() const +{ + return m_supportedExtensions; +} + +void QBasicPlatformVulkanInstance::initInstance(QVulkanInstance *instance, const QByteArrayList &extraExts) +{ + if (!m_vkGetInstanceProcAddr) { + qWarning("initInstance: No Vulkan library available"); + return; + } + + m_vkInst = instance->vkInstance(); // when non-null we are adopting an existing instance + + QVulkanInstance::Flags flags = instance->flags(); + m_enabledLayers = instance->layers(); + m_enabledExtensions = instance->extensions(); + + if (!m_vkInst) { + VkApplicationInfo appInfo; + memset(&appInfo, 0, sizeof(appInfo)); + appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; + QByteArray appName = QCoreApplication::applicationName().toUtf8(); + appInfo.pApplicationName = appName.constData(); + const QVersionNumber apiVersion = instance->apiVersion(); + if (!apiVersion.isNull()) { + appInfo.apiVersion = VK_MAKE_VERSION(apiVersion.majorVersion(), + apiVersion.minorVersion(), + apiVersion.microVersion()); + } + + if (!flags.testFlag(QVulkanInstance::NoDebugOutputRedirect)) + m_enabledExtensions.append("VK_EXT_debug_report"); + + m_enabledExtensions.append("VK_KHR_surface"); + + for (const QByteArray &ext : extraExts) + m_enabledExtensions.append(ext); + + QByteArray envExts = qgetenv("QT_VULKAN_INSTANCE_EXTENSIONS"); + if (!envExts.isEmpty()) { + QByteArrayList envExtList = envExts.split(';'); + for (auto ext : m_enabledExtensions) + envExtList.removeAll(ext); + m_enabledExtensions.append(envExtList); + } + + QByteArray envLayers = qgetenv("QT_VULKAN_INSTANCE_LAYERS"); + if (!envLayers.isEmpty()) { + QByteArrayList envLayerList = envLayers.split(';'); + for (auto ext : m_enabledLayers) + envLayerList.removeAll(ext); + m_enabledLayers.append(envLayerList); + } + + // No clever stuff with QSet and friends: the order for layers matters + // and the user-provided order must be kept. + for (int i = 0; i < m_enabledLayers.count(); ++i) { + const QByteArray &layerName(m_enabledLayers[i]); + if (!m_supportedLayers.contains(layerName)) + m_enabledLayers.removeAt(i--); + } + qDebug(lcPlatVk) << "Enabling Vulkan instance layers:" << m_enabledLayers; + for (int i = 0; i < m_enabledExtensions.count(); ++i) { + const QByteArray &extName(m_enabledExtensions[i]); + if (!m_supportedExtensions.contains(extName)) + m_enabledExtensions.removeAt(i--); + } + qDebug(lcPlatVk) << "Enabling Vulkan instance extensions:" << m_enabledExtensions; + + VkInstanceCreateInfo instInfo; + memset(&instInfo, 0, sizeof(instInfo)); + instInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; + instInfo.pApplicationInfo = &appInfo; + + QVector layerNameVec; + for (const QByteArray &ba : qAsConst(m_enabledLayers)) + layerNameVec.append(ba.constData()); + if (!layerNameVec.isEmpty()) { + instInfo.enabledLayerCount = layerNameVec.count(); + instInfo.ppEnabledLayerNames = layerNameVec.constData(); + } + + QVector extNameVec; + for (const QByteArray &ba : qAsConst(m_enabledExtensions)) + extNameVec.append(ba.constData()); + if (!extNameVec.isEmpty()) { + instInfo.enabledExtensionCount = extNameVec.count(); + instInfo.ppEnabledExtensionNames = extNameVec.constData(); + } + + m_errorCode = m_vkCreateInstance(&instInfo, nullptr, &m_vkInst); + if (m_errorCode != VK_SUCCESS || !m_vkInst) { + qWarning("Failed to create Vulkan instance: %d", m_errorCode); + return; + } + + m_vkDestroyInstance = reinterpret_cast(m_vkGetInstanceProcAddr(m_vkInst, "vkDestroyInstance")); + if (!m_vkDestroyInstance) { + qWarning("Failed to find vkDestroyInstance"); + m_vkInst = VK_NULL_HANDLE; + return; + } + + m_ownsVkInst = true; + } + + m_getPhysDevSurfaceSupport = reinterpret_cast( + m_vkGetInstanceProcAddr(m_vkInst, "vkGetPhysicalDeviceSurfaceSupportKHR")); + if (!m_getPhysDevSurfaceSupport) + qWarning("Failed to find vkGetPhysicalDeviceSurfaceSupportKHR"); + + m_destroySurface = reinterpret_cast( + m_vkGetInstanceProcAddr(m_vkInst, "vkDestroySurfaceKHR")); + if (!m_destroySurface) + qWarning("Failed to find vkDestroySurfaceKHR"); + + if (!flags.testFlag(QVulkanInstance::NoDebugOutputRedirect)) + setupDebugOutput(); +} + +bool QBasicPlatformVulkanInstance::isValid() const +{ + return m_vkInst != VK_NULL_HANDLE; +} + +VkResult QBasicPlatformVulkanInstance::errorCode() const +{ + return m_errorCode; +} + +VkInstance QBasicPlatformVulkanInstance::vkInstance() const +{ + return m_vkInst; +} + +QByteArrayList QBasicPlatformVulkanInstance::enabledLayers() const +{ + return m_enabledLayers; +} + +QByteArrayList QBasicPlatformVulkanInstance::enabledExtensions() const +{ + return m_enabledExtensions; +} + +PFN_vkVoidFunction QBasicPlatformVulkanInstance::getInstanceProcAddr(const char *name) +{ + if (!name) + return nullptr; + + const bool needsNullInstance = !strcmp(name, "vkEnumerateInstanceLayerProperties") + || !strcmp(name, "vkEnumerateInstanceExtensionProperties"); + + return m_vkGetInstanceProcAddr(needsNullInstance ? 0 : m_vkInst, name); +} + +bool QBasicPlatformVulkanInstance::supportsPresent(VkPhysicalDevice physicalDevice, + uint32_t queueFamilyIndex, + QWindow *window) +{ + if (!m_getPhysDevSurfaceSupport) + return true; + + VkSurfaceKHR surface = QVulkanInstance::surfaceForWindow(window); + VkBool32 supported = false; + m_getPhysDevSurfaceSupport(physicalDevice, queueFamilyIndex, surface, &supported); + + return supported; +} + +void QBasicPlatformVulkanInstance::setDebugFilters(const QVector &filters) +{ + m_debugFilters = filters; +} + +void QBasicPlatformVulkanInstance::destroySurface(VkSurfaceKHR surface) const +{ + if (m_destroySurface && surface) + m_destroySurface(m_vkInst, surface, nullptr); +} + +static VKAPI_ATTR VkBool32 VKAPI_CALL defaultDebugCallbackFunc(VkDebugReportFlagsEXT flags, + VkDebugReportObjectTypeEXT objectType, + uint64_t object, + size_t location, + int32_t messageCode, + const char *pLayerPrefix, + const char *pMessage, + void *pUserData) +{ + QBasicPlatformVulkanInstance *self = static_cast(pUserData); + for (QVulkanInstance::DebugFilter filter : *self->debugFilters()) { + if (filter(flags, objectType, object, location, messageCode, pLayerPrefix, pMessage)) + return VK_FALSE; + } + + // not categorized, just route to plain old qDebug + qDebug("vkDebug: %s: %d: %s", pLayerPrefix, messageCode, pMessage); + + return VK_FALSE; +} + +void QBasicPlatformVulkanInstance::setupDebugOutput() +{ + if (!m_enabledExtensions.contains("VK_EXT_debug_report")) + return; + + PFN_vkCreateDebugReportCallbackEXT createDebugReportCallback = reinterpret_cast( + m_vkGetInstanceProcAddr(m_vkInst, "vkCreateDebugReportCallbackEXT")); + m_vkDestroyDebugReportCallbackEXT = reinterpret_cast( + m_vkGetInstanceProcAddr(m_vkInst, "vkDestroyDebugReportCallbackEXT")); + + VkDebugReportCallbackCreateInfoEXT dbgCallbackInfo; + memset(&dbgCallbackInfo, 0, sizeof(dbgCallbackInfo)); + dbgCallbackInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT; + dbgCallbackInfo.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT + | VK_DEBUG_REPORT_WARNING_BIT_EXT + | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT; + dbgCallbackInfo.pfnCallback = defaultDebugCallbackFunc; + dbgCallbackInfo.pUserData = this; + + VkResult err = createDebugReportCallback(m_vkInst, &dbgCallbackInfo, nullptr, &m_debugCallback); + if (err != VK_SUCCESS) + qWarning("Failed to create debug report callback: %d", err); +} + +QT_END_NAMESPACE diff --git a/src/gui/vulkan/qbasicvulkanplatforminstance_p.h b/src/gui/vulkan/qbasicvulkanplatforminstance_p.h new file mode 100644 index 0000000000..cfd180b57a --- /dev/null +++ b/src/gui/vulkan/qbasicvulkanplatforminstance_p.h @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBASICVULKANPLATFORMINSTANCE_P_H +#define QBASICVULKANPLATFORMINSTANCE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +#include +#include + +QT_BEGIN_NAMESPACE + +class QLibrary; + +class Q_GUI_EXPORT QBasicPlatformVulkanInstance : public QPlatformVulkanInstance +{ +public: + QBasicPlatformVulkanInstance(); + ~QBasicPlatformVulkanInstance(); + + QVulkanInfoVector supportedLayers() const override; + QVulkanInfoVector supportedExtensions() const override; + bool isValid() const override; + VkResult errorCode() const override; + VkInstance vkInstance() const override; + QByteArrayList enabledLayers() const override; + QByteArrayList enabledExtensions() const override; + PFN_vkVoidFunction getInstanceProcAddr(const char *name) override; + bool supportsPresent(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, QWindow *window) override; + void setDebugFilters(const QVector &filters) override; + + void destroySurface(VkSurfaceKHR surface) const; + const QVector *debugFilters() const { return &m_debugFilters; } + +protected: + void loadVulkanLibrary(const QString &defaultLibraryName); + void init(QLibrary *lib); + void initInstance(QVulkanInstance *instance, const QByteArrayList &extraExts); + + VkInstance m_vkInst; + PFN_vkGetInstanceProcAddr m_vkGetInstanceProcAddr; + PFN_vkGetPhysicalDeviceSurfaceSupportKHR m_getPhysDevSurfaceSupport; + PFN_vkDestroySurfaceKHR m_destroySurface; + +private: + void setupDebugOutput(); + + QLibrary m_vulkanLib; + + bool m_ownsVkInst; + VkResult m_errorCode; + QVulkanInfoVector m_supportedLayers; + QVulkanInfoVector m_supportedExtensions; + QByteArrayList m_enabledLayers; + QByteArrayList m_enabledExtensions; + + PFN_vkCreateInstance m_vkCreateInstance; + PFN_vkEnumerateInstanceLayerProperties m_vkEnumerateInstanceLayerProperties; + PFN_vkEnumerateInstanceExtensionProperties m_vkEnumerateInstanceExtensionProperties; + + PFN_vkDestroyInstance m_vkDestroyInstance; + + VkDebugReportCallbackEXT m_debugCallback; + PFN_vkDestroyDebugReportCallbackEXT m_vkDestroyDebugReportCallbackEXT; + QVector m_debugFilters; +}; + +QT_END_NAMESPACE + +#endif // QBASICVULKANPLATFORMINSTANCE_P_H diff --git a/src/gui/vulkan/qvulkanwindow_p.h b/src/gui/vulkan/qvulkanwindow_p.h index 915e359673..41abf977e4 100644 --- a/src/gui/vulkan/qvulkanwindow_p.h +++ b/src/gui/vulkan/qvulkanwindow_p.h @@ -61,7 +61,7 @@ QT_BEGIN_NAMESPACE -class QVulkanWindowPrivate : public QWindowPrivate +class Q_GUI_EXPORT QVulkanWindowPrivate : public QWindowPrivate { Q_DECLARE_PUBLIC(QVulkanWindow) diff --git a/src/gui/vulkan/vulkan.pri b/src/gui/vulkan/vulkan.pri index 5c902e8b82..3ac3b8edc3 100644 --- a/src/gui/vulkan/vulkan.pri +++ b/src/gui/vulkan/vulkan.pri @@ -5,13 +5,15 @@ qtConfig(vulkan) { vulkan/qvulkaninstance.h \ vulkan/qplatformvulkaninstance.h \ vulkan/qvulkanwindow.h \ - vulkan/qvulkanwindow_p.h + vulkan/qvulkanwindow_p.h \ + vulkan/qbasicvulkanplatforminstance_p.h SOURCES += \ vulkan/qvulkaninstance.cpp \ vulkan/qplatformvulkaninstance.cpp \ vulkan/qvulkanfunctions.cpp \ - vulkan/qvulkanwindow.cpp + vulkan/qvulkanwindow.cpp \ + vulkan/qbasicvulkanplatforminstance.cpp # Applications must inherit the Vulkan header include path. QMAKE_USE += vulkan/nolink diff --git a/src/opengl/CMakeLists.txt b/src/opengl/CMakeLists.txt index c0acee56e5..9050ad0c58 100644 --- a/src/opengl/CMakeLists.txt +++ b/src/opengl/CMakeLists.txt @@ -84,6 +84,14 @@ qt_extend_target(OpenGL CONDITION NOT QT_FEATURE_opengles2 qopenglqueryhelper_p.h qopengltimerquery.cpp qopengltimerquery.h ) + +qt_extend_target(OpenGL CONDITION QT_FEATURE_vulkan + SOURCES + qvkconvenience.cpp qvkconvenience_p.h + PUBLIC_LIBRARIES + Vulkan::Vulkan_nolink +) + qt_add_docs(OpenGL doc/qtopengl.qdocconf ) diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index 777bca40ec..37694787f3 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -129,4 +129,14 @@ qtConfig(opengles2) { SOURCES += qopenglfunctions_es2.cpp } +qtConfig(vulkan) { + CONFIG += generated_privates + + HEADERS += qvkconvenience_p.h + SOURCES += qvkconvenience.cpp + + # Applications must inherit the Vulkan header include path. + QMAKE_USE += vulkan/nolink +} + load(qt_module) diff --git a/src/opengl/qvkconvenience.cpp b/src/opengl/qvkconvenience.cpp new file mode 100644 index 0000000000..59de335333 --- /dev/null +++ b/src/opengl/qvkconvenience.cpp @@ -0,0 +1,219 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qvkconvenience_p.h" + +#if QT_CONFIG(opengl) +#include +#endif + +QT_BEGIN_NAMESPACE + +/*! + \class QVkConvenience + \brief A collection of static helper functions for Vulkan support + \since 5.14 + \internal + \ingroup qpa + */ + +#if QT_CONFIG(opengl) +VkFormat QVkConvenience::vkFormatFromGlFormat(uint glFormat) +{ + using GlFormat = QOpenGLTexture::TextureFormat; + switch (glFormat) { + case GlFormat::NoFormat: return VK_FORMAT_UNDEFINED; // GL_NONE + + // Unsigned normalized formats + case GlFormat::R8_UNorm: return VK_FORMAT_R8_UNORM; // GL_R8 + case GlFormat::RG8_UNorm: return VK_FORMAT_R8G8_UNORM; // GL_RG8 + case GlFormat::RGB8_UNorm: return VK_FORMAT_R8G8B8_UNORM; // GL_RGB8 + case GlFormat::RGBA8_UNorm: return VK_FORMAT_R8G8B8A8_UNORM; // GL_RGBA8 + + case GlFormat::R16_UNorm: return VK_FORMAT_R16_UNORM; // GL_R16 + case GlFormat::RG16_UNorm: return VK_FORMAT_R16G16_UNORM; // GL_RG16 + case GlFormat::RGB16_UNorm: return VK_FORMAT_R16G16B16_UNORM; // GL_RGB16 + case GlFormat::RGBA16_UNorm: return VK_FORMAT_R16G16B16A16_UNORM; // GL_RGBA16 + + // Signed normalized formats + case GlFormat::R8_SNorm: return VK_FORMAT_R8_SNORM; // GL_R8_SNORM + case GlFormat::RG8_SNorm: return VK_FORMAT_R8G8_SNORM; // GL_RG8_SNORM + case GlFormat::RGB8_SNorm: return VK_FORMAT_R8G8B8_SNORM; // GL_RGB8_SNORM + case GlFormat::RGBA8_SNorm: return VK_FORMAT_R8G8B8A8_SNORM; // GL_RGBA8_SNORM + + case GlFormat::R16_SNorm: return VK_FORMAT_R16_SNORM; // GL_R16_SNORM + case GlFormat::RG16_SNorm: return VK_FORMAT_R16G16_SNORM; // GL_RG16_SNORM + case GlFormat::RGB16_SNorm: return VK_FORMAT_R16G16B16_SNORM; // GL_RGB16_SNORM + case GlFormat::RGBA16_SNorm: return VK_FORMAT_R16G16B16A16_SNORM; // GL_RGBA16_SNORM + + // Unsigned integer formats + case GlFormat::R8U: return VK_FORMAT_R8_UINT; // GL_R8UI + case GlFormat::RG8U: return VK_FORMAT_R8G8_UINT; // GL_RG8UI + case GlFormat::RGB8U: return VK_FORMAT_R8G8B8_UINT; // GL_RGB8UI + case GlFormat::RGBA8U: return VK_FORMAT_R8G8B8A8_UINT; // GL_RGBA8UI + + case GlFormat::R16U: return VK_FORMAT_R16_UINT; // GL_R16UI + case GlFormat::RG16U: return VK_FORMAT_R16G16_UINT; // GL_RG16UI + case GlFormat::RGB16U: return VK_FORMAT_R16G16B16_UINT; // GL_RGB16UI + case GlFormat::RGBA16U: return VK_FORMAT_R16G16B16A16_UINT; // GL_RGBA16UI + + case GlFormat::R32U: return VK_FORMAT_R32_UINT; // GL_R32UI + case GlFormat::RG32U: return VK_FORMAT_R32G32_UINT; // GL_RG32UI + case GlFormat::RGB32U: return VK_FORMAT_R32G32B32_UINT; // GL_RGB32UI + case GlFormat::RGBA32U: return VK_FORMAT_R32G32B32A32_UINT; // GL_RGBA32UI + + // Signed integer formats + case GlFormat::R8I: return VK_FORMAT_R8_SINT; // GL_R8I + case GlFormat::RG8I: return VK_FORMAT_R8G8_SINT; // GL_RG8I + case GlFormat::RGB8I: return VK_FORMAT_R8G8B8_SINT; // GL_RGB8I + case GlFormat::RGBA8I: return VK_FORMAT_R8G8B8A8_SINT; // GL_RGBA8I + + case GlFormat::R16I: return VK_FORMAT_R16_SINT; // GL_R16I + case GlFormat::RG16I: return VK_FORMAT_R16G16_SINT; // GL_RG16I + case GlFormat::RGB16I: return VK_FORMAT_R16G16B16_SINT; // GL_RGB16I + case GlFormat::RGBA16I: return VK_FORMAT_R16G16B16A16_SINT; // GL_RGBA16I + + case GlFormat::R32I: return VK_FORMAT_R32_SINT; // GL_R32I + case GlFormat::RG32I: return VK_FORMAT_R32G32_SINT; // GL_RG32I + case GlFormat::RGB32I: return VK_FORMAT_R32G32B32_SINT; // GL_RGB32I + case GlFormat::RGBA32I: return VK_FORMAT_R32G32B32A32_SINT; // GL_RGBA32I + + // Floating point formats + case GlFormat::R16F: return VK_FORMAT_R16_SFLOAT; // GL_R16F + case GlFormat::RG16F: return VK_FORMAT_R16G16_SFLOAT; // GL_RG16F + case GlFormat::RGB16F: return VK_FORMAT_R16G16B16_SFLOAT; // GL_RGB16F + case GlFormat::RGBA16F: return VK_FORMAT_R16G16B16A16_SFLOAT; // GL_RGBA16F + + case GlFormat::R32F: return VK_FORMAT_R32_SFLOAT; // GL_R32F + case GlFormat::RG32F: return VK_FORMAT_R32G32_SFLOAT; // GL_RG32F + case GlFormat::RGB32F: return VK_FORMAT_R32G32B32_SFLOAT; // GL_RGB32F + case GlFormat::RGBA32F: return VK_FORMAT_R32G32B32A32_SFLOAT; // GL_RGBA32F + + // Packed formats + case GlFormat::RGB9E5: return VK_FORMAT_E5B9G9R9_UFLOAT_PACK32; // GL_RGB9_E5 + case GlFormat::RG11B10F: return VK_FORMAT_B10G11R11_UFLOAT_PACK32; // GL_R11F_G11F_B10F +// case GlFormat::RG3B2: return VK_FORMAT_R3_G3_B2; // GL_R3_G3_B2 + case GlFormat::R5G6B5: return VK_FORMAT_R5G6B5_UNORM_PACK16; // GL_RGB565 + case GlFormat::RGB5A1: return VK_FORMAT_R5G5B5A1_UNORM_PACK16; // GL_RGB5_A1 + case GlFormat::RGBA4: return VK_FORMAT_R4G4B4A4_UNORM_PACK16; // GL_RGBA4 + case GlFormat::RGB10A2: return VK_FORMAT_A2R10G10B10_UINT_PACK32; // GL_RGB10_A2UI + + // Depth formats +// case Format::D16: return VK_FORMAT_DEPTH_COMPONENT16; // GL_DEPTH_COMPONENT16 +// case Format::D24: return VK_FORMAT_DEPTH_COMPONENT24; // GL_DEPTH_COMPONENT24 +// case Format::D24S8: return VK_FORMAT_DEPTH24_STENCIL8; // GL_DEPTH24_STENCIL8 +// case Format::D32: return VK_FORMAT_DEPTH_COMPONENT32; // GL_DEPTH_COMPONENT32 +// case Format::D32F: return VK_FORMAT_DEPTH_COMPONENT32F; // GL_DEPTH_COMPONENT32F +// case Format::D32FS8X24: return VK_FORMAT_DEPTH32F_STENCIL8; // GL_DEPTH32F_STENCIL8 +// case Format::S8: return VK_FORMAT_STENCIL_INDEX8; // GL_STENCIL_INDEX8 + + // Compressed formats + case GlFormat::RGB_DXT1: return VK_FORMAT_BC1_RGB_UNORM_BLOCK; // GL_COMPRESSED_RGB_S3TC_DXT1_EXT + case GlFormat::RGBA_DXT1: return VK_FORMAT_BC1_RGBA_UNORM_BLOCK; // GL_COMPRESSED_RGBA_S3TC_DXT1_EXT + case GlFormat::RGBA_DXT3: return VK_FORMAT_BC2_UNORM_BLOCK; // GL_COMPRESSED_RGBA_S3TC_DXT3_EXT + case GlFormat::RGBA_DXT5: return VK_FORMAT_BC3_UNORM_BLOCK; // GL_COMPRESSED_RGBA_S3TC_DXT5_EXT + case GlFormat::R_ATI1N_UNorm: return VK_FORMAT_BC4_UNORM_BLOCK; // GL_COMPRESSED_RED_RGTC1 + case GlFormat::R_ATI1N_SNorm: return VK_FORMAT_BC4_SNORM_BLOCK; // GL_COMPRESSED_SIGNED_RED_RGTC1 + case GlFormat::RG_ATI2N_UNorm: return VK_FORMAT_BC5_UNORM_BLOCK; // GL_COMPRESSED_RG_RGTC2 + case GlFormat::RG_ATI2N_SNorm: return VK_FORMAT_BC5_SNORM_BLOCK; // GL_COMPRESSED_SIGNED_RG_RGTC2 + case GlFormat::RGB_BP_UNSIGNED_FLOAT: return VK_FORMAT_BC6H_UFLOAT_BLOCK; // GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB + case GlFormat::RGB_BP_SIGNED_FLOAT: return VK_FORMAT_BC6H_SFLOAT_BLOCK; // GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB + case GlFormat::RGB_BP_UNorm: return VK_FORMAT_BC7_UNORM_BLOCK; // GL_COMPRESSED_RGBA_BPTC_UNORM_ARB + case GlFormat::R11_EAC_UNorm: return VK_FORMAT_EAC_R11_UNORM_BLOCK; // GL_COMPRESSED_R11_EAC + case GlFormat::R11_EAC_SNorm: return VK_FORMAT_EAC_R11_SNORM_BLOCK; // GL_COMPRESSED_SIGNED_R11_EAC + case GlFormat::RG11_EAC_UNorm: return VK_FORMAT_EAC_R11G11_UNORM_BLOCK; // GL_COMPRESSED_RG11_EAC + case GlFormat::RG11_EAC_SNorm: return VK_FORMAT_EAC_R11G11_SNORM_BLOCK; // GL_COMPRESSED_SIGNED_RG11_EAC + case GlFormat::RGB8_ETC2: return VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK; // GL_COMPRESSED_RGB8_ETC2 + case GlFormat::SRGB8_ETC2: return VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ETC2 + case GlFormat::RGB8_PunchThrough_Alpha1_ETC2: return VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK; // GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 + case GlFormat::SRGB8_PunchThrough_Alpha1_ETC2: return VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 + case GlFormat::RGBA8_ETC2_EAC: return VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK; // GL_COMPRESSED_RGBA8_ETC2_EAC + case GlFormat::SRGB8_Alpha8_ETC2_EAC: return VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC +// case GlFormat::RGB8_ETC1: return VK_FORMAT_ETC1_RGB8_OES; // GL_ETC1_RGB8_OES + case GlFormat::RGBA_ASTC_4x4: return VK_FORMAT_ASTC_4x4_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_4x4_KHR + case GlFormat::RGBA_ASTC_5x4: return VK_FORMAT_ASTC_5x4_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_5x4_KHR + case GlFormat::RGBA_ASTC_5x5: return VK_FORMAT_ASTC_5x5_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_5x5_KHR + case GlFormat::RGBA_ASTC_6x5: return VK_FORMAT_ASTC_6x5_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_6x5_KHR + case GlFormat::RGBA_ASTC_6x6: return VK_FORMAT_ASTC_6x6_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_6x6_KHR + case GlFormat::RGBA_ASTC_8x5: return VK_FORMAT_ASTC_8x5_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_8x5_KHR + case GlFormat::RGBA_ASTC_8x6: return VK_FORMAT_ASTC_8x6_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_8x6_KHR + case GlFormat::RGBA_ASTC_8x8: return VK_FORMAT_ASTC_8x8_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_8x8_KHR + case GlFormat::RGBA_ASTC_10x5: return VK_FORMAT_ASTC_10x5_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_10x5_KHR + case GlFormat::RGBA_ASTC_10x6: return VK_FORMAT_ASTC_10x6_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_10x6_KHR + case GlFormat::RGBA_ASTC_10x8: return VK_FORMAT_ASTC_10x8_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_10x8_KHR + case GlFormat::RGBA_ASTC_10x10: return VK_FORMAT_ASTC_10x10_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_10x10_KHR + case GlFormat::RGBA_ASTC_12x10: return VK_FORMAT_ASTC_12x10_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_12x10_KHR + case GlFormat::RGBA_ASTC_12x12: return VK_FORMAT_ASTC_12x12_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_12x12_KHR + case GlFormat::SRGB8_Alpha8_ASTC_4x4: return VK_FORMAT_ASTC_4x4_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR + case GlFormat::SRGB8_Alpha8_ASTC_5x4: return VK_FORMAT_ASTC_5x4_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR + case GlFormat::SRGB8_Alpha8_ASTC_5x5: return VK_FORMAT_ASTC_5x5_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR + case GlFormat::SRGB8_Alpha8_ASTC_6x5: return VK_FORMAT_ASTC_6x5_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR + case GlFormat::SRGB8_Alpha8_ASTC_6x6: return VK_FORMAT_ASTC_6x6_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR + case GlFormat::SRGB8_Alpha8_ASTC_8x5: return VK_FORMAT_ASTC_8x5_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR + case GlFormat::SRGB8_Alpha8_ASTC_8x6: return VK_FORMAT_ASTC_8x6_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR + case GlFormat::SRGB8_Alpha8_ASTC_8x8: return VK_FORMAT_ASTC_8x8_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR + case GlFormat::SRGB8_Alpha8_ASTC_10x5: return VK_FORMAT_ASTC_10x5_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR + case GlFormat::SRGB8_Alpha8_ASTC_10x6: return VK_FORMAT_ASTC_10x6_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR + case GlFormat::SRGB8_Alpha8_ASTC_10x8: return VK_FORMAT_ASTC_10x8_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR + case GlFormat::SRGB8_Alpha8_ASTC_10x10: return VK_FORMAT_ASTC_10x10_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR + case GlFormat::SRGB8_Alpha8_ASTC_12x10: return VK_FORMAT_ASTC_12x10_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR + case GlFormat::SRGB8_Alpha8_ASTC_12x12: return VK_FORMAT_ASTC_12x12_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR + + // sRGB formats + case GlFormat::SRGB8: return VK_FORMAT_R8G8B8_SRGB; // GL_SRGB8 + case GlFormat::SRGB8_Alpha8: return VK_FORMAT_R8G8B8A8_SRGB; // GL_SRGB8_ALPHA8 + case GlFormat::SRGB_DXT1: return VK_FORMAT_BC1_RGB_SRGB_BLOCK; // GL_COMPRESSED_SRGB_S3TC_DXT1_EXT + case GlFormat::SRGB_Alpha_DXT1: return VK_FORMAT_BC1_RGBA_SRGB_BLOCK; // GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT + case GlFormat::SRGB_Alpha_DXT3: return VK_FORMAT_BC2_SRGB_BLOCK; // GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT + case GlFormat::SRGB_Alpha_DXT5: return VK_FORMAT_BC3_SRGB_BLOCK; // GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT + case GlFormat::SRGB_BP_UNorm: return VK_FORMAT_BC7_SRGB_BLOCK; // GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB + + // ES 2 formats +// case GlFormat::DepthFormat: return VK_FORMAT_DEPTH_COMPONENT; // GL_DEPTH_COMPONENT +// case GlFormat::AlphaFormat: return VK_FORMAT_ALPHA; // GL_ALPHA +// case GlFormat::RGBFormat: return VK_FORMAT_RGB; // GL_RGB +// case GlFormat::RGBAFormat: return VK_FORMAT_RGBA; // GL_RGBA +// case GlFormat::LuminanceFormat: return VK_FORMAT_LUMINANCE; // GL_LUMINANCE +// case GlFormat::LuminanceAlphaFormat: return VK_FORMAT; + default: return VK_FORMAT_UNDEFINED; + } +} +#endif + +QT_END_NAMESPACE diff --git a/src/opengl/qvkconvenience_p.h b/src/opengl/qvkconvenience_p.h new file mode 100644 index 0000000000..bc8694979b --- /dev/null +++ b/src/opengl/qvkconvenience_p.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QVKCONVENIENCE_P_H +#define QVKCONVENIENCE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +class Q_OPENGL_EXPORT QVkConvenience +{ +public: +#if QT_CONFIG(opengl) + static VkFormat vkFormatFromGlFormat(uint glFormat); +#endif +}; + +QT_END_NAMESPACE + +#endif // QVKCONVENIENCE_P_H diff --git a/src/platformsupport/CMakeLists.txt b/src/platformsupport/CMakeLists.txt index 0e589ecc86..eb67070d24 100644 --- a/src/platformsupport/CMakeLists.txt +++ b/src/platformsupport/CMakeLists.txt @@ -40,6 +40,3 @@ endif() if(QT_FEATURE_accessibility AND WIN32 AND NOT WINRT) add_subdirectory(windowsuiautomation) endif() -if(QT_FEATURE_vulkan) - add_subdirectory(vkconvenience) -endif() diff --git a/src/platformsupport/platformsupport.pro b/src/platformsupport/platformsupport.pro index fe3f6504fe..7d099b7bbc 100644 --- a/src/platformsupport/platformsupport.pro +++ b/src/platformsupport/platformsupport.pro @@ -37,9 +37,6 @@ qtConfig(accessibility) { win32:!winrt: SUBDIRS += windowsuiautomation } -qtConfig(vulkan): \ - SUBDIRS += vkconvenience - !android:linux*:qtHaveModule(dbus) \ SUBDIRS += linuxofono diff --git a/src/platformsupport/vkconvenience/.prev_CMakeLists.txt b/src/platformsupport/vkconvenience/.prev_CMakeLists.txt deleted file mode 100644 index 6f17cfa306..0000000000 --- a/src/platformsupport/vkconvenience/.prev_CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ -# Generated from vkconvenience.pro. - -##################################################################### -## VulkanSupport Module: -##################################################################### - -qt_add_module(VulkanSupport - STATIC - INTERNAL_MODULE - SOURCES - qbasicvulkanplatforminstance.cpp qbasicvulkanplatforminstance_p.h - qvkconvenience.cpp qvkconvenience_p.h - DEFINES - QT_NO_CAST_FROM_ASCII - PUBLIC_LIBRARIES - Qt::CorePrivate - Qt::GuiPrivate - PRECOMPILED_HEADER - "../../corelib/global/qt_pch.h" -) - -#### Keys ignored in scope 1:.:.:vkconvenience.pro:: -# MODULE = "vulkan_support" - -## Scopes: -##################################################################### - -qt_extend_target(VulkanSupport CONDITION QT_FEATURE_opengl - PUBLIC_LIBRARIES - Qt::OpenGL -) diff --git a/src/platformsupport/vkconvenience/CMakeLists.txt b/src/platformsupport/vkconvenience/CMakeLists.txt deleted file mode 100644 index 6ec2574375..0000000000 --- a/src/platformsupport/vkconvenience/CMakeLists.txt +++ /dev/null @@ -1,33 +0,0 @@ -# Generated from vkconvenience.pro. - -qt_find_package(Vulkan) # special case - -##################################################################### -## VulkanSupport Module: -##################################################################### - -qt_add_module(VulkanSupport - STATIC - INTERNAL_MODULE - SOURCES - qbasicvulkanplatforminstance.cpp qbasicvulkanplatforminstance_p.h - qvkconvenience.cpp qvkconvenience_p.h - DEFINES - QT_NO_CAST_FROM_ASCII - PUBLIC_LIBRARIES - Qt::CorePrivate - Qt::GuiPrivate - PRECOMPILED_HEADER - "../../corelib/global/qt_pch.h" -) - -#### Keys ignored in scope 1:.:.:vkconvenience.pro:: -# MODULE = "vulkan_support" - -## Scopes: -##################################################################### - -qt_extend_target(VulkanSupport CONDITION QT_FEATURE_opengl - PUBLIC_LIBRARIES - Qt::OpenGL -) diff --git a/src/platformsupport/vkconvenience/qbasicvulkanplatforminstance.cpp b/src/platformsupport/vkconvenience/qbasicvulkanplatforminstance.cpp deleted file mode 100644 index 6f6ba58319..0000000000 --- a/src/platformsupport/vkconvenience/qbasicvulkanplatforminstance.cpp +++ /dev/null @@ -1,405 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qbasicvulkanplatforminstance_p.h" -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -Q_LOGGING_CATEGORY(lcPlatVk, "qt.vulkan") - -/*! - \class QBasicPlatformVulkanInstance - \brief A generic platform Vulkan instance implementation. - \since 5.10 - \internal - \ingroup qpa - - Implements QPlatformVulkanInstance, serving as a base for platform-specific - implementations. The library loading and any WSI-specifics are excluded. - - Subclasses are expected to call init() from their constructor and - initInstance() from their createOrAdoptInstance() implementation. - */ - -QBasicPlatformVulkanInstance::QBasicPlatformVulkanInstance() - : m_vkInst(VK_NULL_HANDLE), - m_vkGetInstanceProcAddr(nullptr), - m_ownsVkInst(false), - m_errorCode(VK_SUCCESS), - m_debugCallback(0) -{ -} - -QBasicPlatformVulkanInstance::~QBasicPlatformVulkanInstance() -{ - if (!m_vkInst) - return; - - if (m_debugCallback && m_vkDestroyDebugReportCallbackEXT) - m_vkDestroyDebugReportCallbackEXT(m_vkInst, m_debugCallback, nullptr); - - if (m_ownsVkInst) - m_vkDestroyInstance(m_vkInst, nullptr); -} - -void QBasicPlatformVulkanInstance::loadVulkanLibrary(const QString &defaultLibraryName) -{ - if (qEnvironmentVariableIsSet("QT_VULKAN_LIB")) - m_vulkanLib.setFileName(QString::fromUtf8(qgetenv("QT_VULKAN_LIB"))); - else - m_vulkanLib.setFileName(defaultLibraryName); - - if (!m_vulkanLib.load()) { - qWarning("Failed to load %s: %s", qPrintable(m_vulkanLib.fileName()), qPrintable(m_vulkanLib.errorString())); - return; - } - - init(&m_vulkanLib); -} - -void QBasicPlatformVulkanInstance::init(QLibrary *lib) -{ - if (m_vkGetInstanceProcAddr) - return; - - qCDebug(lcPlatVk, "Vulkan init (%s)", qPrintable(lib->fileName())); - - // While not strictly required with every implementation, try to follow the spec - // and do not rely on core functions being exported. - // - // 1. dlsym vkGetInstanceProcAddr - // 2. with a special null instance resolve vkCreateInstance and vkEnumerateInstance* - // 3. all other core functions are resolved with the created instance - - m_vkGetInstanceProcAddr = reinterpret_cast(lib->resolve("vkGetInstanceProcAddr")); - if (!m_vkGetInstanceProcAddr) { - qWarning("Failed to find vkGetInstanceProcAddr"); - return; - } - - m_vkCreateInstance = reinterpret_cast(m_vkGetInstanceProcAddr(VK_NULL_HANDLE, "vkCreateInstance")); - if (!m_vkCreateInstance) { - qWarning("Failed to find vkCreateInstance"); - return; - } - m_vkEnumerateInstanceLayerProperties = reinterpret_cast( - m_vkGetInstanceProcAddr(VK_NULL_HANDLE, "vkEnumerateInstanceLayerProperties")); - if (!m_vkEnumerateInstanceLayerProperties) { - qWarning("Failed to find vkEnumerateInstanceLayerProperties"); - return; - } - m_vkEnumerateInstanceExtensionProperties = reinterpret_cast( - m_vkGetInstanceProcAddr(VK_NULL_HANDLE, "vkEnumerateInstanceExtensionProperties")); - if (!m_vkEnumerateInstanceExtensionProperties) { - qWarning("Failed to find vkEnumerateInstanceExtensionProperties"); - return; - } - - uint32_t layerCount = 0; - m_vkEnumerateInstanceLayerProperties(&layerCount, nullptr); - if (layerCount) { - QVector layerProps(layerCount); - m_vkEnumerateInstanceLayerProperties(&layerCount, layerProps.data()); - m_supportedLayers.reserve(layerCount); - for (const VkLayerProperties &p : qAsConst(layerProps)) { - QVulkanLayer layer; - layer.name = p.layerName; - layer.version = p.implementationVersion; - layer.specVersion = QVersionNumber(VK_VERSION_MAJOR(p.specVersion), - VK_VERSION_MINOR(p.specVersion), - VK_VERSION_PATCH(p.specVersion)); - layer.description = p.description; - m_supportedLayers.append(layer); - } - } - qCDebug(lcPlatVk) << "Supported Vulkan instance layers:" << m_supportedLayers; - - uint32_t extCount = 0; - m_vkEnumerateInstanceExtensionProperties(nullptr, &extCount, nullptr); - if (extCount) { - QVector extProps(extCount); - m_vkEnumerateInstanceExtensionProperties(nullptr, &extCount, extProps.data()); - m_supportedExtensions.reserve(extCount); - for (const VkExtensionProperties &p : qAsConst(extProps)) { - QVulkanExtension ext; - ext.name = p.extensionName; - ext.version = p.specVersion; - m_supportedExtensions.append(ext); - } - } - qDebug(lcPlatVk) << "Supported Vulkan instance extensions:" << m_supportedExtensions; -} - -QVulkanInfoVector QBasicPlatformVulkanInstance::supportedLayers() const -{ - return m_supportedLayers; -} - -QVulkanInfoVector QBasicPlatformVulkanInstance::supportedExtensions() const -{ - return m_supportedExtensions; -} - -void QBasicPlatformVulkanInstance::initInstance(QVulkanInstance *instance, const QByteArrayList &extraExts) -{ - if (!m_vkGetInstanceProcAddr) { - qWarning("initInstance: No Vulkan library available"); - return; - } - - m_vkInst = instance->vkInstance(); // when non-null we are adopting an existing instance - - QVulkanInstance::Flags flags = instance->flags(); - m_enabledLayers = instance->layers(); - m_enabledExtensions = instance->extensions(); - - if (!m_vkInst) { - VkApplicationInfo appInfo; - memset(&appInfo, 0, sizeof(appInfo)); - appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; - QByteArray appName = QCoreApplication::applicationName().toUtf8(); - appInfo.pApplicationName = appName.constData(); - const QVersionNumber apiVersion = instance->apiVersion(); - if (!apiVersion.isNull()) { - appInfo.apiVersion = VK_MAKE_VERSION(apiVersion.majorVersion(), - apiVersion.minorVersion(), - apiVersion.microVersion()); - } - - if (!flags.testFlag(QVulkanInstance::NoDebugOutputRedirect)) - m_enabledExtensions.append("VK_EXT_debug_report"); - - m_enabledExtensions.append("VK_KHR_surface"); - - for (const QByteArray &ext : extraExts) - m_enabledExtensions.append(ext); - - QByteArray envExts = qgetenv("QT_VULKAN_INSTANCE_EXTENSIONS"); - if (!envExts.isEmpty()) { - QByteArrayList envExtList = envExts.split(';'); - for (auto ext : m_enabledExtensions) - envExtList.removeAll(ext); - m_enabledExtensions.append(envExtList); - } - - QByteArray envLayers = qgetenv("QT_VULKAN_INSTANCE_LAYERS"); - if (!envLayers.isEmpty()) { - QByteArrayList envLayerList = envLayers.split(';'); - for (auto ext : m_enabledLayers) - envLayerList.removeAll(ext); - m_enabledLayers.append(envLayerList); - } - - // No clever stuff with QSet and friends: the order for layers matters - // and the user-provided order must be kept. - for (int i = 0; i < m_enabledLayers.count(); ++i) { - const QByteArray &layerName(m_enabledLayers[i]); - if (!m_supportedLayers.contains(layerName)) - m_enabledLayers.removeAt(i--); - } - qDebug(lcPlatVk) << "Enabling Vulkan instance layers:" << m_enabledLayers; - for (int i = 0; i < m_enabledExtensions.count(); ++i) { - const QByteArray &extName(m_enabledExtensions[i]); - if (!m_supportedExtensions.contains(extName)) - m_enabledExtensions.removeAt(i--); - } - qDebug(lcPlatVk) << "Enabling Vulkan instance extensions:" << m_enabledExtensions; - - VkInstanceCreateInfo instInfo; - memset(&instInfo, 0, sizeof(instInfo)); - instInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; - instInfo.pApplicationInfo = &appInfo; - - QVector layerNameVec; - for (const QByteArray &ba : qAsConst(m_enabledLayers)) - layerNameVec.append(ba.constData()); - if (!layerNameVec.isEmpty()) { - instInfo.enabledLayerCount = layerNameVec.count(); - instInfo.ppEnabledLayerNames = layerNameVec.constData(); - } - - QVector extNameVec; - for (const QByteArray &ba : qAsConst(m_enabledExtensions)) - extNameVec.append(ba.constData()); - if (!extNameVec.isEmpty()) { - instInfo.enabledExtensionCount = extNameVec.count(); - instInfo.ppEnabledExtensionNames = extNameVec.constData(); - } - - m_errorCode = m_vkCreateInstance(&instInfo, nullptr, &m_vkInst); - if (m_errorCode != VK_SUCCESS || !m_vkInst) { - qWarning("Failed to create Vulkan instance: %d", m_errorCode); - return; - } - - m_vkDestroyInstance = reinterpret_cast(m_vkGetInstanceProcAddr(m_vkInst, "vkDestroyInstance")); - if (!m_vkDestroyInstance) { - qWarning("Failed to find vkDestroyInstance"); - m_vkInst = VK_NULL_HANDLE; - return; - } - - m_ownsVkInst = true; - } - - m_getPhysDevSurfaceSupport = reinterpret_cast( - m_vkGetInstanceProcAddr(m_vkInst, "vkGetPhysicalDeviceSurfaceSupportKHR")); - if (!m_getPhysDevSurfaceSupport) - qWarning("Failed to find vkGetPhysicalDeviceSurfaceSupportKHR"); - - m_destroySurface = reinterpret_cast( - m_vkGetInstanceProcAddr(m_vkInst, "vkDestroySurfaceKHR")); - if (!m_destroySurface) - qWarning("Failed to find vkDestroySurfaceKHR"); - - if (!flags.testFlag(QVulkanInstance::NoDebugOutputRedirect)) - setupDebugOutput(); -} - -bool QBasicPlatformVulkanInstance::isValid() const -{ - return m_vkInst != VK_NULL_HANDLE; -} - -VkResult QBasicPlatformVulkanInstance::errorCode() const -{ - return m_errorCode; -} - -VkInstance QBasicPlatformVulkanInstance::vkInstance() const -{ - return m_vkInst; -} - -QByteArrayList QBasicPlatformVulkanInstance::enabledLayers() const -{ - return m_enabledLayers; -} - -QByteArrayList QBasicPlatformVulkanInstance::enabledExtensions() const -{ - return m_enabledExtensions; -} - -PFN_vkVoidFunction QBasicPlatformVulkanInstance::getInstanceProcAddr(const char *name) -{ - if (!name) - return nullptr; - - const bool needsNullInstance = !strcmp(name, "vkEnumerateInstanceLayerProperties") - || !strcmp(name, "vkEnumerateInstanceExtensionProperties"); - - return m_vkGetInstanceProcAddr(needsNullInstance ? 0 : m_vkInst, name); -} - -bool QBasicPlatformVulkanInstance::supportsPresent(VkPhysicalDevice physicalDevice, - uint32_t queueFamilyIndex, - QWindow *window) -{ - if (!m_getPhysDevSurfaceSupport) - return true; - - VkSurfaceKHR surface = QVulkanInstance::surfaceForWindow(window); - VkBool32 supported = false; - m_getPhysDevSurfaceSupport(physicalDevice, queueFamilyIndex, surface, &supported); - - return supported; -} - -void QBasicPlatformVulkanInstance::setDebugFilters(const QVector &filters) -{ - m_debugFilters = filters; -} - -void QBasicPlatformVulkanInstance::destroySurface(VkSurfaceKHR surface) const -{ - if (m_destroySurface && surface) - m_destroySurface(m_vkInst, surface, nullptr); -} - -static VKAPI_ATTR VkBool32 VKAPI_CALL defaultDebugCallbackFunc(VkDebugReportFlagsEXT flags, - VkDebugReportObjectTypeEXT objectType, - uint64_t object, - size_t location, - int32_t messageCode, - const char *pLayerPrefix, - const char *pMessage, - void *pUserData) -{ - QBasicPlatformVulkanInstance *self = static_cast(pUserData); - for (QVulkanInstance::DebugFilter filter : *self->debugFilters()) { - if (filter(flags, objectType, object, location, messageCode, pLayerPrefix, pMessage)) - return VK_FALSE; - } - - // not categorized, just route to plain old qDebug - qDebug("vkDebug: %s: %d: %s", pLayerPrefix, messageCode, pMessage); - - return VK_FALSE; -} - -void QBasicPlatformVulkanInstance::setupDebugOutput() -{ - if (!m_enabledExtensions.contains("VK_EXT_debug_report")) - return; - - PFN_vkCreateDebugReportCallbackEXT createDebugReportCallback = reinterpret_cast( - m_vkGetInstanceProcAddr(m_vkInst, "vkCreateDebugReportCallbackEXT")); - m_vkDestroyDebugReportCallbackEXT = reinterpret_cast( - m_vkGetInstanceProcAddr(m_vkInst, "vkDestroyDebugReportCallbackEXT")); - - VkDebugReportCallbackCreateInfoEXT dbgCallbackInfo; - memset(&dbgCallbackInfo, 0, sizeof(dbgCallbackInfo)); - dbgCallbackInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT; - dbgCallbackInfo.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT - | VK_DEBUG_REPORT_WARNING_BIT_EXT - | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT; - dbgCallbackInfo.pfnCallback = defaultDebugCallbackFunc; - dbgCallbackInfo.pUserData = this; - - VkResult err = createDebugReportCallback(m_vkInst, &dbgCallbackInfo, nullptr, &m_debugCallback); - if (err != VK_SUCCESS) - qWarning("Failed to create debug report callback: %d", err); -} - -QT_END_NAMESPACE diff --git a/src/platformsupport/vkconvenience/qbasicvulkanplatforminstance_p.h b/src/platformsupport/vkconvenience/qbasicvulkanplatforminstance_p.h deleted file mode 100644 index e59d9219fb..0000000000 --- a/src/platformsupport/vkconvenience/qbasicvulkanplatforminstance_p.h +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QBASICVULKANPLATFORMINSTANCE_P_H -#define QBASICVULKANPLATFORMINSTANCE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include - -QT_BEGIN_NAMESPACE - -class QLibrary; - -class QBasicPlatformVulkanInstance : public QPlatformVulkanInstance -{ -public: - QBasicPlatformVulkanInstance(); - ~QBasicPlatformVulkanInstance(); - - QVulkanInfoVector supportedLayers() const override; - QVulkanInfoVector supportedExtensions() const override; - bool isValid() const override; - VkResult errorCode() const override; - VkInstance vkInstance() const override; - QByteArrayList enabledLayers() const override; - QByteArrayList enabledExtensions() const override; - PFN_vkVoidFunction getInstanceProcAddr(const char *name) override; - bool supportsPresent(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, QWindow *window) override; - void setDebugFilters(const QVector &filters) override; - - void destroySurface(VkSurfaceKHR surface) const; - const QVector *debugFilters() const { return &m_debugFilters; } - -protected: - void loadVulkanLibrary(const QString &defaultLibraryName); - void init(QLibrary *lib); - void initInstance(QVulkanInstance *instance, const QByteArrayList &extraExts); - - VkInstance m_vkInst; - PFN_vkGetInstanceProcAddr m_vkGetInstanceProcAddr; - PFN_vkGetPhysicalDeviceSurfaceSupportKHR m_getPhysDevSurfaceSupport; - PFN_vkDestroySurfaceKHR m_destroySurface; - -private: - void setupDebugOutput(); - - QLibrary m_vulkanLib; - - bool m_ownsVkInst; - VkResult m_errorCode; - QVulkanInfoVector m_supportedLayers; - QVulkanInfoVector m_supportedExtensions; - QByteArrayList m_enabledLayers; - QByteArrayList m_enabledExtensions; - - PFN_vkCreateInstance m_vkCreateInstance; - PFN_vkEnumerateInstanceLayerProperties m_vkEnumerateInstanceLayerProperties; - PFN_vkEnumerateInstanceExtensionProperties m_vkEnumerateInstanceExtensionProperties; - - PFN_vkDestroyInstance m_vkDestroyInstance; - - VkDebugReportCallbackEXT m_debugCallback; - PFN_vkDestroyDebugReportCallbackEXT m_vkDestroyDebugReportCallbackEXT; - QVector m_debugFilters; -}; - -QT_END_NAMESPACE - -#endif // QBASICVULKANPLATFORMINSTANCE_P_H diff --git a/src/platformsupport/vkconvenience/qvkconvenience.cpp b/src/platformsupport/vkconvenience/qvkconvenience.cpp deleted file mode 100644 index 59de335333..0000000000 --- a/src/platformsupport/vkconvenience/qvkconvenience.cpp +++ /dev/null @@ -1,219 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qvkconvenience_p.h" - -#if QT_CONFIG(opengl) -#include -#endif - -QT_BEGIN_NAMESPACE - -/*! - \class QVkConvenience - \brief A collection of static helper functions for Vulkan support - \since 5.14 - \internal - \ingroup qpa - */ - -#if QT_CONFIG(opengl) -VkFormat QVkConvenience::vkFormatFromGlFormat(uint glFormat) -{ - using GlFormat = QOpenGLTexture::TextureFormat; - switch (glFormat) { - case GlFormat::NoFormat: return VK_FORMAT_UNDEFINED; // GL_NONE - - // Unsigned normalized formats - case GlFormat::R8_UNorm: return VK_FORMAT_R8_UNORM; // GL_R8 - case GlFormat::RG8_UNorm: return VK_FORMAT_R8G8_UNORM; // GL_RG8 - case GlFormat::RGB8_UNorm: return VK_FORMAT_R8G8B8_UNORM; // GL_RGB8 - case GlFormat::RGBA8_UNorm: return VK_FORMAT_R8G8B8A8_UNORM; // GL_RGBA8 - - case GlFormat::R16_UNorm: return VK_FORMAT_R16_UNORM; // GL_R16 - case GlFormat::RG16_UNorm: return VK_FORMAT_R16G16_UNORM; // GL_RG16 - case GlFormat::RGB16_UNorm: return VK_FORMAT_R16G16B16_UNORM; // GL_RGB16 - case GlFormat::RGBA16_UNorm: return VK_FORMAT_R16G16B16A16_UNORM; // GL_RGBA16 - - // Signed normalized formats - case GlFormat::R8_SNorm: return VK_FORMAT_R8_SNORM; // GL_R8_SNORM - case GlFormat::RG8_SNorm: return VK_FORMAT_R8G8_SNORM; // GL_RG8_SNORM - case GlFormat::RGB8_SNorm: return VK_FORMAT_R8G8B8_SNORM; // GL_RGB8_SNORM - case GlFormat::RGBA8_SNorm: return VK_FORMAT_R8G8B8A8_SNORM; // GL_RGBA8_SNORM - - case GlFormat::R16_SNorm: return VK_FORMAT_R16_SNORM; // GL_R16_SNORM - case GlFormat::RG16_SNorm: return VK_FORMAT_R16G16_SNORM; // GL_RG16_SNORM - case GlFormat::RGB16_SNorm: return VK_FORMAT_R16G16B16_SNORM; // GL_RGB16_SNORM - case GlFormat::RGBA16_SNorm: return VK_FORMAT_R16G16B16A16_SNORM; // GL_RGBA16_SNORM - - // Unsigned integer formats - case GlFormat::R8U: return VK_FORMAT_R8_UINT; // GL_R8UI - case GlFormat::RG8U: return VK_FORMAT_R8G8_UINT; // GL_RG8UI - case GlFormat::RGB8U: return VK_FORMAT_R8G8B8_UINT; // GL_RGB8UI - case GlFormat::RGBA8U: return VK_FORMAT_R8G8B8A8_UINT; // GL_RGBA8UI - - case GlFormat::R16U: return VK_FORMAT_R16_UINT; // GL_R16UI - case GlFormat::RG16U: return VK_FORMAT_R16G16_UINT; // GL_RG16UI - case GlFormat::RGB16U: return VK_FORMAT_R16G16B16_UINT; // GL_RGB16UI - case GlFormat::RGBA16U: return VK_FORMAT_R16G16B16A16_UINT; // GL_RGBA16UI - - case GlFormat::R32U: return VK_FORMAT_R32_UINT; // GL_R32UI - case GlFormat::RG32U: return VK_FORMAT_R32G32_UINT; // GL_RG32UI - case GlFormat::RGB32U: return VK_FORMAT_R32G32B32_UINT; // GL_RGB32UI - case GlFormat::RGBA32U: return VK_FORMAT_R32G32B32A32_UINT; // GL_RGBA32UI - - // Signed integer formats - case GlFormat::R8I: return VK_FORMAT_R8_SINT; // GL_R8I - case GlFormat::RG8I: return VK_FORMAT_R8G8_SINT; // GL_RG8I - case GlFormat::RGB8I: return VK_FORMAT_R8G8B8_SINT; // GL_RGB8I - case GlFormat::RGBA8I: return VK_FORMAT_R8G8B8A8_SINT; // GL_RGBA8I - - case GlFormat::R16I: return VK_FORMAT_R16_SINT; // GL_R16I - case GlFormat::RG16I: return VK_FORMAT_R16G16_SINT; // GL_RG16I - case GlFormat::RGB16I: return VK_FORMAT_R16G16B16_SINT; // GL_RGB16I - case GlFormat::RGBA16I: return VK_FORMAT_R16G16B16A16_SINT; // GL_RGBA16I - - case GlFormat::R32I: return VK_FORMAT_R32_SINT; // GL_R32I - case GlFormat::RG32I: return VK_FORMAT_R32G32_SINT; // GL_RG32I - case GlFormat::RGB32I: return VK_FORMAT_R32G32B32_SINT; // GL_RGB32I - case GlFormat::RGBA32I: return VK_FORMAT_R32G32B32A32_SINT; // GL_RGBA32I - - // Floating point formats - case GlFormat::R16F: return VK_FORMAT_R16_SFLOAT; // GL_R16F - case GlFormat::RG16F: return VK_FORMAT_R16G16_SFLOAT; // GL_RG16F - case GlFormat::RGB16F: return VK_FORMAT_R16G16B16_SFLOAT; // GL_RGB16F - case GlFormat::RGBA16F: return VK_FORMAT_R16G16B16A16_SFLOAT; // GL_RGBA16F - - case GlFormat::R32F: return VK_FORMAT_R32_SFLOAT; // GL_R32F - case GlFormat::RG32F: return VK_FORMAT_R32G32_SFLOAT; // GL_RG32F - case GlFormat::RGB32F: return VK_FORMAT_R32G32B32_SFLOAT; // GL_RGB32F - case GlFormat::RGBA32F: return VK_FORMAT_R32G32B32A32_SFLOAT; // GL_RGBA32F - - // Packed formats - case GlFormat::RGB9E5: return VK_FORMAT_E5B9G9R9_UFLOAT_PACK32; // GL_RGB9_E5 - case GlFormat::RG11B10F: return VK_FORMAT_B10G11R11_UFLOAT_PACK32; // GL_R11F_G11F_B10F -// case GlFormat::RG3B2: return VK_FORMAT_R3_G3_B2; // GL_R3_G3_B2 - case GlFormat::R5G6B5: return VK_FORMAT_R5G6B5_UNORM_PACK16; // GL_RGB565 - case GlFormat::RGB5A1: return VK_FORMAT_R5G5B5A1_UNORM_PACK16; // GL_RGB5_A1 - case GlFormat::RGBA4: return VK_FORMAT_R4G4B4A4_UNORM_PACK16; // GL_RGBA4 - case GlFormat::RGB10A2: return VK_FORMAT_A2R10G10B10_UINT_PACK32; // GL_RGB10_A2UI - - // Depth formats -// case Format::D16: return VK_FORMAT_DEPTH_COMPONENT16; // GL_DEPTH_COMPONENT16 -// case Format::D24: return VK_FORMAT_DEPTH_COMPONENT24; // GL_DEPTH_COMPONENT24 -// case Format::D24S8: return VK_FORMAT_DEPTH24_STENCIL8; // GL_DEPTH24_STENCIL8 -// case Format::D32: return VK_FORMAT_DEPTH_COMPONENT32; // GL_DEPTH_COMPONENT32 -// case Format::D32F: return VK_FORMAT_DEPTH_COMPONENT32F; // GL_DEPTH_COMPONENT32F -// case Format::D32FS8X24: return VK_FORMAT_DEPTH32F_STENCIL8; // GL_DEPTH32F_STENCIL8 -// case Format::S8: return VK_FORMAT_STENCIL_INDEX8; // GL_STENCIL_INDEX8 - - // Compressed formats - case GlFormat::RGB_DXT1: return VK_FORMAT_BC1_RGB_UNORM_BLOCK; // GL_COMPRESSED_RGB_S3TC_DXT1_EXT - case GlFormat::RGBA_DXT1: return VK_FORMAT_BC1_RGBA_UNORM_BLOCK; // GL_COMPRESSED_RGBA_S3TC_DXT1_EXT - case GlFormat::RGBA_DXT3: return VK_FORMAT_BC2_UNORM_BLOCK; // GL_COMPRESSED_RGBA_S3TC_DXT3_EXT - case GlFormat::RGBA_DXT5: return VK_FORMAT_BC3_UNORM_BLOCK; // GL_COMPRESSED_RGBA_S3TC_DXT5_EXT - case GlFormat::R_ATI1N_UNorm: return VK_FORMAT_BC4_UNORM_BLOCK; // GL_COMPRESSED_RED_RGTC1 - case GlFormat::R_ATI1N_SNorm: return VK_FORMAT_BC4_SNORM_BLOCK; // GL_COMPRESSED_SIGNED_RED_RGTC1 - case GlFormat::RG_ATI2N_UNorm: return VK_FORMAT_BC5_UNORM_BLOCK; // GL_COMPRESSED_RG_RGTC2 - case GlFormat::RG_ATI2N_SNorm: return VK_FORMAT_BC5_SNORM_BLOCK; // GL_COMPRESSED_SIGNED_RG_RGTC2 - case GlFormat::RGB_BP_UNSIGNED_FLOAT: return VK_FORMAT_BC6H_UFLOAT_BLOCK; // GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB - case GlFormat::RGB_BP_SIGNED_FLOAT: return VK_FORMAT_BC6H_SFLOAT_BLOCK; // GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB - case GlFormat::RGB_BP_UNorm: return VK_FORMAT_BC7_UNORM_BLOCK; // GL_COMPRESSED_RGBA_BPTC_UNORM_ARB - case GlFormat::R11_EAC_UNorm: return VK_FORMAT_EAC_R11_UNORM_BLOCK; // GL_COMPRESSED_R11_EAC - case GlFormat::R11_EAC_SNorm: return VK_FORMAT_EAC_R11_SNORM_BLOCK; // GL_COMPRESSED_SIGNED_R11_EAC - case GlFormat::RG11_EAC_UNorm: return VK_FORMAT_EAC_R11G11_UNORM_BLOCK; // GL_COMPRESSED_RG11_EAC - case GlFormat::RG11_EAC_SNorm: return VK_FORMAT_EAC_R11G11_SNORM_BLOCK; // GL_COMPRESSED_SIGNED_RG11_EAC - case GlFormat::RGB8_ETC2: return VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK; // GL_COMPRESSED_RGB8_ETC2 - case GlFormat::SRGB8_ETC2: return VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ETC2 - case GlFormat::RGB8_PunchThrough_Alpha1_ETC2: return VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK; // GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 - case GlFormat::SRGB8_PunchThrough_Alpha1_ETC2: return VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 - case GlFormat::RGBA8_ETC2_EAC: return VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK; // GL_COMPRESSED_RGBA8_ETC2_EAC - case GlFormat::SRGB8_Alpha8_ETC2_EAC: return VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC -// case GlFormat::RGB8_ETC1: return VK_FORMAT_ETC1_RGB8_OES; // GL_ETC1_RGB8_OES - case GlFormat::RGBA_ASTC_4x4: return VK_FORMAT_ASTC_4x4_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_4x4_KHR - case GlFormat::RGBA_ASTC_5x4: return VK_FORMAT_ASTC_5x4_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_5x4_KHR - case GlFormat::RGBA_ASTC_5x5: return VK_FORMAT_ASTC_5x5_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_5x5_KHR - case GlFormat::RGBA_ASTC_6x5: return VK_FORMAT_ASTC_6x5_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_6x5_KHR - case GlFormat::RGBA_ASTC_6x6: return VK_FORMAT_ASTC_6x6_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_6x6_KHR - case GlFormat::RGBA_ASTC_8x5: return VK_FORMAT_ASTC_8x5_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_8x5_KHR - case GlFormat::RGBA_ASTC_8x6: return VK_FORMAT_ASTC_8x6_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_8x6_KHR - case GlFormat::RGBA_ASTC_8x8: return VK_FORMAT_ASTC_8x8_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_8x8_KHR - case GlFormat::RGBA_ASTC_10x5: return VK_FORMAT_ASTC_10x5_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_10x5_KHR - case GlFormat::RGBA_ASTC_10x6: return VK_FORMAT_ASTC_10x6_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_10x6_KHR - case GlFormat::RGBA_ASTC_10x8: return VK_FORMAT_ASTC_10x8_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_10x8_KHR - case GlFormat::RGBA_ASTC_10x10: return VK_FORMAT_ASTC_10x10_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_10x10_KHR - case GlFormat::RGBA_ASTC_12x10: return VK_FORMAT_ASTC_12x10_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_12x10_KHR - case GlFormat::RGBA_ASTC_12x12: return VK_FORMAT_ASTC_12x12_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_12x12_KHR - case GlFormat::SRGB8_Alpha8_ASTC_4x4: return VK_FORMAT_ASTC_4x4_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR - case GlFormat::SRGB8_Alpha8_ASTC_5x4: return VK_FORMAT_ASTC_5x4_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR - case GlFormat::SRGB8_Alpha8_ASTC_5x5: return VK_FORMAT_ASTC_5x5_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR - case GlFormat::SRGB8_Alpha8_ASTC_6x5: return VK_FORMAT_ASTC_6x5_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR - case GlFormat::SRGB8_Alpha8_ASTC_6x6: return VK_FORMAT_ASTC_6x6_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR - case GlFormat::SRGB8_Alpha8_ASTC_8x5: return VK_FORMAT_ASTC_8x5_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR - case GlFormat::SRGB8_Alpha8_ASTC_8x6: return VK_FORMAT_ASTC_8x6_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR - case GlFormat::SRGB8_Alpha8_ASTC_8x8: return VK_FORMAT_ASTC_8x8_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR - case GlFormat::SRGB8_Alpha8_ASTC_10x5: return VK_FORMAT_ASTC_10x5_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR - case GlFormat::SRGB8_Alpha8_ASTC_10x6: return VK_FORMAT_ASTC_10x6_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR - case GlFormat::SRGB8_Alpha8_ASTC_10x8: return VK_FORMAT_ASTC_10x8_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR - case GlFormat::SRGB8_Alpha8_ASTC_10x10: return VK_FORMAT_ASTC_10x10_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR - case GlFormat::SRGB8_Alpha8_ASTC_12x10: return VK_FORMAT_ASTC_12x10_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR - case GlFormat::SRGB8_Alpha8_ASTC_12x12: return VK_FORMAT_ASTC_12x12_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR - - // sRGB formats - case GlFormat::SRGB8: return VK_FORMAT_R8G8B8_SRGB; // GL_SRGB8 - case GlFormat::SRGB8_Alpha8: return VK_FORMAT_R8G8B8A8_SRGB; // GL_SRGB8_ALPHA8 - case GlFormat::SRGB_DXT1: return VK_FORMAT_BC1_RGB_SRGB_BLOCK; // GL_COMPRESSED_SRGB_S3TC_DXT1_EXT - case GlFormat::SRGB_Alpha_DXT1: return VK_FORMAT_BC1_RGBA_SRGB_BLOCK; // GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT - case GlFormat::SRGB_Alpha_DXT3: return VK_FORMAT_BC2_SRGB_BLOCK; // GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT - case GlFormat::SRGB_Alpha_DXT5: return VK_FORMAT_BC3_SRGB_BLOCK; // GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT - case GlFormat::SRGB_BP_UNorm: return VK_FORMAT_BC7_SRGB_BLOCK; // GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB - - // ES 2 formats -// case GlFormat::DepthFormat: return VK_FORMAT_DEPTH_COMPONENT; // GL_DEPTH_COMPONENT -// case GlFormat::AlphaFormat: return VK_FORMAT_ALPHA; // GL_ALPHA -// case GlFormat::RGBFormat: return VK_FORMAT_RGB; // GL_RGB -// case GlFormat::RGBAFormat: return VK_FORMAT_RGBA; // GL_RGBA -// case GlFormat::LuminanceFormat: return VK_FORMAT_LUMINANCE; // GL_LUMINANCE -// case GlFormat::LuminanceAlphaFormat: return VK_FORMAT; - default: return VK_FORMAT_UNDEFINED; - } -} -#endif - -QT_END_NAMESPACE diff --git a/src/platformsupport/vkconvenience/qvkconvenience_p.h b/src/platformsupport/vkconvenience/qvkconvenience_p.h deleted file mode 100644 index 580271b593..0000000000 --- a/src/platformsupport/vkconvenience/qvkconvenience_p.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QVKCONVENIENCE_P_H -#define QVKCONVENIENCE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include - -QT_BEGIN_NAMESPACE - -class QVkConvenience -{ -public: -#if QT_CONFIG(opengl) - static VkFormat vkFormatFromGlFormat(uint glFormat); -#endif -}; - -QT_END_NAMESPACE - -#endif // QVKCONVENIENCE_P_H diff --git a/src/platformsupport/vkconvenience/vkconvenience.pro b/src/platformsupport/vkconvenience/vkconvenience.pro deleted file mode 100644 index f3ada5768a..0000000000 --- a/src/platformsupport/vkconvenience/vkconvenience.pro +++ /dev/null @@ -1,20 +0,0 @@ -TARGET = QtVulkanSupport -MODULE = vulkan_support - -QT = core-private gui-private -qtConfig(opengl): QT += opengl - -CONFIG += static internal_module - -DEFINES += QT_NO_CAST_FROM_ASCII -PRECOMPILED_HEADER = ../../corelib/global/qt_pch.h - -SOURCES += \ - qvkconvenience.cpp \ - qbasicvulkanplatforminstance.cpp - -HEADERS += \ - qvkconvenience_p.h \ - qbasicvulkanplatforminstance_p.h - -load(qt_module) diff --git a/src/plugins/platforms/android/CMakeLists.txt b/src/plugins/platforms/android/CMakeLists.txt index 6333e51e03..c61d8653c7 100644 --- a/src/plugins/platforms/android/CMakeLists.txt +++ b/src/plugins/platforms/android/CMakeLists.txt @@ -74,8 +74,6 @@ qt_extend_target(QAndroidIntegrationPlugin CONDITION QT_FEATURE_vulkan SOURCES qandroidplatformvulkaninstance.cpp qandroidplatformvulkaninstance.h qandroidplatformvulkanwindow.cpp qandroidplatformvulkanwindow.h - PUBLIC_LIBRARIES - Qt::VulkanSupportPrivate ) qt_extend_target(QAndroidIntegrationPlugin CONDITION TARGET Qt::PlatformCompositorSupportPrivate diff --git a/src/plugins/platforms/android/android.pro b/src/plugins/platforms/android/android.pro index 8ea78f7cba..2baf04addd 100644 --- a/src/plugins/platforms/android/android.pro +++ b/src/plugins/platforms/android/android.pro @@ -7,8 +7,6 @@ QT += \ eventdispatcher_support-private accessibility_support-private \ fontdatabase_support-private egl_support-private -qtConfig(vulkan): QT += vulkan_support-private - qtHaveModule(platformcompositor_support-private): QT += platformcompositor_support-private OTHER_FILES += $$PWD/android.json diff --git a/src/plugins/platforms/android/qandroidplatformvulkaninstance.h b/src/plugins/platforms/android/qandroidplatformvulkaninstance.h index 67edcceed9..80f73215ad 100644 --- a/src/plugins/platforms/android/qandroidplatformvulkaninstance.h +++ b/src/plugins/platforms/android/qandroidplatformvulkaninstance.h @@ -40,7 +40,7 @@ #ifndef QANDROIDPLATFORMVULKANINSTANCE_H #define QANDROIDPLATFORMVULKANINSTANCE_H -#include +#include #include QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/cocoa/CMakeLists.txt b/src/plugins/platforms/cocoa/CMakeLists.txt index c79a320318..14244a6dac 100644 --- a/src/plugins/platforms/cocoa/CMakeLists.txt +++ b/src/plugins/platforms/cocoa/CMakeLists.txt @@ -93,8 +93,6 @@ qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_opengl qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_vulkan SOURCES qcocoavulkaninstance.h qcocoavulkaninstance.mm - PUBLIC_LIBRARIES - Qt::VulkanSupportPrivate ) qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_accessibility diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro index 2fa6b67747..be75cf3f51 100644 --- a/src/plugins/platforms/cocoa/cocoa.pro +++ b/src/plugins/platforms/cocoa/cocoa.pro @@ -99,8 +99,6 @@ QT += \ theme_support-private \ fontdatabase_support-private -qtConfig(vulkan): QT += vulkan_support-private - qtHaveModule(platformcompositor_support-private): QT += platformcompositor_support-private CONFIG += no_app_extension_api_only diff --git a/src/plugins/platforms/cocoa/qcocoavulkaninstance.h b/src/plugins/platforms/cocoa/qcocoavulkaninstance.h index 2a8d04757e..e6b69ba54f 100644 --- a/src/plugins/platforms/cocoa/qcocoavulkaninstance.h +++ b/src/plugins/platforms/cocoa/qcocoavulkaninstance.h @@ -47,7 +47,7 @@ #include #include -#include +#include #include diff --git a/src/plugins/platforms/direct2d/direct2d.pro b/src/plugins/platforms/direct2d/direct2d.pro index 6e73bd14f9..a68e1f10ff 100644 --- a/src/plugins/platforms/direct2d/direct2d.pro +++ b/src/plugins/platforms/direct2d/direct2d.pro @@ -6,7 +6,6 @@ QT += \ fontdatabase_support-private theme_support-private qtConfig(accessibility): QT += accessibility_support-private -qtConfig(vulkan): QT += vulkan_support-private LIBS += -ldwmapi -lversion QMAKE_USE_PRIVATE += gdi32 dwrite_1 d2d1_1 d3d11_1 dxgi1_2 diff --git a/src/plugins/platforms/eglfs/CMakeLists.txt b/src/plugins/platforms/eglfs/CMakeLists.txt index 0078c1f0d7..cef9b94859 100644 --- a/src/plugins/platforms/eglfs/CMakeLists.txt +++ b/src/plugins/platforms/eglfs/CMakeLists.txt @@ -53,8 +53,6 @@ qt_extend_target(EglFSDeviceIntegration CONDITION QT_FEATURE_vulkan SOURCES api/vulkan/qeglfsvulkaninstance.cpp api/vulkan/qeglfsvulkaninstance_p.h api/vulkan/qeglfsvulkanwindow.cpp api/vulkan/qeglfsvulkanwindow_p.h - PUBLIC_LIBRARIES - Qt::VulkanSupportPrivate ) # special case: diff --git a/src/plugins/platforms/eglfs/api/vulkan/qeglfsvulkaninstance_p.h b/src/plugins/platforms/eglfs/api/vulkan/qeglfsvulkaninstance_p.h index 9d6d47f439..7715cc37c0 100644 --- a/src/plugins/platforms/eglfs/api/vulkan/qeglfsvulkaninstance_p.h +++ b/src/plugins/platforms/eglfs/api/vulkan/qeglfsvulkaninstance_p.h @@ -52,7 +52,7 @@ // #include "qeglfsglobal_p.h" -#include +#include QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/eglfs/eglfsdeviceintegration.pro b/src/plugins/platforms/eglfs/eglfsdeviceintegration.pro index bd02aea4d3..8bb7b614f1 100644 --- a/src/plugins/platforms/eglfs/eglfsdeviceintegration.pro +++ b/src/plugins/platforms/eglfs/eglfsdeviceintegration.pro @@ -20,9 +20,6 @@ qtHaveModule(input_support-private): \ qtHaveModule(platformcompositor_support-private): \ QT += platformcompositor_support-private -qtConfig(vulkan): \ - QT += vulkan_support-private - # Avoid X11 header collision, use generic EGL native types DEFINES += QT_EGL_NO_X11 diff --git a/src/plugins/platforms/windows/CMakeLists.txt b/src/plugins/platforms/windows/CMakeLists.txt index b8655ac69d..ba39c7567d 100644 --- a/src/plugins/platforms/windows/CMakeLists.txt +++ b/src/plugins/platforms/windows/CMakeLists.txt @@ -120,8 +120,6 @@ qt_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_accessibility qt_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_vulkan SOURCES qwindowsvulkaninstance.cpp qwindowsvulkaninstance.h - PUBLIC_LIBRARIES - Qt::VulkanSupportPrivate ) qt_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_directwrite3 diff --git a/src/plugins/platforms/windows/qwindowsvulkaninstance.h b/src/plugins/platforms/windows/qwindowsvulkaninstance.h index cc7ef476d4..4b9293cc64 100644 --- a/src/plugins/platforms/windows/qwindowsvulkaninstance.h +++ b/src/plugins/platforms/windows/qwindowsvulkaninstance.h @@ -46,7 +46,7 @@ #define VK_USE_PLATFORM_WIN32_KHR -#include +#include #include QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/windows/windows.pro b/src/plugins/platforms/windows/windows.pro index b14969cc3a..ff5201e290 100644 --- a/src/plugins/platforms/windows/windows.pro +++ b/src/plugins/platforms/windows/windows.pro @@ -8,7 +8,6 @@ QT += \ qtHaveModule(platformcompositor_support-private): QT += platformcompositor_support-private qtConfig(accessibility): QT += accessibility_support-private -qtConfig(vulkan): QT += vulkan_support-private qtConfig(directwrite3): DEFINES *= QT_USE_DIRECTWRITE2 QT_USE_DIRECTWRITE3 diff --git a/src/plugins/platforms/xcb/CMakeLists.txt b/src/plugins/platforms/xcb/CMakeLists.txt index a7cb58ba29..278ef82cb8 100644 --- a/src/plugins/platforms/xcb/CMakeLists.txt +++ b/src/plugins/platforms/xcb/CMakeLists.txt @@ -81,8 +81,6 @@ qt_extend_target(XcbQpa CONDITION QT_FEATURE_vulkan SOURCES qxcbvulkaninstance.cpp qxcbvulkaninstance.h qxcbvulkanwindow.cpp qxcbvulkanwindow.h - PUBLIC_LIBRARIES - Qt::VulkanSupportPrivate ) qt_extend_target(XcbQpa CONDITION QT_FEATURE_glib diff --git a/src/plugins/platforms/xcb/qxcbvulkaninstance.h b/src/plugins/platforms/xcb/qxcbvulkaninstance.h index 53f7345254..abf8935e6a 100644 --- a/src/plugins/platforms/xcb/qxcbvulkaninstance.h +++ b/src/plugins/platforms/xcb/qxcbvulkaninstance.h @@ -46,7 +46,7 @@ #define VK_USE_PLATFORM_XCB_KHR -#include +#include #include QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/xcb/xcb_qpa_lib.pro b/src/plugins/platforms/xcb/xcb_qpa_lib.pro index 1f651e7697..8154d300b1 100644 --- a/src/plugins/platforms/xcb/xcb_qpa_lib.pro +++ b/src/plugins/platforms/xcb/xcb_qpa_lib.pro @@ -15,8 +15,6 @@ qtHaveModule(platformcompositor_support-private): \ qtHaveModule(linuxaccessibility_support-private): \ QT += linuxaccessibility_support-private -qtConfig(vulkan): QT += vulkan_support-private - qtConfig(glib) : QMAKE_USE_PRIVATE += glib SOURCES = \ -- cgit v1.2.3