Watch sessions from the Google for Games Developer Summit.

Swappy common tools

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

Summary

Typedefs

SwappyPostSwapBuffersCallback)(void *, long desiredPresentationTimeMillis) typedef
void(*
Pointer to a function that can be attached to SwappyTracer::postSwapBuffers.
SwappyPostWaitCallback)(void *, long cpu_time_ns, long 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, long desiredPresentationTimeMillis) typedef
void(*
Pointer to a function that can be attached to SwappyTracer::startFrame.
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.

Macros

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

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 *, long 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 *, long cpu_time_ns, long 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, long 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.

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.

Macros

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.