Common: Add a render_window field to WindowSystemInfo

We need this because we need to pass the layer to MoltenVK, not
the view handle. But the input subsystem still needs the window.
This commit is contained in:
Stenzek 2020-03-11 23:09:28 +10:00
parent bb7623e3ba
commit 86db015c23
8 changed files with 24 additions and 10 deletions

View File

@ -680,7 +680,7 @@ static void Run(JNIEnv* env, const std::vector<std::string>& paths,
s_have_wm_user_stop = false;
std::unique_ptr<BootParameters> 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))
{

View File

@ -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.

View File

@ -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;
}

View File

@ -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;
}

View File

@ -134,6 +134,7 @@ WindowSystemInfo PlatformWin32::GetWindowSystemInfo() const
{
WindowSystemInfo wsi;
wsi.type = WindowSystemType::Windows;
wsi.render_window = reinterpret_cast<void*>(m_hwnd);
wsi.render_surface = reinterpret_cast<void*>(m_hwnd);
return wsi;
}

View File

@ -159,6 +159,7 @@ WindowSystemInfo PlatformX11::GetWindowSystemInfo() const
WindowSystemInfo wsi;
wsi.type = WindowSystemType::X11;
wsi.display_connection = static_cast<void*>(m_display);
wsi.render_window = reinterpret_cast<void*>(m_window);
wsi.render_surface = reinterpret_cast<void*>(m_window);
return wsi;
}

View File

@ -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<void*>(window->winId()) : nullptr;
wsi.render_window = window ? reinterpret_cast<void*>(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<void*>(window->winId()) : nullptr;
wsi.render_window = window ? reinterpret_cast<void*>(window->winId()) : nullptr;
wsi.render_surface = wsi.render_window;
#endif
wsi.render_surface_scale = window ? static_cast<float>(window->devicePixelRatio()) : 1.0f;

View File

@ -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();
}