From 8c4ecdc42697b43748ea83fdec0465c91fdc5841 Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Tue, 22 Aug 2023 20:49:06 +0200 Subject: [PATCH] early-access version 3829 --- CMakeLists.txt | 4 ++- CMakeModules/DownloadExternals.cmake | 18 +++++++++++++ README.md | 2 +- src/core/hle/service/ssl/ssl.cpp | 10 +------- .../hle/service/ssl/ssl_backend_openssl.cpp | 3 +-- .../hle/service/ssl/ssl_backend_schannel.cpp | 25 +++++++++---------- .../vulkan_common/vulkan_instance.cpp | 8 +++--- .../vulkan_common/vulkan_library.cpp | 16 +++++++----- src/yuzu/CMakeLists.txt | 12 +++++++++ 9 files changed, 63 insertions(+), 35 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c2878d42..46fff48cd 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,7 +49,7 @@ option(YUZU_TESTS "Compile tests" "${BUILD_TESTING}") option(YUZU_USE_PRECOMPILED_HEADERS "Use precompiled headers" ON) -cmake_dependent_option(YUZU_ROOM "Compile LDN room server" ON "NOT ANDROID" OFF) +CMAKE_DEPENDENT_OPTION(YUZU_ROOM "Compile LDN room server" ON "NOT ANDROID" OFF) CMAKE_DEPENDENT_OPTION(YUZU_CRASH_DUMPS "Compile Windows crash dump (Minidump) support" OFF "WIN32" OFF) @@ -63,6 +63,8 @@ option(YUZU_DOWNLOAD_TIME_ZONE_DATA "Always download time zone binaries" OFF) CMAKE_DEPENDENT_OPTION(YUZU_USE_FASTER_LD "Check if a faster linker is available" ON "NOT WIN32" OFF) +CMAKE_DEPENDENT_OPTION(USE_SYSTEM_MOLTENVK "Use the system MoltenVK lib (instead of the bundled one)" OFF "APPLE" OFF) + set(DEFAULT_ENABLE_OPENSSL ON) if (ANDROID OR WIN32 OR APPLE) # - Windows defaults to the Schannel backend. diff --git a/CMakeModules/DownloadExternals.cmake b/CMakeModules/DownloadExternals.cmake index 3d4ace79e..bcce1d908 100755 --- a/CMakeModules/DownloadExternals.cmake +++ b/CMakeModules/DownloadExternals.cmake @@ -36,3 +36,21 @@ endif() message(STATUS "Using bundled binaries at ${prefix}") set(${prefix_var} "${prefix}" PARENT_SCOPE) endfunction() + +function(download_moltenvk_external platform version) + set(MOLTENVK_DIR "${CMAKE_BINARY_DIR}/externals/MoltenVK") + set(MOLTENVK_TAR "${CMAKE_BINARY_DIR}/externals/MoltenVK.tar") + if (NOT EXISTS ${MOLTENVK_DIR}) + if (NOT EXISTS ${MOLTENVK_TAR}) + file(DOWNLOAD https://github.com/KhronosGroup/MoltenVK/releases/download/${version}/MoltenVK-${platform}.tar + ${MOLTENVK_TAR} SHOW_PROGRESS) + endif() + + execute_process(COMMAND ${CMAKE_COMMAND} -E tar xf "${MOLTENVK_TAR}" + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/externals") + endif() + + # Add the MoltenVK library path to the prefix so find_library can locate it. + list(APPEND CMAKE_PREFIX_PATH "${MOLTENVK_DIR}/MoltenVK/dylib/${platform}") + set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} PARENT_SCOPE) +endfunction() diff --git a/README.md b/README.md index 0b7dcf1c4..ac912eb77 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 3828. +This is the source code for early-access 3829. ## Legal Notice diff --git a/src/core/hle/service/ssl/ssl.cpp b/src/core/hle/service/ssl/ssl.cpp index 652d989ed..12951121f 100755 --- a/src/core/hle/service/ssl/ssl.cpp +++ b/src/core/hle/service/ssl/ssl.cpp @@ -139,7 +139,6 @@ private: bool do_not_close_socket = false; bool get_server_cert_chain = false; std::shared_ptr socket; - bool did_set_host_name = false; bool did_handshake = false; Result SetSocketDescriptorImpl(s32* out_fd, s32 fd) { @@ -174,11 +173,7 @@ private: Result SetHostNameImpl(const std::string& hostname) { LOG_DEBUG(Service_SSL, "called. hostname={}", hostname); ASSERT(!did_handshake); - Result res = backend->SetHostName(hostname); - if (res == ResultSuccess) { - did_set_host_name = true; - } - return res; + return backend->SetHostName(hostname); } Result SetVerifyOptionImpl(u32 option) { @@ -208,9 +203,6 @@ private: Result DoHandshakeImpl() { ASSERT_OR_EXECUTE(!did_handshake && socket, { return ResultNoSocket; }); - ASSERT_OR_EXECUTE_MSG( - did_set_host_name, { return ResultInternalError; }, - "Expected SetHostName before DoHandshake"); Result res = backend->DoHandshake(); did_handshake = res.IsSuccess(); return res; diff --git a/src/core/hle/service/ssl/ssl_backend_openssl.cpp b/src/core/hle/service/ssl/ssl_backend_openssl.cpp index b2dd37cd4..5714e6f3c 100755 --- a/src/core/hle/service/ssl/ssl_backend_openssl.cpp +++ b/src/core/hle/service/ssl/ssl_backend_openssl.cpp @@ -167,9 +167,8 @@ public: } ~SSLConnectionBackendOpenSSL() { - // these are null-tolerant: + // this is null-tolerant: SSL_free(ssl); - BIO_free(bio); } static void KeyLogCallback(const SSL* ssl, const char* line) { diff --git a/src/core/hle/service/ssl/ssl_backend_schannel.cpp b/src/core/hle/service/ssl/ssl_backend_schannel.cpp index bda12b761..d834a0c1f 100755 --- a/src/core/hle/service/ssl/ssl_backend_schannel.cpp +++ b/src/core/hle/service/ssl/ssl_backend_schannel.cpp @@ -31,9 +31,9 @@ CredHandle cred_handle; static void OneTimeInit() { schannel_cred.dwVersion = SCHANNEL_CRED_VERSION; schannel_cred.dwFlags = - SCH_USE_STRONG_CRYPTO | // don't allow insecure protocols - SCH_CRED_AUTO_CRED_VALIDATION | // validate certs - SCH_CRED_NO_DEFAULT_CREDS; // don't automatically present a client certificate + SCH_USE_STRONG_CRYPTO | // don't allow insecure protocols + SCH_CRED_NO_SERVERNAME_CHECK | // don't validate server names + SCH_CRED_NO_DEFAULT_CREDS; // don't automatically present a client certificate // ^ I'm assuming that nobody would want to connect Yuzu to a // service that requires some OS-provided corporate client // certificate, and presenting one to some arbitrary server @@ -227,16 +227,15 @@ public: ciphertext_read_buf.size()); } - const SECURITY_STATUS ret = - InitializeSecurityContextA(&cred_handle, initial_call_done ? &ctxt : nullptr, - // Caller ensured we have set a hostname: - const_cast(hostname.value().c_str()), req, - 0, // Reserved1 - 0, // TargetDataRep not used with Schannel - initial_call_done ? &input_desc : nullptr, - 0, // Reserved2 - initial_call_done ? nullptr : &ctxt, &output_desc, &attr, - nullptr); // ptsExpiry + char* hostname_ptr = hostname ? const_cast(hostname->c_str()) : nullptr; + const SECURITY_STATUS ret = InitializeSecurityContextA( + &cred_handle, initial_call_done ? &ctxt : nullptr, hostname_ptr, req, + 0, // Reserved1 + 0, // TargetDataRep not used with Schannel + initial_call_done ? &input_desc : nullptr, + 0, // Reserved2 + initial_call_done ? nullptr : &ctxt, &output_desc, &attr, + nullptr); // ptsExpiry if (output_buffers[0].pvBuffer) { const std::span span(static_cast(output_buffers[0].pvBuffer), diff --git a/src/video_core/vulkan_common/vulkan_instance.cpp b/src/video_core/vulkan_common/vulkan_instance.cpp index c27d1bfdd..1787f53dd 100755 --- a/src/video_core/vulkan_common/vulkan_instance.cpp +++ b/src/video_core/vulkan_common/vulkan_instance.cpp @@ -41,9 +41,6 @@ namespace { bool enable_validation) { std::vector extensions; extensions.reserve(6); -#ifdef __APPLE__ - extensions.push_back(VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME); -#endif switch (window_type) { case Core::Frontend::WindowSystemType::Headless: break; @@ -74,6 +71,11 @@ namespace { if (window_type != Core::Frontend::WindowSystemType::Headless) { extensions.push_back(VK_KHR_SURFACE_EXTENSION_NAME); } +#ifdef __APPLE__ + if (AreExtensionsSupported(dld, std::array{VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME})) { + extensions.push_back(VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME); + } +#endif if (enable_validation) { const bool debug_utils = AreExtensionsSupported(dld, std::array{VK_EXT_DEBUG_UTILS_EXTENSION_NAME}); diff --git a/src/video_core/vulkan_common/vulkan_library.cpp b/src/video_core/vulkan_common/vulkan_library.cpp index 1b77b60b2..0732ace59 100755 --- a/src/video_core/vulkan_common/vulkan_library.cpp +++ b/src/video_core/vulkan_common/vulkan_library.cpp @@ -19,13 +19,17 @@ std::shared_ptr OpenLibrary( #else auto library = std::make_shared(); #ifdef __APPLE__ + const auto libvulkan_filename = + Common::FS::GetBundleDirectory() / "Contents/Frameworks/libvulkan.1.dylib"; + const auto libmoltenvk_filename = + Common::FS::GetBundleDirectory() / "Contents/Frameworks/libMoltenVK.dylib"; + const char* library_paths[] = {std::getenv("LIBVULKAN_PATH"), libvulkan_filename.c_str(), + libmoltenvk_filename.c_str()}; // Check if a path to a specific Vulkan library has been specified. - char* const libvulkan_env = std::getenv("LIBVULKAN_PATH"); - if (!libvulkan_env || !library->Open(libvulkan_env)) { - // Use the libvulkan.dylib from the application bundle. - const auto filename = - Common::FS::GetBundleDirectory() / "Contents/Frameworks/libvulkan.dylib"; - void(library->Open(Common::FS::PathToUTF8String(filename).c_str())); + for (const auto& library_path : library_paths) { + if (library_path && library->Open(library_path)) { + break; + } } #else std::string filename = Common::DynamicLibrary::GetVersionedFilename("vulkan", 1); diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt index 536302710..1f7aed98b 100755 --- a/src/yuzu/CMakeLists.txt +++ b/src/yuzu/CMakeLists.txt @@ -313,6 +313,18 @@ if (APPLE) target_sources(yuzu PRIVATE ${MACOSX_ICON}) set_target_properties(yuzu PROPERTIES MACOSX_BUNDLE TRUE) set_target_properties(yuzu PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist) + + if (NOT USE_SYSTEM_MOLTENVK) + set(MOLTENVK_PLATFORM "macOS") + set(MOLTENVK_VERSION "v1.2.5") + download_moltenvk_external(${MOLTENVK_PLATFORM} ${MOLTENVK_VERSION}) + endif() + find_library(MOLTENVK_LIBRARY MoltenVK REQUIRED) + message(STATUS "Using MoltenVK at ${MOLTENVK_LIBRARY}.") + set_source_files_properties(${MOLTENVK_LIBRARY} PROPERTIES MACOSX_PACKAGE_LOCATION Frameworks + XCODE_FILE_ATTRIBUTES "CodeSignOnCopy") + target_sources(yuzu PRIVATE ${MOLTENVK_LIBRARY}) + elseif(WIN32) # compile as a win32 gui application instead of a console application if (QT_VERSION VERSION_GREATER_EQUAL 6)