ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
CuTexImage.h
Go to the documentation of this file.
1 // 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 //
22 
23 
24 #ifndef CU_TEX_IMAGE_H
25 #define CU_TEX_IMAGE_H
26 
27 #include <cuda_runtime.h>
28 
29 class GLTexImage;
30 
32 {
33 protected:
34  void* _cuData;
35  cudaArray* _cuData2D;
37  size_t _numBytes;
38  int _imgWidth;
40  int _texWidth;
42  GLuint _fromPBO;
43 public:
44  struct CuTexObj
45  {
46  cudaTextureObject_t handle;
48  };
49 
50  virtual void SetImageSize(int width, int height);
51  virtual bool InitTexture(int width, int height, int nchannel = 1);
52  void InitTexture2D();
53  CuTexObj BindTexture(const cudaTextureDesc& textureDesc,
54  const cudaChannelFormatDesc& channelFmtDesc);
55  CuTexObj BindTexture2D(const cudaTextureDesc& textureDesc,
56  const cudaChannelFormatDesc& channelFmtDesc);
57  void CopyToHost(void* buf);
58  void CopyToHost(void* buf, int stream);
59  void CopyFromHost(const void* buf);
61  int CopyToPBO(GLuint pbo);
62  void CopyFromPBO(int width, int height, GLuint pbo);
63 public:
64  inline int GetImgWidth(){return _imgWidth;}
65  inline int GetImgHeight(){return _imgHeight;}
66  inline int GetDataSize(){return _numBytes;}
67 public:
69  CuTexImage(int width, int height, int nchannel, GLuint pbo);
70  virtual ~CuTexImage();
71  friend class ProgramCU;
72  friend class PyramidCU;
73 };
74 
76 //transfer OpenGL Texture to PBO, then to CUDA vector
77 //#endif
78 #endif // !defined(CU_TEX_IMAGE_H)
int width
int height
void CopyFromPBO(int width, int height, GLuint pbo)
void CopyFromHost(const void *buf)
size_t _numBytes
Definition: CuTexImage.h:37
friend class ProgramCU
Definition: CuTexImage.h:71
int _texWidth
Definition: CuTexImage.h:40
CuTexImage(int width, int height, int nchannel, GLuint pbo)
int _imgHeight
Definition: CuTexImage.h:39
GLuint _fromPBO
Definition: CuTexImage.h:42
void CopyToTexture2D()
virtual ~CuTexImage()
void CopyToHost(void *buf)
cudaArray * _cuData2D
Definition: CuTexImage.h:35
int GetDataSize()
Definition: CuTexImage.h:66
int _numChannel
Definition: CuTexImage.h:36
int GetImgWidth()
Definition: CuTexImage.h:64
int _imgWidth
Definition: CuTexImage.h:38
int _texHeight
Definition: CuTexImage.h:41
void InitTexture2D()
friend class PyramidCU
Definition: CuTexImage.h:72
virtual void SetImageSize(int width, int height)
void CopyToHost(void *buf, int stream)
void * _cuData
Definition: CuTexImage.h:34
virtual bool InitTexture(int width, int height, int nchannel=1)
int GetImgHeight()
Definition: CuTexImage.h:65
CuTexObj BindTexture2D(const cudaTextureDesc &textureDesc, const cudaChannelFormatDesc &channelFmtDesc)
int CopyToPBO(GLuint pbo)
CuTexObj BindTexture(const cudaTextureDesc &textureDesc, const cudaChannelFormatDesc &channelFmtDesc)
cudaTextureObject_t handle
Definition: CuTexImage.h:46