Swappy for OpenGL extras
Extra utility functions to use Swappy with OpenGL.
Summary
Functions |
|
---|---|
SwappyGL_clearStats()
|
void
Clears the frame statistics collected so far.
|
SwappyGL_enableStats(bool enabled)
|
void
Toggle statistics collection on/off.
|
SwappyGL_getStats(SwappyStats *swappyStats)
|
void
Returns the stats collected, if statistics collection was toggled on.
|
SwappyGL_injectTracer(const SwappyTracer *t)
|
void
Pass callbacks to be called each frame to trace execution.
|
SwappyGL_onChoreographer(int64_t frameTimeNanos)
|
void
If an app wishes to use the Android choreographer to provide ticks to Swappy, it can call this function.
|
SwappyGL_recordFrameStart(EGLDisplay display, EGLSurface surface)
|
void
Should be called if stats have been enabled with SwappyGL_enableStats.
|
SwappyGL_setAutoPipelineMode(bool enabled)
|
void
Toggle auto-pipeline mode on/off.
|
SwappyGL_setAutoSwapInterval(bool enabled)
|
void
Toggle auto-swap interval detection on/off.
|
SwappyGL_setMaxAutoSwapIntervalNS(uint64_t max_swap_ns)
|
void
Sets the maximal duration for auto-swap interval in milliseconds.
|
SwappyGL_uninjectTracer(const SwappyTracer *t)
|
void
Remove callbacks that were previously added using SwappyGL_injectTracer.
|
Functions
SwappyGL_clearStats
void SwappyGL_clearStats()
Clears the frame statistics collected so far.
All the frame statistics collected are reset to 0, frame statistics are collected normally after this call.
SwappyGL_enableStats
void SwappyGL_enableStats( bool enabled )
Toggle statistics collection on/off.
By default, stats collection is off and there is no overhead related to stats. An app can turn on stats collection by calling SwappyGL_enableStats(true)
. Then, the app is expected to call SwappyGL_recordFrameStart for each frame before starting to do any CPU related work. Stats will be logged to logcat with a 'FrameStatistics' tag. An app can get the stats by calling SwappyGL_getStats.
SwappyGL_getStats
void SwappyGL_getStats( SwappyStats *swappyStats )
Returns the stats collected, if statistics collection was toggled on.
See also: SwappyStats See also: SwappyGL_enableStats
Details | |||
---|---|---|---|
Parameters |
|
SwappyGL_injectTracer
void SwappyGL_injectTracer( const SwappyTracer *t )
Pass callbacks to be called each frame to trace execution.
SwappyGL_onChoreographer
void SwappyGL_onChoreographer( int64_t frameTimeNanos )
If an app wishes to use the Android choreographer to provide ticks to Swappy, it can call this function.
This function must be called before the first Swappy_swap()
call. Afterwards, call this function every choreographer tick.
SwappyGL_recordFrameStart
void SwappyGL_recordFrameStart( EGLDisplay display, EGLSurface surface )
Should be called if stats have been enabled with SwappyGL_enableStats.
When stats collection is enabled with SwappyGL_enableStats, the app is expected to call this function for each frame before starting to do any CPU related work.
See also:SwappyGL_enableStats.
SwappyGL_setAutoPipelineMode
void SwappyGL_setAutoPipelineMode( bool enabled )
Toggle auto-pipeline mode on/off.
By default, if auto-swap interval is on, auto-pipelining is on and Swappy will try to reduce latency by scheduling cpu and gpu work in the same pipeline stage, if it fits.
SwappyGL_setAutoSwapInterval
void SwappyGL_setAutoSwapInterval( bool enabled )
Toggle auto-swap interval detection on/off.
By default, Swappy will adjust the swap interval based on actual frame rendering time. If an app wants to override the swap interval calculated by Swappy, it can call SwappyGL_setSwapIntervalNS
. This will temporarily override Swappy's frame timings but, unless SwappyGL_setAutoSwapInterval(false)
is called, the timings will continue to be be updated dynamically, so the swap interval may change.
SwappyGL_setMaxAutoSwapIntervalNS
void SwappyGL_setMaxAutoSwapIntervalNS( uint64_t max_swap_ns )
Sets the maximal duration for auto-swap interval in milliseconds.
If Swappy is operating in auto-swap interval and the frame duration is longer than max_swap_ns
, Swappy will not do any pacing and just submit the frame as soon as possible.
SwappyGL_uninjectTracer
void SwappyGL_uninjectTracer( const SwappyTracer *t )
Remove callbacks that were previously added using SwappyGL_injectTracer.