From 8bcd7637e597299a4ccc5a81c3fd1b6cffa3b858 Mon Sep 17 00:00:00 2001 From: "Dr. Chat" Date: Mon, 14 May 2018 15:49:48 -0500 Subject: [PATCH] [Qt] Initialize Vulkan window and APU --- src/xenia/app/emulator_window.cc | 20 +++++++++++++++++++- src/xenia/app/emulator_window.h | 1 + src/xenia/app/premake5.lua | 2 +- src/xenia/app/xenia_main.cc | 9 ++++++++- 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/xenia/app/emulator_window.cc b/src/xenia/app/emulator_window.cc index 905e3df75..41fefe268 100644 --- a/src/xenia/app/emulator_window.cc +++ b/src/xenia/app/emulator_window.cc @@ -10,6 +10,7 @@ #include #include "xenia/app/emulator_window.h" +#include "xenia/apu/xaudio2/xaudio2_audio_system.h" #include "xenia/gpu/vulkan/vulkan_graphics_system.h" #include "xenia/ui/vulkan/vulkan_instance.h" @@ -39,6 +40,10 @@ bool EmulatorWindow::Setup() { return false; } + auto audio_factory = [&](cpu::Processor* processor) { + return apu::xaudio2::XAudio2AudioSystem::Create(processor); + }; + auto graphics_factory = [&](cpu::Processor* processor, kernel::KernelState* kernel_state) { auto graphics = std::make_unique(); @@ -47,10 +52,12 @@ bool EmulatorWindow::Setup() { return std::unique_ptr(nullptr); } + graphics->SetSwapCallback( + [&]() { this->graphics_window_->requestUpdate(); }); return graphics; }; - X_STATUS result = emulator_->Setup(nullptr, graphics_factory, nullptr); + X_STATUS result = emulator_->Setup(audio_factory, graphics_factory, nullptr); return result == X_STATUS_SUCCESS; } @@ -61,13 +68,24 @@ bool EmulatorWindow::InitializeVulkan() { // Create a Qt wrapper around our vulkan instance. vulkan_instance_ = std::make_unique(); vulkan_instance_->setVkInstance(*provider->instance()); + if (!vulkan_instance_->create()) { + return false; + } graphics_window_ = std::make_unique(); graphics_window_->setVulkanInstance(vulkan_instance_.get()); + // Now set the graphics window as our central widget. + QWidget* wrapper = QWidget::createWindowContainer(graphics_window_.get()); + setCentralWidget(wrapper); + graphics_provider_ = std::move(provider); return true; } +bool EmulatorWindow::Launch(const std::wstring& path) { + return emulator_->LaunchPath(path) == X_STATUS_SUCCESS; +} + } // namespace app } // namespace xe \ No newline at end of file diff --git a/src/xenia/app/emulator_window.h b/src/xenia/app/emulator_window.h index 545aa9718..cbe471202 100644 --- a/src/xenia/app/emulator_window.h +++ b/src/xenia/app/emulator_window.h @@ -29,6 +29,7 @@ class EmulatorWindow : public QMainWindow { bool Setup(); bool InitializeVulkan(); + bool Launch(const std::wstring& path); protected: // Events diff --git a/src/xenia/app/premake5.lua b/src/xenia/app/premake5.lua index 7b61e10d3..073af7564 100644 --- a/src/xenia/app/premake5.lua +++ b/src/xenia/app/premake5.lua @@ -33,7 +33,7 @@ project("xenia-app") "xenia-hid-nop", "xenia-kernel", "xenia-ui", - "xenia-ui-qt", + -- "xenia-ui-qt", "xenia-ui-spirv", "xenia-ui-vulkan", "xenia-vfs", diff --git a/src/xenia/app/xenia_main.cc b/src/xenia/app/xenia_main.cc index 1604d8e87..861f10eef 100644 --- a/src/xenia/app/xenia_main.cc +++ b/src/xenia/app/xenia_main.cc @@ -37,7 +37,9 @@ int xenia_main(const std::vector& args) { if (!main_wnd.Setup()) { return 1; } - + + main_wnd.setFixedSize(1280, 720); + /* if (FLAGS_mount_scratch) { auto scratch_device = std::make_unique( @@ -104,6 +106,11 @@ int xenia_main(const std::vector& args) { */ main_wnd.show(); + if (args.size() >= 2) { + // Launch the path passed in args[1]. + main_wnd.Launch(args[1]); + } + int rc = app.exec(); Profiler::Dump();