Expose a playback percentage rather than pointers in TracePlayer
This commit is contained in:
parent
a59e83e0d0
commit
414519fb6c
|
@ -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<TraceCommandType>(xe::load<uint32_t>(trace_ptr));
|
||||
switch (type) {
|
||||
|
|
|
@ -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<bool> playing_trace_ = false;
|
||||
std::atomic<const uint8_t*> player_current_ptr_ = 0;
|
||||
std::atomic<const uint8_t*> player_start_ptr_ = 0;
|
||||
std::atomic<const uint8_t*> player_target_ptr_ = 0;
|
||||
bool playing_trace_ = false;
|
||||
std::atomic<uint32_t> playback_percent_ = 0;
|
||||
};
|
||||
|
||||
} // namespace gpu
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue