[Qt] Vulkan Window/Renderer only needs the GS

This commit is contained in:
Dr. Chat 2018-05-15 13:52:13 -05:00
parent 573d314140
commit 90929d74a8
5 changed files with 24 additions and 26 deletions

View File

@ -30,21 +30,23 @@ namespace app {
class VulkanWindow : public QVulkanWindow { class VulkanWindow : public QVulkanWindow {
public: public:
VulkanWindow(EmulatorWindow* parent) : window_(parent) {} VulkanWindow(gpu::vulkan::VulkanGraphicsSystem* gfx)
: graphics_system_(gfx) {}
QVulkanWindowRenderer* createRenderer() override; QVulkanWindowRenderer* createRenderer() override;
private: private:
EmulatorWindow* window_; gpu::vulkan::VulkanGraphicsSystem* graphics_system_;
}; };
class VulkanRenderer : public QVulkanWindowRenderer { class VulkanRenderer : public QVulkanWindowRenderer {
public: public:
VulkanRenderer(VulkanWindow* window, xe::Emulator* emulator) VulkanRenderer(VulkanWindow* window,
: window_(window), emulator_(emulator) {} gpu::vulkan::VulkanGraphicsSystem* graphics_system)
: window_(window), graphics_system_(graphics_system) {}
void startNextFrame() override { void startNextFrame() override {
// Copy the graphics frontbuffer to our backbuffer. // Copy the graphics frontbuffer to our backbuffer.
auto swap_state = emulator_->graphics_system()->swap_state(); auto swap_state = graphics_system_->swap_state();
auto cmd = window_->currentCommandBuffer(); auto cmd = window_->currentCommandBuffer();
auto src = reinterpret_cast<VkImage>(swap_state->front_buffer_texture); auto src = reinterpret_cast<VkImage>(swap_state->front_buffer_texture);
@ -85,24 +87,22 @@ class VulkanRenderer : public QVulkanWindowRenderer {
} }
private: private:
xe::Emulator* emulator_; gpu::vulkan::VulkanGraphicsSystem* graphics_system_;
VulkanWindow* window_; VulkanWindow* window_;
}; };
QVulkanWindowRenderer* VulkanWindow::createRenderer() { QVulkanWindowRenderer* VulkanWindow::createRenderer() {
return new VulkanRenderer(this, window_->emulator()); return new VulkanRenderer(this, graphics_system_);
} }
EmulatorWindow::EmulatorWindow() {} EmulatorWindow::EmulatorWindow() {
bool EmulatorWindow::Setup() {
// TODO(DrChat): Pass in command line arguments. // TODO(DrChat): Pass in command line arguments.
emulator_ = std::make_unique<xe::Emulator>(L""); emulator_ = std::make_unique<xe::Emulator>(L"");
// Initialize the graphics backend. // Initialize the graphics backend.
// TODO(DrChat): Pick from gpu command line flag. // TODO(DrChat): Pick from gpu command line flag.
if (!InitializeVulkan()) { if (!InitializeVulkan()) {
return false; return;
} }
auto audio_factory = [&](cpu::Processor* processor, auto audio_factory = [&](cpu::Processor* processor,
@ -121,6 +121,7 @@ bool EmulatorWindow::Setup() {
auto graphics = std::make_unique<gpu::vulkan::VulkanGraphicsSystem>(); auto graphics = std::make_unique<gpu::vulkan::VulkanGraphicsSystem>();
if (graphics->Setup(processor, kernel_state, if (graphics->Setup(processor, kernel_state,
graphics_provider_->CreateOffscreenContext())) { graphics_provider_->CreateOffscreenContext())) {
graphics->Shutdown();
return std::unique_ptr<gpu::vulkan::VulkanGraphicsSystem>(nullptr); return std::unique_ptr<gpu::vulkan::VulkanGraphicsSystem>(nullptr);
} }
@ -135,8 +136,6 @@ bool EmulatorWindow::Setup() {
Qt::QueuedConnection); Qt::QueuedConnection);
}); });
} }
return result == X_STATUS_SUCCESS;
} }
bool EmulatorWindow::InitializeVulkan() { bool EmulatorWindow::InitializeVulkan() {
@ -150,7 +149,9 @@ bool EmulatorWindow::InitializeVulkan() {
return false; return false;
} }
graphics_window_ = std::make_unique<VulkanWindow>(this); graphics_window_ = std::make_unique<VulkanWindow>(
reinterpret_cast<gpu::vulkan::VulkanGraphicsSystem*>(
emulator_->graphics_system()));
graphics_window_->setVulkanInstance(vulkan_instance_.get()); graphics_window_->setVulkanInstance(vulkan_instance_.get());
// Now set the graphics window as our central widget. // Now set the graphics window as our central widget.
@ -161,8 +162,6 @@ bool EmulatorWindow::InitializeVulkan() {
return true; return true;
} }
void EmulatorWindow::SwapVulkan() {}
bool EmulatorWindow::Launch(const std::wstring& path) { bool EmulatorWindow::Launch(const std::wstring& path) {
return emulator_->LaunchPath(path) == X_STATUS_SUCCESS; return emulator_->LaunchPath(path) == X_STATUS_SUCCESS;
} }

View File

@ -30,9 +30,6 @@ class EmulatorWindow : public QMainWindow {
public: public:
EmulatorWindow(); EmulatorWindow();
bool Setup();
bool InitializeVulkan();
void SwapVulkan();
bool Launch(const std::wstring& path); bool Launch(const std::wstring& path);
xe::Emulator* emulator() { return emulator_.get(); } xe::Emulator* emulator() { return emulator_.get(); }
@ -45,6 +42,8 @@ class EmulatorWindow : public QMainWindow {
private: private:
void CreateMenuBar(); void CreateMenuBar();
bool InitializeVulkan();
std::unique_ptr<xe::Emulator> emulator_; std::unique_ptr<xe::Emulator> emulator_;
std::unique_ptr<QWindow> graphics_window_; std::unique_ptr<QWindow> graphics_window_;

View File

@ -61,6 +61,9 @@ project("xenia-app")
files({ files({
"xenia_main.cc", "xenia_main.cc",
"../base/main_"..platform_suffix..".cc", "../base/main_"..platform_suffix..".cc",
-- Qt files
"*.qrc",
}) })
filter("platforms:Windows") filter("platforms:Windows")
files({ files({

View File

@ -1,4 +1,4 @@
<!DOCTYPE RCC><RCC version="1.0"> <RCC>
<qresource> <qresource prefix="/">
</qresource> </qresource>
</RCC> </RCC>

View File

@ -37,9 +37,6 @@ int xenia_main(const std::vector<std::wstring>& args) {
char* argv[] = {"xenia", nullptr}; char* argv[] = {"xenia", nullptr};
QApplication app(argc, argv); QApplication app(argc, argv);
EmulatorWindow main_wnd; EmulatorWindow main_wnd;
if (!main_wnd.Setup()) {
return 1;
}
main_wnd.setFixedSize(1280, 720); main_wnd.setFixedSize(1280, 720);