From fd03d886e9a512cd3b2a95e28fb25659e12fd5f1 Mon Sep 17 00:00:00 2001 From: Triang3l Date: Tue, 5 Jul 2022 21:21:22 +0300 Subject: [PATCH] [GPU] Make Processor optional for GraphicsSystem setup --- src/xenia/emulator.cc | 2 +- src/xenia/gpu/d3d12/d3d12_graphics_system.cc | 4 ++-- src/xenia/gpu/d3d12/d3d12_graphics_system.h | 3 ++- src/xenia/gpu/graphics_system.cc | 5 +++-- src/xenia/gpu/graphics_system.h | 3 ++- src/xenia/gpu/null/null_graphics_system.cc | 4 ++-- src/xenia/gpu/null/null_graphics_system.h | 3 ++- src/xenia/gpu/vulkan/vulkan_graphics_system.cc | 4 ++-- src/xenia/gpu/vulkan/vulkan_graphics_system.h | 3 ++- 9 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/xenia/emulator.cc b/src/xenia/emulator.cc index da9fb18d4..c4cc8c150 100644 --- a/src/xenia/emulator.cc +++ b/src/xenia/emulator.cc @@ -228,7 +228,7 @@ X_STATUS Emulator::Setup( // Setup the core components. result = graphics_system_->Setup( - processor_.get(), kernel_state_.get(), + memory_.get(), processor_.get(), kernel_state_.get(), display_window_ ? &display_window_->app_context() : nullptr, display_window_ != nullptr); if (result) { diff --git a/src/xenia/gpu/d3d12/d3d12_graphics_system.cc b/src/xenia/gpu/d3d12/d3d12_graphics_system.cc index b4e0d025d..6f168d4c2 100644 --- a/src/xenia/gpu/d3d12/d3d12_graphics_system.cc +++ b/src/xenia/gpu/d3d12/d3d12_graphics_system.cc @@ -39,12 +39,12 @@ std::string D3D12GraphicsSystem::name() const { return "Direct3D 12"; } -X_STATUS D3D12GraphicsSystem::Setup(cpu::Processor* processor, +X_STATUS D3D12GraphicsSystem::Setup(Memory* memory, cpu::Processor* processor, kernel::KernelState* kernel_state, ui::WindowedAppContext* app_context, bool is_surface_required) { provider_ = xe::ui::d3d12::D3D12Provider::Create(); - return GraphicsSystem::Setup(processor, kernel_state, app_context, + return GraphicsSystem::Setup(memory, processor, kernel_state, app_context, is_surface_required); } diff --git a/src/xenia/gpu/d3d12/d3d12_graphics_system.h b/src/xenia/gpu/d3d12/d3d12_graphics_system.h index 249cc3ffa..fc515311e 100644 --- a/src/xenia/gpu/d3d12/d3d12_graphics_system.h +++ b/src/xenia/gpu/d3d12/d3d12_graphics_system.h @@ -29,7 +29,8 @@ class D3D12GraphicsSystem : public GraphicsSystem { std::string name() const override; - X_STATUS Setup(cpu::Processor* processor, kernel::KernelState* kernel_state, + X_STATUS Setup(Memory* memory, cpu::Processor* processor, + kernel::KernelState* kernel_state, ui::WindowedAppContext* app_context, bool is_surface_required) override; diff --git a/src/xenia/gpu/graphics_system.cc b/src/xenia/gpu/graphics_system.cc index b5470fd0a..f57d966d4 100644 --- a/src/xenia/gpu/graphics_system.cc +++ b/src/xenia/gpu/graphics_system.cc @@ -52,11 +52,11 @@ GraphicsSystem::GraphicsSystem() : vsync_worker_running_(false) {} GraphicsSystem::~GraphicsSystem() = default; -X_STATUS GraphicsSystem::Setup(cpu::Processor* processor, +X_STATUS GraphicsSystem::Setup(Memory* memory, cpu::Processor* processor, kernel::KernelState* kernel_state, ui::WindowedAppContext* app_context, [[maybe_unused]] bool is_surface_required) { - memory_ = processor->memory(); + memory_ = memory; processor_ = processor; kernel_state_ = kernel_state; app_context_ = app_context; @@ -233,6 +233,7 @@ void GraphicsSystem::EnableReadPointerWriteBack(uint32_t ptr, void GraphicsSystem::SetInterruptCallback(uint32_t callback, uint32_t user_data) { + assert_false(callback && !processor_); interrupt_callback_ = callback; interrupt_callback_data_ = user_data; XELOGGPU("SetInterruptCallback({:08X}, {:08X})", callback, user_data); diff --git a/src/xenia/gpu/graphics_system.h b/src/xenia/gpu/graphics_system.h index 0434a5619..90cd6a4ae 100644 --- a/src/xenia/gpu/graphics_system.h +++ b/src/xenia/gpu/graphics_system.h @@ -43,12 +43,13 @@ class GraphicsSystem { virtual std::string name() const = 0; Memory* memory() const { return memory_; } + // The Processor is optional and may be null (needed only for interrupts). cpu::Processor* processor() const { return processor_; } kernel::KernelState* kernel_state() const { return kernel_state_; } ui::GraphicsProvider* provider() const { return provider_.get(); } ui::Presenter* presenter() const { return presenter_.get(); } - virtual X_STATUS Setup(cpu::Processor* processor, + virtual X_STATUS Setup(Memory* memory, cpu::Processor* processor, kernel::KernelState* kernel_state, ui::WindowedAppContext* app_context, bool is_surface_required); diff --git a/src/xenia/gpu/null/null_graphics_system.cc b/src/xenia/gpu/null/null_graphics_system.cc index 57d5e958f..7a92d16d9 100644 --- a/src/xenia/gpu/null/null_graphics_system.cc +++ b/src/xenia/gpu/null/null_graphics_system.cc @@ -21,14 +21,14 @@ NullGraphicsSystem::NullGraphicsSystem() {} NullGraphicsSystem::~NullGraphicsSystem() {} -X_STATUS NullGraphicsSystem::Setup(cpu::Processor* processor, +X_STATUS NullGraphicsSystem::Setup(Memory* memory, cpu::Processor* processor, kernel::KernelState* kernel_state, ui::WindowedAppContext* app_context, bool is_surface_required) { // This is a null graphics system, but we still setup vulkan because UI needs // it through us :| provider_ = xe::ui::vulkan::VulkanProvider::Create(is_surface_required); - return GraphicsSystem::Setup(processor, kernel_state, app_context, + return GraphicsSystem::Setup(memory, processor, kernel_state, app_context, is_surface_required); } diff --git a/src/xenia/gpu/null/null_graphics_system.h b/src/xenia/gpu/null/null_graphics_system.h index d5b8d32b9..fd866c694 100644 --- a/src/xenia/gpu/null/null_graphics_system.h +++ b/src/xenia/gpu/null/null_graphics_system.h @@ -28,7 +28,8 @@ class NullGraphicsSystem : public GraphicsSystem { std::string name() const override { return "null"; } - X_STATUS Setup(cpu::Processor* processor, kernel::KernelState* kernel_state, + X_STATUS Setup(Memory* memory, cpu::Processor* processor, + kernel::KernelState* kernel_state, ui::WindowedAppContext* app_context, bool is_surface_required) override; diff --git a/src/xenia/gpu/vulkan/vulkan_graphics_system.cc b/src/xenia/gpu/vulkan/vulkan_graphics_system.cc index c42510050..89a95bdf7 100644 --- a/src/xenia/gpu/vulkan/vulkan_graphics_system.cc +++ b/src/xenia/gpu/vulkan/vulkan_graphics_system.cc @@ -21,12 +21,12 @@ VulkanGraphicsSystem::VulkanGraphicsSystem() {} VulkanGraphicsSystem::~VulkanGraphicsSystem() {} -X_STATUS VulkanGraphicsSystem::Setup(cpu::Processor* processor, +X_STATUS VulkanGraphicsSystem::Setup(Memory* memory, cpu::Processor* processor, kernel::KernelState* kernel_state, ui::WindowedAppContext* app_context, bool is_surface_required) { provider_ = xe::ui::vulkan::VulkanProvider::Create(is_surface_required); - return GraphicsSystem::Setup(processor, kernel_state, app_context, + return GraphicsSystem::Setup(memory, processor, kernel_state, app_context, is_surface_required); } diff --git a/src/xenia/gpu/vulkan/vulkan_graphics_system.h b/src/xenia/gpu/vulkan/vulkan_graphics_system.h index ae81e144c..e28cb6381 100644 --- a/src/xenia/gpu/vulkan/vulkan_graphics_system.h +++ b/src/xenia/gpu/vulkan/vulkan_graphics_system.h @@ -30,7 +30,8 @@ class VulkanGraphicsSystem : public GraphicsSystem { return "Vulkan - HEAVILY INCOMPLETE, early development"; } - X_STATUS Setup(cpu::Processor* processor, kernel::KernelState* kernel_state, + X_STATUS Setup(Memory* memory, cpu::Processor* processor, + kernel::KernelState* kernel_state, ui::WindowedAppContext* app_context, bool is_surface_required) override;