## GPU synchronisation fences

GPU synchronisation fences — Functions for notification of command completion

## Functions

void | (*CoglFenceCallback) ()
void * | cogl_fence_closure_get_user_data ()
CoglFenceClosure * | cogl_framebuffer_add_fence_callback ()
void | cogl_framebuffer_cancel_fence_callback ()

## Types and Values

| CoglFence
| CoglFenceClosure

## Description

Cogl allows notification of GPU command completion; users may mark points in the GPU command stream and receive notification when the GPU has executed to that point.

## Functions

### CoglFenceCallback ()

    void
    (*CoglFenceCallback) (CoglFence *fence,
                          void *user_data);

The callback prototype used with `cogl_framebuffer_add_fence_callback()` for notification of GPU command completion.

#### Parameters

fence | Unused. In the future this parameter may be used to pass extra information about the fence completion but for now it should be ignored. |
user_data | The private data passed to `cogl_framebuffer_add_fence_callback()` |

Since: 2.0

Stability Level: Unstable

### cogl_fence_closure_get_user_data ()

    void *
    cogl_fence_closure_get_user_data (CoglFenceClosure *closure);

### cogl_framebuffer_add_fence_callback ()

    CoglFenceClosure *
    cogl_framebuffer_add_fence_callback (CoglFramebuffer *framebuffer,
                                         CoglFenceCallback callback,
                                         void *user_data);

Calls the provided callback when all previously-submitted commands have been executed by the GPU.

Returns non-NULL if the fence succeeded, or `NULL` if it was unable to be inserted and the callback will never be called. The user does not need to free the closure; it will be freed automatically when the callback is called, or cancelled.

#### Parameters

framebuffer | The CoglFramebuffer the commands have been submitted to |
callback | A CoglFenceCallback to be called when all commands submitted to Cogl have been executed. | [scope notified]
user_data | Private data that will be passed to the callback. | [closure]

Since: 2.0

Stability Level: Unstable

### cogl_framebuffer_cancel_fence_callback ()

    void
    cogl_framebuffer_cancel_fence_callback
                                   (CoglFramebuffer *framebuffer,
                                    CoglFenceClosure *closure);

Removes a fence previously submitted with `cogl_framebuffer_add_fence_callback()`; the callback will not be called.

#### Parameters

framebuffer | The CoglFramebuffer the commands were submitted to |
closure | The CoglFenceClosure returned from `cogl_framebuffer_add_fence_callback()` |

Since: 2.0

Stability Level: Unstable

## Types and Values

### CoglFence

    typedef struct _CoglFence CoglFence;

An opaque object representing a fence. This type is currently unused but in the future may be used to pass extra information about the fence completion.

Since: 2.0

Stability Level: Unstable

### CoglFenceClosure

    typedef struct _CoglFenceClosure CoglFenceClosure;

An opaque type representing one future callback to be made when the GPU command stream has passed a certain point.

Since: 2.0

Stability Level: Unstable