[Qt] Initialize Vulkan window and APU

This commit is contained in:
Dr. Chat 2018-05-14 15:49:48 -05:00
parent 843ebc96fe
commit 8bcd7637e5
4 changed files with 29 additions and 3 deletions

View File

@ -10,6 +10,7 @@
#include <gflags/gflags.h> #include <gflags/gflags.h>
#include "xenia/app/emulator_window.h" #include "xenia/app/emulator_window.h"
#include "xenia/apu/xaudio2/xaudio2_audio_system.h"
#include "xenia/gpu/vulkan/vulkan_graphics_system.h" #include "xenia/gpu/vulkan/vulkan_graphics_system.h"
#include "xenia/ui/vulkan/vulkan_instance.h" #include "xenia/ui/vulkan/vulkan_instance.h"
@ -39,6 +40,10 @@ bool EmulatorWindow::Setup() {
return false; return false;
} }
auto audio_factory = [&](cpu::Processor* processor) {
return apu::xaudio2::XAudio2AudioSystem::Create(processor);
};
auto graphics_factory = [&](cpu::Processor* processor, auto graphics_factory = [&](cpu::Processor* processor,
kernel::KernelState* kernel_state) { kernel::KernelState* kernel_state) {
auto graphics = std::make_unique<gpu::vulkan::VulkanGraphicsSystem>(); auto graphics = std::make_unique<gpu::vulkan::VulkanGraphicsSystem>();
@ -47,10 +52,12 @@ bool EmulatorWindow::Setup() {
return std::unique_ptr<gpu::vulkan::VulkanGraphicsSystem>(nullptr); return std::unique_ptr<gpu::vulkan::VulkanGraphicsSystem>(nullptr);
} }
graphics->SetSwapCallback(
[&]() { this->graphics_window_->requestUpdate(); });
return graphics; 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; return result == X_STATUS_SUCCESS;
} }
@ -61,13 +68,24 @@ bool EmulatorWindow::InitializeVulkan() {
// Create a Qt wrapper around our vulkan instance. // Create a Qt wrapper around our vulkan instance.
vulkan_instance_ = std::make_unique<QVulkanInstance>(); vulkan_instance_ = std::make_unique<QVulkanInstance>();
vulkan_instance_->setVkInstance(*provider->instance()); vulkan_instance_->setVkInstance(*provider->instance());
if (!vulkan_instance_->create()) {
return false;
}
graphics_window_ = std::make_unique<QVulkanWindow>(); graphics_window_ = std::make_unique<QVulkanWindow>();
graphics_window_->setVulkanInstance(vulkan_instance_.get()); 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); graphics_provider_ = std::move(provider);
return true; return true;
} }
bool EmulatorWindow::Launch(const std::wstring& path) {
return emulator_->LaunchPath(path) == X_STATUS_SUCCESS;
}
} // namespace app } // namespace app
} // namespace xe } // namespace xe

View File

@ -29,6 +29,7 @@ class EmulatorWindow : public QMainWindow {
bool Setup(); bool Setup();
bool InitializeVulkan(); bool InitializeVulkan();
bool Launch(const std::wstring& path);
protected: protected:
// Events // Events

View File

@ -33,7 +33,7 @@ project("xenia-app")
"xenia-hid-nop", "xenia-hid-nop",
"xenia-kernel", "xenia-kernel",
"xenia-ui", "xenia-ui",
"xenia-ui-qt", -- "xenia-ui-qt",
"xenia-ui-spirv", "xenia-ui-spirv",
"xenia-ui-vulkan", "xenia-ui-vulkan",
"xenia-vfs", "xenia-vfs",

View File

@ -38,6 +38,8 @@ int xenia_main(const std::vector<std::wstring>& args) {
return 1; return 1;
} }
main_wnd.setFixedSize(1280, 720);
/* /*
if (FLAGS_mount_scratch) { if (FLAGS_mount_scratch) {
auto scratch_device = std::make_unique<xe::vfs::HostPathDevice>( auto scratch_device = std::make_unique<xe::vfs::HostPathDevice>(
@ -104,6 +106,11 @@ int xenia_main(const std::vector<std::wstring>& args) {
*/ */
main_wnd.show(); main_wnd.show();
if (args.size() >= 2) {
// Launch the path passed in args[1].
main_wnd.Launch(args[1]);
}
int rc = app.exec(); int rc = app.exec();
Profiler::Dump(); Profiler::Dump();