libCL closely integrates with OpenCL Studio via the libBind library. All of the demo applications bundled with OpenCL Studio are built upon libCL.

API Overview

util\

oclMemory

memSet(cl_mem buffer, cl_float4 value)

Initialize memory with the given value. So far this function is only implemented for clImage2D and clBuffer of type cl_float4.

math\

oclVector

normalize(cl_mem srce, cl_mem dest)

Normalize the buffer entries. So far this function is only implemented for clImage2D.

xor(cl_mem srce, cl_mem dest, cl_float4 mask)

Combine two buffers s and d given mask m such that d = s*m+(1.0-m) . So far this function is only implemented for clImage2D.

sort\

oclRadixSort

compute(cl_mem key, cl_mem value)

Sort the key value pairs using radix sort. Sorts up to 4 million elements.

filter\

oclBilateral

iso2D(cl_mem srce, cl_mem dest, cl_uint radius, cl_float range, cl_float4 mask)

Apply an isotropic bilateral filter to the input image.

aniso2Dtang(cl_mem srce, cl_mem dest, cl_uint radius, cl_float range, cl_mem vector, cl_float4 mask)

Apply an anisotropic 1D bilateral filter to the input image along the tangent direction of the given vector field.

aniso2Dorth(cl_mem srce, cl_mem dest, cl_uint radius, cl_float range, cl_mem vector, cl_float4 mask)

Apply an anisotropic 1D bilateral filter to the input image along the orthogonal direction of the given vector field.

oclBilateralGrid

split(cl_mem srce, cl_float4 mask)

Populate the bilateral grid from the input image.

slice(cl_mem srce, cl_float4 mask, cl_mem dest)

Generate an output image from the bilateral grid.

equalize(cl_float4 mask)

Apply local histogram equalization to the bilateral grid.

resize(cl_uint dimX, cl_uint dimY, cl_uint dimZ)

Specify the dimensions of the bilateral grid.

getBuffer

smoothZ(cl_mem kernel)

Apply a convolution to the bilateral grid z axis.

smoothXY(cl_mem kernel)

Apply a separable convolution to the bilateral grid x and y axis.

smoothXYZ(cl_mem kernel)

Apply a separable convolution to the bilateral grid x, y and z axis.

oclBilinearPyramid

compute(cl_mem srce)

Construct recursive low pass filtered images from the input image. Faster than constructing a gaussian pyramid by using bilinear hardware filtering.

getLevel(cl_uint level)

Returns the given level of the pyramid.

oclConvolute

iso2D(cl_mem srce, cl_mem dest, cl_mem kernel, cl_uint width, cl_uint height)

Apply an isometric 2D kernel to the input image.

iso2Dsep(cl_mem srce, cl_mem dest, cl_uint2 axis, cl_mem kernel)

Apply an isometric 1D separable kernel to the input image x and y axis.

aniso2Dtang(cl_mem srce, cl_mem dest, cl_mem vector, cl_mem kernel)

Apply an anisotropic 1D kernel to the input image along the tangent direction of the given a vector field.

aniso2Dorth(cl_mem srce, cl_mem dest, cl_mem vector, cl_mem kernel)

Apply an anisotropic 1D kernel to the input image along the orthogonal direction of the given a vector field.

gauss1D(cl_float sigma, cl_mem kernel)

Compute a 1D gaussian kernel of the given dimensions. the kernel size is determined by the input buffer.

gauss2D(cl_float sigma, cl_mem kernel, cl_uint width, cl_uint height)

Compute a 2D gaussian kernel of the given dimensions.

DoG1D(cl_float sigma0, cl_float sigma1, cl_float sensitivity, cl_mem kernel)

Compute a 1D difference of gaussian kernel of the given dimension. the kernel size is determined by the input buffer.

DoG2D(cl_float sigma0, cl_float sigma1, cl_float sensitivity, cl_mem kernel, cl_uint width, cl_uint height)

Compute a 2D difference of gaussian kernel of the given dimension.

oclRecursiveGaussian

compute(cl_mem source, cl_mem temp, cl_mem destination)

Apply recursive Gaussian smoothing to the given buffer.

setSigma(cl_float sigma)

Specify the standard deviation for the recursive Gaussian smoothing.

oclSobel

compute(cl_mem srce, cl_mem dx, cl_mem dy)

Apply a Sobel filter to compute the dx/dy gradients of the input image.

