vk_instance: Set moltenvk configuration
This commit is contained in:
parent
6c391971c6
commit
ba9f1f8ae9
4 changed files with 1121 additions and 0 deletions
3
externals/CMakeLists.txt
vendored
3
externals/CMakeLists.txt
vendored
|
@ -242,6 +242,9 @@ target_include_directories(vma SYSTEM INTERFACE ./vma/include)
|
|||
# vulkan-headers
|
||||
add_library(vulkan-headers INTERFACE)
|
||||
target_include_directories(vulkan-headers SYSTEM INTERFACE ./vulkan-headers/include)
|
||||
if (APPLE)
|
||||
target_include_directories(vulkan-headers SYSTEM INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/MoltenVK)
|
||||
endif()
|
||||
|
||||
# adrenotools
|
||||
if (ANDROID)
|
||||
|
|
1071
externals/moltenvk/mvk_config.h
vendored
Normal file
1071
externals/moltenvk/mvk_config.h
vendored
Normal file
File diff suppressed because it is too large
Load diff
|
@ -14,6 +14,10 @@
|
|||
|
||||
#include <vk_mem_alloc.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <mvk_config.h>
|
||||
#endif
|
||||
|
||||
namespace Vulkan {
|
||||
|
||||
namespace {
|
||||
|
@ -537,6 +541,12 @@ bool Instance::CreateDevice() {
|
|||
#undef PROP_GET
|
||||
#undef FEAT_SET
|
||||
|
||||
#ifdef __APPLE__
|
||||
if (!SetMoltenVkConfig()) {
|
||||
LOG_WARNING(Render_Vulkan, "Unable to set MoltenVK configuration");
|
||||
}
|
||||
#endif
|
||||
|
||||
try {
|
||||
device = physical_device.createDeviceUnique(device_chain.get());
|
||||
} catch (vk::ExtensionNotPresentError& err) {
|
||||
|
@ -597,4 +607,38 @@ void Instance::CollectToolingInfo() {
|
|||
}
|
||||
}
|
||||
|
||||
bool Instance::SetMoltenVkConfig() {
|
||||
#ifdef __APPLE__
|
||||
size_t mvk_config_size = sizeof(MVKConfiguration);
|
||||
MVKConfiguration mvk_config{};
|
||||
|
||||
const auto _vkGetMoltenVKConfigurationMVK =
|
||||
library->GetSymbol<PFN_vkGetMoltenVKConfigurationMVK>("vkGetMoltenVKConfigurationMVK");
|
||||
if (!_vkGetMoltenVKConfigurationMVK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto _vkSetMoltenVKConfigurationMVK =
|
||||
library->GetSymbol<PFN_vkSetMoltenVKConfigurationMVK>("vkSetMoltenVKConfigurationMVK");
|
||||
if (!_vkSetMoltenVKConfigurationMVK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_vkGetMoltenVKConfigurationMVK(VK_NULL_HANDLE, &mvk_config, &mvk_config_size) !=
|
||||
VK_SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mvk_config.synchronousQueueSubmits = Settings::values.async_presentation.GetValue();
|
||||
mvk_config.resumeLostDevice = true;
|
||||
mvk_config.shouldMaximizeConcurrentCompilation = true;
|
||||
|
||||
if (_vkSetMoltenVKConfigurationMVK(VK_NULL_HANDLE, &mvk_config, &mvk_config_size) !=
|
||||
VK_SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace Vulkan
|
||||
|
|
|
@ -256,6 +256,9 @@ private:
|
|||
void CollectTelemetryParameters();
|
||||
void CollectToolingInfo();
|
||||
|
||||
/// Sets MoltenVK configuration to the desired state.
|
||||
bool SetMoltenVkConfig();
|
||||
|
||||
private:
|
||||
std::shared_ptr<Common::DynamicLibrary> library;
|
||||
vk::UniqueInstance instance;
|
||||
|
|
Loading…
Reference in a new issue