diff --git a/premake5.lua b/premake5.lua index d0c2261f3..0d33ac11b 100644 --- a/premake5.lua +++ b/premake5.lua @@ -183,6 +183,7 @@ solution("xenia") include("src/xenia/cpu/backend/x64") include("src/xenia/debug/ui") include("src/xenia/gpu") + include("src/xenia/gpu/null") include("src/xenia/gpu/gl4") include("src/xenia/gpu/vulkan") include("src/xenia/hid") diff --git a/src/xenia/app/xenia_main.cc b/src/xenia/app/xenia_main.cc index 11b47438b..ed42869ab 100644 --- a/src/xenia/app/xenia_main.cc +++ b/src/xenia/app/xenia_main.cc @@ -27,6 +27,7 @@ // Available graphics systems: #include "xenia/gpu/gl4/gl4_graphics_system.h" +#include "xenia/gpu/null/null_graphics_system.h" #include "xenia/gpu/vulkan/vulkan_graphics_system.h" // Available input drivers: @@ -37,7 +38,7 @@ #endif // XE_PLATFORM_WIN32 DEFINE_string(apu, "any", "Audio system. Use: [any, nop, xaudio2]"); -DEFINE_string(gpu, "any", "Graphics system. Use: [any, gl4, vulkan]"); +DEFINE_string(gpu, "any", "Graphics system. Use: [any, gl4, vulkan, null]"); DEFINE_string(hid, "any", "Input system. Use: [any, nop, winkey, xinput]"); DEFINE_string(target, "", "Specifies the target .xex or .iso to execute."); @@ -75,6 +76,9 @@ std::unique_ptr CreateGraphicsSystem() { } else if (FLAGS_gpu.compare("vulkan") == 0) { return std::unique_ptr( new xe::gpu::vulkan::VulkanGraphicsSystem()); + } else if (FLAGS_gpu.compare("null") == 0) { + return std::unique_ptr( + new xe::gpu::null::NullGraphicsSystem()); } else { // Create best available. std::unique_ptr best; diff --git a/src/xenia/gpu/null/null_command_processor.cc b/src/xenia/gpu/null/null_command_processor.cc new file mode 100644 index 000000000..86efc07c8 --- /dev/null +++ b/src/xenia/gpu/null/null_command_processor.cc @@ -0,0 +1,50 @@ +/** + ****************************************************************************** + * Xenia : Xbox 360 Emulator Research Project * + ****************************************************************************** + * Copyright 2016 Ben Vanik. All rights reserved. * + * Released under the BSD license - see LICENSE in the root for more details. * + ****************************************************************************** + */ + +#include "xenia/gpu/null/null_command_processor.h" + +namespace xe { +namespace gpu { +namespace null { + +NullCommandProcessor::NullCommandProcessor(NullGraphicsSystem* graphics_system, + kernel::KernelState* kernel_state) + : CommandProcessor(graphics_system, kernel_state) {} +NullCommandProcessor::~NullCommandProcessor() = default; + +bool NullCommandProcessor::SetupContext() { + return CommandProcessor::SetupContext(); +} + +void NullCommandProcessor::ShutdownContext() { + return CommandProcessor::ShutdownContext(); +} + +void NullCommandProcessor::PerformSwap(uint32_t frontbuffer_ptr, + uint32_t frontbuffer_width, + uint32_t frontbuffer_height) {} + +Shader* NullCommandProcessor::LoadShader(ShaderType shader_type, + uint32_t guest_address, + const uint32_t* host_address, + uint32_t dword_count) { + return nullptr; +} + +bool NullCommandProcessor::IssueDraw(PrimitiveType prim_type, + uint32_t index_count, + IndexBufferInfo* index_buffer_info) { + return true; +} + +bool NullCommandProcessor::IssueCopy() { return true; } + +} // namespace null +} // namespace gpu +} // namespace xe \ No newline at end of file diff --git a/src/xenia/gpu/null/null_command_processor.h b/src/xenia/gpu/null/null_command_processor.h new file mode 100644 index 000000000..3eef6108d --- /dev/null +++ b/src/xenia/gpu/null/null_command_processor.h @@ -0,0 +1,48 @@ +/** + ****************************************************************************** + * Xenia : Xbox 360 Emulator Research Project * + ****************************************************************************** + * Copyright 2016 Ben Vanik. All rights reserved. * + * Released under the BSD license - see LICENSE in the root for more details. * + ****************************************************************************** + */ + +#ifndef XENIA_GPU_NULL_NULL_COMMAND_PROCESSOR_H_ +#define XENIA_GPU_NULL_NULL_COMMAND_PROCESSOR_H_ + +#include "xenia/gpu/command_processor.h" +#include "xenia/gpu/null/null_graphics_system.h" +#include "xenia/gpu/xenos.h" +#include "xenia/kernel/kernel_state.h" + +namespace xe { +namespace gpu { +namespace null { + +class NullCommandProcessor : public CommandProcessor { + public: + NullCommandProcessor(NullGraphicsSystem* graphics_system, + kernel::KernelState* kernel_state); + ~NullCommandProcessor(); + + private: + bool SetupContext() override; + void ShutdownContext() override; + + void PerformSwap(uint32_t frontbuffer_ptr, uint32_t frontbuffer_width, + uint32_t frontbuffer_height) override; + + Shader* LoadShader(ShaderType shader_type, uint32_t guest_address, + const uint32_t* host_address, + uint32_t dword_count) override; + + bool IssueDraw(PrimitiveType prim_type, uint32_t index_count, + IndexBufferInfo* index_buffer_info) override; + bool IssueCopy() override; +}; + +} // namespace null +} // namespace gpu +} // namespace xe + +#endif // XENIA_GPU_NULL_NULL_COMMAND_PROCESSOR_H_ \ No newline at end of file diff --git a/src/xenia/gpu/null/null_graphics_system.cc b/src/xenia/gpu/null/null_graphics_system.cc new file mode 100644 index 000000000..f1a88010f --- /dev/null +++ b/src/xenia/gpu/null/null_graphics_system.cc @@ -0,0 +1,53 @@ +/** + ****************************************************************************** + * Xenia : Xbox 360 Emulator Research Project * + ****************************************************************************** + * Copyright 2016 Ben Vanik. All rights reserved. * + * Released under the BSD license - see LICENSE in the root for more details. * + ****************************************************************************** + */ + +#include "xenia/gpu/null/null_graphics_system.h" + +#include "xenia/gpu/null//null_command_processor.h" +#include "xenia/ui/vulkan/vulkan_provider.h" +#include "xenia/xbox.h" + +namespace xe { +namespace gpu { +namespace null { + +NullGraphicsSystem::NullGraphicsSystem() {} + +NullGraphicsSystem::~NullGraphicsSystem() {} + +X_STATUS NullGraphicsSystem::Setup(cpu::Processor* processor, + kernel::KernelState* kernel_state, + ui::Window* target_window) { + // This is a null graphics system, but we still setup vulkan because UI needs + // it through us :| + provider_ = xe::ui::vulkan::VulkanProvider::Create(target_window); + + return GraphicsSystem::Setup(processor, kernel_state, target_window); +} + +void NullGraphicsSystem::Shutdown() { GraphicsSystem::Shutdown(); } + +std::unique_ptr NullGraphicsSystem::CreateCommandProcessor() { + return std::unique_ptr( + new NullCommandProcessor(this, kernel_state_)); +} + +void NullGraphicsSystem::Swap(xe::ui::UIEvent* e) { + if (!command_processor_) { + return; + } + + auto& swap_state = command_processor_->swap_state(); + std::lock_guard lock(swap_state.mutex); + swap_state.pending = false; +} + +} // namespace null +} // namespace gpu +} // namespace xe \ No newline at end of file diff --git a/src/xenia/gpu/null/null_graphics_system.h b/src/xenia/gpu/null/null_graphics_system.h new file mode 100644 index 000000000..1669f1303 --- /dev/null +++ b/src/xenia/gpu/null/null_graphics_system.h @@ -0,0 +1,41 @@ +/** + ****************************************************************************** + * Xenia : Xbox 360 Emulator Research Project * + ****************************************************************************** + * Copyright 2016 Ben Vanik. All rights reserved. * + * Released under the BSD license - see LICENSE in the root for more details. * + ****************************************************************************** + */ + +#ifndef XENIA_GPU_NULL_NULL_GRAPHICS_SYSTEM_H_ +#define XENIA_GPU_NULL_NULL_GRAPHICS_SYSTEM_H_ + +#include + +#include "xenia/gpu/graphics_system.h" +#include "xenia/gpu/command_processor.h" + +namespace xe { +namespace gpu { +namespace null { + +class NullGraphicsSystem : public GraphicsSystem { + public: + NullGraphicsSystem(); + ~NullGraphicsSystem() override; + + X_STATUS Setup(cpu::Processor* processor, kernel::KernelState* kernel_state, + ui::Window* target_window) override; + void Shutdown() override; + + private: + std::unique_ptr CreateCommandProcessor() override; + + void Swap(xe::ui::UIEvent* e) override; +}; + +} // namespace null +} // namespace gpu +} // namespace xe + +#endif // XENIA_GPU_NULL_NULL_GRAPHICS_SYSTEM_H_ \ No newline at end of file diff --git a/src/xenia/gpu/null/premake5.lua b/src/xenia/gpu/null/premake5.lua new file mode 100644 index 000000000..4d902b992 --- /dev/null +++ b/src/xenia/gpu/null/premake5.lua @@ -0,0 +1,21 @@ +project_root = "../../../.." +include(project_root.."/tools/build") + +group("src") +project("xenia-gpu-null") + uuid("42FCA0B3-4C20-4532-95E9-07D297013BE4") + kind("StaticLib") + language("C++") + links({ + "xenia-base", + "xenia-gpu", + "xenia-ui", + "xenia-ui-vulkan", + "xxhash", + }) + defines({ + }) + includedirs({ + project_root.."/third_party/gflags/src", + }) + local_platform_files()