COVISE Core
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
GPUResourceManager.h
Go to the documentation of this file.
1 /* This file is part of COVISE.
2 
3  You can use it under the terms of the GNU Lesser General Public License
4  version 2.1 or later, see lgpl-2.1.txt.
5 
6  * License: LGPL 2+ */
7 
8 #ifndef GPU_RESOURCE_MANAGER_H
9 #define GPU_RESOURCE_MANAGER_H
10 
11 #include <string.h>
12 #include <util/coTypes.h>
13 
14 #include <string>
15 #include <map>
16 
17 struct ltstr
18 {
19  bool operator()(const char *s1, const char *s2) const
20  {
21  return strcmp(s1, s2) < 0;
22  }
23 };
24 
26 {
27 public:
28  GPUObject(const char *name);
29  virtual ~GPUObject();
30  const char *getName();
31 
32 private:
34 };
35 
36 class GPUEXPORT GPUUsg : public GPUObject
37 {
38 public:
39  GPUUsg(const char *name, int numElem, int numConn,
40  int numCoord, int *elemList, int *typeList,
41  int *connList, float *vertices, int numElemM, int numConnM, int numCoordM);
42 
43  virtual ~GPUUsg()
44  {
45  }
46 
47  int getNumElem();
48  int getNumConn();
49  int getNumCoord();
50 
51  int *getTypeList();
52  int *getElemList();
53  int *getConnList();
54 
55  float *getVertices();
56 
57 private:
58  int numElem;
59  int numConn;
60  int numCoord;
61 
62  int *typeList;
63  int *elemList;
64  int *connList;
65  float *vertices;
66 
67  int numElemM;
68  int numConnM;
69  int numCoordM;
70 };
71 
73 {
74 public:
75  GPUScalar(const char *name, const int numElem, float *data,
76  const int numElemM);
77  virtual ~GPUScalar()
78  {
79  }
80 
81  float *getData();
82  int getNumElem();
83 
84 private:
85  int numElem;
86  float *data;
87  int numElemM;
88 };
89 
91 {
92 public:
93  GPUVector(const char *name, const int numElem, float *data,
94  const int numElemM);
95  virtual ~GPUVector()
96  {
97  }
98 
99  float *getData();
100  int getNumElem();
101 
102 private:
103  int numElem;
104  float *data;
105  int numElemM;
106 };
107 
109 {
110 public:
111  GPUUsg *addUSG(const char *name,
112  const int numElem, const int numConn, const int numCoord,
113  const int *typeList, const int *elemList, const int *connList,
114  const float *x, const float *y, const float *z,
115  const int numElemM = 0, const int numConnM = 0, const int numCoordM = 0);
116 
117  GPUScalar *addScalar(const char *name, const int numElem, const float *data, const int numElemM);
118  GPUVector *addVector(const char *name, const int numElem, const float *u, const float *v, const float *w, const int numElemM);
119  void deleteObject(const char *name);
120 
121 protected:
124  virtual ~GPUResourceManager() = 0;
125 
126 private:
127  /*
128  virtual GPUUsg *replaceUSG(GPUUsg *usg,
129  const int numElem, const int numConn,
130  const int numCoord, const int *typeList,
131  const int *elemList, const int *connList,
132  const float *x, const float *y, const float *z) = 0;
133 */
134  virtual GPUUsg *allocUSG(const char *name,
135  const int numElem, const int numConn,
136  const int numCoord, const int *typeList,
137  const int *elemList, const int *connList,
138  const float *x, const float *y, const float *z,
139  const int numElemM = 0, const int numConnM = 0,
140  const int numCoordM = 0) = 0;
141 
142  virtual GPUScalar *allocScalar(const char *name, const int numElem,
143  const float *data, const int numElemM = 0) = 0;
144  virtual GPUVector *allocVector(const char *name, const int numElem,
145  const float *u, const float *v, const float *w, const int numElemM = 0) = 0;
146 
147  virtual void deallocUSG(GPUUsg *usg) = 0;
148  virtual void deallocScalar(GPUScalar *scalar) = 0;
149  virtual void deallocVector(GPUVector *vector) = 0;
150 
151  std::map<std::string, GPUObject *> objects;
152  std::map<std::string, int> refCount;
153 
154  std::map<void *, void *> pointers;
155 };
156 
157 #endif
float * data
Definition: GPUResourceManager.h:86
int numCoordM
Definition: GPUResourceManager.h:69
GLuint const GLchar * name
Definition: khronos-glext.h:6722
Definition: GPUResourceManager.h:90
static const int s2
Definition: SammConv.cpp:38
int numCoord
Definition: GPUResourceManager.h:60
GLint GLint GLint GLint GLint GLint y
Definition: khronos-glext.h:6346
virtual ~GPUVector()
Definition: GPUResourceManager.h:95
int numConn
Definition: GPUResourceManager.h:59
float * vertices
Definition: GPUResourceManager.h:65
std::string name
Definition: GPUResourceManager.h:33
int * connList
Definition: GPUResourceManager.h:64
GLsizei const GLchar *const * string
Definition: khronos-glext.h:6750
std::map< std::string, int > refCount
Definition: GPUResourceManager.h:152
GLdouble GLdouble z
Definition: khronos-glext.h:6565
int numElemM
Definition: GPUResourceManager.h:105
int numElemM
Definition: GPUResourceManager.h:87
#define GPUEXPORT
Definition: coExport.h:93
float * data
Definition: GPUResourceManager.h:104
Definition: GPUResourceManager.h:36
GLint GLint GLint GLint GLint x
Definition: khronos-glext.h:6346
Definition: GPUResourceManager.h:108
int numElem
Definition: GPUResourceManager.h:85
const GLdouble * v
Definition: khronos-glext.h:6442
bool operator()(const char *s1, const char *s2) const
Definition: GPUResourceManager.h:19
int numConnM
Definition: GPUResourceManager.h:68
int numElem
Definition: GPUResourceManager.h:58
virtual ~GPUUsg()
Definition: GPUResourceManager.h:43
GLubyte GLubyte GLubyte GLubyte w
Definition: khronos-glext.h:6793
Definition: GPUResourceManager.h:17
std::map< void *, void * > pointers
Definition: GPUResourceManager.h:154
Definition: GPUResourceManager.h:72
Definition: GPUResourceManager.h:25
int numElem
Definition: GPUResourceManager.h:103
int numElemM
Definition: GPUResourceManager.h:67
int * typeList
Definition: GPUResourceManager.h:62
std::map< std::string, GPUObject * > objects
Definition: GPUResourceManager.h:151
virtual ~GPUScalar()
Definition: GPUResourceManager.h:77
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s1
Definition: khronos-glext.h:13144
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: khronos-glext.h:6354
int * elemList
Definition: GPUResourceManager.h:63