Statistics
| Branch: | Revision:

root / rgbdslam / external / siftgpu / src / SiftGPU / CuTexImage.h @ 9240aaa3

History | View | Annotate | Download (2.25 KB)

1
////////////////////////////////////////////////////////////////////////////
2
//        File:                CuTexImage.h
3
//        Author:                Changchang Wu
4
//        Description :        interface for the CuTexImage 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 ccwu@cs.unc.edu
20
//
21
////////////////////////////////////////////////////////////////////////////
22

    
23

    
24
#ifndef CU_TEX_IMAGE_H
25
#define CU_TEX_IMAGE_H
26

    
27
class GLTexImage;
28
struct cudaArray;
29
struct textureReference;
30

    
31
//using texture2D from linear memory
32

    
33
#define SIFTGPU_ENABLE_LINEAR_TEX2D
34

    
35
class CuTexImage
36
{        
37
protected:
38
        void*                _cuData;
39
        cudaArray*        _cuData2D;
40
        int                        _numChannel;
41
        int                        _numBytes;
42
        int                        _imgWidth;
43
        int                        _imgHeight;
44
        int                        _texWidth;
45
        int                        _texHeight;
46
        GLuint                _fromPBO;
47
public:
48
        virtual void SetImageSize(int width, int height);
49
        virtual void InitTexture(int width, int height, int nchannel = 1);
50
        void InitTexture2D();
51
        inline void BindTexture(textureReference& texRef);
52
        inline void BindTexture2D(textureReference& texRef);
53
        void CopyToTexture2D();
54
        void CopyToHost(void* buf);
55
        void CopyToHost(void* buf, int stream);
56
        void CopyFromHost(const void* buf);
57
        int  CopyToPBO(GLuint pbo);
58
        void CopyFromPBO(int width, int height, GLuint pbo);
59
        static int DebugCopyToTexture2D();
60
public:
61
        inline int GetImgWidth(){return _imgWidth;}
62
        inline int GetImgHeight(){return _imgHeight;}
63
        inline int GetDataSize(){return _numBytes;}
64
public:
65
        CuTexImage();
66
        CuTexImage(int width, int height, int nchannel, GLuint pbo);
67
        virtual ~CuTexImage();
68
        friend class ProgramCU;
69
        friend class PyramidCU;
70
};
71

    
72
//////////////////////////////////////////////////
73
//transfer OpenGL Texture to PBO, then to CUDA vector
74
//#endif 
75
#endif // !defined(CU_TEX_IMAGE_H)
76