From 32c433c7906ef18759b3b687139e284351970a36 Mon Sep 17 00:00:00 2001 From: Pavel Govyadinov Date: Fri, 22 May 2015 19:06:12 -0500 Subject: [PATCH] recovered the majority of the code lost during the merge, code is functional, compiles and runs with no error. There is still an error with the cuda aspect causing squashed impropper images. Encoding of the pixel dimensions is lost and needs to be redone --- cuda/cost.h | 6 +++--- cuda/glbind.h | 18 ++++++++++-------- gl/gl_spider.h | 2 +- image/image.h | 2 +- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/cuda/cost.h b/cuda/cost.h index faf9b98..5aaeb2f 100644 --- a/cuda/cost.h +++ b/cuda/cost.h @@ -13,7 +13,7 @@ typedef unsigned char uchar; //surface texOut; ///// maybe just do a normal array instead of a surface. //we may not need a surface at all. //texture texTemplate -texture texIn; +texture texIn; float *result; float* v_dif; cudaArray* srcArray; @@ -60,13 +60,13 @@ void get_diff (float *result) //cuPrintf("Hello"); int x = threadIdx.x + blockIdx.x * blockDim.x; int y = threadIdx.y + blockIdx.y * blockDim.y; - int idx = y*DIM_Y+x; + int idx = y*DIM_X+x; //int idx = x*DIM_X+y; //uchar4 color = tex2D(texIn, x, y); //float3 tempcolor = make_float3(color.x, color.y, color.z); //float valIn = tempcolor.x + tempcolor.y + tempcolor.z; - float valIn = x;//tex2D(texIn, x, y); + float valIn = tex2D(texIn, x, y); float valTemp = Template(x); result[idx] = valIn; // - valTemp; diff --git a/cuda/glbind.h b/cuda/glbind.h index 483c504..bd841cc 100644 --- a/cuda/glbind.h +++ b/cuda/glbind.h @@ -7,12 +7,14 @@ #include #include -#include +//#include #include "cuda_gl_interop.h" -#include "rts/gl/error.h" +#include "../gl/error.h" +namespace stim +{ -static void rtsInitGLEW() +static void InitGLEW() { //Initialize the GLEW toolkit @@ -24,7 +26,7 @@ static void rtsInitGLEW() fprintf(stdout, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION)); } -static void rts_cudaSetDevice(int major = 1, int minor = 3) +static void cudaSetDevice(int major = 1, int minor = 3) { cudaDeviceProp prop; int dev; @@ -41,7 +43,7 @@ static void rts_cudaSetDevice(int major = 1, int minor = 3) HANDLE_ERROR(cudaGLSetGLDevice(dev)); } -static void* rts_cudaMapResource(cudaGraphicsResource* cudaBufferResource) +static void* cudaMapResource(cudaGraphicsResource* cudaBufferResource) { //this function takes a predefined CUDA resource and maps it to a pointer void* buffer; @@ -50,13 +52,13 @@ static void* rts_cudaMapResource(cudaGraphicsResource* cudaBufferResource) HANDLE_ERROR(cudaGraphicsResourceGetMappedPointer( (void**)&buffer, &size, cudaBufferResource)); return buffer; } -static void rts_cudaUnmapResource(cudaGraphicsResource* resource) +static void cudaUnmapResource(cudaGraphicsResource* resource) { //this function unmaps the CUDA resource so it can be used by OpenGL HANDLE_ERROR(cudaGraphicsUnmapResources(1, &resource, NULL)); } -static void rts_cudaCreateRenderBuffer(GLuint &glBufferName, cudaGraphicsResource* &cudaBufferResource, int resX, int resY) +static void cudaCreateRenderBuffer(GLuint &glBufferName, cudaGraphicsResource* &cudaBufferResource, int resX, int resY) { //delete the previous buffer name and resource if(cudaBufferResource != 0) @@ -73,5 +75,5 @@ static void rts_cudaCreateRenderBuffer(GLuint &glBufferName, cudaGraphicsResourc CHECK_OPENGL_ERROR HANDLE_ERROR(cudaGraphicsGLRegisterBuffer(&cudaBufferResource, glBufferName, cudaGraphicsMapFlagsNone)); } - +} #endif diff --git a/gl/gl_spider.h b/gl/gl_spider.h index b9b32ed..a22aac5 100644 --- a/gl/gl_spider.h +++ b/gl/gl_spider.h @@ -31,7 +31,7 @@ class gl_spider : public virtual gl_texture //mag[0] = length. //mag[1] = width. using gl_texture::texID; - using image_stack::S; + //using image_stack::S; cudaArray* c_Array; //void** devPtr; //size_t size; diff --git a/image/image.h b/image/image.h index f40b31a..a6d5195 100644 --- a/image/image.h +++ b/image/image.h @@ -1,6 +1,6 @@ #ifndef STIM_IMAGE_H #define STIM_IMAGE_H -//#define cimg_use_jpeg //necessary for JPG files +#define cimg_use_jpeg //necessary for JPG files #include "CImg.h" #include -- libgit2 0.21.4