File: CuTexImage.h

package info (click to toggle)
colmap 3.5-1
  • links: PTS
  • area: main
  • in suites: buster
  • size: 20,564 kB
  • sloc: ansic: 170,595; cpp: 95,339; python: 2,335; makefile: 183; sh: 51
file content (76 lines) | stat: -rwxr-xr-x 2,298 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
////////////////////////////////////////////////////////////////////////////
//	File:		CuTexImage.h
//	Author:		Changchang Wu
//	Description :	interface for the CuTexImage class.
//					class for storing data in CUDA.
//
//	Copyright (c) 2007 University of North Carolina at Chapel Hill
//	All Rights Reserved
//
//	Permission to use, copy, modify and distribute this software and its
//	documentation for educational, research and non-profit purposes, without
//	fee, and without a written agreement is hereby granted, provided that the
//	above copyright notice and the following paragraph appear in all copies.
//
//	The University of North Carolina at Chapel Hill make no representations
//	about the suitability of this software for any purpose. It is provided
//	'as is' without express or implied warranty.
//
//	Please send BUG REPORTS to ccwu@cs.unc.edu
//
////////////////////////////////////////////////////////////////////////////


#ifndef CU_TEX_IMAGE_H
#define CU_TEX_IMAGE_H

class GLTexImage;
struct cudaArray;
struct textureReference;

//using texture2D from linear memory

#define SIFTGPU_ENABLE_LINEAR_TEX2D

class CuTexImage
{
protected:
	void*		_cuData;
	cudaArray*	_cuData2D;
	int			_numChannel;
	size_t			_numBytes;
	int			_imgWidth;
	int			_imgHeight;
	int			_texWidth;
	int			_texHeight;
	GLuint		_fromPBO;
public:
	virtual void SetImageSize(int width, int height);
	virtual bool InitTexture(int width, int height, int nchannel = 1);
	void InitTexture2D();
	inline void BindTexture(textureReference& texRef);
	inline void BindTexture2D(textureReference& texRef);
	void CopyToTexture2D();
	void CopyToHost(void* buf);
	void CopyToHost(void* buf, int stream);
	void CopyFromHost(const void* buf);
	int  CopyToPBO(GLuint pbo);
	void CopyFromPBO(int width, int height, GLuint pbo);
	static int DebugCopyToTexture2D();
public:
	inline int GetImgWidth(){return _imgWidth;}
	inline int GetImgHeight(){return _imgHeight;}
	inline int GetDataSize(){return _numBytes;}
public:
	CuTexImage();
	CuTexImage(int width, int height, int nchannel, GLuint pbo);
	virtual ~CuTexImage();
	friend class ProgramCU;
	friend class PyramidCU;
};

//////////////////////////////////////////////////
//transfer OpenGL Texture to PBO, then to CUDA vector
//#endif
#endif // !defined(CU_TEX_IMAGE_H)