COVISE Core
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
17struct ltstr
18{
19 bool operator()(const char *s1, const char *s2) const
20 {
21 return strcmp(s1, s2) < 0;
22 }
23};
24
26{
27public:
28 GPUObject(const char *name);
29 virtual ~GPUObject();
30 const char *getName();
31
32private:
34};
35
37{
38public:
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
57private:
61
65 float *vertices;
66
70};
71
73{
74public:
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
84private:
86 float *data;
88};
89
91{
92public:
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
102private:
104 float *data;
106};
107
109{
110public:
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
121protected:
124 virtual ~GPUResourceManager() = 0;
125
126private:
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
#define GPUEXPORT
Definition: coExport.h:111
GLsizei const GLchar *const * string
Definition: khronos-glext.h:6750
GLdouble GLdouble z
Definition: khronos-glext.h:6565
const GLdouble * v
Definition: khronos-glext.h:6442
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s1
Definition: khronos-glext.h:13144
GLint GLint GLint GLint GLint GLint y
Definition: khronos-glext.h:6346
GLuint const GLchar * name
Definition: khronos-glext.h:6722
GLubyte GLubyte GLubyte GLubyte w
Definition: khronos-glext.h:6793
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: khronos-glext.h:6354
GLint GLint GLint GLint GLint x
Definition: khronos-glext.h:6346
static const int s2
Definition: SammConv.cpp:38
Definition: GPUResourceManager.h:18
bool operator()(const char *s1, const char *s2) const
Definition: GPUResourceManager.h:19
Definition: GPUResourceManager.h:26
std::string name
Definition: GPUResourceManager.h:33
Definition: GPUResourceManager.h:37
virtual ~GPUUsg()
Definition: GPUResourceManager.h:43
int numCoord
Definition: GPUResourceManager.h:60
int numElemM
Definition: GPUResourceManager.h:67
int numCoordM
Definition: GPUResourceManager.h:69
float * vertices
Definition: GPUResourceManager.h:65
int * typeList
Definition: GPUResourceManager.h:62
int numConnM
Definition: GPUResourceManager.h:68
int * elemList
Definition: GPUResourceManager.h:63
int * connList
Definition: GPUResourceManager.h:64
int numConn
Definition: GPUResourceManager.h:59
int numElem
Definition: GPUResourceManager.h:58
Definition: GPUResourceManager.h:73
virtual ~GPUScalar()
Definition: GPUResourceManager.h:77
int numElem
Definition: GPUResourceManager.h:85
float * data
Definition: GPUResourceManager.h:86
int numElemM
Definition: GPUResourceManager.h:87
Definition: GPUResourceManager.h:91
int numElem
Definition: GPUResourceManager.h:103
virtual ~GPUVector()
Definition: GPUResourceManager.h:95
float * data
Definition: GPUResourceManager.h:104
int numElemM
Definition: GPUResourceManager.h:105
Definition: GPUResourceManager.h:109
virtual void deallocVector(GPUVector *vector)=0
std::map< std::string, int > refCount
Definition: GPUResourceManager.h:152
virtual GPUVector * allocVector(const char *name, const int numElem, const float *u, const float *v, const float *w, const int numElemM=0)=0
std::map< void *, void * > pointers
Definition: GPUResourceManager.h:154
std::map< std::string, GPUObject * > objects
Definition: GPUResourceManager.h:151
GPUResourceManager(const GPUResourceManager &)