Merge branch 'master' into vulkan

This commit is contained in:
Triang3l
2021-09-12 14:10:36 +03:00
161 changed files with 3359 additions and 1562 deletions

View File

@@ -11,6 +11,7 @@
#include "third_party/fmt/include/fmt/format.h"
#include "third_party/imgui/imgui.h"
#include "xenia/base/assert.h"
#include "xenia/base/clock.h"
#include "xenia/base/cvar.h"
#include "xenia/base/debugging.h"
@@ -40,12 +41,13 @@ using xe::ui::MenuItem;
using xe::ui::MouseEvent;
using xe::ui::UIEvent;
const std::string kBaseTitle = "xenia";
const std::string kBaseTitle = "Xenia";
EmulatorWindow::EmulatorWindow(Emulator* emulator)
EmulatorWindow::EmulatorWindow(Emulator* emulator,
ui::WindowedAppContext& app_context)
: emulator_(emulator),
loop_(ui::Loop::Create()),
window_(ui::Window::Create(loop_.get(), kBaseTitle)) {
app_context_(app_context),
window_(ui::Window::Create(app_context, kBaseTitle)) {
base_title_ = kBaseTitle +
#ifdef DEBUG
#if _NO_DEBUG_HEAP == 1
@@ -54,27 +56,23 @@ EmulatorWindow::EmulatorWindow(Emulator* emulator)
" CHECKED"
#endif
#endif
" (" XE_BUILD_BRANCH "/" XE_BUILD_COMMIT_SHORT "/" XE_BUILD_DATE
" ("
#ifdef XE_BUILD_IS_PR
"PR#" XE_BUILD_PR_NUMBER " " XE_BUILD_PR_REPO
" " XE_BUILD_PR_BRANCH "@" XE_BUILD_PR_COMMIT_SHORT " against "
#endif
XE_BUILD_BRANCH "@" XE_BUILD_COMMIT_SHORT " on " XE_BUILD_DATE
")";
}
EmulatorWindow::~EmulatorWindow() {
loop_->PostSynchronous([this]() { window_.reset(); });
}
std::unique_ptr<EmulatorWindow> EmulatorWindow::Create(Emulator* emulator) {
std::unique_ptr<EmulatorWindow> emulator_window(new EmulatorWindow(emulator));
emulator_window->loop()->PostSynchronous([&emulator_window]() {
xe::threading::set_name("Windowing Loop");
xe::Profiler::ThreadEnter("Windowing Loop");
if (!emulator_window->Initialize()) {
xe::FatalError("Failed to initialize main window");
return;
}
});
std::unique_ptr<EmulatorWindow> EmulatorWindow::Create(
Emulator* emulator, ui::WindowedAppContext& app_context) {
assert_true(app_context.IsInUIThread());
std::unique_ptr<EmulatorWindow> emulator_window(
new EmulatorWindow(emulator, app_context));
if (!emulator_window->Initialize()) {
return nullptr;
}
return emulator_window;
}
@@ -86,8 +84,8 @@ bool EmulatorWindow::Initialize() {
UpdateTitle();
window_->on_closed.AddListener([this](UIEvent* e) { loop_->Quit(); });
loop_->on_quit.AddListener([this](UIEvent* e) { window_.reset(); });
window_->on_closed.AddListener(
[this](UIEvent* e) { app_context_.QuitFromUIThread(); });
window_->on_file_drop.AddListener(
[this](FileDropEvent* e) { FileDrop(e->filename()); });
@@ -308,7 +306,7 @@ void EmulatorWindow::FileOpen() {
file_picker->set_multi_selection(false);
file_picker->set_title("Select Content Package");
file_picker->set_extensions({
{"Supported Files", "*.iso;*.xex;*.xcp;*.*"},
{"Supported Files", "*.iso;*.xex;*.*"},
{"Disc Image (*.iso)", "*.iso"},
{"Xbox Executable (*.xex)", "*.xex"},
//{"Content Package (*.xcp)", "*.xcp" },
@@ -426,8 +424,13 @@ void EmulatorWindow::ToggleFullscreen() {
void EmulatorWindow::ShowHelpWebsite() { LaunchWebBrowser("https://xenia.jp"); }
void EmulatorWindow::ShowCommitID() {
#ifdef XE_BUILD_IS_PR
LaunchWebBrowser(
"https://github.com/xenia-project/xenia/pull/" XE_BUILD_PR_NUMBER);
#else
LaunchWebBrowser(
"https://github.com/xenia-project/xenia/commit/" XE_BUILD_COMMIT "/");
#endif
}
void EmulatorWindow::UpdateTitle() {

View File

@@ -13,9 +13,9 @@
#include <memory>
#include <string>
#include "xenia/ui/loop.h"
#include "xenia/ui/menu_item.h"
#include "xenia/ui/window.h"
#include "xenia/ui/windowed_app_context.h"
#include "xenia/xbox.h"
namespace xe {
@@ -27,12 +27,11 @@ namespace app {
class EmulatorWindow {
public:
virtual ~EmulatorWindow();
static std::unique_ptr<EmulatorWindow> Create(Emulator* emulator);
static std::unique_ptr<EmulatorWindow> Create(
Emulator* emulator, ui::WindowedAppContext& app_context);
Emulator* emulator() const { return emulator_; }
ui::Loop* loop() const { return loop_.get(); }
ui::WindowedAppContext& app_context() const { return app_context_; }
ui::Window* window() const { return window_.get(); }
void UpdateTitle();
@@ -40,7 +39,8 @@ class EmulatorWindow {
void SetInitializingShaderStorage(bool initializing);
private:
explicit EmulatorWindow(Emulator* emulator);
explicit EmulatorWindow(Emulator* emulator,
ui::WindowedAppContext& app_context);
bool Initialize();
@@ -60,7 +60,7 @@ class EmulatorWindow {
void ShowCommitID();
Emulator* emulator_;
std::unique_ptr<ui::Loop> loop_;
ui::WindowedAppContext& app_context_;
std::unique_ptr<ui::Window> window_;
std::string base_title_;
uint64_t cursor_hide_time_ = 0;

View File

@@ -50,8 +50,8 @@ project("xenia-app")
local_platform_files()
files({
"xenia_main.cc",
"../base/main_"..platform_suffix..".cc",
"../base/main_init_"..platform_suffix..".cc",
"../ui/windowed_app_main_"..platform_suffix..".cc",
})
resincludedirs({
@@ -71,7 +71,6 @@ project("xenia-app")
"X11",
"xcb",
"X11-xcb",
"vulkan",
"SDL2",
})

View File

@@ -7,18 +7,29 @@
******************************************************************************
*/
#include <atomic>
#include <cstdlib>
#include <functional>
#include <memory>
#include <string>
#include <thread>
#include <vector>
#include "xenia/app/discord/discord_presence.h"
#include "xenia/app/emulator_window.h"
#include "xenia/base/cvar.h"
#include "xenia/base/debugging.h"
#include "xenia/base/logging.h"
#include "xenia/base/main.h"
#include "xenia/base/platform.h"
#include "xenia/base/profiling.h"
#include "xenia/base/threading.h"
#include "xenia/config.h"
#include "xenia/debug/ui/debug_window.h"
#include "xenia/emulator.h"
#include "xenia/ui/file_picker.h"
#include "xenia/ui/window.h"
#include "xenia/ui/windowed_app.h"
#include "xenia/ui/windowed_app_context.h"
#include "xenia/vfs/devices/host_path_device.h"
// Available audio systems:
@@ -44,7 +55,6 @@
#endif // XE_PLATFORM_WIN32
#include "third_party/fmt/include/fmt/format.h"
#include "third_party/xbyak/xbyak/xbyak_util.h"
DEFINE_string(apu, "any", "Audio system. Use: [any, nop, sdl, xaudio2]", "APU");
DEFINE_string(gpu, "any", "Graphics system. Use: [any, d3d12, vulkan, null]",
@@ -91,83 +101,134 @@ DEFINE_bool(discord, true, "Enable Discord rich presence", "General");
namespace xe {
namespace app {
template <typename T, typename... Args>
class Factory {
class EmulatorApp final : public xe::ui::WindowedApp {
public:
static std::unique_ptr<xe::ui::WindowedApp> Create(
xe::ui::WindowedAppContext& app_context) {
return std::unique_ptr<xe::ui::WindowedApp>(new EmulatorApp(app_context));
}
~EmulatorApp();
bool OnInitialize() override;
protected:
void OnDestroy() override;
private:
struct Creator {
std::string name;
std::function<bool()> is_available;
std::function<std::unique_ptr<T>(Args...)> instantiate;
template <typename T, typename... Args>
class Factory {
private:
struct Creator {
std::string name;
std::function<bool()> is_available;
std::function<std::unique_ptr<T>(Args...)> instantiate;
};
std::vector<Creator> creators_;
public:
void Add(const std::string_view name, std::function<bool()> is_available,
std::function<std::unique_ptr<T>(Args...)> instantiate) {
creators_.push_back({std::string(name), is_available, instantiate});
}
void Add(const std::string_view name,
std::function<std::unique_ptr<T>(Args...)> instantiate) {
auto always_available = []() { return true; };
Add(name, always_available, instantiate);
}
template <typename DT>
void Add(const std::string_view name) {
Add(name, DT::IsAvailable, [](Args... args) {
return std::make_unique<DT>(std::forward<Args>(args)...);
});
}
std::unique_ptr<T> Create(const std::string_view name, Args... args) {
if (!name.empty() && name != "any") {
auto it = std::find_if(
creators_.cbegin(), creators_.cend(),
[&name](const auto& f) { return name.compare(f.name) == 0; });
if (it != creators_.cend() && (*it).is_available()) {
return (*it).instantiate(std::forward<Args>(args)...);
}
return nullptr;
} else {
for (const auto& creator : creators_) {
if (!creator.is_available()) continue;
auto instance = creator.instantiate(std::forward<Args>(args)...);
if (!instance) continue;
return instance;
}
return nullptr;
}
}
std::vector<std::unique_ptr<T>> CreateAll(const std::string_view name,
Args... args) {
std::vector<std::unique_ptr<T>> instances;
if (!name.empty() && name != "any") {
auto it = std::find_if(
creators_.cbegin(), creators_.cend(),
[&name](const auto& f) { return name.compare(f.name) == 0; });
if (it != creators_.cend() && (*it).is_available()) {
auto instance = (*it).instantiate(std::forward<Args>(args)...);
if (instance) {
instances.emplace_back(std::move(instance));
}
}
} else {
for (const auto& creator : creators_) {
if (!creator.is_available()) continue;
auto instance = creator.instantiate(std::forward<Args>(args)...);
if (instance) {
instances.emplace_back(std::move(instance));
}
}
}
return instances;
}
};
std::vector<Creator> creators_;
explicit EmulatorApp(xe::ui::WindowedAppContext& app_context);
public:
void Add(const std::string_view name, std::function<bool()> is_available,
std::function<std::unique_ptr<T>(Args...)> instantiate) {
creators_.push_back({std::string(name), is_available, instantiate});
}
static std::unique_ptr<apu::AudioSystem> CreateAudioSystem(
cpu::Processor* processor);
static std::unique_ptr<gpu::GraphicsSystem> CreateGraphicsSystem();
static std::vector<std::unique_ptr<hid::InputDriver>> CreateInputDrivers(
ui::Window* window);
void Add(const std::string_view name,
std::function<std::unique_ptr<T>(Args...)> instantiate) {
auto always_available = []() { return true; };
Add(name, always_available, instantiate);
}
void EmulatorThread();
void ShutdownEmulatorThreadFromUIThread();
template <typename DT>
void Add(const std::string_view name) {
Add(name, DT::IsAvailable, [](Args... args) {
return std::make_unique<DT>(std::forward<Args>(args)...);
});
}
std::unique_ptr<Emulator> emulator_;
std::unique_ptr<EmulatorWindow> emulator_window_;
std::unique_ptr<T> Create(const std::string_view name, Args... args) {
if (!name.empty() && name != "any") {
auto it = std::find_if(
creators_.cbegin(), creators_.cend(),
[&name](const auto& f) { return name.compare(f.name) == 0; });
if (it != creators_.cend() && (*it).is_available()) {
return (*it).instantiate(std::forward<Args>(args)...);
}
return nullptr;
} else {
for (const auto& creator : creators_) {
if (!creator.is_available()) continue;
auto instance = creator.instantiate(std::forward<Args>(args)...);
if (!instance) continue;
return instance;
}
return nullptr;
}
}
// Created on demand, used by the emulator.
std::unique_ptr<xe::debug::ui::DebugWindow> debug_window_;
std::vector<std::unique_ptr<T>> CreateAll(const std::string_view name,
Args... args) {
std::vector<std::unique_ptr<T>> instances;
if (!name.empty() && name != "any") {
auto it = std::find_if(
creators_.cbegin(), creators_.cend(),
[&name](const auto& f) { return name.compare(f.name) == 0; });
if (it != creators_.cend() && (*it).is_available()) {
auto instance = (*it).instantiate(std::forward<Args>(args)...);
if (instance) {
instances.emplace_back(std::move(instance));
}
}
} else {
for (const auto& creator : creators_) {
if (!creator.is_available()) continue;
auto instance = creator.instantiate(std::forward<Args>(args)...);
if (instance) {
instances.emplace_back(std::move(instance));
}
}
}
return instances;
}
// Refreshing the emulator - placed after its dependencies.
std::atomic<bool> emulator_thread_quit_requested_;
std::unique_ptr<xe::threading::Event> emulator_thread_event_;
std::thread emulator_thread_;
};
std::unique_ptr<apu::AudioSystem> CreateAudioSystem(cpu::Processor* processor) {
EmulatorApp::EmulatorApp(xe::ui::WindowedAppContext& app_context)
: xe::ui::WindowedApp(app_context, "xenia", "[Path to .iso/.xex]") {
AddPositionalOption("target");
}
EmulatorApp::~EmulatorApp() {
// Should be shut down from OnDestroy if OnInitialize has ever been done, but
// for the most safety as a running thread may be destroyed only after
// joining.
ShutdownEmulatorThreadFromUIThread();
}
std::unique_ptr<apu::AudioSystem> EmulatorApp::CreateAudioSystem(
cpu::Processor* processor) {
Factory<apu::AudioSystem, cpu::Processor*> factory;
#if XE_PLATFORM_WIN32
factory.Add<apu::xaudio2::XAudio2AudioSystem>("xaudio2");
@@ -177,7 +238,7 @@ std::unique_ptr<apu::AudioSystem> CreateAudioSystem(cpu::Processor* processor) {
return factory.Create(cvars::apu, processor);
}
std::unique_ptr<gpu::GraphicsSystem> CreateGraphicsSystem() {
std::unique_ptr<gpu::GraphicsSystem> EmulatorApp::CreateGraphicsSystem() {
Factory<gpu::GraphicsSystem> factory;
factory.Add<gpu::vulkan::VulkanGraphicsSystem>("vulkan");
// TODO(Triang3l): Move D3D12 back to the top.
@@ -188,7 +249,7 @@ std::unique_ptr<gpu::GraphicsSystem> CreateGraphicsSystem() {
return factory.Create(cvars::gpu);
}
std::vector<std::unique_ptr<hid::InputDriver>> CreateInputDrivers(
std::vector<std::unique_ptr<hid::InputDriver>> EmulatorApp::CreateInputDrivers(
ui::Window* window) {
std::vector<std::unique_ptr<hid::InputDriver>> drivers;
if (cvars::hid.compare("nop") == 0) {
@@ -216,9 +277,9 @@ std::vector<std::unique_ptr<hid::InputDriver>> CreateInputDrivers(
return drivers;
}
int xenia_main(const std::vector<std::string>& args) {
bool EmulatorApp::OnInitialize() {
Profiler::Initialize();
Profiler::ThreadEnter("main");
Profiler::ThreadEnter("Main");
// Figure out where internal files and content should go.
std::filesystem::path storage_root = cvars::storage_root;
@@ -276,20 +337,55 @@ int xenia_main(const std::vector<std::string>& args) {
}
// Create the emulator but don't initialize so we can setup the window.
auto emulator =
emulator_ =
std::make_unique<Emulator>("", storage_root, content_root, cache_root);
// Main emulator display window.
auto emulator_window = EmulatorWindow::Create(emulator.get());
emulator_window_ = EmulatorWindow::Create(emulator_.get(), app_context());
if (!emulator_window_) {
XELOGE("Failed to create the main emulator window");
return false;
}
// Setup the emulator and run its loop in a separate thread.
emulator_thread_quit_requested_.store(false, std::memory_order_relaxed);
emulator_thread_event_ = xe::threading::Event::CreateAutoResetEvent(false);
emulator_thread_ = std::thread(&EmulatorApp::EmulatorThread, this);
return true;
}
void EmulatorApp::OnDestroy() {
ShutdownEmulatorThreadFromUIThread();
if (cvars::discord) {
discord::DiscordPresence::Shutdown();
}
Profiler::Dump();
// The profiler needs to shut down before the graphics context.
Profiler::Shutdown();
// TODO(DrChat): Remove this code and do a proper exit.
XELOGI("Cheap-skate exit!");
std::quick_exit(EXIT_SUCCESS);
}
void EmulatorApp::EmulatorThread() {
assert_not_null(emulator_thread_event_);
xe::threading::set_name("Emulator");
Profiler::ThreadEnter("Emulator");
// Setup and initialize all subsystems. If we can't do something
// (unsupported system, memory issues, etc) this will fail early.
X_STATUS result =
emulator->Setup(emulator_window->window(), CreateAudioSystem,
CreateGraphicsSystem, CreateInputDrivers);
emulator_->Setup(emulator_window_->window(), CreateAudioSystem,
CreateGraphicsSystem, CreateInputDrivers);
if (XFAILED(result)) {
XELOGE("Failed to setup emulator: {:08X}", result);
return 1;
app_context().RequestDeferredQuit();
return;
}
if (cvars::mount_scratch) {
@@ -298,10 +394,11 @@ int xenia_main(const std::vector<std::string>& args) {
if (!scratch_device->Initialize()) {
XELOGE("Unable to scan scratch path");
} else {
if (!emulator->file_system()->RegisterDevice(std::move(scratch_device))) {
if (!emulator_->file_system()->RegisterDevice(
std::move(scratch_device))) {
XELOGE("Unable to register scratch path");
} else {
emulator->file_system()->RegisterSymbolicLink("scratch:", "\\SCRATCH");
emulator_->file_system()->RegisterSymbolicLink("scratch:", "\\SCRATCH");
}
}
}
@@ -312,10 +409,10 @@ int xenia_main(const std::vector<std::string>& args) {
if (!cache0_device->Initialize()) {
XELOGE("Unable to scan cache0 path");
} else {
if (!emulator->file_system()->RegisterDevice(std::move(cache0_device))) {
if (!emulator_->file_system()->RegisterDevice(std::move(cache0_device))) {
XELOGE("Unable to register cache0 path");
} else {
emulator->file_system()->RegisterSymbolicLink("cache0:", "\\CACHE0");
emulator_->file_system()->RegisterSymbolicLink("cache0:", "\\CACHE0");
}
}
@@ -324,79 +421,78 @@ int xenia_main(const std::vector<std::string>& args) {
if (!cache1_device->Initialize()) {
XELOGE("Unable to scan cache1 path");
} else {
if (!emulator->file_system()->RegisterDevice(std::move(cache1_device))) {
if (!emulator_->file_system()->RegisterDevice(std::move(cache1_device))) {
XELOGE("Unable to register cache1 path");
} else {
emulator->file_system()->RegisterSymbolicLink("cache1:", "\\CACHE1");
emulator_->file_system()->RegisterSymbolicLink("cache1:", "\\CACHE1");
}
}
// Some (older?) games try accessing cache:\ too
// NOTE: this must be registered _after_ the cache0/cache1 devices, due to
// substring/start_with logic inside VirtualFileSystem::ResolvePath, else
// accesses to those devices will go here instead
auto cache_device =
std::make_unique<xe::vfs::HostPathDevice>("\\CACHE", "cache", false);
if (!cache_device->Initialize()) {
XELOGE("Unable to scan cache path");
} else {
if (!emulator_->file_system()->RegisterDevice(std::move(cache_device))) {
XELOGE("Unable to register cache path");
} else {
emulator_->file_system()->RegisterSymbolicLink("cache:", "\\CACHE");
}
}
}
// Set a debug handler.
// This will respond to debugging requests so we can open the debug UI.
std::unique_ptr<xe::debug::ui::DebugWindow> debug_window;
if (cvars::debug) {
emulator->processor()->set_debug_listener_request_handler(
[&](xe::cpu::Processor* processor) {
if (debug_window) {
return debug_window.get();
emulator_->processor()->set_debug_listener_request_handler(
[this](xe::cpu::Processor* processor) {
if (debug_window_) {
return debug_window_.get();
}
emulator_window->loop()->PostSynchronous([&]() {
debug_window = xe::debug::ui::DebugWindow::Create(
emulator.get(), emulator_window->loop());
debug_window->window()->on_closed.AddListener(
[&](xe::ui::UIEvent* e) {
emulator->processor()->set_debug_listener(nullptr);
emulator_window->loop()->Post(
[&]() { debug_window.reset(); });
app_context().CallInUIThreadSynchronous([this]() {
debug_window_ = xe::debug::ui::DebugWindow::Create(emulator_.get(),
app_context());
debug_window_->window()->on_closed.AddListener(
[this](xe::ui::UIEvent* e) {
emulator_->processor()->set_debug_listener(nullptr);
app_context().CallInUIThread(
[this]() { debug_window_.reset(); });
});
});
return debug_window.get();
// If failed to enqueue the UI thread call, this will just be null.
return debug_window_.get();
});
}
auto evt = xe::threading::Event::CreateAutoResetEvent(false);
emulator->on_launch.AddListener([&](auto title_id, const auto& game_title) {
emulator_->on_launch.AddListener([&](auto title_id, const auto& game_title) {
if (cvars::discord) {
discord::DiscordPresence::PlayingTitle(
game_title.empty() ? "Unknown Title" : std::string(game_title));
}
emulator_window->UpdateTitle();
evt->Set();
app_context().CallInUIThread([this]() { emulator_window_->UpdateTitle(); });
emulator_thread_event_->Set();
});
emulator->on_shader_storage_initialization.AddListener(
[&](bool initializing) {
emulator_window->SetInitializingShaderStorage(initializing);
emulator_->on_shader_storage_initialization.AddListener(
[this](bool initializing) {
app_context().CallInUIThread([this, initializing]() {
emulator_window_->SetInitializingShaderStorage(initializing);
});
});
emulator->on_terminate.AddListener([&]() {
emulator_->on_terminate.AddListener([]() {
if (cvars::discord) {
discord::DiscordPresence::NotPlaying();
}
});
emulator_window->window()->on_closing.AddListener([&](ui::UIEvent* e) {
// This needs to shut down before the graphics context.
Profiler::Shutdown();
});
bool exiting = false;
emulator_window->loop()->on_quit.AddListener([&](ui::UIEvent* e) {
exiting = true;
evt->Set();
if (cvars::discord) {
discord::DiscordPresence::Shutdown();
}
// TODO(DrChat): Remove this code and do a proper exit.
XELOGI("Cheap-skate exit!");
exit(0);
});
// Enable the main menu now that the emulator is properly loaded
emulator_window->window()->EnableMainMenu();
app_context().CallInUIThread(
[this]() { emulator_window_->window()->EnableMainMenu(); });
// Grab path from the flag or unnamed argument.
std::filesystem::path path;
@@ -405,50 +501,56 @@ int xenia_main(const std::vector<std::string>& args) {
}
// Toggles fullscreen
if (cvars::fullscreen) emulator_window->ToggleFullscreen();
if (cvars::fullscreen) {
app_context().CallInUIThread(
[this]() { emulator_window_->ToggleFullscreen(); });
}
if (!path.empty()) {
// Normalize the path and make absolute.
auto abs_path = std::filesystem::absolute(path);
result = emulator->LaunchPath(abs_path);
result = emulator_->LaunchPath(abs_path);
if (XFAILED(result)) {
xe::FatalError(fmt::format("Failed to launch target: {:08X}", result));
emulator.reset();
emulator_window.reset();
return 1;
app_context().RequestDeferredQuit();
return;
}
}
// Now, we're going to use the main thread to drive events related to
// emulation.
while (!exiting) {
xe::threading::Wait(evt.get(), false);
// Now, we're going to use this thread to drive events related to emulation.
while (!emulator_thread_quit_requested_.load(std::memory_order_relaxed)) {
xe::threading::Wait(emulator_thread_event_.get(), false);
while (true) {
emulator->WaitUntilExit();
if (emulator->TitleRequested()) {
emulator->LaunchNextTitle();
emulator_->WaitUntilExit();
if (emulator_->TitleRequested()) {
emulator_->LaunchNextTitle();
} else {
break;
}
}
}
}
debug_window.reset();
emulator.reset();
if (cvars::discord) {
discord::DiscordPresence::Shutdown();
void EmulatorApp::ShutdownEmulatorThreadFromUIThread() {
// TODO(Triang3l): Proper shutdown of the emulator (relying on std::quick_exit
// for now) - currently WaitUntilExit loops forever otherwise (plus possibly
// lots of other things not shutting down correctly now). Some parts of the
// code call the regular std::exit, which seems to be calling destructors (at
// least on Linux), so the entire join is currently commented out.
#if 0
// Same thread as the one created it, to make sure there's zero possibility of
// a race with the creation of the emulator thread.
assert_true(app_context().IsInUIThread());
emulator_thread_quit_requested_.store(true, std::memory_order_relaxed);
if (!emulator_thread_.joinable()) {
return;
}
Profiler::Dump();
Profiler::Shutdown();
emulator_window.reset();
return 0;
emulator_thread_event_->Set();
emulator_thread_.join();
#endif
}
} // namespace app
} // namespace xe
DEFINE_ENTRY_POINT("xenia", xe::app::xenia_main, "[Path to .iso/.xex]",
"target");
XE_DEFINE_WINDOWED_APP(xenia, xe::app::EmulatorApp::Create);