Dependency injection for apu/gpu/hid.

This commit is contained in:
Ben Vanik
2015-11-08 15:02:24 -08:00
parent 9a6c5c5c74
commit 5834a42ef3
34 changed files with 217 additions and 158 deletions

View File

@@ -24,10 +24,6 @@ namespace xe {
namespace gpu {
namespace gl4 {
std::unique_ptr<GraphicsSystem> Create() {
return std::make_unique<GL4GraphicsSystem>();
}
std::unique_ptr<ui::GraphicsContext> GL4GraphicsSystem::CreateContext(
ui::Window* target_window) {
// Setup the GL control that actually does the drawing.

View File

@@ -30,6 +30,10 @@ using namespace xe::gpu::xenos;
class GL4TraceViewer : public TraceViewer {
public:
std::unique_ptr<gpu::GraphicsSystem> CreateGraphicsSystem() override {
return std::unique_ptr<gpu::GraphicsSystem>(new GL4GraphicsSystem());
}
uintptr_t GetColorRenderTarget(uint32_t pitch, MsaaSamples samples,
uint32_t base,
ColorRenderTargetFormat format) override {

View File

@@ -9,8 +9,6 @@
#include "xenia/gpu/gpu_flags.h"
DEFINE_string(gpu, "any", "Graphics system. Use: [any, gl4]");
DEFINE_string(trace_gpu_prefix, "scratch/gpu/gpu_trace_",
"Prefix path for GPU trace files.");
DEFINE_bool(trace_gpu_stream, false, "Trace all GPU packets.");

View File

@@ -12,8 +12,6 @@
#include <gflags/gflags.h>
DECLARE_string(gpu);
DECLARE_string(trace_gpu_prefix);
DECLARE_bool(trace_gpu_stream);

View File

@@ -21,27 +21,6 @@
namespace xe {
namespace gpu {
namespace gl4 {
std::unique_ptr<GraphicsSystem> Create();
} // namespace gl4
std::unique_ptr<GraphicsSystem> GraphicsSystem::Create() {
if (FLAGS_gpu.compare("gl4") == 0) {
return xe::gpu::gl4::Create();
} else {
// Create best available.
std::unique_ptr<GraphicsSystem> best;
best = xe::gpu::gl4::Create();
if (best) {
return best;
}
// Nothing!
return nullptr;
}
}
GraphicsSystem::GraphicsSystem() : vsync_worker_running_(false) {}
GraphicsSystem::~GraphicsSystem() = default;

View File

@@ -34,7 +34,6 @@ class GraphicsSystem {
public:
virtual ~GraphicsSystem();
static std::unique_ptr<GraphicsSystem> Create();
virtual std::unique_ptr<ui::GraphicsContext> CreateContext(
ui::Window* target_window) = 0;

View File

@@ -66,7 +66,9 @@ bool TraceViewer::Setup() {
// Create the emulator but don't initialize so we can setup the window.
emulator_ = std::make_unique<Emulator>(L"");
X_STATUS result = emulator_->Setup(window_.get());
X_STATUS result =
emulator_->Setup(window_.get(), nullptr,
[this]() { return CreateGraphicsSystem(); }, nullptr);
if (XFAILED(result)) {
XELOGE("Failed to setup emulator: %.8X", result);
return false;

View File

@@ -44,6 +44,8 @@ class TraceViewer {
protected:
TraceViewer();
virtual std::unique_ptr<gpu::GraphicsSystem> CreateGraphicsSystem() = 0;
void DrawMultilineString(const std::string& str);
virtual uintptr_t GetColorRenderTarget(