[CPU] Null backend enough for GPU trace viewing
This commit is contained in:
parent
3ee68d79ea
commit
88c055eb30
|
@ -477,7 +477,7 @@ void EmulatorApp::EmulatorThread() {
|
||||||
// Setup and initialize all subsystems. If we can't do something
|
// Setup and initialize all subsystems. If we can't do something
|
||||||
// (unsupported system, memory issues, etc) this will fail early.
|
// (unsupported system, memory issues, etc) this will fail early.
|
||||||
X_STATUS result = emulator_->Setup(
|
X_STATUS result = emulator_->Setup(
|
||||||
emulator_window_->window(), emulator_window_->imgui_drawer(),
|
emulator_window_->window(), emulator_window_->imgui_drawer(), true,
|
||||||
CreateAudioSystem, CreateGraphicsSystem, CreateInputDrivers);
|
CreateAudioSystem, CreateGraphicsSystem, CreateInputDrivers);
|
||||||
if (XFAILED(result)) {
|
if (XFAILED(result)) {
|
||||||
XELOGE("Failed to setup emulator: {:08X}", result);
|
XELOGE("Failed to setup emulator: {:08X}", result);
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* Xenia : Xbox 360 Emulator Research Project *
|
||||||
|
******************************************************************************
|
||||||
|
* Copyright 2022 Ben Vanik. All rights reserved. *
|
||||||
|
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "xenia/cpu/backend/null_backend.h"
|
||||||
|
|
||||||
|
#include "xenia/cpu/backend/assembler.h"
|
||||||
|
#include "xenia/cpu/function.h"
|
||||||
|
|
||||||
|
namespace xe {
|
||||||
|
namespace cpu {
|
||||||
|
namespace backend {
|
||||||
|
|
||||||
|
void NullBackend::CommitExecutableRange(uint32_t guest_low,
|
||||||
|
uint32_t guest_high) {}
|
||||||
|
|
||||||
|
std::unique_ptr<Assembler> NullBackend::CreateAssembler() { return nullptr; }
|
||||||
|
|
||||||
|
std::unique_ptr<GuestFunction> NullBackend::CreateGuestFunction(
|
||||||
|
Module* module, uint32_t address) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t NullBackend::CalculateNextHostInstruction(ThreadDebugInfo* thread_info,
|
||||||
|
uint64_t current_pc) {
|
||||||
|
return current_pc;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace backend
|
||||||
|
} // namespace cpu
|
||||||
|
} // namespace xe
|
|
@ -0,0 +1,36 @@
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* Xenia : Xbox 360 Emulator Research Project *
|
||||||
|
******************************************************************************
|
||||||
|
* Copyright 2022 Ben Vanik. All rights reserved. *
|
||||||
|
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef XENIA_CPU_BACKEND_NULL_BACKEND_H_
|
||||||
|
#define XENIA_CPU_BACKEND_NULL_BACKEND_H_
|
||||||
|
|
||||||
|
#include "xenia/cpu/backend/backend.h"
|
||||||
|
|
||||||
|
namespace xe {
|
||||||
|
namespace cpu {
|
||||||
|
namespace backend {
|
||||||
|
|
||||||
|
class NullBackend : public Backend {
|
||||||
|
public:
|
||||||
|
void CommitExecutableRange(uint32_t guest_low, uint32_t guest_high) override;
|
||||||
|
|
||||||
|
std::unique_ptr<Assembler> CreateAssembler() override;
|
||||||
|
|
||||||
|
std::unique_ptr<GuestFunction> CreateGuestFunction(Module* module,
|
||||||
|
uint32_t address) override;
|
||||||
|
|
||||||
|
uint64_t CalculateNextHostInstruction(ThreadDebugInfo* thread_info,
|
||||||
|
uint64_t current_pc) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace backend
|
||||||
|
} // namespace cpu
|
||||||
|
} // namespace xe
|
||||||
|
|
||||||
|
#endif // XENIA_CPU_BACKEND_NULL_BACKEND_H_
|
|
@ -134,7 +134,11 @@ bool Processor::Setup(std::unique_ptr<backend::Backend> backend) {
|
||||||
// Stack walker is used when profiling, debugging, and dumping.
|
// Stack walker is used when profiling, debugging, and dumping.
|
||||||
// Note that creation may fail, in which case we'll have to disable those
|
// Note that creation may fail, in which case we'll have to disable those
|
||||||
// features.
|
// features.
|
||||||
stack_walker_ = StackWalker::Create(backend_->code_cache());
|
// The code cache may be unavailable in case of a "null" backend.
|
||||||
|
cpu::backend::CodeCache* code_cache = backend_->code_cache();
|
||||||
|
if (code_cache) {
|
||||||
|
stack_walker_ = StackWalker::Create(code_cache);
|
||||||
|
}
|
||||||
if (!stack_walker_) {
|
if (!stack_walker_) {
|
||||||
// TODO(benvanik): disable features.
|
// TODO(benvanik): disable features.
|
||||||
if (cvars::debug) {
|
if (cvars::debug) {
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "xenia/base/platform.h"
|
#include "xenia/base/platform.h"
|
||||||
#include "xenia/base/string.h"
|
#include "xenia/base/string.h"
|
||||||
#include "xenia/cpu/backend/code_cache.h"
|
#include "xenia/cpu/backend/code_cache.h"
|
||||||
|
#include "xenia/cpu/backend/null_backend.h"
|
||||||
#include "xenia/cpu/cpu_flags.h"
|
#include "xenia/cpu/cpu_flags.h"
|
||||||
#include "xenia/cpu/thread_state.h"
|
#include "xenia/cpu/thread_state.h"
|
||||||
#include "xenia/gpu/graphics_system.h"
|
#include "xenia/gpu/graphics_system.h"
|
||||||
|
@ -131,6 +132,7 @@ Emulator::~Emulator() {
|
||||||
|
|
||||||
X_STATUS Emulator::Setup(
|
X_STATUS Emulator::Setup(
|
||||||
ui::Window* display_window, ui::ImGuiDrawer* imgui_drawer,
|
ui::Window* display_window, ui::ImGuiDrawer* imgui_drawer,
|
||||||
|
bool require_cpu_backend,
|
||||||
std::function<std::unique_ptr<apu::AudioSystem>(cpu::Processor*)>
|
std::function<std::unique_ptr<apu::AudioSystem>(cpu::Processor*)>
|
||||||
audio_system_factory,
|
audio_system_factory,
|
||||||
std::function<std::unique_ptr<gpu::GraphicsSystem>()>
|
std::function<std::unique_ptr<gpu::GraphicsSystem>()>
|
||||||
|
@ -164,20 +166,21 @@ X_STATUS Emulator::Setup(
|
||||||
export_resolver_ = std::make_unique<xe::cpu::ExportResolver>();
|
export_resolver_ = std::make_unique<xe::cpu::ExportResolver>();
|
||||||
|
|
||||||
std::unique_ptr<xe::cpu::backend::Backend> backend;
|
std::unique_ptr<xe::cpu::backend::Backend> backend;
|
||||||
if (!backend) {
|
|
||||||
#if XE_ARCH_AMD64
|
#if XE_ARCH_AMD64
|
||||||
if (cvars::cpu == "x64") {
|
if (cvars::cpu == "x64") {
|
||||||
|
backend.reset(new xe::cpu::backend::x64::X64Backend());
|
||||||
|
}
|
||||||
|
#endif // XE_ARCH
|
||||||
|
if (cvars::cpu == "any") {
|
||||||
|
if (!backend) {
|
||||||
|
#if XE_ARCH_AMD64
|
||||||
backend.reset(new xe::cpu::backend::x64::X64Backend());
|
backend.reset(new xe::cpu::backend::x64::X64Backend());
|
||||||
}
|
|
||||||
#endif // XE_ARCH
|
#endif // XE_ARCH
|
||||||
if (cvars::cpu == "any") {
|
|
||||||
if (!backend) {
|
|
||||||
#if XE_ARCH_AMD64
|
|
||||||
backend.reset(new xe::cpu::backend::x64::X64Backend());
|
|
||||||
#endif // XE_ARCH
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!backend && !require_cpu_backend) {
|
||||||
|
backend.reset(new xe::cpu::backend::NullBackend());
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize the CPU.
|
// Initialize the CPU.
|
||||||
processor_ = std::make_unique<xe::cpu::Processor>(memory_.get(),
|
processor_ = std::make_unique<xe::cpu::Processor>(memory_.get(),
|
||||||
|
|
|
@ -161,6 +161,7 @@ class Emulator {
|
||||||
// functions.
|
// functions.
|
||||||
X_STATUS Setup(
|
X_STATUS Setup(
|
||||||
ui::Window* display_window, ui::ImGuiDrawer* imgui_drawer,
|
ui::Window* display_window, ui::ImGuiDrawer* imgui_drawer,
|
||||||
|
bool require_cpu_backend,
|
||||||
std::function<std::unique_ptr<apu::AudioSystem>(cpu::Processor*)>
|
std::function<std::unique_ptr<apu::AudioSystem>(cpu::Processor*)>
|
||||||
audio_system_factory,
|
audio_system_factory,
|
||||||
std::function<std::unique_ptr<gpu::GraphicsSystem>()>
|
std::function<std::unique_ptr<gpu::GraphicsSystem>()>
|
||||||
|
|
|
@ -95,8 +95,8 @@ bool TraceDump::Setup() {
|
||||||
// Create the emulator but don't initialize so we can setup the window.
|
// Create the emulator but don't initialize so we can setup the window.
|
||||||
emulator_ = std::make_unique<Emulator>("", "", "", "");
|
emulator_ = std::make_unique<Emulator>("", "", "", "");
|
||||||
X_STATUS result = emulator_->Setup(
|
X_STATUS result = emulator_->Setup(
|
||||||
nullptr, nullptr, nullptr, [this]() { return CreateGraphicsSystem(); },
|
nullptr, nullptr, false, nullptr,
|
||||||
nullptr);
|
[this]() { return CreateGraphicsSystem(); }, nullptr);
|
||||||
if (XFAILED(result)) {
|
if (XFAILED(result)) {
|
||||||
XELOGE("Failed to setup emulator: {:08X}", result);
|
XELOGE("Failed to setup emulator: {:08X}", result);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -125,7 +125,7 @@ bool TraceViewer::Setup() {
|
||||||
// Create the emulator but don't initialize so we can setup the window.
|
// Create the emulator but don't initialize so we can setup the window.
|
||||||
emulator_ = std::make_unique<Emulator>("", "", "", "");
|
emulator_ = std::make_unique<Emulator>("", "", "", "");
|
||||||
X_STATUS result = emulator_->Setup(
|
X_STATUS result = emulator_->Setup(
|
||||||
window_.get(), nullptr, nullptr,
|
window_.get(), nullptr, false, nullptr,
|
||||||
[this]() { return CreateGraphicsSystem(); }, nullptr);
|
[this]() { return CreateGraphicsSystem(); }, nullptr);
|
||||||
if (XFAILED(result)) {
|
if (XFAILED(result)) {
|
||||||
XELOGE("Failed to setup emulator: {:08X}", result);
|
XELOGE("Failed to setup emulator: {:08X}", result);
|
||||||
|
|
Loading…
Reference in New Issue