Unravel Engine C++ Reference
Loading...
Searching...
No Matches
profiler_timeline_panel.h
Go to the documentation of this file.
1#pragma once
3
4#include <base/basetypes.hpp>
5#include <context/context.hpp>
7
8namespace unravel
9{
10
11class imgui_panels;
12
14{
15public:
16 explicit profiler_timeline_panel(imgui_panels* parent, const char* name);
17
18 void on_frame_ui_render(rtti::context& ctx, const char* name);
19
20 void show(bool s);
21
23 {
24 ImVec2 canvas_pos;
30 };
31
32private:
33 void draw_ui(rtti::context& ctx);
34 void draw_recording_toolbar();
35 void draw_frame_selector_bar();
36 void draw_profiler_bottom_sections(rtti::context& ctx);
37 void draw_timeline();
38 void draw_time_ruler(double view_start_ns, double reference_ns, double ns_per_pixel,
39 float ruler_width, ImVec2 canvas_pos);
40
41 void draw_lane_events(const lane_context& lc,
42 const std::vector<const frame_snapshot*>& visible_frames,
43 const std::vector<uint32_t>& visible_hist_indices,
44 const frame_snapshot* selected_snap,
45 uint16_t thread_index,
46 const std::string& thread_name);
47
48 static void timeline_render_event_block(const lane_context& lc,
49 const profile_event& ev,
50 bool is_reference_frame,
51 const std::string& thread_name,
53 uint32_t hist_frame_idx,
54 uint16_t thread_idx,
55 uint32_t event_idx);
56
57 void validate_timeline_scope_selection(uint32_t frame_count);
58
59 [[nodiscard]] auto is_timeline_scope_selected(uint32_t hist_frame,
60 uint16_t thread_index,
61 uint32_t event_index) const -> bool
62 {
63 return has_timeline_scope_selection_ && selected_scope_hist_frame_ == hist_frame &&
64 selected_scope_thread_index_ == thread_index && selected_scope_event_index_ == event_index;
65 }
66
67 void set_timeline_scope_selection(uint32_t hist_frame,
68 uint16_t thread_index,
69 uint32_t event_index,
70 const char* label)
71 {
72 has_timeline_scope_selection_ = true;
73 selected_scope_hist_frame_ = hist_frame;
74 selected_scope_thread_index_ = thread_index;
75 selected_scope_event_index_ = event_index;
76 selected_scope_label_ = label ? label : "";
77 }
78 void draw_lane_frame_boundaries(const lane_context& lc,
79 const std::vector<const frame_snapshot*>& visible_frames,
80 const frame_snapshot* selected_snap);
81 void gather_visible_frames(performance_profiler* profiler,
82 uint32_t frame_count,
83 const frame_snapshot* selected_snap,
84 std::vector<const frame_snapshot*>& out);
85
86 struct thread_entry
87 {
88 std::string name;
89 uint16_t index;
90 uint16_t max_depth;
91 };
92
93 static void collect_unique_threads(const std::vector<const frame_snapshot*>& frames,
94 std::vector<thread_entry>& out);
95
96 void draw_aggregate_section();
97 void draw_frame_histogram(performance_profiler* profiler, uint32_t frame_count, float bar_width);
98 void draw_live_histogram_stack(float bar_width);
99
100 [[nodiscard]] auto histogram_stack_height() const -> float;
101 void handle_histogram_input(performance_profiler* profiler, uint32_t frame_count,
102 ImVec2 canvas_pos, float bar_width,
103 float eff_start, float eff_range);
104 void handle_histogram_zoom_pan(uint32_t frame_count, ImVec2 canvas_pos,
105 float bar_width, float eff_start, float eff_range);
106
107 std::string name_;
108 imgui_panels* parent_{nullptr};
109
110 sample_data frame_time_history_;
112 sample_data frame_busy_ms_history_;
113 sample_data cpu_heap_mb_history_;
114 sample_data gpu_memory_mb_history_;
115 sample_data process_rss_mb_history_;
116
117 bool show_histogram_managed_heap_{false};
118 bool show_histogram_gpu_memory_{false};
119 bool show_histogram_process_rss_{false};
120
121 double view_start_ns_{0.0};
122 double view_duration_ns_{20'000'000.0};
123 int32_t last_centered_frame_{-2};
124
125 int32_t selected_frame_{-1};
126 bool auto_follow_{true};
127 bool is_dragging_cursor_{false};
128
129 float hist_start_{0.0f};
130 float hist_range_{0.0f};
131
132 bool show_request_{};
133 bool show_{false};
134
135 bool has_timeline_scope_selection_{false};
136 uint32_t selected_scope_hist_frame_{0};
137 uint16_t selected_scope_thread_index_{0};
138 uint32_t selected_scope_event_index_{0};
139 std::string selected_scope_label_{};
140};
141
142} // namespace unravel
profiler_timeline_panel(imgui_panels *parent, const char *name)
void on_frame_ui_render(rtti::context &ctx, const char *name)
std::string name
Definition hub.cpp:33
Hash specialization for batch_key to enable use in std::unordered_map.
Compacted copy of one frame's profiling data across all threads.
Definition profiler.h:201
A single profiling event captured during a frame.
Definition profiler.h:141