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();
|
auto command_processor = graphics_system_->command_processor();
|
||||||
|
|
||||||
command_processor->set_swap_mode(SwapMode::kIgnored);
|
command_processor->set_swap_mode(SwapMode::kIgnored);
|
||||||
player_start_ptr_ = trace_data;
|
playback_percent_ = 0;
|
||||||
player_target_ptr_ = trace_data + trace_size;
|
auto trace_end = trace_data + trace_size;
|
||||||
player_current_ptr_ = trace_data;
|
|
||||||
|
|
||||||
playing_trace_ = true;
|
playing_trace_ = true;
|
||||||
auto trace_ptr = trace_data;
|
auto trace_ptr = trace_data;
|
||||||
bool pending_break = false;
|
bool pending_break = false;
|
||||||
const PacketStartCommand* pending_packet = nullptr;
|
const PacketStartCommand* pending_packet = nullptr;
|
||||||
while (trace_ptr < trace_data + trace_size) {
|
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));
|
auto type = static_cast<TraceCommandType>(xe::load<uint32_t>(trace_ptr));
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
|
|
@ -39,9 +39,8 @@ class TracePlayer : public TraceReader {
|
||||||
const Frame* current_frame() const;
|
const Frame* current_frame() const;
|
||||||
|
|
||||||
// Only valid if playing_trace is true.
|
// Only valid if playing_trace is true.
|
||||||
const uint8_t* player_current_ptr() const { return player_current_ptr_; }
|
// Scalar from 0-10000
|
||||||
const uint8_t* player_start_ptr() const { return player_start_ptr_; }
|
uint32_t playback_percent() const { return playback_percent_; }
|
||||||
const uint8_t* player_target_ptr() const { return player_target_ptr_; }
|
|
||||||
|
|
||||||
void SeekFrame(int target_frame);
|
void SeekFrame(int target_frame);
|
||||||
void SeekCommand(int target_command);
|
void SeekCommand(int target_command);
|
||||||
|
@ -56,10 +55,8 @@ class TracePlayer : public TraceReader {
|
||||||
GraphicsSystem* graphics_system_;
|
GraphicsSystem* graphics_system_;
|
||||||
int current_frame_index_;
|
int current_frame_index_;
|
||||||
int current_command_index_;
|
int current_command_index_;
|
||||||
std::atomic<bool> playing_trace_ = false;
|
bool playing_trace_ = false;
|
||||||
std::atomic<const uint8_t*> player_current_ptr_ = 0;
|
std::atomic<uint32_t> playback_percent_ = 0;
|
||||||
std::atomic<const uint8_t*> player_start_ptr_ = 0;
|
|
||||||
std::atomic<const uint8_t*> player_target_ptr_ = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace gpu
|
} // namespace gpu
|
||||||
|
|
|
@ -947,16 +947,9 @@ void TraceViewer::DrawStateUI() {
|
||||||
|
|
||||||
if (player_->playing_trace()) {
|
if (player_->playing_trace()) {
|
||||||
ImGui::Text("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;
|
float width = ImGui::GetWindowWidth() - 20.f;
|
||||||
|
|
||||||
ProgressBar((float)rel_cur / (float)rel_end, width);
|
ProgressBar(float(player_->playback_percent()) / 10000.f, width);
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue