Vulkan: Switch from vkCreateMacOSSurfaceMVK() to vkCreateMetalSurfaceEXT()

Since we are calling this off the UI thread, we can't use anything which
accesses the underlying NSView object. We create and set the Metal layer
on the UI thread before the video backend is initialized. This extension
is both compatible with MoltenVK and gfx-portability for accepting a
layer at surface creation.
This commit is contained in:
Stenzek
2020-04-07 18:49:40 +10:00
parent 52d4756679
commit a2f4fafe86
5 changed files with 14 additions and 13 deletions

View File

@ -23,7 +23,7 @@
#include "VideoCommon/VideoBackendBase.h"
#include "VideoCommon/VideoConfig.h"
#if defined(VK_USE_PLATFORM_MACOS_MVK)
#if defined(VK_USE_PLATFORM_METAL_EXT)
#include <objc/message.h>
#endif
@ -280,7 +280,7 @@ void VideoBackend::Shutdown()
UnloadVulkanLibrary();
}
#if defined(VK_USE_PLATFORM_MACOS_MVK)
#if defined(VK_USE_PLATFORM_METAL_EXT)
static bool IsRunningOnMojaveOrHigher()
{
// id processInfo = [NSProcessInfo processInfo]
@ -306,7 +306,7 @@ static bool IsRunningOnMojaveOrHigher()
void VideoBackend::PrepareWindow(WindowSystemInfo& wsi)
{
#if defined(VK_USE_PLATFORM_MACOS_MVK)
#if defined(VK_USE_PLATFORM_METAL_EXT)
// This is kinda messy, but it avoids having to write Objective C++ just to create a metal layer.
id view = reinterpret_cast<id>(wsi.render_surface);
Class clsCAMetalLayer = objc_getClass("CAMetalLayer");