Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qcocoavulkaninstance.mm
Go to the documentation of this file.
1// Copyright (C) 2018 The Qt Company Ltd.
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 <AppKit/AppKit.h>
5
7#include "qcocoawindow.h"
8
10
12 : m_instance(instance)
13{
15}
16
20
22{
23 initInstance(m_instance, QByteArrayList() << QByteArrayLiteral("VK_MVK_macos_surface"));
24}
25
27{
28 QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow *>(window->handle());
29 if (!cocoaWindow->m_vulkanSurface)
30 cocoaWindow->m_vulkanSurface = createSurface(cocoaWindow->m_view);
31 return &cocoaWindow->m_vulkanSurface;
32}
33
34VkSurfaceKHR QCocoaVulkanInstance::createSurface(NSView *view)
35{
36 if (!m_createSurface) {
37 m_createSurface = reinterpret_cast<PFN_vkCreateMacOSSurfaceMVK>(
38 m_vkGetInstanceProcAddr(m_vkInst, "vkCreateMacOSSurfaceMVK"));
39 }
40 if (!m_createSurface) {
41 qWarning("Failed to find vkCreateMacOSSurfaceMVK");
42 return m_nullSurface;
43 }
44
45 VkMacOSSurfaceCreateInfoMVK surfaceInfo;
46 surfaceInfo.sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK;
47 surfaceInfo.pNext = nullptr;
48 surfaceInfo.flags = 0;
49 surfaceInfo.pView = view.layer;
50
51 VkSurfaceKHR surface = nullptr;
52 VkResult err = m_createSurface(m_vkInst, &surfaceInfo, nullptr, &surface);
53 if (err != VK_SUCCESS)
54 qWarning("Failed to create Vulkan surface: %d", err);
55
56 return surface;
57}
58
59
PFN_vkGetInstanceProcAddr m_vkGetInstanceProcAddr
void loadVulkanLibrary(const QString &defaultLibraryName, int defaultLibraryVersion=-1)
void initInstance(QVulkanInstance *instance, const QByteArrayList &extraExts)
VkSurfaceKHR * surface(QWindow *window)
void createOrAdoptInstance() override
QCocoaVulkanInstance(QVulkanInstance *instance)
NSView * m_view
The QVulkanInstance class represents a native Vulkan instance, enabling Vulkan rendering onto a QSurf...
\inmodule QtGui
Definition qwindow.h:63
Combined button and popup list for selecting options.
#define QByteArrayLiteral(str)
Definition qbytearray.h:52
QList< QByteArray > QByteArrayList
#define qWarning
Definition qlogging.h:166
#define QStringLiteral(str)
aWidget window() -> setWindowTitle("New Window Title")
[2]
QQuickView * view
[0]