/*

    ================================================================================================================================
    Time warp rendering test.
    ================================================================================================================================
    /
    boolRenderTimeWarp( ksStartupSettings
    startupSettings )
    {
    ksThread_SetAffinity( THREAD_AFFINITY_BIG_CORES );
    ksDriverInstance instance;
    ksDriverInstance_Create( &instance );
    const ksGpuQueueInfo queueInfo =
    {
    1,
    KS_GPU_QUEUE_PROPERTY_GRAPHICS | KS_GPU_QUEUE_PROPERTY_COMPUTE,
    { KS_GPU_QUEUE_PRIORITY_MEDIUM }
    };
    ksGpuWindow window;
    ksGpuWindow_Create( &window, &instance, &queueInfo, 0,
    KS_GPU_SURFACE_COLOR_FORMAT_R8G8B8A8, KS_GPU_SURFACE_DEPTH_FORMAT_NONE, KS_GPU_SAMPLE_COUNT_1,
    WINDOW_RESOLUTION( displayResolutionTable[startupSettings->displayResolutionLevel 2 + 0], startupSettings->fullscreen ),
    WINDOW_RESOLUTION( displayResolutionTable[startupSettings->displayResolutionLevel
    2 + 1], startupSettings->fullscreen ),
    startupSettings->fullscreen );
    intswapInterval = ( startupSettings->noVSyncNanoseconds <= 0 );
    ksGpuWindow_SwapInterval( &window, swapInterval );
    ksTimeWarptimeWarp;
    ksTimeWarp_Create( &timeWarp, &window );
    ksTimeWarp_SetBarGraphState( &timeWarp, startupSettings->hideGraphs ? BAR_GRAPH_HIDDEN : BAR_GRAPH_VISIBLE );
    ksTimeWarp_SetImplementation( &timeWarp, startupSettings->timeWarpImplementation );
    ksTimeWarp_SetChromaticAberrationCorrection( &timeWarp, startupSettings->correctChromaticAberration );
    ksTimeWarp_SetDisplayResolutionLevel( &timeWarp, startupSettings->displayResolutionLevel );
    hmd_headRotationDisabled = startupSettings->headRotationDisabled;
    ksNanoseconds startupTimeNanoseconds = startupSettings->startupTimeNanoseconds;
    ksNanoseconds noVSyncNanoseconds = startupSettings->noVSyncNanoseconds;
    ksNanoseconds noLogNanoseconds = startupSettings->noLogNanoseconds;
    ksThread_SetName( “atw:timewarp” );
    boolexit = false;
    while ( !exit )
    {
    const ksNanoseconds time = GetTimeNanoseconds();
    const ksGpuWindowEvent handleEvent = ksGpuWindow_ProcessEvents( &window );
    if ( handleEvent == KS_GPU_WINDOW_EVENT_ACTIVATED )
    {
    PrintInfo( &window, 0, 0 );
    }
    elseif ( handleEvent == KS_GPU_WINDOW_EVENT_EXIT )
    {
    exit = true;
    }
    if ( ksGpuWindowInput_ConsumeKeyboardKey( &window.input, KEY_ESCAPE ) )
    {
    ksGpuWindow_Exit( &window );
    }
    if ( ksGpuWindowInput_ConsumeKeyboardKey( &window.input, KEY_Z ) )
    {
    startupSettings->renderMode = (ksRenderMode) ( ( startupSettings->renderMode + 1 ) % RENDER_MODE_MAX );
    break;
    }
    if ( ksGpuWindowInput_ConsumeKeyboardKey( &window.input, KEY_F ) )
    {
    startupSettings->fullscreen = !startupSettings->fullscreen;
    break;
    }
    if ( ksGpuWindowInput_ConsumeKeyboardKey( &window.input, KEY_V ) ||
    ( noVSyncNanoseconds > 0 && time - startupTimeNanoseconds > noVSyncNanoseconds ) )
    {
    swapInterval = !swapInterval;
    ksGpuWindow_SwapInterval( &window, swapInterval );
    noVSyncNanoseconds = 0;
    }
    if ( ksGpuWindowInput_ConsumeKeyboardKey( &window.input, KEY_L ) ||
    ( noLogNanoseconds > 0 && time - startupTimeNanoseconds > noLogNanoseconds ) )
    {
    ksFrameLog_Open( OUTPUT_PATH “framelog_timewarp.txt”, 10 );
    noLogNanoseconds = 0;
    }
    if ( ksGpuWindowInput_ConsumeKeyboardKey( &window.input, KEY_H ) )
    {
    hmd_headRoksDriverInstance
    if ( ksGpuWindowInput_ConsumeKeyboardKey( &window.input, KEY_I ) )
    {
    ksTimeWarp_CycleImplementation( &timeWarp );
    }
    if ( ksGpuWindowInput_ConsumeKeyboardKey( &window.input, KEY_C ) )
    {
    ksTimeWarp_ToggleChromaticAberrationCorrection( &timeWarp );
    }
    if ( ksGpuWindowInput_ConsumeKeyboardKey( &window.input, KEY_D ) )
    {
    DumpGLSL();
    }
    if ( window.windowActive )
    {
    ksTimeWarp_Render( &timeWarp );
    }
    }
    ksGpuContext_WaitIdle( &window.context );
    ksTimeWarp_Destroy( &timeWarp, &window );
    ksGpuWindow_Destroy( &window );
    ksDriverInstance_Destroy( &instance );
    returnexit;
    }