void FrameTimeManagerCore::SubmitDisplayFrame( unsigned displayFrameIndex,
                                               unsigned appFrameIndex,
                                               double scanoutStartSeconds )
{
    int displayFrameDelta = (displayFrameIndex - LastTiming.DisplayFrameIndex);

    // FIXME: Add queue ahead support here by detecting two frames targeting the same scanout.

    // Update frameDelta tracking.
    if ((LastTiming.FrameSubmitSeconds > 0.0) && (displayFrameDelta < 2))
    {
        if (displayFrameDelta > 0)
        {
            double thisFrameDelta = (scanoutStartSeconds - LastTiming.FrameSubmitSeconds) / displayFrameDelta;
            FrameTimeDeltas.Add(thisFrameDelta);
        }
        LastTiming.FrameDelta = calcFrameDelta();
    }

    // Update indices mapping
    FrameIndices.Add(displayFrameIndex, appFrameIndex);

    LastTiming.AppFrameIndex          = appFrameIndex;
    LastTiming.DisplayFrameIndex      = displayFrameIndex;
    LastTiming.FrameSubmitSeconds     = scanoutStartSeconds;
    LastTiming.AppToDisplayFrameRatio = FrameIndices.GetAppToDisplayFrameRatio();

    // Update Lockless
    LocklessTiming.SetState(LastTiming);
}
Пример #2
0
void FrameTimeManager::EndFrame()
{
    // Record timing since last frame; must be called after Present & sync.
    FrameTiming.NextFrameTime = ovr_GetTimeInSeconds();    
    if (FrameTiming.ThisFrameTime > 0.0)
    {
        FrameTimeDeltas.AddTimeDelta(FrameTiming.NextFrameTime - FrameTiming.ThisFrameTime);
        FrameTiming.Inputs.FrameDelta = calcFrameDelta();
    }

    // Write to Lock-less
    LocklessTiming.SetState(FrameTiming);
}
Пример #3
0
void FrameTimeManager::ResetFrameTiming(unsigned frameIndex,
                                        bool dynamicPrediction,
                                        bool sdkRender)
{    
    DynamicPrediction   = dynamicPrediction;
    SdkRender           = sdkRender;

    FrameTimeDeltas.Clear();
    DistortionRenderTimes.Clear();
    ScreenLatencyTracker.Reset();

    FrameTiming.FrameIndex               = frameIndex;
    FrameTiming.NextFrameTime            = 0.0;
    FrameTiming.ThisFrameTime            = 0.0;
    FrameTiming.Inputs.FrameDelta        = calcFrameDelta();
    FrameTiming.Inputs.ScreenDelay       = calcScreenDelay();
    FrameTiming.Inputs.TimewarpWaitDelta = 0.0f;

    LocklessTiming.SetState(FrameTiming);
}
void FrameTimeManager::EndFrame()
{
    // Record timing since last frame; must be called after Present & sync.
    FrameTiming.NextFrameTime = ovr_GetTimeInSeconds();    
    if (FrameTiming.ThisFrameTime > 0.0)
    {
    //Revisit dynamic pre-Timewarp delay adjustment logic
    /*
        double actualFrameDelta = FrameTiming.NextFrameTime - FrameTiming.ThisFrameTime;

        if (VsyncEnabled)
            TimewarpAdjuster.UpdateTimewarpWaitIfSkippedFrames(this, actualFrameDelta,
                                                               FrameTiming.NextFrameTime);

        FrameTimeDeltas.AddTimeDelta(actualFrameDelta);
    */
        FrameTimeDeltas.AddTimeDelta(FrameTiming.NextFrameTime - FrameTiming.ThisFrameTime);
        FrameTiming.Inputs.FrameDelta = calcFrameDelta();
    }

    // Write to Lock-less
    LocklessTiming.SetState(FrameTiming);
}
void FrameTimeManager::ResetFrameTiming(unsigned frameIndex,
                                        bool dynamicPrediction,
                                        bool sdkRender)
{    
    DynamicPrediction   = dynamicPrediction;
    SdkRender           = sdkRender;

    FrameTimeDeltas.Clear();
    DistortionRenderTimes.Clear();
    ScreenLatencyTracker.Reset();
    //Revisit dynamic pre-Timewarp delay adjustment logic
    //TimewarpAdjuster.Reset();

    FrameTiming.FrameIndex               = frameIndex;
    FrameTiming.NextFrameTime            = 0.0;
    FrameTiming.ThisFrameTime            = 0.0;
    FrameTiming.Inputs.FrameDelta        = calcFrameDelta();
    // This one is particularly critical, and has been missed in the past because
    // this init function wasn't called for app-rendered.
    FrameTiming.Inputs.ScreenDelay       = calcScreenDelay();
    FrameTiming.Inputs.TimewarpWaitDelta = 0.0f;

    LocklessTiming.SetState(FrameTiming);
}