oclTangent

compute(cl_mem dx, cl_mem dy, cl_mem dest)

Compute the edge tangent flow of the given dx/dy gradients.

lineConv(cl_mem vector, cl_mem srce, cl_mem dest, cl_uint depth)

Compute the line integral convolution of the given tangent flow. This function is used to visualize an edge tangent flow.

color\

oclColor

HSVtoRGB(cl_mem srce, cl_mem dest)

RGBtoHSV(cl_mem srce, cl_mem dest)

Cconvert RGB to HSV color space.

XYZtoRGB(cl_mem srce, cl_mem dest)

Convert XYZ to RGB color space.

RGBtoXYZ(cl_mem srce, cl_mem dest)

Convert RGB to XYZ color space.

LABtoRGB(cl_mem srce, cl_mem dest)

Convert LAB to RGB color space.

RGBtoLAB(cl_mem srce, cl_mem dest)

Convert RGB to LAB color space.

oclQuantize

quantizeLAB(cl_mem srce, cl_mem dest, cl_float binL, cl_float binA, cl_float binB, cl_float sharpness)

Quantize an image in LAB color space.

image\

oclAmbientOcclusion

compute(cl_mem depth, cl_mem normal)

Apply screen space occlusion culling to the given image buffers.

oclBloom

compute(cl_mem srce, cl_mem dest)

Apply the Bloom effect to the given image buffers.

setThreshold(cl_float threshold)

Specify the luminance threshold for the Bloom effect.

setSmoothing(cl_float radius)

Specify the recursive gaussian smoothing radius.

setIntensity(cl_float intensity)

Specify the intensity exponent of the Bloom effect. see kernel clCombine for how this values is used.

phys\

oclFluid3D

getParticleCount()

Returns the number of particles in the fluid. Resizes all buffers including the ones specfied using setXXXBuffer functions.

setParticleCount(number particleCount)

Specify the number of particles in the fluid.

getParticleRadius()

Returns the particle radius. This number is determined by the mass and density specified in kernel clInitFluid.

getParamBuffer()

Returns a buffer containing the fluid parameter struct. see the OpenCL Source code for the parameter struct definition.

getForceBuffer()

Returns a buffer of cl_float4 containing the force of each particle. You can specify your own buffer using setForceBuffer.

getVelocityBuffer()

Returns a buffer of cl_float4 containing the velocity of each particle. You can specify your own buffer using setVelocityBuffer.

getPositionBuffer()

Returns a buffer of cl_float4 containing the position of each particle. You can specify your own buffer using setPositionBuffer.

getIndexBuffer()

Returns a buffer of cl_uint containing the mapping from sorted to unsorted velocities and positions. You can specify your own buffer using setIndexBuffer.

getSortedPositionBuffer()

Returns a buffer of cl_float4 containing the sorted position of each particle. You can specify your own buffer using setSortedPositionBuffer.

getSortedVelocityBuffer()

Returns a buffer of cl_float4 containing the sorted velocity of each particle. You can specify your own buffer using setSortedVelocityBuffer.

setForceBuffer(cl_mem forces)

Specify a buffer for storing the force acting on each particle.

setVelocityBuffer(cl_mem velocities)

Specify a buffer for storing the velocity of each particle.

setPositionBuffer(cl_mem positions)

Specify a buffer for storing the position of each particle.

setIndexBuffer(clBuffer(cl_uint) index)

Specify a buffer for storing the mapping from unsorted to sorted position and velocity.

setSortedPositionBuffer(cl_mem velocities)

Specify a buffer for storing the sorted velocity of each particle.

setSortedVelocityBuffer(cl_mem positions)

Specify a buffer for storing the sorted position of each particle.

compute()

compute one time step of the fluid simulation. You can specify various initial parameters via the clInitFluid kernel.

geom\

oclBvhTrimesh

getNodeBuffer()

Return the buffer of type BVHNode containing the bounding volume hierarchy. See the OpenCL code for the structure definition of a BVHNode node.

getRootNode()

Return the index to the root node of the BVH.

getNodeCount()

Return the number of nodes in the BVH.

compute()

Compute the bounding volume hierarchy. This calls returns the index to the root node, the size of the BVH and a buffer containing the BVH.

setNodeBuffer(cl_mem nodes)

Specify the buffer for storing the BVH. The buffer will be adjusted to fit the BVH when the compute function is called.