Skip to content

Instantly share code, notes, and snippets.

@aamedina
Created July 18, 2013 00:51
Show Gist options
  • Select an option

  • Save aamedina/6025882 to your computer and use it in GitHub Desktop.

Select an option

Save aamedina/6025882 to your computer and use it in GitHub Desktop.
opencl stupid toy kernel
const sampler_t sampler =
CLK_NORMALIZED_COORDS_FALSE | CLK_FILTER_NEAREST | CLK_ADDRESS_CLAMP_TO_EDGE;
float add_color(float color) {
return color + 0.75;
}
__kernel void identity(read_only image2d_t inputImage,
write_only image2d_t outputImage) {
int2 dimensions = get_image_dim(inputImage);
int width = dimensions.x, height = dimensions.y;
int x = get_global_id(0), y = get_global_id(1);
float4 pixel = read_imagef(inputImage, sampler, (int2)(x, y));
float red = pixel.x, green = pixel.y, blue = pixel.z, alpha = pixel.w;
float4 transformedPixel = (float4)(add_color(red), green, blue, alpha);
write_imagef(outputImage, (int2)(x, y), transformedPixel);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment