unique_ptr'ing things and removing some XECLEANUP.
This commit is contained in:
@@ -11,34 +11,30 @@
|
||||
|
||||
#include <xenia/gpu/d3d11/d3d11_graphics_system.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
using namespace xe::gpu;
|
||||
using namespace xe::gpu::d3d11;
|
||||
|
||||
|
||||
namespace {
|
||||
void InitializeIfNeeded();
|
||||
void CleanupOnShutdown();
|
||||
void InitializeIfNeeded();
|
||||
void CleanupOnShutdown();
|
||||
|
||||
void InitializeIfNeeded() {
|
||||
static bool has_initialized = false;
|
||||
if (has_initialized) {
|
||||
return;
|
||||
}
|
||||
has_initialized = true;
|
||||
|
||||
//
|
||||
|
||||
atexit(CleanupOnShutdown);
|
||||
void InitializeIfNeeded() {
|
||||
static bool has_initialized = false;
|
||||
if (has_initialized) {
|
||||
return;
|
||||
}
|
||||
has_initialized = true;
|
||||
|
||||
void CleanupOnShutdown() {
|
||||
}
|
||||
//
|
||||
|
||||
atexit(CleanupOnShutdown);
|
||||
}
|
||||
|
||||
void CleanupOnShutdown() {}
|
||||
}
|
||||
|
||||
GraphicsSystem* xe::gpu::d3d11::Create(Emulator* emulator) {
|
||||
std::unique_ptr<GraphicsSystem> xe::gpu::d3d11::Create(Emulator* emulator) {
|
||||
InitializeIfNeeded();
|
||||
return new D3D11GraphicsSystem(emulator);
|
||||
return std::make_unique<D3D11GraphicsSystem>(emulator);
|
||||
}
|
||||
|
||||
@@ -10,24 +10,23 @@
|
||||
#ifndef XENIA_GPU_D3D11_D3D11_GPU_H_
|
||||
#define XENIA_GPU_D3D11_D3D11_GPU_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <xenia/core.h>
|
||||
|
||||
|
||||
XEDECLARECLASS1(xe, Emulator);
|
||||
XEDECLARECLASS2(xe, gpu, GraphicsSystem);
|
||||
|
||||
namespace xe {
|
||||
class Emulator;
|
||||
} // namespace xe
|
||||
|
||||
namespace xe {
|
||||
namespace gpu {
|
||||
class GraphicsSystem;
|
||||
namespace d3d11 {
|
||||
|
||||
|
||||
GraphicsSystem* Create(Emulator* emulator);
|
||||
|
||||
std::unique_ptr<GraphicsSystem> Create(Emulator* emulator);
|
||||
|
||||
} // namespace d3d11
|
||||
} // namespace gpu
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_GPU_D3D11_D3D11_GPU_H_
|
||||
|
||||
@@ -10,37 +10,28 @@
|
||||
#include <xenia/gpu/gpu.h>
|
||||
#include <xenia/gpu/gpu-private.h>
|
||||
|
||||
|
||||
|
||||
using namespace xe;
|
||||
using namespace xe::gpu;
|
||||
|
||||
DEFINE_string(gpu, "any", "Graphics system. Use: [any, nop, d3d11]");
|
||||
|
||||
DEFINE_string(gpu, "any",
|
||||
"Graphics system. Use: [any, nop, d3d11]");
|
||||
|
||||
|
||||
DEFINE_bool(trace_ring_buffer, false,
|
||||
"Trace GPU ring buffer packets.");
|
||||
DEFINE_bool(trace_ring_buffer, false, "Trace GPU ring buffer packets.");
|
||||
DEFINE_string(dump_shaders, "",
|
||||
"Path to write GPU shaders to as they are compiled.");
|
||||
|
||||
"Path to write GPU shaders to as they are compiled.");
|
||||
|
||||
#include <xenia/gpu/nop/nop_gpu.h>
|
||||
GraphicsSystem* xe::gpu::CreateNop(Emulator* emulator) {
|
||||
std::unique_ptr<GraphicsSystem> xe::gpu::CreateNop(Emulator* emulator) {
|
||||
return xe::gpu::nop::Create(emulator);
|
||||
}
|
||||
|
||||
|
||||
#if XE_PLATFORM_WIN32
|
||||
#include <xenia/gpu/d3d11/d3d11_gpu.h>
|
||||
GraphicsSystem* xe::gpu::CreateD3D11(Emulator* emulator) {
|
||||
std::unique_ptr<GraphicsSystem> xe::gpu::CreateD3D11(Emulator* emulator) {
|
||||
return xe::gpu::d3d11::Create(emulator);
|
||||
}
|
||||
#endif // WIN32
|
||||
|
||||
|
||||
GraphicsSystem* xe::gpu::Create(Emulator* emulator) {
|
||||
std::unique_ptr<GraphicsSystem> xe::gpu::Create(Emulator* emulator) {
|
||||
if (FLAGS_gpu.compare("nop") == 0) {
|
||||
return CreateNop(emulator);
|
||||
#if XE_PLATFORM_WIN32
|
||||
@@ -49,7 +40,7 @@ GraphicsSystem* xe::gpu::Create(Emulator* emulator) {
|
||||
#endif // WIN32
|
||||
} else {
|
||||
// Create best available.
|
||||
GraphicsSystem* best = NULL;
|
||||
std::unique_ptr<GraphicsSystem> best;
|
||||
|
||||
#if XE_PLATFORM_WIN32
|
||||
best = CreateD3D11(emulator);
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#ifndef XENIA_GPU_GPU_H_
|
||||
#define XENIA_GPU_GPU_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <xenia/gpu/graphics_system.h>
|
||||
|
||||
namespace xe {
|
||||
@@ -19,12 +21,12 @@ class Emulator;
|
||||
namespace xe {
|
||||
namespace gpu {
|
||||
|
||||
GraphicsSystem* Create(Emulator* emulator);
|
||||
std::unique_ptr<GraphicsSystem> Create(Emulator* emulator);
|
||||
|
||||
GraphicsSystem* CreateNop(Emulator* emulator);
|
||||
std::unique_ptr<GraphicsSystem> CreateNop(Emulator* emulator);
|
||||
|
||||
#if XE_PLATFORM_WIN32
|
||||
GraphicsSystem* CreateD3D11(Emulator* emulator);
|
||||
std::unique_ptr<GraphicsSystem> CreateD3D11(Emulator* emulator);
|
||||
#endif // WIN32
|
||||
|
||||
} // namespace gpu
|
||||
|
||||
@@ -11,34 +11,30 @@
|
||||
|
||||
#include <xenia/gpu/nop/nop_graphics_system.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
using namespace xe::gpu;
|
||||
using namespace xe::gpu::nop;
|
||||
|
||||
|
||||
namespace {
|
||||
void InitializeIfNeeded();
|
||||
void CleanupOnShutdown();
|
||||
void InitializeIfNeeded();
|
||||
void CleanupOnShutdown();
|
||||
|
||||
void InitializeIfNeeded() {
|
||||
static bool has_initialized = false;
|
||||
if (has_initialized) {
|
||||
return;
|
||||
}
|
||||
has_initialized = true;
|
||||
|
||||
//
|
||||
|
||||
atexit(CleanupOnShutdown);
|
||||
void InitializeIfNeeded() {
|
||||
static bool has_initialized = false;
|
||||
if (has_initialized) {
|
||||
return;
|
||||
}
|
||||
has_initialized = true;
|
||||
|
||||
void CleanupOnShutdown() {
|
||||
}
|
||||
//
|
||||
|
||||
atexit(CleanupOnShutdown);
|
||||
}
|
||||
|
||||
void CleanupOnShutdown() {}
|
||||
}
|
||||
|
||||
GraphicsSystem* xe::gpu::nop::Create(Emulator* emulator) {
|
||||
std::unique_ptr<GraphicsSystem> xe::gpu::nop::Create(Emulator* emulator) {
|
||||
InitializeIfNeeded();
|
||||
return new NopGraphicsSystem(emulator);
|
||||
return std::make_unique<NopGraphicsSystem>(emulator);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#ifndef XENIA_GPU_NOP_NOP_GPU_H_
|
||||
#define XENIA_GPU_NOP_NOP_GPU_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <xenia/core.h>
|
||||
|
||||
namespace xe {
|
||||
@@ -21,7 +23,7 @@ namespace gpu {
|
||||
class GraphicsSystem;
|
||||
namespace nop {
|
||||
|
||||
GraphicsSystem* Create(Emulator* emulator);
|
||||
std::unique_ptr<GraphicsSystem> Create(Emulator* emulator);
|
||||
|
||||
} // namespace nop
|
||||
} // namespace gpu
|
||||
|
||||
Reference in New Issue
Block a user