00001 00002 // File: CuTexImage.h 00003 // Author: Changchang Wu 00004 // Description : interface for the CuTexImage class. 00005 // class for storing data in CUDA. 00006 // 00007 // Copyright (c) 2007 University of North Carolina at Chapel Hill 00008 // All Rights Reserved 00009 // 00010 // Permission to use, copy, modify and distribute this software and its 00011 // documentation for educational, research and non-profit purposes, without 00012 // fee, and without a written agreement is hereby granted, provided that the 00013 // above copyright notice and the following paragraph appear in all copies. 00014 // 00015 // The University of North Carolina at Chapel Hill make no representations 00016 // about the suitability of this software for any purpose. It is provided 00017 // 'as is' without express or implied warranty. 00018 // 00019 // Please send BUG REPORTS to ccwu@cs.unc.edu 00020 // 00022 00023 00024 #ifndef CU_TEX_IMAGE_H 00025 #define CU_TEX_IMAGE_H 00026 00027 class GLTexImage; 00028 struct cudaArray; 00029 struct textureReference; 00030 00031 //using texture2D from linear memory 00032 00033 #define SIFTGPU_ENABLE_LINEAR_TEX2D 00034 00035 class CuTexImage 00036 { 00037 protected: 00038 void* _cuData; 00039 cudaArray* _cuData2D; 00040 int _numChannel; 00041 int _numBytes; 00042 int _imgWidth; 00043 int _imgHeight; 00044 int _texWidth; 00045 int _texHeight; 00046 GLuint _fromPBO; 00047 public: 00048 virtual void SetImageSize(int width, int height); 00049 virtual void InitTexture(int width, int height, int nchannel = 1); 00050 void InitTexture2D(); 00051 inline void BindTexture(textureReference& texRef); 00052 inline void BindTexture2D(textureReference& texRef); 00053 void CopyToTexture2D(); 00054 void CopyToHost(void* buf); 00055 void CopyToHost(void* buf, int stream); 00056 void CopyFromHost(const void* buf); 00057 int CopyToPBO(GLuint pbo); 00058 void CopyFromPBO(int width, int height, GLuint pbo); 00059 static int DebugCopyToTexture2D(); 00060 public: 00061 inline int GetImgWidth(){return _imgWidth;} 00062 inline int GetImgHeight(){return _imgHeight;} 00063 inline int GetDataSize(){return _numBytes;} 00064 public: 00065 CuTexImage(); 00066 CuTexImage(int width, int height, int nchannel, GLuint pbo); 00067 virtual ~CuTexImage(); 00068 friend class ProgramCU; 00069 friend class PyramidCU; 00070 }; 00071 00073 //transfer OpenGL Texture to PBO, then to CUDA vector 00074 //#endif 00075 #endif // !defined(CU_TEX_IMAGE_H) 00076