qt: Extract CAMetalLayer from NSView to pass to MoltenVK.

This commit is contained in:
Steveice10
2022-11-03 01:47:10 -07:00
committed by GPUCode
parent b86b19d366
commit 763127605e
4 changed files with 36 additions and 1 deletions

View File

@@ -250,6 +250,8 @@ if (APPLE)
set_target_properties(citra-qt PROPERTIES MACOSX_BUNDLE TRUE) set_target_properties(citra-qt PROPERTIES MACOSX_BUNDLE TRUE)
set_target_properties(citra-qt PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist) set_target_properties(citra-qt PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist)
target_sources(citra-qt PRIVATE target_sources(citra-qt PRIVATE
applesurfacehelper.h
applesurfacehelper.mm
macos_authorization.h macos_authorization.h
macos_authorization.mm macos_authorization.mm
) )

View File

@@ -0,0 +1,11 @@
// Copyright 2022 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
namespace AppleSurfaceHelper {
void* GetSurfaceLayer(void* surface);
} // namespace AppleSurfaceHelper

View File

@@ -0,0 +1,16 @@
// Copyright 2022 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#import <Cocoa/Cocoa.h>
#include "citra_qt/applesurfacehelper.h"
namespace AppleSurfaceHelper {
void* GetSurfaceLayer(void* surface) {
NSView* view = static_cast<NSView*>(surface);
return view.layer;
}
} // AppleSurfaceHelper

View File

@@ -24,6 +24,10 @@
#include "video_core/renderer_base.h" #include "video_core/renderer_base.h"
#include "video_core/video_core.h" #include "video_core/video_core.h"
#if defined(__APPLE__)
#include "citra_qt/applesurfacehelper.h"
#endif
#if !defined(WIN32) #if !defined(WIN32)
#include <qpa/qplatformnativeinterface.h> #include <qpa/qplatformnativeinterface.h>
#endif #endif
@@ -334,8 +338,10 @@ static Frontend::EmuWindow::WindowSystemInfo GetWindowSystemInfo(QWindow* window
wsi.type = GetWindowSystemType(); wsi.type = GetWindowSystemType();
// Our Win32 Qt external doesn't have the private API. // Our Win32 Qt external doesn't have the private API.
#if defined(WIN32) || defined(__APPLE__) #if defined(WIN32)
wsi.render_surface = window ? reinterpret_cast<void*>(window->winId()) : nullptr; wsi.render_surface = window ? reinterpret_cast<void*>(window->winId()) : nullptr;
#elif defined(__APPLE__)
wsi.render_surface = window ? AppleSurfaceHelper::GetSurfaceLayer(reinterpret_cast<void*>(window->winId())) : nullptr;
#else #else
QPlatformNativeInterface* pni = QGuiApplication::platformNativeInterface(); QPlatformNativeInterface* pni = QGuiApplication::platformNativeInterface();
wsi.display_connection = pni->nativeResourceForWindow("display", window); wsi.display_connection = pni->nativeResourceForWindow("display", window);