Swappy common tools

Tools to be used with Swappy for OpenGL or Swappy for Vulkan.

Summary

Typedefs

SwappyPostSwapBuffersCallback)(void *, int64_t desiredPresentationTimeMillis) typedef
void(*
Pointer to a function that can be attached to SwappyTracer::postSwapBuffers.
SwappyPostWaitCallback)(void *, int64_t cpu_time_ns, int64_t gpu_time_ns) typedef
void(*
Pointer to a function that can be attached to SwappyTracer::postWait.
SwappyPreSwapBuffersCallback)(void *) typedef
void(*
Pointer to a function that can be attached to SwappyTracer::preSwapBuffers.
SwappyPreWaitCallback)(void *) typedef
void(*
Pointer to a function that can be attached to SwappyTracer::preWait.
SwappyStartFrameCallback)(void *, int currentFrame, int64_t desiredPresentationTimeMillis) typedef
void(*
Pointer to a function that can be attached to SwappyTracer::startFrame.
SwappyStats typedef
struct SwappyStats
Swappy frame statistics, collected if toggled on with SwappyGL_enableStats or SwappyVk_enableStats.
SwappySwapIntervalChangedCallback)(void *) typedef
void(*
Pointer to a function that can be attached to SwappyTracer::swapIntervalChanged.
SwappyThreadFunctions typedef
A structure enabling you to set how Swappy starts and joins threads by calling Swappy_setThreadFunctions.
SwappyThreadId typedef
uint64_t
Id of a thread returned by an external thread manager.
SwappyTracer typedef
struct SwappyTracer
Collection of callbacks to be called each frame to trace execution.

Functions

Swappy_setThreadFunctions(const SwappyThreadFunctions *thread_functions)
void
Call this before any other functions in order to use a custom thread manager.
Swappy_version()
uint32_t
Return the version of the Swappy library at runtime.
Swappy_versionString()
const char *
Return the full version of the Swappy library at runtime, e.g.

Macros

MAX_FRAME_BUCKETS 6
The longest duration, in refresh periods, represented by the statistics.
SWAPPY_SWAP_20FPS (50000000L)
Swap interval for 20fps, in nanoseconds.
SWAPPY_SWAP_30FPS (33333333L)
Swap interval for 30fps, in nanoseconds.
SWAPPY_SWAP_60FPS (16666667L)
Swap interval for 60fps, in nanoseconds.

Structs

SwappyStats

Swappy frame statistics, collected if toggled on with SwappyGL_enableStats or SwappyVk_enableStats.

SwappyThreadFunctions

A structure enabling you to set how Swappy starts and joins threads by calling Swappy_setThreadFunctions.

SwappyTracer

Collection of callbacks to be called each frame to trace execution.

Typedefs

SwappyPostSwapBuffersCallback

void(* SwappyPostSwapBuffersCallback)(void *, int64_t desiredPresentationTimeMillis)

Pointer to a function that can be attached to SwappyTracer::postSwapBuffers.

Details
Parameters
userData
Pointer to arbitrary data, see SwappyTracer::userData.
desiredPresentationTimeMillis
The target time, in milliseconds, at which the frame would be presented on screen.

SwappyPostWaitCallback

void(* SwappyPostWaitCallback)(void *, int64_t cpu_time_ns, int64_t gpu_time_ns)

Pointer to a function that can be attached to SwappyTracer::postWait.

Details
Parameters
userData
Pointer to arbitrary data, see SwappyTracer::userData.
cpu_time_ns
Time for CPU processing of this frame in nanoseconds.
gpu_time_ns
Time for GPU processing of previous frame in nanoseconds.

SwappyPreSwapBuffersCallback

void(* SwappyPreSwapBuffersCallback)(void *)

Pointer to a function that can be attached to SwappyTracer::preSwapBuffers.

Details
Parameters
userData
Pointer to arbitrary data, see SwappyTracer::userData.

SwappyPreWaitCallback

void(* SwappyPreWaitCallback)(void *)

Pointer to a function that can be attached to SwappyTracer::preWait.

Details
Parameters
userData
Pointer to arbitrary data, see SwappyTracer::userData.

SwappyStartFrameCallback

void(* SwappyStartFrameCallback)(void *, int currentFrame, int64_t desiredPresentationTimeMillis)

Pointer to a function that can be attached to SwappyTracer::startFrame.

Details
Parameters
userData
Pointer to arbitrary data, see SwappyTracer::userData.
desiredPresentationTimeMillis
The time, in milliseconds, at which the frame is scheduled to be presented.

SwappyStats

struct SwappyStats SwappyStats

Swappy frame statistics, collected if toggled on with SwappyGL_enableStats or SwappyVk_enableStats.

SwappySwapIntervalChangedCallback

void(* SwappySwapIntervalChangedCallback)(void *)

Pointer to a function that can be attached to SwappyTracer::swapIntervalChanged.

Call SwappyGL_getSwapIntervalNS or SwappyVk_getSwapIntervalNS to get the latest swapInterval.

Details
Parameters
userData
Pointer to arbitrary data, see SwappyTracer::userData.

SwappyThreadFunctions

struct SwappyThreadFunctions SwappyThreadFunctions

A structure enabling you to set how Swappy starts and joins threads by calling Swappy_setThreadFunctions.

Usage of this functionality is optional.

SwappyThreadId

uint64_t SwappyThreadId

Id of a thread returned by an external thread manager.

SwappyTracer

struct SwappyTracer SwappyTracer

Collection of callbacks to be called each frame to trace execution.

Injection of these is optional.

Functions

Swappy_setThreadFunctions

void Swappy_setThreadFunctions(
  const SwappyThreadFunctions *thread_functions
)

Call this before any other functions in order to use a custom thread manager.

Usage of this function is entirely optional. Swappy uses std::thread by default.

Swappy_version

uint32_t Swappy_version()

Return the version of the Swappy library at runtime.

Swappy_versionString

const char * Swappy_versionString()

Return the full version of the Swappy library at runtime, e.g.

"1.9.0_8a85ab7c46"

Macros

MAX_FRAME_BUCKETS

 MAX_FRAME_BUCKETS 6

The longest duration, in refresh periods, represented by the statistics.

See also: SwappyStats

SWAPPY_SWAP_20FPS

 SWAPPY_SWAP_20FPS (50000000L)

Swap interval for 20fps, in nanoseconds.

SWAPPY_SWAP_30FPS

 SWAPPY_SWAP_30FPS (33333333L)

Swap interval for 30fps, in nanoseconds.

SWAPPY_SWAP_60FPS

 SWAPPY_SWAP_60FPS (16666667L)

Swap interval for 60fps, in nanoseconds.