emu_window_sdl2_vk.cpp 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // Copyright 2018 yuzu Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include <cstdlib>
  5. #include <memory>
  6. #include <string>
  7. #include <fmt/format.h>
  8. #include "common/assert.h"
  9. #include "common/logging/log.h"
  10. #include "common/scm_rev.h"
  11. #include "core/settings.h"
  12. #include "video_core/renderer_vulkan/renderer_vulkan.h"
  13. #include "yuzu_cmd/emu_window/emu_window_sdl2_vk.h"
  14. // Include these late to avoid polluting everything with Xlib macros
  15. #include <SDL.h>
  16. #include <SDL_syswm.h>
  17. EmuWindow_SDL2_VK::EmuWindow_SDL2_VK(Core::System& system, bool fullscreen)
  18. : EmuWindow_SDL2{system, fullscreen} {
  19. const std::string window_title = fmt::format("yuzu {} | {}-{} (Vulkan)", Common::g_build_name,
  20. Common::g_scm_branch, Common::g_scm_desc);
  21. render_window =
  22. SDL_CreateWindow(window_title.c_str(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
  23. Layout::ScreenUndocked::Width, Layout::ScreenUndocked::Height,
  24. SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
  25. SDL_SysWMinfo wm;
  26. SDL_VERSION(&wm.version);
  27. if (SDL_GetWindowWMInfo(render_window, &wm) == SDL_FALSE) {
  28. LOG_CRITICAL(Frontend, "Failed to get information from the window manager");
  29. std::exit(EXIT_FAILURE);
  30. }
  31. switch (wm.subsystem) {
  32. #ifdef SDL_VIDEO_DRIVER_WINDOWS
  33. case SDL_SYSWM_TYPE::SDL_SYSWM_WINDOWS:
  34. window_info.type = Core::Frontend::WindowSystemType::Windows;
  35. window_info.render_surface = reinterpret_cast<void*>(wm.info.win.window);
  36. break;
  37. #endif
  38. #ifdef SDL_VIDEO_DRIVER_X11
  39. case SDL_SYSWM_TYPE::SDL_SYSWM_X11:
  40. window_info.type = Core::Frontend::WindowSystemType::X11;
  41. window_info.display_connection = wm.info.x11.display;
  42. window_info.render_surface = reinterpret_cast<void*>(wm.info.x11.window);
  43. break;
  44. #endif
  45. #ifdef SDL_VIDEO_DRIVER_WAYLAND
  46. case SDL_SYSWM_TYPE::SDL_SYSWM_WAYLAND:
  47. window_info.type = Core::Frontend::WindowSystemType::Wayland;
  48. window_info.display_connection = wm.info.wl.display;
  49. window_info.render_surface = wm.info.wl.surface;
  50. break;
  51. #endif
  52. default:
  53. LOG_CRITICAL(Frontend, "Window manager subsystem not implemented");
  54. std::exit(EXIT_FAILURE);
  55. }
  56. OnResize();
  57. OnMinimalClientAreaChangeRequest(GetActiveConfig().min_client_area_size);
  58. SDL_PumpEvents();
  59. LOG_INFO(Frontend, "yuzu Version: {} | {}-{} (Vulkan)", Common::g_build_name,
  60. Common::g_scm_branch, Common::g_scm_desc);
  61. }
  62. EmuWindow_SDL2_VK::~EmuWindow_SDL2_VK() = default;
  63. std::unique_ptr<Core::Frontend::GraphicsContext> EmuWindow_SDL2_VK::CreateSharedContext() const {
  64. return std::make_unique<DummyContext>();
  65. }
  66. void EmuWindow_SDL2_VK::Present() {
  67. // TODO (bunnei): ImplementMe
  68. }