diff --git a/Source/Android/jni/MainAndroid.cpp b/Source/Android/jni/MainAndroid.cpp index 2b8b91de74..9b081b9ad1 100644 --- a/Source/Android/jni/MainAndroid.cpp +++ b/Source/Android/jni/MainAndroid.cpp @@ -680,7 +680,7 @@ static void Run(JNIEnv* env, const std::vector& paths, s_have_wm_user_stop = false; std::unique_ptr boot = BootParameters::GenerateFromFile(paths, savestate_path); boot->delete_savestate = delete_savestate; - WindowSystemInfo wsi(WindowSystemType::Android, nullptr, s_surf); + WindowSystemInfo wsi(WindowSystemType::Android, nullptr, s_surf, s_surf); wsi.render_surface_scale = GetRenderSurfaceScale(env); if (BootManager::BootCore(std::move(boot), wsi)) { diff --git a/Source/Core/Common/WindowSystemInfo.h b/Source/Core/Common/WindowSystemInfo.h index 03f230f8e6..244a985cdf 100644 --- a/Source/Core/Common/WindowSystemInfo.h +++ b/Source/Core/Common/WindowSystemInfo.h @@ -18,8 +18,10 @@ enum class WindowSystemType struct WindowSystemInfo { WindowSystemInfo() = default; - WindowSystemInfo(WindowSystemType type_, void* display_connection_, void* render_surface_) - : type(type_), display_connection(display_connection_), render_surface(render_surface_) + WindowSystemInfo(WindowSystemType type_, void* display_connection_, void* render_window_, + void* render_surface_) + : type(type_), display_connection(display_connection_), render_window(render_window_), + render_surface(render_surface_) { } @@ -29,9 +31,14 @@ struct WindowSystemInfo // Connection to a display server. This is used on X11 and Wayland platforms. void* display_connection = nullptr; - // Render surface. This is a pointer to the native window handle, which depends + // Render window. This is a pointer to the native window handle, which depends // on the platform. e.g. HWND for Windows, Window for X11. If the surface is // set to nullptr, the video backend will run in headless mode. + void* render_window = nullptr; + + // Render surface. Depending on the host platform, this may differ from the window. + // This is kept seperate as input may require a different handle to rendering, and + // during video backend startup the surface pointer may change (MoltenVK). void* render_surface = nullptr; // Scale of the render surface. For hidpi systems, this will be >1. diff --git a/Source/Core/DolphinNoGUI/PlatformFBDev.cpp b/Source/Core/DolphinNoGUI/PlatformFBDev.cpp index 9818105521..04770d46ea 100644 --- a/Source/Core/DolphinNoGUI/PlatformFBDev.cpp +++ b/Source/Core/DolphinNoGUI/PlatformFBDev.cpp @@ -91,6 +91,7 @@ WindowSystemInfo PlatformFBDev::GetWindowSystemInfo() const WindowSystemInfo wsi; wsi.type = WindowSystemType::FBDev; wsi.display_connection = nullptr; // EGL_DEFAULT_DISPLAY + wsi.render_window = nullptr; wsi.render_surface = nullptr; return wsi; } diff --git a/Source/Core/DolphinNoGUI/PlatformHeadless.cpp b/Source/Core/DolphinNoGUI/PlatformHeadless.cpp index b848492152..9ca4113fbd 100644 --- a/Source/Core/DolphinNoGUI/PlatformHeadless.cpp +++ b/Source/Core/DolphinNoGUI/PlatformHeadless.cpp @@ -38,6 +38,7 @@ WindowSystemInfo PlatformHeadless::GetWindowSystemInfo() const WindowSystemInfo wsi; wsi.type = WindowSystemType::Headless; wsi.display_connection = nullptr; + wsi.render_window = nullptr; wsi.render_surface = nullptr; return wsi; } diff --git a/Source/Core/DolphinNoGUI/PlatformWin32.cpp b/Source/Core/DolphinNoGUI/PlatformWin32.cpp index add981b361..7ad2f0322c 100644 --- a/Source/Core/DolphinNoGUI/PlatformWin32.cpp +++ b/Source/Core/DolphinNoGUI/PlatformWin32.cpp @@ -134,6 +134,7 @@ WindowSystemInfo PlatformWin32::GetWindowSystemInfo() const { WindowSystemInfo wsi; wsi.type = WindowSystemType::Windows; + wsi.render_window = reinterpret_cast(m_hwnd); wsi.render_surface = reinterpret_cast(m_hwnd); return wsi; } diff --git a/Source/Core/DolphinNoGUI/PlatformX11.cpp b/Source/Core/DolphinNoGUI/PlatformX11.cpp index af8993a4a5..87d401cc72 100644 --- a/Source/Core/DolphinNoGUI/PlatformX11.cpp +++ b/Source/Core/DolphinNoGUI/PlatformX11.cpp @@ -159,6 +159,7 @@ WindowSystemInfo PlatformX11::GetWindowSystemInfo() const WindowSystemInfo wsi; wsi.type = WindowSystemType::X11; wsi.display_connection = static_cast(m_display); + wsi.render_window = reinterpret_cast(m_window); wsi.render_surface = reinterpret_cast(m_window); return wsi; } diff --git a/Source/Core/DolphinQt/MainWindow.cpp b/Source/Core/DolphinQt/MainWindow.cpp index a3102b5449..9de5883cf8 100644 --- a/Source/Core/DolphinQt/MainWindow.cpp +++ b/Source/Core/DolphinQt/MainWindow.cpp @@ -162,14 +162,16 @@ static WindowSystemInfo GetWindowSystemInfo(QWindow* window) // Our Win32 Qt external doesn't have the private API. #if defined(WIN32) || defined(__APPLE__) - wsi.render_surface = window ? reinterpret_cast(window->winId()) : nullptr; + wsi.render_window = window ? reinterpret_cast(window->winId()) : nullptr; + wsi.render_surface = wsi.render_window; #else QPlatformNativeInterface* pni = QGuiApplication::platformNativeInterface(); wsi.display_connection = pni->nativeResourceForWindow("display", window); if (wsi.type == WindowSystemType::Wayland) - wsi.render_surface = window ? pni->nativeResourceForWindow("surface", window) : nullptr; + wsi.render_window = window ? pni->nativeResourceForWindow("surface", window) : nullptr; else - wsi.render_surface = window ? reinterpret_cast(window->winId()) : nullptr; + wsi.render_window = window ? reinterpret_cast(window->winId()) : nullptr; + wsi.render_surface = wsi.render_window; #endif wsi.render_surface_scale = window ? static_cast(window->devicePixelRatio()) : 1.0f; diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp index 833f288da5..189738e76b 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp @@ -50,14 +50,14 @@ void ControllerInterface::Initialize(const WindowSystemInfo& wsi) m_is_populating_devices = true; #ifdef CIFACE_USE_WIN32 - ciface::Win32::Init(wsi.render_surface); + ciface::Win32::Init(wsi.render_window); #endif #ifdef CIFACE_USE_XLIB // nothing needed #endif #ifdef CIFACE_USE_OSX if (m_wsi.type == WindowSystemType::MacOS) - ciface::OSX::Init(wsi.render_surface); + ciface::OSX::Init(wsi.render_window); // nothing needed for Quartz #endif #ifdef CIFACE_USE_SDL @@ -84,7 +84,8 @@ void ControllerInterface::ChangeWindow(void* hwnd) if (!m_is_init) return; - m_wsi.render_surface = hwnd; + // This shouldn't use render_surface so no need to update it. + m_wsi.render_window = hwnd; RefreshDevices(); }