Sharing more of trace viewer code.
This commit is contained in:
parent
5db84105c4
commit
95b0ecf774
|
@ -50,8 +50,12 @@ Emulator::~Emulator() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Give the systems time to shutdown before we delete them.
|
// Give the systems time to shutdown before we delete them.
|
||||||
graphics_system_->Shutdown();
|
if (graphics_system_) {
|
||||||
audio_system_->Shutdown();
|
graphics_system_->Shutdown();
|
||||||
|
}
|
||||||
|
if (audio_system_) {
|
||||||
|
audio_system_->Shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
input_system_.reset();
|
input_system_.reset();
|
||||||
graphics_system_.reset();
|
graphics_system_.reset();
|
||||||
|
|
|
@ -7,21 +7,11 @@
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <gflags/gflags.h>
|
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
#include "xenia/base/logging.h"
|
#include "xenia/base/logging.h"
|
||||||
#include "xenia/base/main.h"
|
#include "xenia/base/main.h"
|
||||||
#include "xenia/gpu/trace_viewer.h"
|
|
||||||
|
|
||||||
// HACK: until we have another impl, we just use gl4 directly.
|
|
||||||
#include "xenia/gpu/gl4/gl4_command_processor.h"
|
#include "xenia/gpu/gl4/gl4_command_processor.h"
|
||||||
#include "xenia/gpu/gl4/gl4_graphics_system.h"
|
#include "xenia/gpu/gl4/gl4_graphics_system.h"
|
||||||
#include "xenia/gpu/gl4/gl4_shader.h"
|
#include "xenia/gpu/trace_viewer.h"
|
||||||
#include "xenia/ui/file_picker.h"
|
|
||||||
|
|
||||||
DEFINE_string(target_trace_file, "", "Specifies the trace file to load.");
|
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
namespace gpu {
|
namespace gpu {
|
||||||
|
@ -69,55 +59,8 @@ class GL4TraceViewer : public TraceViewer {
|
||||||
};
|
};
|
||||||
|
|
||||||
int trace_viewer_main(const std::vector<std::wstring>& args) {
|
int trace_viewer_main(const std::vector<std::wstring>& args) {
|
||||||
// Grab path from the flag or unnamed argument.
|
|
||||||
std::wstring path;
|
|
||||||
if (!FLAGS_target_trace_file.empty()) {
|
|
||||||
// Passed as a named argument.
|
|
||||||
// TODO(benvanik): find something better than gflags that supports
|
|
||||||
// unicode.
|
|
||||||
path = xe::to_wstring(FLAGS_target_trace_file);
|
|
||||||
} else if (args.size() >= 2) {
|
|
||||||
// Passed as an unnamed argument.
|
|
||||||
path = args[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
// If no path passed, ask the user.
|
|
||||||
if (path.empty()) {
|
|
||||||
auto file_picker = xe::ui::FilePicker::Create();
|
|
||||||
file_picker->set_mode(ui::FilePicker::Mode::kOpen);
|
|
||||||
file_picker->set_type(ui::FilePicker::Type::kFile);
|
|
||||||
file_picker->set_multi_selection(false);
|
|
||||||
file_picker->set_title(L"Select Trace File");
|
|
||||||
file_picker->set_extensions({
|
|
||||||
{L"Supported Files", L"*.*"}, {L"All Files (*.*)", L"*.*"},
|
|
||||||
});
|
|
||||||
if (file_picker->Show()) {
|
|
||||||
auto selected_files = file_picker->selected_files();
|
|
||||||
if (!selected_files.empty()) {
|
|
||||||
path = selected_files[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (path.empty()) {
|
|
||||||
xe::FatalError("No trace file specified");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Normalize the path and make absolute.
|
|
||||||
auto abs_path = xe::to_absolute_path(path);
|
|
||||||
|
|
||||||
GL4TraceViewer trace_viewer;
|
GL4TraceViewer trace_viewer;
|
||||||
if (!trace_viewer.Setup()) {
|
return trace_viewer.Main(args);
|
||||||
xe::FatalError("Unable to setup trace viewer");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (!trace_viewer.Load(std::move(abs_path))) {
|
|
||||||
xe::FatalError("Unable to load trace file; not found?");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
trace_viewer.Run();
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace gl4
|
} // namespace gl4
|
||||||
|
|
|
@ -43,9 +43,8 @@ void TraceReader::Close() {
|
||||||
|
|
||||||
void TraceReader::ParseTrace() {
|
void TraceReader::ParseTrace() {
|
||||||
auto trace_ptr = trace_data_;
|
auto trace_ptr = trace_data_;
|
||||||
Frame current_frame = {
|
Frame current_frame;
|
||||||
trace_ptr, nullptr, 0,
|
current_frame.start_ptr = trace_ptr;
|
||||||
};
|
|
||||||
const PacketStartCommand* packet_start = nullptr;
|
const PacketStartCommand* packet_start = nullptr;
|
||||||
const uint8_t* packet_start_ptr = nullptr;
|
const uint8_t* packet_start_ptr = nullptr;
|
||||||
const uint8_t* last_ptr = trace_ptr;
|
const uint8_t* last_ptr = trace_ptr;
|
||||||
|
|
|
@ -71,9 +71,9 @@ class TraceReader {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const uint8_t* start_ptr;
|
const uint8_t* start_ptr = nullptr;
|
||||||
const uint8_t* end_ptr;
|
const uint8_t* end_ptr = nullptr;
|
||||||
int command_count;
|
int command_count = 0;
|
||||||
std::vector<Command> commands;
|
std::vector<Command> commands;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -24,10 +24,13 @@
|
||||||
#include "xenia/gpu/sampler_info.h"
|
#include "xenia/gpu/sampler_info.h"
|
||||||
#include "xenia/gpu/texture_info.h"
|
#include "xenia/gpu/texture_info.h"
|
||||||
#include "xenia/memory.h"
|
#include "xenia/memory.h"
|
||||||
|
#include "xenia/ui/file_picker.h"
|
||||||
#include "xenia/ui/imgui_drawer.h"
|
#include "xenia/ui/imgui_drawer.h"
|
||||||
#include "xenia/ui/window.h"
|
#include "xenia/ui/window.h"
|
||||||
#include "xenia/xbox.h"
|
#include "xenia/xbox.h"
|
||||||
|
|
||||||
|
DEFINE_string(target_trace_file, "", "Specifies the trace file to load.");
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
namespace gpu {
|
namespace gpu {
|
||||||
|
|
||||||
|
@ -44,6 +47,57 @@ TraceViewer::TraceViewer() = default;
|
||||||
|
|
||||||
TraceViewer::~TraceViewer() = default;
|
TraceViewer::~TraceViewer() = default;
|
||||||
|
|
||||||
|
int TraceViewer::Main(const std::vector<std::wstring>& args) {
|
||||||
|
// Grab path from the flag or unnamed argument.
|
||||||
|
std::wstring path;
|
||||||
|
if (!FLAGS_target_trace_file.empty()) {
|
||||||
|
// Passed as a named argument.
|
||||||
|
// TODO(benvanik): find something better than gflags that supports
|
||||||
|
// unicode.
|
||||||
|
path = xe::to_wstring(FLAGS_target_trace_file);
|
||||||
|
} else if (args.size() >= 2) {
|
||||||
|
// Passed as an unnamed argument.
|
||||||
|
path = args[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
// If no path passed, ask the user.
|
||||||
|
if (path.empty()) {
|
||||||
|
auto file_picker = xe::ui::FilePicker::Create();
|
||||||
|
file_picker->set_mode(ui::FilePicker::Mode::kOpen);
|
||||||
|
file_picker->set_type(ui::FilePicker::Type::kFile);
|
||||||
|
file_picker->set_multi_selection(false);
|
||||||
|
file_picker->set_title(L"Select Trace File");
|
||||||
|
file_picker->set_extensions({
|
||||||
|
{L"Supported Files", L"*.*"}, {L"All Files (*.*)", L"*.*"},
|
||||||
|
});
|
||||||
|
if (file_picker->Show()) {
|
||||||
|
auto selected_files = file_picker->selected_files();
|
||||||
|
if (!selected_files.empty()) {
|
||||||
|
path = selected_files[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (path.empty()) {
|
||||||
|
xe::FatalError("No trace file specified");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Normalize the path and make absolute.
|
||||||
|
auto abs_path = xe::to_absolute_path(path);
|
||||||
|
|
||||||
|
if (!Setup()) {
|
||||||
|
xe::FatalError("Unable to setup trace viewer");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (!Load(std::move(abs_path))) {
|
||||||
|
xe::FatalError("Unable to load trace file; not found?");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
Run();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
bool TraceViewer::Setup() {
|
bool TraceViewer::Setup() {
|
||||||
// Main display window.
|
// Main display window.
|
||||||
loop_ = ui::Loop::Create();
|
loop_ = ui::Loop::Create();
|
||||||
|
|
|
@ -37,9 +37,7 @@ class TraceViewer {
|
||||||
public:
|
public:
|
||||||
virtual ~TraceViewer();
|
virtual ~TraceViewer();
|
||||||
|
|
||||||
bool Setup();
|
int Main(const std::vector<std::wstring>& args);
|
||||||
bool Load(std::wstring trace_file_path);
|
|
||||||
void Run();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
TraceViewer();
|
TraceViewer();
|
||||||
|
@ -73,6 +71,10 @@ class TraceViewer {
|
||||||
kHostDisasm,
|
kHostDisasm,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool Setup();
|
||||||
|
bool Load(std::wstring trace_file_path);
|
||||||
|
void Run();
|
||||||
|
|
||||||
void DrawUI();
|
void DrawUI();
|
||||||
void DrawControllerUI();
|
void DrawControllerUI();
|
||||||
void DrawPacketDisassemblerUI();
|
void DrawPacketDisassemblerUI();
|
||||||
|
|
Loading…
Reference in New Issue