|
|
|
@ -206,10 +206,12 @@ std::vector<const char*> GetInstanceExtensions(Frontend::WindowSystemType window
|
|
|
|
|
|
|
|
|
|
// Add the windowing system specific extension
|
|
|
|
|
std::vector<const char*> extensions;
|
|
|
|
|
extensions.reserve(6);
|
|
|
|
|
extensions.reserve(7);
|
|
|
|
|
|
|
|
|
|
#if defined(__APPLE__)
|
|
|
|
|
extensions.push_back(VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME);
|
|
|
|
|
// For configuring MoltenVK.
|
|
|
|
|
extensions.push_back(VK_EXT_LAYER_SETTINGS_EXTENSION_NAME);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
switch (window_type) {
|
|
|
|
@ -281,10 +283,21 @@ vk::UniqueInstance CreateInstance(const Common::DynamicLibrary& library,
|
|
|
|
|
throw std::runtime_error("Failed to load Vulkan driver library");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const auto vkGetInstanceProcAddr =
|
|
|
|
|
auto vkGetInstanceProcAddr =
|
|
|
|
|
library.GetSymbol<PFN_vkGetInstanceProcAddr>("vkGetInstanceProcAddr");
|
|
|
|
|
if (!vkGetInstanceProcAddr) {
|
|
|
|
|
#ifdef __APPLE__
|
|
|
|
|
// MoltenVK now hides most Vulkan symbols by default to avoid clashes,
|
|
|
|
|
// so we may need to use the ICD hook instead.
|
|
|
|
|
vkGetInstanceProcAddr =
|
|
|
|
|
library.GetSymbol<PFN_vkGetInstanceProcAddr>("vk_icdGetInstanceProcAddr");
|
|
|
|
|
if (!vkGetInstanceProcAddr) {
|
|
|
|
|
throw std::runtime_error(
|
|
|
|
|
"Failed GetSymbol vkGetInstanceProcAddr or vk_icdGetInstanceProcAddr");
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
throw std::runtime_error("Failed GetSymbol vkGetInstanceProcAddr");
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
VULKAN_HPP_DEFAULT_DISPATCHER.init(vkGetInstanceProcAddr);
|
|
|
|
|
|
|
|
|
@ -315,7 +328,7 @@ vk::UniqueInstance CreateInstance(const Common::DynamicLibrary& library,
|
|
|
|
|
layers.push_back("VK_LAYER_LUNARG_api_dump");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const vk::InstanceCreateInfo instance_ci = {
|
|
|
|
|
vk::InstanceCreateInfo instance_ci = {
|
|
|
|
|
.flags = GetInstanceFlags(),
|
|
|
|
|
.pApplicationInfo = &application_info,
|
|
|
|
|
.enabledLayerCount = static_cast<u32>(layers.size()),
|
|
|
|
@ -324,6 +337,36 @@ vk::UniqueInstance CreateInstance(const Common::DynamicLibrary& library,
|
|
|
|
|
.ppEnabledExtensionNames = extensions.data(),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#ifdef __APPLE__
|
|
|
|
|
// Use synchronous queue submits if async presentation is enabled, to avoid threading
|
|
|
|
|
// indirection.
|
|
|
|
|
const auto synchronous_queue_submits = Settings::values.async_presentation.GetValue();
|
|
|
|
|
// If the device is lost, make an attempt to resume if possible to avoid crashes.
|
|
|
|
|
constexpr auto resume_lost_device = true;
|
|
|
|
|
// Maximize concurrency to improve shader compilation performance.
|
|
|
|
|
constexpr auto maximize_concurrent_compilation = true;
|
|
|
|
|
|
|
|
|
|
constexpr auto layer_name = "MoltenVK";
|
|
|
|
|
const vk::LayerSettingEXT layer_settings[] = {
|
|
|
|
|
{layer_name, "MVK_CONFIG_SYNCHRONOUS_QUEUE_SUBMITS", vk::LayerSettingTypeEXT::eBool32, 1,
|
|
|
|
|
&synchronous_queue_submits},
|
|
|
|
|
{layer_name, "MVK_CONFIG_RESUME_LOST_DEVICE", vk::LayerSettingTypeEXT::eBool32, 1,
|
|
|
|
|
&resume_lost_device},
|
|
|
|
|
{layer_name, "MVK_CONFIG_SHOULD_MAXIMIZE_CONCURRENT_COMPILATION",
|
|
|
|
|
vk::LayerSettingTypeEXT::eBool32, 1, &maximize_concurrent_compilation},
|
|
|
|
|
};
|
|
|
|
|
const vk::LayerSettingsCreateInfoEXT layer_settings_ci = {
|
|
|
|
|
.pNext = nullptr,
|
|
|
|
|
.settingCount = static_cast<uint32_t>(std::size(layer_settings)),
|
|
|
|
|
.pSettings = layer_settings,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (std::find(extensions.begin(), extensions.end(), VK_EXT_LAYER_SETTINGS_EXTENSION_NAME) !=
|
|
|
|
|
extensions.end()) {
|
|
|
|
|
instance_ci.pNext = &layer_settings_ci;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
auto instance = vk::createInstanceUnique(instance_ci);
|
|
|
|
|
|
|
|
|
|
VULKAN_HPP_DEFAULT_DISPATCHER.init(*instance);
|
|
|
|
|