[GPU] Fix TraceDump progress not showing

This commit is contained in:
DrChat 2017-12-17 13:44:39 -06:00
parent 12e796bc0a
commit c7859da997
1 changed files with 20 additions and 24 deletions

View File

@ -164,22 +164,30 @@ bool TraceDump::Load(std::wstring trace_file_path) {
} }
int TraceDump::Run() { int TraceDump::Run() {
loop_->Post([&]() { loop_->PostSynchronous([&]() {
player_->SeekFrame(0); player_->SeekFrame(0);
player_->SeekCommand( player_->SeekCommand(
static_cast<int>(player_->current_frame()->commands.size() - 1)); 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_->WaitOnPlayback(); player_->WaitOnPlayback();
loop_->PostSynchronous([&]() { xe::threading::Fence capture_fence;
// Breathe.
});
loop_->PostSynchronous([&]() {
// Breathe.
});
int result = 0; int result = 0;
auto capture_event = xe::threading::Event::CreateManualResetEvent(false);
loop_->PostDelayed( loop_->PostDelayed(
[&]() { [&]() {
// Capture. // Capture.
@ -187,7 +195,7 @@ int TraceDump::Run() {
if (!raw_image) { if (!raw_image) {
// Failed to capture anything. // Failed to capture anything.
result = -1; result = -1;
capture_event->Set(); capture_fence.Signal();
return; return;
} }
@ -199,23 +207,11 @@ int TraceDump::Run() {
static_cast<int>(raw_image->stride)); static_cast<int>(raw_image->stride));
result = 0; result = 0;
capture_event->Set(); capture_fence.Signal();
}, },
50); 50);
while (xe::threading::Wait(capture_event.get(), false, capture_fence.Wait();
std::chrono::milliseconds(1)) ==
xe::threading::WaitResult::kTimeout) {
// Update titlebar status.
auto file_name = xe::find_name_from_path(trace_file_path_);
std::wstring title = std::wstring(L"Xenia GPU Trace Dump: ") + file_name;
if (player_->is_playing_trace()) {
int percent =
static_cast<int>(player_->playback_percent() / 10000.0 * 100.0);
title += xe::format_string(L" (%d%%)", percent);
}
window_->set_title(title);
}
// Profiler must exit before the window is closed. // Profiler must exit before the window is closed.
Profiler::Shutdown(); Profiler::Shutdown();