The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

u/frame_times_widget: Optimize FPS calculation

Do so using precomputed frame timings.

authored by

meng.jiao and committed by
Jakob Bornecrantz
7e22fa57 ad6f7de0

+4 -6
+4 -6
src/xrt/auxiliary/util/u_frame_times_widget.h
··· 47 47 48 48 // update fps only once every FPS_NUM_TIMINGS 49 49 if (widget->index == 0) { 50 - float total_s = 0; 50 + float total_ms = 0; 51 51 52 52 // frame *timings* are durations between *times* 53 53 int NUM_FRAME_TIMINGS = FPS_WIDGET_NUM_FRAME_TIMES - 1; 54 54 55 55 for (int i = 0; i < NUM_FRAME_TIMINGS; i++) { 56 - uint64_t frametime_ns = widget->times_ns[i + 1] - widget->times_ns[i]; 57 - float frametime_s = (float)time_ns_to_s(frametime_ns); 58 - total_s += frametime_s; 56 + total_ms += widget->timings_ms[i]; 59 57 } 60 - float avg_frametime_s = total_s / ((float)NUM_FRAME_TIMINGS); 61 - widget->fps = 1.f / avg_frametime_s; 58 + float avg_frametime_ms = total_ms / ((float)NUM_FRAME_TIMINGS); 59 + widget->fps = 1000.f / avg_frametime_ms; 62 60 } 63 61 64 62 widget->times_ns[widget->index] = new_frame_time;