Commit bf04edf7 authored by Ravi's avatar Ravi

added thresholding to kernel and changed directories in hello-opengl.pro to that…

added thresholding to kernel and changed directories in hello-opengl.pro to that of lab - /usr and nvidia-331
parent 5ebedc0a
......@@ -14,14 +14,14 @@ CUDA_SOURCES += kernel.cu
LIBS += -lGLEW -lcudart -lcuda -lopencv_core -lopencv_highgui -lopencv_imgproc
QMAKE_LFLAGS += -Wl,-rpath,/usr/lib/nvidia-319-updates -Wl,-rpath,/usr/lib/nvidia-319-updates/tls
QMAKE_LFLAGS += -Wl,-rpath,/usr/lib/nvidia-331-updates -Wl,-rpath,/usr/lib/nvidia-331-updates/tls
# Path to cuda toolkit install
CUDA_DIR = /usr/local/cuda-5.5
CUDA_DIR = /usr
# Path to header and libs files
INCLUDEPATH += $$CUDA_DIR/include
QMAKE_LIBDIR += $$CUDA_DIR/lib64
QMAKE_LIBDIR += /usr/lib/nvidia-319-updates /usr/lib/nvidia-319-updates/tls
QMAKE_LIBDIR += /usr/lib/nvidia-331-updates /usr/lib/nvidia-331-updates/tls
# GPU architecture
CUDA_ARCH = sm_10
NVCCFLAGS = --compiler-options -use_fast_math --ptxas-options=-v
......
......@@ -85,14 +85,15 @@ __global__ void update_Output(uchar4* output, float *U, int w, int h) {
int x = threadIdx.x + blockDim.x * blockIdx.x;
int y = threadIdx.y + blockDim.y * blockIdx.y;
size_t i = x + (size_t)w*y;
size_t idx = x + (size_t) w*(h-1 - y);
unsigned char temp_res = roundf((U[i] * 255.f));
output[idx].x = temp_res;
output[idx].y = temp_res;
output[idx].z = temp_res;
output[idx].w = 255;
if( x < w && y < h ) {
size_t i = x + (size_t)w*y;
size_t idx = x + (size_t) w*(h-1 - y);
unsigned char temp_res = int(U[i] + 0.5f) * 255;
output[idx].x = temp_res;
output[idx].y = temp_res;
output[idx].z = temp_res;
output[idx].w = 255;
}
}
inline int div_ceil(int n, int b) { return (n + b - 1) / b; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment