Skip to content

Commit

Permalink
Common: Add a render_window field to WindowSystemInfo
Browse files Browse the repository at this point in the history
We need this because we need to pass the layer to MoltenVK, not
the view handle. But the input subsystem still needs the window.
  • Loading branch information
stenzek committed Mar 11, 2020
1 parent bb7623e commit 86db015
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Source/Android/jni/MainAndroid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand Down
13 changes: 10 additions & 3 deletions Source/Core/Common/WindowSystemInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_)
{
}

Expand All @@ -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.
Expand Down
1 change: 1 addition & 0 deletions Source/Core/DolphinNoGUI/PlatformFBDev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions Source/Core/DolphinNoGUI/PlatformHeadless.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions Source/Core/DolphinNoGUI/PlatformWin32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions Source/Core/DolphinNoGUI/PlatformX11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 5 additions & 3 deletions Source/Core/DolphinQt/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
}

Expand Down

0 comments on commit 86db015

Please sign in to comment.