Clear existing events when the circular buffer wraps around.

This commit is contained in:
hiker 2017-08-08 16:36:54 +10:00
parent d29d2b831f
commit 6a0fb83209
2 changed files with 23 additions and 4 deletions

View File

@ -280,10 +280,24 @@ void Profiler::synchronizeFrame()
{
EventData &ed = td.m_all_event_data[td.m_event_stack[j]];
ed.setEnd(m_current_frame, now-m_time_last_sync);
ed.setStart(next_frame, now - m_time_last_sync, j);
}
ed.setStart(next_frame, 0, j);
} // for j in event stack
} // for i in threads
}
if (m_has_wrapped_around)
{
// The new entries for the circular buffer need to be cleared
// to make sure the new values are not accumulated on top of
// the data from a previous frame.
for (int i = 0; i < m_threads_used; i++)
{
ThreadData &td = m_all_threads_data[i];
AllEventData &aed = td.m_all_event_data;
AllEventData::iterator k;
for (k = aed.begin(); k != aed.end(); ++k)
k->second.getMarker(next_frame).clear();
}
} // is has wrapped around
m_current_frame = next_frame;

View File

@ -144,10 +144,14 @@ private:
// --------------------------------------------------------------------
size_t getLayer() const { return m_layer; }
// --------------------------------------------------------------------
/** Called when an entry in the cyclic buffer is reused. Makes sure
* that time for a new event can be accumulated. */
void clear() { m_duration = 0; }
// --------------------------------------------------------------------
/** Sets start time and layer for this event. */
void setStart(double start, size_t layer = 0)
{
m_start = start; m_duration = 0; m_layer = layer;
m_start = start; m_layer = layer;
} // setStart
// --------------------------------------------------------------------
/** Sets the end time of this event. */
@ -194,6 +198,7 @@ private:
} // setEnd
// --------------------------------------------------------------------
const Marker& getMarker(int n) const { return m_all_markers[n]; }
Marker& getMarker(int n) { return m_all_markers[n]; }
// --------------------------------------------------------------------
/** Returns the colour for this event. */
video::SColor getColour() const { return m_colour; }