mirror of
https://git.suyu.dev/suyu/suyu
synced 2026-05-13 06:55:45 +00:00
metal: initial support
This commit is contained in:
@@ -21,6 +21,8 @@ add_executable(suyu-cmd
|
||||
emu_window/emu_window_sdl2_null.h
|
||||
emu_window/emu_window_sdl2_vk.cpp
|
||||
emu_window/emu_window_sdl2_vk.h
|
||||
emu_window/emu_window_sdl2_mtl.cpp
|
||||
emu_window/emu_window_sdl2_mtl.h
|
||||
precompiled_headers.h
|
||||
sdl_config.cpp
|
||||
sdl_config.h
|
||||
|
||||
66
src/suyu_cmd/emu_window/emu_window_sdl2_mtl.cpp
Normal file
66
src/suyu_cmd/emu_window/emu_window_sdl2_mtl.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <cstdlib>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include "common/logging/log.h"
|
||||
#include "common/scm_rev.h"
|
||||
#include "suyu_cmd/emu_window/emu_window_sdl2_mtl.h"
|
||||
#include "video_core/renderer_metal/renderer_metal.h"
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL_syswm.h>
|
||||
|
||||
EmuWindow_SDL2_MTL::EmuWindow_SDL2_MTL(InputCommon::InputSubsystem* input_subsystem_,
|
||||
Core::System& system_, bool fullscreen)
|
||||
: EmuWindow_SDL2{input_subsystem_, system_} {
|
||||
const std::string window_title = fmt::format("suyu {} | {}-{} (Vulkan)", Common::g_build_name,
|
||||
Common::g_scm_branch, Common::g_scm_desc);
|
||||
render_window =
|
||||
SDL_CreateWindow(window_title.c_str(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
|
||||
Layout::ScreenUndocked::Width, Layout::ScreenUndocked::Height,
|
||||
SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
||||
|
||||
SDL_SysWMinfo wm;
|
||||
SDL_VERSION(&wm.version);
|
||||
if (SDL_GetWindowWMInfo(render_window, &wm) == SDL_FALSE) {
|
||||
LOG_CRITICAL(Frontend, "Failed to get information from the window manager: {}",
|
||||
SDL_GetError());
|
||||
std::exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
SetWindowIcon();
|
||||
|
||||
if (fullscreen) {
|
||||
Fullscreen();
|
||||
ShowCursor(false);
|
||||
}
|
||||
|
||||
switch (wm.subsystem) {
|
||||
#ifdef SDL_VIDEO_DRIVER_COCOA
|
||||
case SDL_SYSWM_TYPE::SDL_SYSWM_COCOA:
|
||||
window_info.type = Core::Frontend::WindowSystemType::Cocoa;
|
||||
window_info.render_surface = SDL_Metal_CreateView(render_window);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
LOG_CRITICAL(Frontend, "Window manager subsystem {} not implemented", wm.subsystem);
|
||||
std::exit(EXIT_FAILURE);
|
||||
break;
|
||||
}
|
||||
|
||||
OnResize();
|
||||
OnMinimalClientAreaChangeRequest(GetActiveConfig().min_client_area_size);
|
||||
SDL_PumpEvents();
|
||||
LOG_INFO(Frontend, "suyu Version: {} | {}-{} (Vulkan)", Common::g_build_name,
|
||||
Common::g_scm_branch, Common::g_scm_desc);
|
||||
}
|
||||
|
||||
EmuWindow_SDL2_MTL::~EmuWindow_SDL2_MTL() = default;
|
||||
|
||||
std::unique_ptr<Core::Frontend::GraphicsContext> EmuWindow_SDL2_MTL::CreateSharedContext() const {
|
||||
return std::make_unique<DummyContext>();
|
||||
}
|
||||
25
src/suyu_cmd/emu_window/emu_window_sdl2_mtl.h
Normal file
25
src/suyu_cmd/emu_window/emu_window_sdl2_mtl.h
Normal file
@@ -0,0 +1,25 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "core/frontend/emu_window.h"
|
||||
#include "suyu_cmd/emu_window/emu_window_sdl2.h"
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace InputCommon {
|
||||
class InputSubsystem;
|
||||
}
|
||||
|
||||
class EmuWindow_SDL2_MTL final : public EmuWindow_SDL2 {
|
||||
public:
|
||||
explicit EmuWindow_SDL2_MTL(InputCommon::InputSubsystem* input_subsystem_, Core::System& system,
|
||||
bool fullscreen);
|
||||
~EmuWindow_SDL2_MTL() override;
|
||||
|
||||
std::unique_ptr<Core::Frontend::GraphicsContext> CreateSharedContext() const override;
|
||||
};
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "sdl_config.h"
|
||||
#include "suyu_cmd/emu_window/emu_window_sdl2.h"
|
||||
#include "suyu_cmd/emu_window/emu_window_sdl2_gl.h"
|
||||
#include "suyu_cmd/emu_window/emu_window_sdl2_mtl.h"
|
||||
#include "suyu_cmd/emu_window/emu_window_sdl2_null.h"
|
||||
#include "suyu_cmd/emu_window/emu_window_sdl2_vk.h"
|
||||
#include "video_core/renderer_base.h"
|
||||
@@ -385,6 +386,9 @@ int main(int argc, char** argv) {
|
||||
case Settings::RendererBackend::Vulkan:
|
||||
emu_window = std::make_unique<EmuWindow_SDL2_VK>(&input_subsystem, system, fullscreen);
|
||||
break;
|
||||
case Settings::RendererBackend::Metal:
|
||||
emu_window = std::make_unique<EmuWindow_SDL2_MTL>(&input_subsystem, system, fullscreen);
|
||||
break;
|
||||
case Settings::RendererBackend::Null:
|
||||
emu_window = std::make_unique<EmuWindow_SDL2_Null>(&input_subsystem, system, fullscreen);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user