Debian Codegraph @

src/thirdparty/SiftGPU/CLTexImage.h

raw
1 ////////////////////////////////////////////////////////////////////////////
2 // File: CLTexImage.h
3 // Author: Changchang Wu
4 // Description : interface for the CLTexImage class.
5 // class for storing data in CUDA.
6 //
7 // Copyright (c) 2007 University of North Carolina at Chapel Hill
8 // All Rights Reserved
9 //
10 // Permission to use, copy, modify and distribute this software and its
11 // documentation for educational, research and non-profit purposes, without
12 // fee, and without a written agreement is hereby granted, provided that the
13 // above copyright notice and the following paragraph appear in all copies.
14 //
15 // The University of North Carolina at Chapel Hill make no representations
16 // about the suitability of this software for any purpose. It is provided
17 // 'as is' without express or implied warranty.
18 //
19 // Please send BUG REPORTS to [email protected]
20 //
21 ////////////////////////////////////////////////////////////////////////////
22 #if defined(CL_SIFTGPU_ENABLED)
23
24 #ifndef CL_TEX_IMAGE_H
25 #define CL_TEX_IMAGE_H
26
27 class GLTexImage;
28
29 class CLTexImage
30 {
31 protected:
32 cl_context _context;
33 cl_command_queue _queue;
34 cl_mem _clData;
35 int _numChannel;
36 int _imgWidth;
37 int _imgHeight;
38 int _texWidth;
39 int _texHeight;
40 int _bufferLen;
41 int _fromGL;
42 private:
43 void ReleaseTexture();
44 public:
45 void SetImageSize(int width, int height);
46 void SetPackedSize(int width, int height, int packed);
47 void InitBufferTex(int width, int height, int nchannel);
48 void InitTexture(int width, int height, int nchannel);
49 void InitPackedTex(int width, int height, int packed);
50 void InitTextureGL(GLuint tex, int width, int height, int nchannel);
51 void CopyToHost(void* buf);
52 void CopyFromHost(const void* buf);
53 public:
54 int CopyToPBO(GLuint pbo);
55 int GetImageDataSize();
56 public:
57 inline operator cl_mem(){return _clData; }
58 inline int GetImgWidth(){return _imgWidth;}
59 inline int GetImgHeight(){return _imgHeight;}
60 inline int GetTexWidth(){return _texWidth;}
61 inline int GetTexHeight(){return _texHeight;}
62 inline int GetDataSize(){return _bufferLen;}
63 inline bool IsImage2D() {return _bufferLen == 0;}
64 inline int GetImgPixelCount(){return _imgWidth*_imgHeight;}
65 inline int GetTexPixelCount(){return _texWidth*_texHeight;}
66 public:
67 CLTexImage();
68 CLTexImage(cl_context context, cl_command_queue queue);
69 void SetContext(cl_context context, cl_command_queue queue);
70 virtual ~CLTexImage();
71 friend class ProgramCL;
72 friend class PyramidCL;
73 friend class ProgramBagCL;
74 friend class ProgramBagCLN;
75 };
76
77 //////////////////////////////////////////////////
78 //transfer OpenGL Texture to PBO, then to CUDA vector
79 //#endif
80 #endif // !defined(CU_TEX_IMAGE_H)
81 #endif
82
83