libgpcogl - API reference

Atomic counters

typedef GLuint gpcogl_actr_id_t;

gpcogl_actr_id_t gpcogl_actr_init(gpcogl_t *ctx, GLuint binding, GLuint initval);

GLuint gpcogl_actr_get(gpcogl_t *ctx, GLuint binding);

void gpcogl_actr_free(gpcogl_t *ctx, gpcogl_actr_id_t actr_id);

#define GPCOGL_ACTR(name, binding)

An atomic counter is always an unsigned 32 bit integer. It is created using te gpcogl_actr_init() call which returns the gpcogl_actr_id_t of the new counter; the C prorgam references the counter by this ID. Binding is an arbitrary but unique integer value by which the shader program will identify the counter; this number is in its own namespace for atomic counters. When the counter is created, an initial value is set then shader programs can declare it using the GPCOGL_ACTR() macro and then can increment or decrement the value, using atomicCounterIncrement() and atomicCounterDecrement().

The counter is created in GPU memory. The C program can query the current value of the counter, typically after a compute call, using gpcogl_actr_get().

The counter persists and is accessible to all shader programs in the given context until gpcogl_actr_free() is called on it.

The example line_dir_find demonstrates using atomic counters to index a (shared) buffer array.

Requirement

Requires OpenGL 4.2 or extension "ARB_shader_atomic_counters".