Mac: Update MoltenVk to 1.2.7

Remove deprecated extension VK_MVK_moltenvk
This commit is contained in:
Megamouse 2024-01-15 23:29:40 +01:00
parent fd540f1820
commit e23db7efbd
4 changed files with 32 additions and 37 deletions

View File

@ -13,8 +13,8 @@ arch -x86_64 /usr/local/bin/brew reinstall -f --build-from-source gnutls freetyp
arch -x86_64 /usr/local/bin/brew install llvm@16 glew cmake sdl2 vulkan-headers coreutils
arch -x86_64 /usr/local/bin/brew link -f llvm@16 ffmpeg@5
# moltenvk based on commit for 1.2.6 release
wget https://raw.githubusercontent.com/Homebrew/homebrew-core/4ac0cfaca4c2505abe2fcbcc0ce5816572103a6c/Formula/m/molten-vk.rb
# moltenvk based on commit for 1.2.7 release
wget https://raw.githubusercontent.com/Homebrew/homebrew-core/05a8770c483cfddf5b077667a392d846bc2ad719/Formula/m/molten-vk.rb
arch -x86_64 /usr/local/bin/brew install -f --overwrite ./molten-vk.rb
#export MACOSX_DEPLOYMENT_TARGET=12.0
export CXX=clang++

View File

@ -4,7 +4,7 @@ include(ExternalProject)
ExternalProject_Add(moltenvk
GIT_REPOSITORY https://github.com/KhronosGroup/MoltenVK.git
GIT_TAG 9e4ee9e
GIT_TAG 66f6ff1
BUILD_IN_SOURCE 1
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/MoltenVK
CONFIGURE_COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/MoltenVK/fetchDependencies" --macos

View File

@ -3,10 +3,6 @@
#include "util/logs.hpp"
#include "Emu/system_config.h"
#ifdef __APPLE__
#include <MoltenVK/mvk_config.h>
#endif
namespace vk
{
// Global shared render device
@ -156,33 +152,6 @@ namespace vk
_vkGetPhysicalDeviceProperties2KHR(dev, &properties2);
props = properties2.properties;
#ifdef __APPLE__
if (instance_extensions.is_supported(VK_MVK_MOLTENVK_EXTENSION_NAME))
{
MVKConfiguration mvk_config = {};
size_t mvk_config_size = sizeof(MVKConfiguration);
PFN_vkGetMoltenVKConfigurationMVK _vkGetMoltenVKConfigurationMVK = nullptr;
_vkGetMoltenVKConfigurationMVK = reinterpret_cast<PFN_vkGetMoltenVKConfigurationMVK>(vkGetInstanceProcAddr(parent, "vkGetMoltenVKConfigurationMVK"));
ensure(_vkGetMoltenVKConfigurationMVK);
PFN_vkSetMoltenVKConfigurationMVK _vkSetMoltenVKConfigurationMVK = nullptr;
_vkSetMoltenVKConfigurationMVK = reinterpret_cast<PFN_vkSetMoltenVKConfigurationMVK>(vkGetInstanceProcAddr(parent, "vkSetMoltenVKConfigurationMVK"));
ensure(_vkSetMoltenVKConfigurationMVK);
CHECK_RESULT_EX(_vkGetMoltenVKConfigurationMVK(VK_NULL_HANDLE, &mvk_config, &mvk_config_size), std::string("Could not get MoltenVK configuration."));
mvk_config.resumeLostDevice = true;
mvk_config.fastMathEnabled = g_cfg.video.disable_msl_fast_math.get() ? MVK_CONFIG_FAST_MATH_NEVER : MVK_CONFIG_FAST_MATH_ON_DEMAND;
CHECK_RESULT_EX(_vkSetMoltenVKConfigurationMVK(VK_NULL_HANDLE, &mvk_config, &mvk_config_size), std::string("Could not set MoltenVK configuration."));
}
else
{
rsx_log.error("Cannot set the MoltenVK configuration because VK_MVK_moltenvk is not supported.\nIf you're using MoltenVK through libvulkan, please manually set the appropriate environment variables instead.");
}
#endif
if (descriptor_indexing_support)
{
if (descriptor_indexing_props.maxUpdateAfterBindDescriptorsInAllPools < 800'000)

View File

@ -6,6 +6,11 @@
#include <algorithm>
#include <vector>
#ifdef __APPLE__
#include <MoltenVK/mvk_vulkan.h>
#include <MoltenVK/mvk_private_api.h>
#endif
namespace vk
{
class supported_extensions
@ -133,6 +138,16 @@ namespace vk
std::vector<const char*> extensions;
std::vector<const char*> layers;
const void* next_info = nullptr;
#ifdef __APPLE__
// Declare MVK variables here to ensure the lifetime within the entire scope
const VkBool32 setting_true = VK_TRUE;
const int32_t setting_fast_math = g_cfg.video.disable_msl_fast_math.get() ? MVK_CONFIG_FAST_MATH_NEVER : MVK_CONFIG_FAST_MATH_ON_DEMAND;
std::vector<VkLayerSettingEXT> mvk_settings;
VkLayerSettingsCreateInfoEXT mvk_layer_settings_create_info{};
#endif
if (!fast)
{
@ -151,10 +166,20 @@ namespace vk
}
#ifdef __APPLE__
#define VK_MVK_MOLTENVK_EXTENSION_NAME "VK_MVK_moltenvk"
if (support.is_supported(VK_MVK_MOLTENVK_EXTENSION_NAME))
if (support.is_supported(VK_EXT_LAYER_SETTINGS_EXTENSION_NAME))
{
extensions.push_back(VK_MVK_MOLTENVK_EXTENSION_NAME);
extensions.push_back(VK_EXT_LAYER_SETTINGS_EXTENSION_NAME);
layers.push_back(kMVKMoltenVKDriverLayerName);
mvk_settings.push_back(VkLayerSettingEXT{ kMVKMoltenVKDriverLayerName, "MVK_CONFIG_RESUME_LOST_DEVICE", VK_LAYER_SETTING_TYPE_BOOL32_EXT, 1, &setting_true });
mvk_settings.push_back(VkLayerSettingEXT{ kMVKMoltenVKDriverLayerName, "MVK_CONFIG_FAST_MATH_ENABLED", VK_LAYER_SETTING_TYPE_INT32_EXT, 1, &setting_fast_math });
mvk_layer_settings_create_info.sType = VK_STRUCTURE_TYPE_LAYER_SETTINGS_CREATE_INFO_EXT;
mvk_layer_settings_create_info.pNext = next_info;
mvk_layer_settings_create_info.settingCount = static_cast<uint32_t>(mvk_settings.size());
mvk_layer_settings_create_info.pSettings = mvk_settings.data();
next_info = &mvk_layer_settings_create_info;
}
#endif
@ -210,6 +235,7 @@ namespace vk
instance_info.ppEnabledLayerNames = layers.data();
instance_info.enabledExtensionCount = fast ? 0 : static_cast<u32>(extensions.size());
instance_info.ppEnabledExtensionNames = fast ? nullptr : extensions.data();
instance_info.pNext = next_info;
if (VkResult result = vkCreateInstance(&instance_info, nullptr, &m_instance); result != VK_SUCCESS)
{