Created
July 18, 2013 00:51
-
-
Save aamedina/6025882 to your computer and use it in GitHub Desktop.
opencl stupid toy kernel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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