Skip to content

Commit

Permalink
Updates and tweaks for iOS builds (#202)
Browse files Browse the repository at this point in the history
* Added cmake support

* CMAKE updates

* cmake update

* Linux updates

* Linux for real this time

* Added build instructions

* iOS updates and fixes
  • Loading branch information
richard-lunarg committed Apr 12, 2024
1 parent 78eda4b commit 3fbd60d
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 42 deletions.
8 changes: 5 additions & 3 deletions iOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@
<key>CFBundleExecutable</key>
<string>Vulkan Caps Viewer</string>
<key>CFBundleIconName</key>
<string>vulkanCapsViewer.png</string>
<string>AppIcon</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>Vulkan Caps Viewer</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>1.17</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleSupportedPlatforms</key>
Expand Down Expand Up @@ -45,7 +47,7 @@
<key>LSRequiresIPhoneOS</key>
<true/>
<key>MinimumOSVersion</key>
<string>12.0</string>
<string>15.0</string>
<key>NOTE</key>
<string>Ported to iOS by LunarG</string>
<key>UIDeviceFamily</key>
Expand Down
4 changes: 2 additions & 2 deletions settingsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ settingsDialog::settingsDialog(Settings appSet)
formLayout->addRow(tr("Use proxy settings for upload"), createCheckBox("checkBoxUseProxy"));

QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(slotAccept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(slotCancel()));
connect(buttonBox, SIGNAL(accepted()), this, SLOT(slotAccept()), Qt::QueuedConnection);
connect(buttonBox, SIGNAL(rejected()), this, SLOT(slotCancel()), Qt::QueuedConnection);

formLayout->addWidget(buttonBox);

Expand Down
7 changes: 4 additions & 3 deletions submitDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <QLine>
#include <QSettings>
#include <QDialogButtonBox>
#include <QCoreApplication>

SubmitDialog::SubmitDialog(QString submitter, QString caption)
{
Expand Down Expand Up @@ -57,13 +58,13 @@ SubmitDialog::SubmitDialog(QString submitter, QString caption)
formLayout->addRow("Comment:", editComment);

QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(slotAccept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(slotCancel()));
connect(buttonBox, SIGNAL(accepted()), this, SLOT(slotAccept()), Qt::QueuedConnection);
connect(buttonBox, SIGNAL(rejected()), this, SLOT(slotCancel()), Qt::QueuedConnection);

formLayout->addWidget(buttonBox);

setLayout(formLayout);
setWindowTitle(caption);
setWindowTitle(caption);
}


Expand Down
68 changes: 34 additions & 34 deletions vulkancapsviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,13 @@
#include <android/native_window_jni.h>
#endif

#ifdef __APPLE__
#include <vulkan/vulkan_metal.h>

#ifdef VK_USE_PLATFORM_IOS_MVK
extern "C" const char *getWorkingFolderForiOS(void);
#endif
#endif

using std::to_string;

Expand Down Expand Up @@ -169,15 +173,15 @@ VulkanCapsViewer::VulkanCapsViewer(QWidget *parent)
ui.setupUi(this);
setWindowTitle("Vulkan Hardware Capability Viewer " + version);
// Connect slots
connect(ui.comboBoxGPU, SIGNAL(currentIndexChanged(int)), this, SLOT(slotComboBoxGPUIndexChanged(int)));
connect(ui.toolButtonUpload, SIGNAL(pressed()), this, SLOT(slotUploadReport()));
connect(ui.toolButtonSave, SIGNAL(pressed()), this, SLOT(slotSaveReport()));
connect(ui.toolButtonOnlineDevice, SIGNAL(pressed()), this, SLOT(slotDisplayOnlineReport()));
connect(ui.toolButtonOnlineDataBase, SIGNAL(pressed()), this, SLOT(slotBrowseDatabase()));
connect(ui.toolButtonAbout, SIGNAL(pressed()), this, SLOT(slotAbout()));
connect(ui.toolButtonExit, SIGNAL(pressed()), this, SLOT(slotClose()));
connect(ui.toolButtonSettings, SIGNAL(pressed()), this, SLOT(slotSettings()));
connect(ui.comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotComboTabChanged(int)));
connect(ui.comboBoxGPU, SIGNAL(currentIndexChanged(int)), this, SLOT(slotComboBoxGPUIndexChanged(int)), Qt::QueuedConnection);
connect(ui.toolButtonUpload, SIGNAL(pressed()), this, SLOT(slotUploadReport()), Qt::QueuedConnection);
connect(ui.toolButtonSave, SIGNAL(pressed()), this, SLOT(slotSaveReport()), Qt::QueuedConnection);
connect(ui.toolButtonOnlineDevice, SIGNAL(pressed()), this, SLOT(slotDisplayOnlineReport()), Qt::QueuedConnection);
connect(ui.toolButtonOnlineDataBase, SIGNAL(pressed()), this, SLOT(slotBrowseDatabase()), Qt::QueuedConnection);
connect(ui.toolButtonAbout, SIGNAL(pressed()), this, SLOT(slotAbout()), Qt::QueuedConnection);
connect(ui.toolButtonExit, SIGNAL(pressed()), this, SLOT(slotClose()), Qt::QueuedConnection);
connect(ui.toolButtonSettings, SIGNAL(pressed()), this, SLOT(slotSettings()), Qt::QueuedConnection);
connect(ui.comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotComboTabChanged(int)), Qt::QueuedConnection);

