src/third_party/angle/src/tests/perf_tests/TracePerfTest.cpp
// Converts a GL timestamp into a host-side CPU time aligned with "GetHostTimeSeconds".
// This check is necessary to line up sampled trace events in a consistent timeline.
// Uses a linear interpolation from a series of samples. We do a blocking call to sample
// both host and GL time once per swap. We then find the two closest GL timestamps and
// interpolate the host times between them to compute our result. If we are past the last
// GL timestamp we sample a new data point pair.
Converts a GL timestamp into a host-side CPU time aligned with "GetHostTimeSeconds".
This check is necessary to line up sampled trace events in a consistent timeline.
Uses a linear interpolation from a series of samples. We do a blocking call to sample
both host and GL time once per swap. We then find the two closest GL timestamps and
interpolate the host times between them to compute our result. If we are past the last
GL timestamp we sample a new data point pair.
Converts a GL timestamp into a host - side CPU time aligned with " GetHostTimeSeconds " . This check is necessary to line up sampled trace events in a consistent timeline . Uses a linear interpolation from a series of samples . We do a blocking call to sample both host and GL time once per swap . We then find the two closest GL timestamps and interpolate the host times between them to compute our result . If we are past the last GL timestamp we sample a new data point pair .
double TracePerfTest::getHostTimeFromGLTime(GLint64 glTime)
{
    size_t firstSampleIndex = mTimeline.size() - 1;
    while (firstSampleIndex > 0)
    {
        if (mTimeline[firstSampleIndex].glTime < glTime)
        {
            break;
        }
        firstSampleIndex--;
    }
    if (firstSampleIndex == mTimeline.size() - 1)
    {
        sampleTime();
    }
    const TimeSample &start = mTimeline[firstSampleIndex];
    const TimeSample &end   = mTimeline[firstSampleIndex + 1];
    double glDelta = static_cast<double>(glTime - start.glTime);
    double glRange = static_cast<double>(end.glTime - start.glTime);
    double t       = glDelta / glRange;
    double hostRange = end.hostTime - start.hostTime;
    return mTimeline[firstSampleIndex].hostTime + hostRange * t;
}
double TracePerfTest :: getHostTimeFromGLTime ( GLint64 glTime ) { size_t firstSampleIndex = mTimeline . size ( ) - 1 ; while ( firstSampleIndex > 0 ) { if ( mTimeline [ firstSampleIndex ] . glTime < glTime ) { break ; } firstSampleIndex -- ; } if ( firstSampleIndex == mTimeline . size ( ) - 1 ) { sampleTime ( ) ; } const TimeSample & start = mTimeline [ firstSampleIndex ] ; const TimeSample & end = mTimeline [ firstSampleIndex + 1 ] ; double glDelta = static_cast < double > ( glTime - start . glTime ) ; double glRange = static_cast < double > ( end . glTime - start . glTime ) ; double t = glDelta / glRange ; double hostRange = end . hostTime - start . hostTime ; return mTimeline [ firstSampleIndex ] . hostTime + hostRange * t ; }
Converts a GL timestamp into a host-side CPU time aligned with "GetHostTimeSeconds".
Converts a GL timestamp into a host - side CPU time aligned with " GetHostTimeSeconds " .
// Find two samples to do a lerp. // Add an extra sample if we're missing an ending sample. // Note: we have observed in some odd cases later timestamps producing values that are // smaller than preceding timestamps. This bears further investigation. // Compute the scaling factor for the lerp. // Lerp(t1, t2, t)