Created
September 17, 2013 08:28
-
-
Save nesteruk/6591575 to your computer and use it in GitHub Desktop.
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
#include "cuda_runtime.h" | |
#include "device_launch_parameters.h" | |
#include <cmath> | |
using namespace std; | |
__device__ __inline__ float trim(unsigned char value) | |
{ | |
return fminf((unsigned char)255, fmaxf(value, (unsigned char)0)); | |
} | |
__global__ void kernel(unsigned char* img, const float* a) | |
{ | |
int ix = blockIdx.x; | |
int iy = threadIdx.x; | |
int tid = iy*blockDim.x + ix; | |
float x = (float)ix / blockDim.x; | |
float y = (float)iy / gridDim.x; | |
//placeholder | |
img[tid*4+0] = trim((a[0]*z*z+a[1]*z+a[2]) * 255.0f); | |
img[tid*4+1] = trim((a[3]*z*z+a[4]*z+a[5]) * 255.0f); | |
img[tid*4+2] = trim((a[6]*z*z+a[7]*z+a[8]) * 255.0f); | |
img[tid*4+3] = 255; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment