diff --git a/src/xenia/gpu/d3d11/d3d11-private.h b/src/xenia/gpu/d3d11/d3d11-private.h new file mode 100644 index 000000000..561b15f85 --- /dev/null +++ b/src/xenia/gpu/d3d11/d3d11-private.h @@ -0,0 +1,31 @@ +/** + ****************************************************************************** + * Xenia : Xbox 360 Emulator Research Project * + ****************************************************************************** + * Copyright 2013 Ben Vanik. All rights reserved. * + * Released under the BSD license - see LICENSE in the root for more details. * + ****************************************************************************** + */ + +#ifndef XENIA_GPU_D3D11_D3D11_PRIVATE_H_ +#define XENIA_GPU_D3D11_D3D11_PRIVATE_H_ + +#include + +#include + + +namespace xe { +namespace gpu { +namespace d3d11 { + + + + + +} // namespace d3d11 +} // namespace gpu +} // namespace xe + + +#endif // XENIA_GPU_D3D11_D3D11_PRIVATE_H_ diff --git a/src/xenia/gpu/d3d11/d3d11.cc b/src/xenia/gpu/d3d11/d3d11.cc new file mode 100644 index 000000000..d9b11a3d9 --- /dev/null +++ b/src/xenia/gpu/d3d11/d3d11.cc @@ -0,0 +1,44 @@ +/** + ****************************************************************************** + * Xenia : Xbox 360 Emulator Research Project * + ****************************************************************************** + * Copyright 2013 Ben Vanik. All rights reserved. * + * Released under the BSD license - see LICENSE in the root for more details. * + ****************************************************************************** + */ + +#include + +#include + + +using namespace xe; +using namespace xe::gpu; +using namespace xe::gpu::d3d11; + + +namespace { + void InitializeIfNeeded(); + void CleanupOnShutdown(); + + void InitializeIfNeeded() { + static bool has_initialized = false; + if (has_initialized) { + return; + } + has_initialized = true; + + // + + atexit(CleanupOnShutdown); + } + + void CleanupOnShutdown() { + } +} + + +GraphicsSystem* xe::gpu::d3d11::Create(const CreationParams* params) { + InitializeIfNeeded(); + return new D3D11GraphicsSystem(params); +} diff --git a/src/xenia/gpu/d3d11/d3d11.h b/src/xenia/gpu/d3d11/d3d11.h new file mode 100644 index 000000000..d215f60db --- /dev/null +++ b/src/xenia/gpu/d3d11/d3d11.h @@ -0,0 +1,33 @@ +/** + ****************************************************************************** + * Xenia : Xbox 360 Emulator Research Project * + ****************************************************************************** + * Copyright 2013 Ben Vanik. All rights reserved. * + * Released under the BSD license - see LICENSE in the root for more details. * + ****************************************************************************** + */ + +#ifndef XENIA_GPU_D3D11_D3D11_H_ +#define XENIA_GPU_D3D11_D3D11_H_ + +#include + + +namespace xe { +namespace gpu { + +class CreationParams; +class GraphicsSystem; + +namespace d3d11 { + + +GraphicsSystem* Create(const CreationParams* params); + + +} // namespace d3d11 +} // namespace gpu +} // namespace xe + + +#endif // XENIA_GPU_D3D11_D3D11_H_ diff --git a/src/xenia/gpu/d3d11/d3d11_graphics_system.cc b/src/xenia/gpu/d3d11/d3d11_graphics_system.cc new file mode 100644 index 000000000..97d61fb9e --- /dev/null +++ b/src/xenia/gpu/d3d11/d3d11_graphics_system.cc @@ -0,0 +1,25 @@ +/** + ****************************************************************************** + * Xenia : Xbox 360 Emulator Research Project * + ****************************************************************************** + * Copyright 2013 Ben Vanik. All rights reserved. * + * Released under the BSD license - see LICENSE in the root for more details. * + ****************************************************************************** + */ + +#include + +#include + + +using namespace xe; +using namespace xe::gpu; +using namespace xe::gpu::d3d11; + + +D3D11GraphicsSystem::D3D11GraphicsSystem(const CreationParams* params) : + GraphicsSystem(params) { +} + +D3D11GraphicsSystem::~D3D11GraphicsSystem() { +} diff --git a/src/xenia/gpu/d3d11/d3d11_graphics_system.h b/src/xenia/gpu/d3d11/d3d11_graphics_system.h new file mode 100644 index 000000000..51f8d5687 --- /dev/null +++ b/src/xenia/gpu/d3d11/d3d11_graphics_system.h @@ -0,0 +1,39 @@ +/** + ****************************************************************************** + * Xenia : Xbox 360 Emulator Research Project * + ****************************************************************************** + * Copyright 2013 Ben Vanik. All rights reserved. * + * Released under the BSD license - see LICENSE in the root for more details. * + ****************************************************************************** + */ + +#ifndef XENIA_GPU_D3D11_D3D11_GRAPHICS_SYSTEM_H_ +#define XENIA_GPU_D3D11_D3D11_GRAPHICS_SYSTEM_H_ + +#include + +#include +#include + + +namespace xe { +namespace gpu { +namespace d3d11 { + + +GraphicsSystem* Create(const CreationParams* params); + + +class D3D11GraphicsSystem : public GraphicsSystem { +public: + D3D11GraphicsSystem(const CreationParams* params); + virtual ~D3D11GraphicsSystem(); +}; + + +} // namespace d3d11 +} // namespace gpu +} // namespace xe + + +#endif // XENIA_GPU_D3D11_D3D11_GRAPHICS_SYSTEM_H_ diff --git a/src/xenia/gpu/d3d11/sources.gypi b/src/xenia/gpu/d3d11/sources.gypi new file mode 100644 index 000000000..d30840704 --- /dev/null +++ b/src/xenia/gpu/d3d11/sources.gypi @@ -0,0 +1,10 @@ +# Copyright 2013 Ben Vanik. All Rights Reserved. +{ + 'sources': [ + 'd3d11-private.h', + 'd3d11.cc', + 'd3d11.h', + 'd3d11_graphics_system.cc', + 'd3d11_graphics_system.h', + ], +} diff --git a/src/xenia/gpu/gpu-private.h b/src/xenia/gpu/gpu-private.h new file mode 100644 index 000000000..e0b177a62 --- /dev/null +++ b/src/xenia/gpu/gpu-private.h @@ -0,0 +1,19 @@ +/** + ****************************************************************************** + * Xenia : Xbox 360 Emulator Research Project * + ****************************************************************************** + * Copyright 2013 Ben Vanik. All rights reserved. * + * Released under the BSD license - see LICENSE in the root for more details. * + ****************************************************************************** + */ + +#ifndef XENIA_GPU_PRIVATE_H_ +#define XENIA_GPU_PRIVATE_H_ + +#include + + +// DECLARE_ flags here + + +#endif // XENIA_GPU_PRIVATE_H_ diff --git a/src/xenia/gpu/gpu.cc b/src/xenia/gpu/gpu.cc index fde7e88b6..14849c777 100644 --- a/src/xenia/gpu/gpu.cc +++ b/src/xenia/gpu/gpu.cc @@ -8,8 +8,29 @@ */ #include +#include + +#if XE_PLATFORM(WIN32) +#include +#endif // WIN32 +#include -void do_gpu_stuff() { - XELOGGPU("gpu"); +using namespace xe; +using namespace xe::gpu; + + +// DEFINE_ flags here. + + +GraphicsSystem* xe::gpu::Create(const CreationParams* params) { + // TODO(benvanik): use flags to determine system, check support, etc. + return xe::gpu::nop::Create(params); +// #if XE_PLATFORM(WIN32) +// return xe::gpu::d3d11::Create(params); +// #endif // WIN32 +} + +GraphicsSystem* xe::gpu::CreateNop(const CreationParams* params) { + return xe::gpu::nop::Create(params); } diff --git a/src/xenia/gpu/gpu.h b/src/xenia/gpu/gpu.h index 48d70b34c..7dd9f6e3f 100644 --- a/src/xenia/gpu/gpu.h +++ b/src/xenia/gpu/gpu.h @@ -10,9 +10,19 @@ #ifndef XENIA_GPU_GPU_H_ #define XENIA_GPU_GPU_H_ -#include -#include +#include + + +namespace xe { +namespace gpu { + + +GraphicsSystem* Create(const CreationParams* params); +GraphicsSystem* CreateNop(const CreationParams* params); + + +} // namespace gpu +} // namespace xe -void do_gpu_stuff(); #endif // XENIA_GPU_GPU_H_ diff --git a/src/xenia/gpu/graphics_system.cc b/src/xenia/gpu/graphics_system.cc new file mode 100644 index 000000000..bd169e407 --- /dev/null +++ b/src/xenia/gpu/graphics_system.cc @@ -0,0 +1,27 @@ +/** + ****************************************************************************** + * Xenia : Xbox 360 Emulator Research Project * + ****************************************************************************** + * Copyright 2013 Ben Vanik. All rights reserved. * + * Released under the BSD license - see LICENSE in the root for more details. * + ****************************************************************************** + */ + +#include + + +using namespace xe; +using namespace xe::gpu; + + +GraphicsSystem::GraphicsSystem(const CreationParams* params) { + memory_ = xe_memory_retain(params->memory); +} + +GraphicsSystem::~GraphicsSystem() { + xe_memory_release(memory_); +} + +xe_memory_ref GraphicsSystem::memory() { + return xe_memory_retain(memory_); +} diff --git a/src/xenia/gpu/graphics_system.h b/src/xenia/gpu/graphics_system.h new file mode 100644 index 000000000..652ce928c --- /dev/null +++ b/src/xenia/gpu/graphics_system.h @@ -0,0 +1,43 @@ +/** + ****************************************************************************** + * Xenia : Xbox 360 Emulator Research Project * + ****************************************************************************** + * Copyright 2013 Ben Vanik. All rights reserved. * + * Released under the BSD license - see LICENSE in the root for more details. * + ****************************************************************************** + */ + +#ifndef XENIA_GPU_GRAPHICS_SYSTEM_H_ +#define XENIA_GPU_GRAPHICS_SYSTEM_H_ + +#include + + +namespace xe { +namespace gpu { + + +class CreationParams { +public: + xe_memory_ref memory; +}; + + +class GraphicsSystem { +public: + virtual ~GraphicsSystem(); + + xe_memory_ref memory(); + +protected: + GraphicsSystem(const CreationParams* params); + + xe_memory_ref memory_; +}; + + +} // namespace gpu +} // namespace xe + + +#endif // XENIA_GPU_GRAPHICS_SYSTEM_H_ diff --git a/src/xenia/gpu/nop/nop-private.h b/src/xenia/gpu/nop/nop-private.h new file mode 100644 index 000000000..47c17ca63 --- /dev/null +++ b/src/xenia/gpu/nop/nop-private.h @@ -0,0 +1,31 @@ +/** + ****************************************************************************** + * Xenia : Xbox 360 Emulator Research Project * + ****************************************************************************** + * Copyright 2013 Ben Vanik. All rights reserved. * + * Released under the BSD license - see LICENSE in the root for more details. * + ****************************************************************************** + */ + +#ifndef XENIA_GPU_NOP_NOP_PRIVATE_H_ +#define XENIA_GPU_NOP_NOP_PRIVATE_H_ + +#include + +#include + + +namespace xe { +namespace gpu { +namespace nop { + + + + + +} // namespace nop +} // namespace gpu +} // namespace xe + + +#endif // XENIA_GPU_NOP_NOP_PRIVATE_H_ diff --git a/src/xenia/gpu/nop/nop.cc b/src/xenia/gpu/nop/nop.cc new file mode 100644 index 000000000..4f416befe --- /dev/null +++ b/src/xenia/gpu/nop/nop.cc @@ -0,0 +1,44 @@ +/** + ****************************************************************************** + * Xenia : Xbox 360 Emulator Research Project * + ****************************************************************************** + * Copyright 2013 Ben Vanik. All rights reserved. * + * Released under the BSD license - see LICENSE in the root for more details. * + ****************************************************************************** + */ + +#include + +#include + + +using namespace xe; +using namespace xe::gpu; +using namespace xe::gpu::nop; + + +namespace { + void InitializeIfNeeded(); + void CleanupOnShutdown(); + + void InitializeIfNeeded() { + static bool has_initialized = false; + if (has_initialized) { + return; + } + has_initialized = true; + + // + + atexit(CleanupOnShutdown); + } + + void CleanupOnShutdown() { + } +} + + +GraphicsSystem* xe::gpu::nop::Create(const CreationParams* params) { + InitializeIfNeeded(); + return new NopGraphicsSystem(params); +} diff --git a/src/xenia/gpu/nop/nop.h b/src/xenia/gpu/nop/nop.h new file mode 100644 index 000000000..896a9822f --- /dev/null +++ b/src/xenia/gpu/nop/nop.h @@ -0,0 +1,33 @@ +/** + ****************************************************************************** + * Xenia : Xbox 360 Emulator Research Project * + ****************************************************************************** + * Copyright 2013 Ben Vanik. All rights reserved. * + * Released under the BSD license - see LICENSE in the root for more details. * + ****************************************************************************** + */ + +#ifndef XENIA_GPU_NOP_NOP_H_ +#define XENIA_GPU_NOP_NOP_H_ + +#include + + +namespace xe { +namespace gpu { + +class CreationParams; +class GraphicsSystem; + +namespace nop { + + +GraphicsSystem* Create(const CreationParams* params); + + +} // namespace nop +} // namespace gpu +} // namespace xe + + +#endif // XENIA_GPU_NOP_NOP_H_ diff --git a/src/xenia/gpu/nop/nop_graphics_system.cc b/src/xenia/gpu/nop/nop_graphics_system.cc new file mode 100644 index 000000000..e4639aa26 --- /dev/null +++ b/src/xenia/gpu/nop/nop_graphics_system.cc @@ -0,0 +1,25 @@ +/** + ****************************************************************************** + * Xenia : Xbox 360 Emulator Research Project * + ****************************************************************************** + * Copyright 2013 Ben Vanik. All rights reserved. * + * Released under the BSD license - see LICENSE in the root for more details. * + ****************************************************************************** + */ + +#include + +#include + + +using namespace xe; +using namespace xe::gpu; +using namespace xe::gpu::nop; + + +NopGraphicsSystem::NopGraphicsSystem(const CreationParams* params) : + GraphicsSystem(params) { +} + +NopGraphicsSystem::~NopGraphicsSystem() { +} diff --git a/src/xenia/gpu/nop/nop_graphics_system.h b/src/xenia/gpu/nop/nop_graphics_system.h new file mode 100644 index 000000000..4c81bc630 --- /dev/null +++ b/src/xenia/gpu/nop/nop_graphics_system.h @@ -0,0 +1,36 @@ +/** + ****************************************************************************** + * Xenia : Xbox 360 Emulator Research Project * + ****************************************************************************** + * Copyright 2013 Ben Vanik. All rights reserved. * + * Released under the BSD license - see LICENSE in the root for more details. * + ****************************************************************************** + */ + +#ifndef XENIA_GPU_NOP_NOP_GRAPHICS_SYSTEM_H_ +#define XENIA_GPU_NOP_NOP_GRAPHICS_SYSTEM_H_ + +#include + +#include +#include + + +namespace xe { +namespace gpu { +namespace nop { + + +class NopGraphicsSystem : public GraphicsSystem { +public: + NopGraphicsSystem(const CreationParams* params); + virtual ~NopGraphicsSystem(); +}; + + +} // namespace nop +} // namespace gpu +} // namespace xe + + +#endif // XENIA_GPU_NOP_NOP_GRAPHICS_SYSTEM_H_ diff --git a/src/xenia/gpu/nop/sources.gypi b/src/xenia/gpu/nop/sources.gypi new file mode 100644 index 000000000..1cea30b42 --- /dev/null +++ b/src/xenia/gpu/nop/sources.gypi @@ -0,0 +1,10 @@ +# Copyright 2013 Ben Vanik. All Rights Reserved. +{ + 'sources': [ + 'nop-private.h', + 'nop.cc', + 'nop.h', + 'nop_graphics_system.cc', + 'nop_graphics_system.h', + ], +} diff --git a/src/xenia/gpu/sources.gypi b/src/xenia/gpu/sources.gypi index c1eb8258d..366bb049d 100644 --- a/src/xenia/gpu/sources.gypi +++ b/src/xenia/gpu/sources.gypi @@ -1,7 +1,22 @@ # Copyright 2013 Ben Vanik. All Rights Reserved. { 'sources': [ + 'gpu-private.h', 'gpu.cc', 'gpu.h', + 'graphics_system.cc', + 'graphics_system.h', + ], + + 'includes': [ + 'nop/sources.gypi', + ], + + 'conditions': [ + ['OS == "win"', { + 'includes': [ + 'd3d11/sources.gypi', + ], + }], ], } diff --git a/tools/xenia-run/xenia-run.cc b/tools/xenia-run/xenia-run.cc index f5f1904d2..9116fa8b0 100644 --- a/tools/xenia-run/xenia-run.cc +++ b/tools/xenia-run/xenia-run.cc @@ -99,9 +99,6 @@ int Run::Launch(const xechar_t* path) { } int xenia_run(int argc, xechar_t **argv) { - // Dummy call to keep the GPU code linking in to ensure it's working. - do_gpu_stuff(); - int result_code = 1; // Grab path.