The open source OpenXR runtime
0
fork

Configure Feed

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

c/main: Try to detect when we miss frames

+19
+19
src/xrt/compositor/main/comp_renderer.c
··· 2027 2027 2028 2028 // Save for timestamps below. 2029 2029 uint64_t frame_id = c->frame.rendering.id; 2030 + uint64_t desired_present_time_ns = c->frame.rendering.desired_present_time_ns; 2030 2031 2031 2032 // Clear the rendered frame. 2032 2033 comp_frame_clear_locked(&c->frame.rendering); ··· 2076 2077 * Only do this if we are ready. 2077 2078 */ 2078 2079 if (comp_target_check_ready(r->c->target)) { 2080 + // For estimating frame misses. 2081 + uint64_t then_ns = os_monotonic_get_ns(); 2082 + 2083 + // Do the acquire 2079 2084 renderer_acquire_swapchain_image(r); 2085 + 2086 + // How long did it take? 2087 + uint64_t now_ns = os_monotonic_get_ns(); 2088 + 2089 + /* 2090 + * Make sure we at least waited 1ms before warning. Then check 2091 + * if we are more then 1ms behind when we wanted to present. 2092 + */ 2093 + if (then_ns + U_TIME_1MS_IN_NS < now_ns && // 2094 + desired_present_time_ns + U_TIME_1MS_IN_NS < now_ns) { 2095 + uint64_t diff_ns = now_ns - desired_present_time_ns; 2096 + double diff_ms_f = time_ns_to_ms_f(diff_ns); 2097 + COMP_WARN(c, "Compositor probably missed frame by %.2fms", diff_ms_f); 2098 + } 2080 2099 } 2081 2100 2082 2101 comp_target_update_timings(ct);