qApp->setStyle(QStyleFactory::create("Fusion"));
boldFont.setBold(true);
Expand Down Expand Up @@ -618,13 +622,14 @@ bool VulkanCapsViewer::initVulkan()
#if defined(VK_USE_PLATFORM_XCB_KHR)
VK_KHR_XCB_SURFACE_EXTENSION_NAME,
#endif
#if defined(VK_USE_PLATFORM_MACOS_MVK)
VK_MVK_MACOS_SURFACE_EXTENSION_NAME,
#endif

#if defined(VK_USE_PLATFORM_IOS_MVK)
VK_MVK_IOS_SURFACE_EXTENSION_NAME,
#endif

//#if defined(VK_USE_PLATFORM_MACOS_MVK)
// VK_MVK_MACOS_SURFACE_EXTENSION_NAME,
//#endif
//
//#if defined(VK_USE_PLATFORM_IOS_MVK)
// VK_MVK_IOS_SURFACE_EXTENSION_NAME,
//#endif
};

std::vector<const char*> enabledExtensions = {};
Expand All @@ -637,6 +642,10 @@ bool VulkanCapsViewer::initVulkan()
if (availableExtensionCount != 0) {
enabledExtensions.push_back(VK_KHR_SURFACE_EXTENSION_NAME);
}

#if __APPLE__
enabledExtensions.push_back("VK_EXT_metal_surface");
#endif

std::vector<std::string> surfaceExtensionsAvailable = {};

Expand Down Expand Up @@ -676,7 +685,7 @@ bool VulkanCapsViewer::initVulkan()
}
}

#if defined(VK_USE_PLATFORM_MACOS_MVK) && (VK_HEADER_VERSION >= 216)
#if defined(__APPLE__) && (VK_HEADER_VERSION >= 216)
instanceCreateInfo.flags = VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR;
enabledExtensions.push_back(VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME);
enabledExtensions.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
Expand Down Expand Up @@ -802,25 +811,16 @@ bool VulkanCapsViewer::initVulkan()
}
#endif

#if defined(VK_USE_PLATFORM_MACOS_MVK)
if (surface_extension == VK_MVK_MACOS_SURFACE_EXTENSION_NAME) {
VkMacOSSurfaceCreateInfoMVK surfaceCreateInfo = {};
surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK;
pMetalSurrogate = new QVukanSurrogate();
surfaceCreateInfo.pView = (void*)pMetalSurrogate->winId();
surfaceResult = vkCreateMacOSSurfaceMVK(vulkanContext.instance, &surfaceCreateInfo, nullptr, &vulkanContext.surface);
}
// This works for deskop and iOS devices
#if __APPLE__
VkMetalSurfaceCreateInfoEXT info = {};
info.sType = VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT;
info.pNext = nullptr;
info.pLayer = (void*)pMetalSurrogate->winId();
info.flags = 0;
vkCreateMetalSurfaceEXT(vulkanContext.instance, &info, nullptr, &vulkanContext.surface);
#endif

#if defined(VK_USE_PLATFORM_IOS_MVK)
if (surface_extension == VK_MVK_IOS_SURFACE_EXTENSION_NAME) {
VkIOSSurfaceCreateInfoMVK surfaceCreateInfo = {};
surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK;
pMetalSurrogate = new QVukanSurrogate();
surfaceCreateInfo.pView = (void*)pMetalSurrogate->winId();
surfaceResult = vkCreateIOSSurfaceMVK(vulkanContext.instance, &surfaceCreateInfo, nullptr, &vulkanContext.surface);
}
#endif
if (surfaceResult == VK_SUCCESS) {
vulkanContext.surfaceExtension = surface_extension;
break;
Expand Down

0 comments on commit 3fbd60d

Please sign in to comment.