From 414519fb6c6f8f34ac6385fda985ad8c4d2bdb75 Mon Sep 17 00:00:00 2001 From: "Dr. Chat" Date: Sun, 22 Nov 2015 11:36:31 -0600 Subject: [PATCH] Expose a playback percentage rather than pointers in TracePlayer --- src/xenia/gpu/trace_player.cc | 9 +++++---- src/xenia/gpu/trace_player.h | 11 ++++------- src/xenia/gpu/trace_viewer.cc | 9 +-------- 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/src/xenia/gpu/trace_player.cc b/src/xenia/gpu/trace_player.cc index 33ac1919d..3e762f451 100644 --- a/src/xenia/gpu/trace_player.cc +++ b/src/xenia/gpu/trace_player.cc @@ -92,16 +92,17 @@ void TracePlayer::PlayTraceOnThread(const uint8_t* trace_data, auto command_processor = graphics_system_->command_processor(); command_processor->set_swap_mode(SwapMode::kIgnored); - player_start_ptr_ = trace_data; - player_target_ptr_ = trace_data + trace_size; - player_current_ptr_ = trace_data; + playback_percent_ = 0; + auto trace_end = trace_data + trace_size; playing_trace_ = true; auto trace_ptr = trace_data; bool pending_break = false; const PacketStartCommand* pending_packet = nullptr; while (trace_ptr < trace_data + trace_size) { - player_current_ptr_ = trace_ptr; + playback_percent_ = uint32_t( + (float(trace_ptr - trace_data) / float(trace_end - trace_data)) * + 10000); auto type = static_cast(xe::load(trace_ptr)); switch (type) { diff --git a/src/xenia/gpu/trace_player.h b/src/xenia/gpu/trace_player.h index d0ef59fb4..70678ec1c 100644 --- a/src/xenia/gpu/trace_player.h +++ b/src/xenia/gpu/trace_player.h @@ -39,9 +39,8 @@ class TracePlayer : public TraceReader { const Frame* current_frame() const; // Only valid if playing_trace is true. - const uint8_t* player_current_ptr() const { return player_current_ptr_; } - const uint8_t* player_start_ptr() const { return player_start_ptr_; } - const uint8_t* player_target_ptr() const { return player_target_ptr_; } + // Scalar from 0-10000 + uint32_t playback_percent() const { return playback_percent_; } void SeekFrame(int target_frame); void SeekCommand(int target_command); @@ -56,10 +55,8 @@ class TracePlayer : public TraceReader { GraphicsSystem* graphics_system_; int current_frame_index_; int current_command_index_; - std::atomic playing_trace_ = false; - std::atomic player_current_ptr_ = 0; - std::atomic player_start_ptr_ = 0; - std::atomic player_target_ptr_ = 0; + bool playing_trace_ = false; + std::atomic playback_percent_ = 0; }; } // namespace gpu diff --git a/src/xenia/gpu/trace_viewer.cc b/src/xenia/gpu/trace_viewer.cc index f3af7a1ff..14513f989 100644 --- a/src/xenia/gpu/trace_viewer.cc +++ b/src/xenia/gpu/trace_viewer.cc @@ -947,16 +947,9 @@ void TraceViewer::DrawStateUI() { if (player_->playing_trace()) { ImGui::Text("Playing trace..."); - uint64_t start = uint64_t(player_->player_start_ptr()); - uint64_t end = uint64_t(player_->player_target_ptr()); - uint64_t cur = uint64_t(player_->player_current_ptr()); - - uint64_t rel_cur = cur - start; - uint64_t rel_end = end - start; - float width = ImGui::GetWindowWidth() - 20.f; - ProgressBar((float)rel_cur / (float)rel_end, width); + ProgressBar(float(player_->playback_percent()) / 10000.f, width); ImGui::End(); return; }