[GPU] Run TraceDump headless, and drop the GL4 trace dumper
This commit is contained in:
parent
09b3a07e3c
commit
4d159efef5
|
@ -1,40 +0,0 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2015 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/base/main.h"
|
||||
#include "xenia/gpu/gl4/gl4_command_processor.h"
|
||||
#include "xenia/gpu/gl4/gl4_graphics_system.h"
|
||||
#include "xenia/gpu/trace_dump.h"
|
||||
|
||||
namespace xe {
|
||||
namespace gpu {
|
||||
namespace gl4 {
|
||||
|
||||
using namespace xe::gpu::xenos;
|
||||
|
||||
class GL4TraceDump : public TraceDump {
|
||||
public:
|
||||
std::unique_ptr<gpu::GraphicsSystem> CreateGraphicsSystem() override {
|
||||
return std::unique_ptr<gpu::GraphicsSystem>(new GL4GraphicsSystem());
|
||||
}
|
||||
};
|
||||
|
||||
int trace_dump_main(const std::vector<std::wstring>& args) {
|
||||
GL4TraceDump trace_dump;
|
||||
return trace_dump.Main(args);
|
||||
}
|
||||
|
||||
} // namespace gl4
|
||||
} // namespace gpu
|
||||
} // namespace xe
|
||||
|
||||
DEFINE_ENTRY_POINT(L"xenia-gpu-gl4-trace-dump",
|
||||
L"xenia-gpu-gl4-trace-dump some.trace",
|
||||
xe::gpu::gl4::trace_dump_main);
|
|
@ -76,53 +76,4 @@ project("xenia-gpu-gl4-trace-viewer")
|
|||
"1>scratch/stdout-trace-viewer.txt",
|
||||
})
|
||||
end
|
||||
|
||||
group("src")
|
||||
project("xenia-gpu-gl4-trace-dump")
|
||||
uuid("5d47299d-f37d-46b4-af48-f4e54b9e5662")
|
||||
kind("ConsoleApp")
|
||||
language("C++")
|
||||
links({
|
||||
"gflags",
|
||||
"glew",
|
||||
"imgui",
|
||||
"xenia-apu",
|
||||
"xenia-apu-nop",
|
||||
"xenia-apu-xaudio2",
|
||||
"xenia-base",
|
||||
"xenia-core",
|
||||
"xenia-cpu",
|
||||
"xenia-cpu-backend-x64",
|
||||
"xenia-gpu",
|
||||
"xenia-gpu-gl4",
|
||||
"xenia-hid-nop",
|
||||
"xenia-hid-winkey",
|
||||
"xenia-hid-xinput",
|
||||
"xenia-kernel",
|
||||
"xenia-ui",
|
||||
"xenia-ui-gl",
|
||||
"xenia-vfs",
|
||||
})
|
||||
defines({
|
||||
"GLEW_STATIC=1",
|
||||
"GLEW_MX=1",
|
||||
})
|
||||
includedirs({
|
||||
project_root.."/third_party/gflags/src",
|
||||
})
|
||||
files({
|
||||
"gl4_trace_dump_main.cc",
|
||||
"../../base/main_"..platform_suffix..".cc",
|
||||
})
|
||||
|
||||
filter("platforms:Windows")
|
||||
-- Only create the .user file if it doesn't already exist.
|
||||
local user_file = project_root.."/build/xenia-gpu-gl4-trace-dump.vcxproj.user"
|
||||
if not os.isfile(user_file) then
|
||||
debugdir(project_root)
|
||||
debugargs({
|
||||
"--flagfile=scratch/flags.txt",
|
||||
"2>&1",
|
||||
"1>scratch/stdout-trace-dump.txt",
|
||||
})
|
||||
end
|
||||
|
|
@ -56,28 +56,11 @@ int TraceDump::Main(const std::vector<std::wstring>& args) {
|
|||
if (args.size() >= 3) {
|
||||
output_path = args[2];
|
||||
}
|
||||
} else {
|
||||
// Open a file chooser and ask the user.
|
||||
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"*.xtr"},
|
||||
{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;
|
||||
XELOGE("No trace file specified");
|
||||
return 5;
|
||||
}
|
||||
|
||||
// Normalize the path and make absolute.
|
||||
|
@ -85,12 +68,12 @@ int TraceDump::Main(const std::vector<std::wstring>& args) {
|
|||
XELOGI("Loading trace file %ls...", abs_path.c_str());
|
||||
|
||||
if (!Setup()) {
|
||||
xe::FatalError("Unable to setup trace dump tool");
|
||||
return 1;
|
||||
XELOGE("Unable to setup trace dump tool");
|
||||
return 4;
|
||||
}
|
||||
if (!Load(std::move(abs_path))) {
|
||||
xe::FatalError("Unable to load trace file; not found?");
|
||||
return 1;
|
||||
XELOGE("Unable to load trace file; not found?");
|
||||
return 5;
|
||||
}
|
||||
|
||||
// Root file name for outputs.
|
||||
|
@ -119,43 +102,16 @@ int TraceDump::Main(const std::vector<std::wstring>& args) {
|
|||
}
|
||||
|
||||
bool TraceDump::Setup() {
|
||||
// Main display window.
|
||||
loop_ = ui::Loop::Create();
|
||||
window_ = xe::ui::Window::Create(loop_.get(), L"xenia-gpu-trace-dump");
|
||||
loop_->PostSynchronous([&]() {
|
||||
xe::threading::set_name("Win32 Loop");
|
||||
if (!window_->Initialize()) {
|
||||
xe::FatalError("Failed to initialize main window");
|
||||
return;
|
||||
}
|
||||
});
|
||||
window_->on_closed.AddListener([&](xe::ui::UIEvent* e) {
|
||||
loop_->Quit();
|
||||
XELOGI("User-initiated death!");
|
||||
exit(1);
|
||||
});
|
||||
loop_->on_quit.AddListener([&](xe::ui::UIEvent* e) { window_.reset(); });
|
||||
window_->Resize(1280, 720);
|
||||
|
||||
// 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(), nullptr,
|
||||
[this]() { return CreateGraphicsSystem(); }, nullptr);
|
||||
X_STATUS result = emulator_->Setup(
|
||||
nullptr, nullptr, [this]() { return CreateGraphicsSystem(); }, nullptr);
|
||||
if (XFAILED(result)) {
|
||||
XELOGE("Failed to setup emulator: %.8X", result);
|
||||
return false;
|
||||
}
|
||||
memory_ = emulator_->memory();
|
||||
graphics_system_ = emulator_->graphics_system();
|
||||
|
||||
window_->on_key_char.AddListener([&](xe::ui::KeyEvent* e) {
|
||||
if (e->key_code() == 0x74 /* VK_F5 */) {
|
||||
graphics_system_->ClearCaches();
|
||||
e->set_handled(true);
|
||||
}
|
||||
});
|
||||
|
||||
player_ = std::make_unique<TracePlayer>(loop_.get(), graphics_system_);
|
||||
return true;
|
||||
}
|
||||
|
@ -172,67 +128,26 @@ bool TraceDump::Load(std::wstring trace_file_path) {
|
|||
}
|
||||
|
||||
int TraceDump::Run() {
|
||||
loop_->PostSynchronous([&]() {
|
||||
player_->SeekFrame(0);
|
||||
player_->SeekCommand(
|
||||
static_cast<int>(player_->current_frame()->commands.size() - 1));
|
||||
});
|
||||
|
||||
auto file_name = xe::find_name_from_path(trace_file_path_);
|
||||
std::wstring title = std::wstring(L"Xenia GPU Trace Dump: ") + file_name;
|
||||
while (player_->is_playing_trace()) {
|
||||
// Update titlebar status.
|
||||
if (player_->is_playing_trace()) {
|
||||
int percent =
|
||||
static_cast<int>(player_->playback_percent() / 10000.0 * 100.0);
|
||||
window_->set_title(title + xe::format_string(L" (%d%%)", percent));
|
||||
}
|
||||
|
||||
xe::threading::Sleep(std::chrono::milliseconds(1));
|
||||
}
|
||||
|
||||
window_->set_title(title);
|
||||
player_->SeekFrame(0);
|
||||
player_->SeekCommand(
|
||||
static_cast<int>(player_->current_frame()->commands.size() - 1));
|
||||
player_->WaitOnPlayback();
|
||||
|
||||
xe::threading::Fence capture_fence;
|
||||
// Capture.
|
||||
int result = 0;
|
||||
loop_->PostDelayed(
|
||||
[&]() {
|
||||
// Capture.
|
||||
auto raw_image = graphics_system_->Capture();
|
||||
if (!raw_image) {
|
||||
// Failed to capture anything.
|
||||
result = -1;
|
||||
capture_fence.Signal();
|
||||
return;
|
||||
}
|
||||
auto raw_image = graphics_system_->Capture();
|
||||
if (raw_image) {
|
||||
// Save framebuffer png.
|
||||
std::string png_path = xe::to_string(base_output_path_ + L".png");
|
||||
stbi_write_png(png_path.c_str(), static_cast<int>(raw_image->width),
|
||||
static_cast<int>(raw_image->height), 4,
|
||||
raw_image->data.data(), static_cast<int>(raw_image->stride));
|
||||
} else {
|
||||
result = 1;
|
||||
}
|
||||
|
||||
// Save framebuffer png.
|
||||
std::string png_path = xe::to_string(base_output_path_ + L".png");
|
||||
stbi_write_png(png_path.c_str(), static_cast<int>(raw_image->width),
|
||||
static_cast<int>(raw_image->height), 4,
|
||||
raw_image->data.data(),
|
||||
static_cast<int>(raw_image->stride));
|
||||
|
||||
result = 0;
|
||||
capture_fence.Signal();
|
||||
},
|
||||
50);
|
||||
|
||||
capture_fence.Wait();
|
||||
|
||||
// Profiler must exit before the window is closed.
|
||||
Profiler::Shutdown();
|
||||
|
||||
// Wait until we are exited.
|
||||
loop_->Quit();
|
||||
loop_->AwaitQuit();
|
||||
|
||||
window_.reset();
|
||||
loop_.reset();
|
||||
player_.reset();
|
||||
emulator_.reset();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue