Compute Shader#

class Context, glsl_source: str)[source]#

Bases: object

A higher level wrapper for an OpenGL compute shader.

property glo: int#

The name/id of the OpenGL resource


Use/activate the compute shader.


This is not necessary to call in normal use cases since run() already does this for you.

run(group_x=1, group_y=1, group_z=1) None[source]#

Run the compute shader.

When running a compute shader we specify how many work groups should be executed on the x, y and z dimension. The size of the work group is defined in the compute shader.

// Work group with one dimension. 16 work groups executed.
layout(local_size_x=16) in;
// Work group with two dimensions. 256 work groups executed.
layout(local_size_x=16, local_size_y=16) in;
// Work group with three dimensions. 4096 work groups executed.
layout(local_size_x=16, local_size_y=16, local_size_z=16) in;

Group sizes are 1 by default. If your compute shader doesn’t specify a size for a dimension or uses 1 as size you don’t have to supply this parameter.

  • group_x (int) – The number of work groups to be launched in the X dimension.

  • group_y (int) – The number of work groups to be launched in the y dimension.

  • group_z (int) – The number of work groups to be launched in the z dimension.


Destroy the internal compute shader object. This is normally not necessary, but depends on the garbage collection more configured in the context.

static delete_glo(ctx, prog_id)[source]#

Low level method for destroying a compute shader by id