Skip to content

Commit

Permalink
vblanks: use high-prec timestamps if available and toggled
Browse files Browse the repository at this point in the history
  • Loading branch information
Heinrich authored and mikesart committed Sep 24, 2019
1 parent 6a35793 commit 14c4600
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/gpuvis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1947,7 +1947,7 @@ void TraceEvents::init_new_event_vblank( trace_event_t &event )
trace_event_t &event_vblank_queued = m_events[ *vblank_queued_id ];

// If so, set the vblank queued time
event_vblank_queued.duration = event.ts - event_vblank_queued.ts;
event_vblank_queued.duration = event.get_vblank_ts( s_opts().getb( OPT_VBlankHighPrecTimestamps ) ) - event_vblank_queued.ts;
}

m_tdopexpr_locs.add_location_str( "$name=drm_vblank_event", event.id );
Expand All @@ -1957,7 +1957,7 @@ void TraceEvents::init_new_event_vblank( trace_event_t &event )
*/
if ( m_vblank_info[ event.crtc ].last_vblank_ts )
{
int64_t diff = event.ts - m_vblank_info[ event.crtc ].last_vblank_ts;
int64_t diff = event.get_vblank_ts( s_opts().getb( OPT_VBlankHighPrecTimestamps ) ) - m_vblank_info[ event.crtc ].last_vblank_ts;

// Normalize ts diff to known frequencies
diff = normalize_vblank_diff( diff );
Expand All @@ -1967,7 +1967,7 @@ void TraceEvents::init_new_event_vblank( trace_event_t &event )
m_vblank_info[ event.crtc ].count++;
}

m_vblank_info[ event.crtc ].last_vblank_ts = event.ts;
m_vblank_info[ event.crtc ].last_vblank_ts = event.get_vblank_ts( s_opts().getb( OPT_VBlankHighPrecTimestamps ) );
}

// new_event_cb adds all events to array, this function initializes them.
Expand Down
14 changes: 7 additions & 7 deletions src/gpuvis_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2570,7 +2570,7 @@ static float get_vblank_xdiffs( TraceWin &win, graph_info_t &gi, const std::vect

if ( s_opts().getcrtc( event.crtc ) )
{
float x = gi.ts_to_screenx( event.ts );
float x = gi.ts_to_screenx( event.get_vblank_ts( s_opts().getb( OPT_VBlankHighPrecTimestamps ) ) );

if ( xlast )
xdiff = std::max< float >( xdiff, x - xlast );
Expand Down Expand Up @@ -2617,7 +2617,7 @@ void TraceWin::graph_render_vblanks( graph_info_t &gi )
{
// Handle drm_vblank_event0 .. drm_vblank_event2
uint32_t col = Clamp< uint32_t >( col_VBlank0 + event.crtc, col_VBlank0, col_VBlank2 );
float x = gi.ts_to_screenx( event.ts );
float x = gi.ts_to_screenx( event.get_vblank_ts( s_opts().getb( OPT_VBlankHighPrecTimestamps ) ) );

imgui_drawrect_filled( x, gi.rc.y, imgui_scale( 1.0f ), gi.rc.h,
s_clrs().get( col, alpha ) );
Expand Down Expand Up @@ -4099,13 +4099,13 @@ void TraceWin::graph_mouse_tooltip_vblanks( std::string &ttip, graph_info_t &gi,
{
if ( event.ts < mouse_ts )
{
if ( mouse_ts - event.ts < prev_vblank_ts )
prev_vblank_ts = mouse_ts - event.ts;
if ( mouse_ts - event.get_vblank_ts( s_opts().getb( OPT_VBlankHighPrecTimestamps ) ) < prev_vblank_ts )
prev_vblank_ts = mouse_ts - event.get_vblank_ts( s_opts().getb( OPT_VBlankHighPrecTimestamps ) );
}
if ( event.ts > mouse_ts )
if ( event.get_vblank_ts( s_opts().getb( OPT_VBlankHighPrecTimestamps ) ) > mouse_ts )
{
if ( event.ts - mouse_ts < next_vblank_ts )
next_vblank_ts = event.ts - mouse_ts;
if ( event.get_vblank_ts( s_opts().getb( OPT_VBlankHighPrecTimestamps ) ) - mouse_ts < next_vblank_ts )
next_vblank_ts = event.get_vblank_ts( s_opts().getb( OPT_VBlankHighPrecTimestamps ) ) - mouse_ts;
}
}
}
Expand Down

0 comments on commit 14c4600

Please sign in to comment.