1 | /* $Id: server_getshaders.c 20511 2009-06-12 13:00:53Z vboxsync $ */
|
---|
2 |
|
---|
3 | /** @file
|
---|
4 | * VBox OpenGL DRI driver functions
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2009 Sun Microsystems, Inc.
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | * available from http://www.virtualbox.org. This file is free software;
|
---|
12 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | * General Public License (GPL) as published by the Free Software
|
---|
14 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | *
|
---|
18 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
19 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
20 | * additional information or have any questions.
|
---|
21 | */
|
---|
22 |
|
---|
23 | #include "cr_spu.h"
|
---|
24 | #include "chromium.h"
|
---|
25 | #include "cr_error.h"
|
---|
26 | #include "cr_mem.h"
|
---|
27 | #include "cr_net.h"
|
---|
28 | #include "server_dispatch.h"
|
---|
29 | #include "server.h"
|
---|
30 |
|
---|
31 | #ifdef CR_OPENGL_VERSION_2_0
|
---|
32 |
|
---|
33 | typedef struct _crGetActive_t
|
---|
34 | {
|
---|
35 | GLsizei length;
|
---|
36 | GLint size;
|
---|
37 | GLenum type;
|
---|
38 | } crGetActive_t;
|
---|
39 |
|
---|
40 | void SERVER_DISPATCH_APIENTRY crServerDispatchGetActiveAttrib(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, char *name)
|
---|
41 | {
|
---|
42 | crGetActive_t *pLocal;
|
---|
43 |
|
---|
44 | pLocal = (crGetActive_t*) crAlloc(bufSize+sizeof(crGetActive_t));
|
---|
45 | if (!pLocal)
|
---|
46 | {
|
---|
47 | crGetActive_t zero;
|
---|
48 | zero.length = 0;
|
---|
49 | crServerReturnValue(&zero, sizeof(zero));
|
---|
50 | }
|
---|
51 | cr_server.head_spu->dispatch_table.GetActiveAttrib(program, index, bufSize, &pLocal->length, &pLocal->size, &pLocal->type, (char*)&pLocal[1]);
|
---|
52 | crServerReturnValue(pLocal, pLocal->length+1+sizeof(crGetActive_t));
|
---|
53 | crFree(pLocal);
|
---|
54 | }
|
---|
55 |
|
---|
56 | void SERVER_DISPATCH_APIENTRY crServerDispatchGetActiveUniform(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, char *name)
|
---|
57 | {
|
---|
58 | crGetActive_t *pLocal;
|
---|
59 |
|
---|
60 | pLocal = (crGetActive_t*) crAlloc(bufSize+sizeof(crGetActive_t));
|
---|
61 | if (!pLocal)
|
---|
62 | {
|
---|
63 | crGetActive_t zero;
|
---|
64 | zero.length = 0;
|
---|
65 | crServerReturnValue(&zero, sizeof(zero));
|
---|
66 | }
|
---|
67 | cr_server.head_spu->dispatch_table.GetActiveUniform(program, index, bufSize, &pLocal->length, &pLocal->size, &pLocal->type, (char*)&pLocal[1]);
|
---|
68 | crServerReturnValue(pLocal, pLocal->length+1+sizeof(crGetActive_t));
|
---|
69 | crFree(pLocal);
|
---|
70 | }
|
---|
71 |
|
---|
72 | void SERVER_DISPATCH_APIENTRY crServerDispatchGetAttachedShaders(GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders)
|
---|
73 | {
|
---|
74 | GLsizei *pLocal;
|
---|
75 |
|
---|
76 | pLocal = (GLsizei*) crAlloc(maxCount*sizeof(GLuint)+sizeof(GLsizei));
|
---|
77 | if (!pLocal)
|
---|
78 | {
|
---|
79 | GLsizei zero=0;
|
---|
80 | crServerReturnValue(&zero, sizeof(zero));
|
---|
81 | }
|
---|
82 | cr_server.head_spu->dispatch_table.GetAttachedShaders(program, maxCount, pLocal, (GLuint*)&pLocal[1]);
|
---|
83 | crServerReturnValue(pLocal, (*pLocal)*sizeof(GLuint)+sizeof(GLsizei));
|
---|
84 | crFree(pLocal);
|
---|
85 | }
|
---|
86 |
|
---|
87 | void SERVER_DISPATCH_APIENTRY crServerDispatchGetAttachedObjectsARB(GLhandleARB containerObj, GLsizei maxCount, GLsizei * count, GLhandleARB * obj)
|
---|
88 | {
|
---|
89 | GLsizei *pLocal;
|
---|
90 |
|
---|
91 | pLocal = (GLsizei*) crAlloc(maxCount*sizeof(GLhandleARB)+sizeof(GLsizei));
|
---|
92 | if (!pLocal)
|
---|
93 | {
|
---|
94 | GLsizei zero=0;
|
---|
95 | crServerReturnValue(&zero, sizeof(zero));
|
---|
96 | }
|
---|
97 | cr_server.head_spu->dispatch_table.GetAttachedObjectsARB(containerObj, maxCount, pLocal, (GLhandleARB*)&pLocal[1]);
|
---|
98 | crServerReturnValue(pLocal, (*pLocal)*sizeof(GLhandleARB)+sizeof(GLsizei));
|
---|
99 | crFree(pLocal);
|
---|
100 | }
|
---|
101 |
|
---|
102 | void SERVER_DISPATCH_APIENTRY crServerDispatchGetInfoLogARB(GLhandleARB obj, GLsizei maxLength, GLsizei * length, GLcharARB * infoLog)
|
---|
103 | {
|
---|
104 | GLsizei *pLocal;
|
---|
105 |
|
---|
106 | pLocal = (GLsizei*) crAlloc(maxLength+sizeof(GLsizei));
|
---|
107 | if (!pLocal)
|
---|
108 | {
|
---|
109 | GLsizei zero=0;
|
---|
110 | crServerReturnValue(&zero, sizeof(zero));
|
---|
111 | }
|
---|
112 | cr_server.head_spu->dispatch_table.GetInfoLogARB(obj, maxLength, pLocal, (char*)&pLocal[1]);
|
---|
113 | crServerReturnValue(pLocal, (*pLocal)+1+sizeof(GLsizei));
|
---|
114 | crFree(pLocal);
|
---|
115 | }
|
---|
116 |
|
---|
117 | void SERVER_DISPATCH_APIENTRY crServerDispatchGetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei *length, char *infoLog)
|
---|
118 | {
|
---|
119 | GLsizei *pLocal;
|
---|
120 |
|
---|
121 | pLocal = (GLsizei*) crAlloc(bufSize+sizeof(GLsizei));
|
---|
122 | if (!pLocal)
|
---|
123 | {
|
---|
124 | GLsizei zero=0;
|
---|
125 | crServerReturnValue(&zero, sizeof(zero));
|
---|
126 | }
|
---|
127 | cr_server.head_spu->dispatch_table.GetShaderInfoLog(shader, bufSize, pLocal, (char*)&pLocal[1]);
|
---|
128 | crServerReturnValue(pLocal, (*pLocal)+1+sizeof(GLsizei));
|
---|
129 | crFree(pLocal);
|
---|
130 | }
|
---|
131 |
|
---|
132 | void SERVER_DISPATCH_APIENTRY crServerDispatchGetProgramInfoLog(GLuint program, GLsizei bufSize, GLsizei *length, char *infoLog)
|
---|
133 | {
|
---|
134 | GLsizei *pLocal;
|
---|
135 |
|
---|
136 | pLocal = (GLsizei*) crAlloc(bufSize+sizeof(GLsizei));
|
---|
137 | if (!pLocal)
|
---|
138 | {
|
---|
139 | GLsizei zero=0;
|
---|
140 | crServerReturnValue(&zero, sizeof(zero));
|
---|
141 | }
|
---|
142 | cr_server.head_spu->dispatch_table.GetProgramInfoLog(program, bufSize, pLocal, (char*)&pLocal[1]);
|
---|
143 | crServerReturnValue(pLocal, (*pLocal)+1+sizeof(GLsizei));
|
---|
144 | crFree(pLocal);
|
---|
145 | }
|
---|
146 |
|
---|
147 | void SERVER_DISPATCH_APIENTRY crServerDispatchGetShaderSource(GLuint shader, GLsizei bufSize, GLsizei *length, char *source)
|
---|
148 | {
|
---|
149 | GLsizei *pLocal;
|
---|
150 |
|
---|
151 | pLocal = (GLsizei*) crAlloc(bufSize+sizeof(GLsizei));
|
---|
152 | if (!pLocal)
|
---|
153 | {
|
---|
154 | GLsizei zero=0;
|
---|
155 | crServerReturnValue(&zero, sizeof(zero));
|
---|
156 | }
|
---|
157 | cr_server.head_spu->dispatch_table.GetShaderSource(shader, bufSize, pLocal, (char*)pLocal+1);
|
---|
158 | crServerReturnValue(pLocal, (*pLocal)+1+sizeof(GLsizei));
|
---|
159 | crFree(pLocal);
|
---|
160 | }
|
---|
161 |
|
---|
162 | static GLint __GetUniformSize(GLuint program, GLint location)
|
---|
163 | {
|
---|
164 | GLint size;
|
---|
165 | GLenum type;
|
---|
166 |
|
---|
167 | /*@todo: check if index and location is the same*/
|
---|
168 | cr_server.head_spu->dispatch_table.GetActiveUniform(program, location, 0, NULL, &size, &type, NULL);
|
---|
169 |
|
---|
170 | switch (type)
|
---|
171 | {
|
---|
172 | case GL_FLOAT:
|
---|
173 | size = 1;
|
---|
174 | break;
|
---|
175 | case GL_FLOAT_VEC2:
|
---|
176 | size = 2;
|
---|
177 | break;
|
---|
178 | case GL_FLOAT_VEC3:
|
---|
179 | size = 3;
|
---|
180 | break;
|
---|
181 | case GL_FLOAT_VEC4:
|
---|
182 | size = 4;
|
---|
183 | break;
|
---|
184 | case GL_INT:
|
---|
185 | size = 1;
|
---|
186 | break;
|
---|
187 | case GL_INT_VEC2:
|
---|
188 | size = 2;
|
---|
189 | break;
|
---|
190 | case GL_INT_VEC3:
|
---|
191 | size = 3;
|
---|
192 | break;
|
---|
193 | case GL_INT_VEC4:
|
---|
194 | size = 4;
|
---|
195 | break;
|
---|
196 | case GL_BOOL:
|
---|
197 | size = 1;
|
---|
198 | break;
|
---|
199 | case GL_BOOL_VEC2:
|
---|
200 | size = 2;
|
---|
201 | break;
|
---|
202 | case GL_BOOL_VEC3:
|
---|
203 | size = 3;
|
---|
204 | break;
|
---|
205 | case GL_BOOL_VEC4:
|
---|
206 | size = 4;
|
---|
207 | break;
|
---|
208 | case GL_FLOAT_MAT2:
|
---|
209 | size = 8;
|
---|
210 | break;
|
---|
211 | case GL_FLOAT_MAT3:
|
---|
212 | size = 12;
|
---|
213 | break;
|
---|
214 | case GL_FLOAT_MAT4:
|
---|
215 | size = 16;
|
---|
216 | break;
|
---|
217 | case GL_SAMPLER_1D:
|
---|
218 | case GL_SAMPLER_2D:
|
---|
219 | case GL_SAMPLER_3D:
|
---|
220 | case GL_SAMPLER_CUBE:
|
---|
221 | case GL_SAMPLER_1D_SHADOW:
|
---|
222 | case GL_SAMPLER_2D_SHADOW:
|
---|
223 | size = 1;
|
---|
224 | break;
|
---|
225 | #ifdef CR_OPENGL_VERSION_2_1
|
---|
226 | case GL_FLOAT_MAT2x3:
|
---|
227 | size = 8;
|
---|
228 | break;
|
---|
229 | case GL_FLOAT_MAT2x4:
|
---|
230 | size = 8;
|
---|
231 | break;
|
---|
232 | case GL_FLOAT_MAT3x2:
|
---|
233 | size = 12;
|
---|
234 | break;
|
---|
235 | case GL_FLOAT_MAT3x4:
|
---|
236 | size = 12;
|
---|
237 | break;
|
---|
238 | case GL_FLOAT_MAT4x2:
|
---|
239 | size = 16;
|
---|
240 | break;
|
---|
241 | case GL_FLOAT_MAT4x3:
|
---|
242 | size = 16;
|
---|
243 | break;
|
---|
244 | #endif
|
---|
245 | default:
|
---|
246 | crWarning("__GetUniformSize: unknown uniform type 0x%x", (GLint)type);
|
---|
247 | size = 16;
|
---|
248 | break;
|
---|
249 | }
|
---|
250 |
|
---|
251 | return size;
|
---|
252 | }
|
---|
253 |
|
---|
254 | void SERVER_DISPATCH_APIENTRY crServerDispatchGetUniformfv(GLuint program, GLint location, GLfloat *params)
|
---|
255 | {
|
---|
256 | int size = __GetUniformSize(program, location) * sizeof(GLfloat);
|
---|
257 | GLfloat *pLocal;
|
---|
258 |
|
---|
259 | pLocal = (GLfloat*) crAlloc(size);
|
---|
260 | if (!pLocal)
|
---|
261 | {
|
---|
262 | GLsizei zero=0;
|
---|
263 | crServerReturnValue(&zero, sizeof(zero));
|
---|
264 | }
|
---|
265 |
|
---|
266 | cr_server.head_spu->dispatch_table.GetUniformfv(program, location, pLocal);
|
---|
267 |
|
---|
268 | crServerReturnValue(pLocal, size);
|
---|
269 | crFree(pLocal);
|
---|
270 | }
|
---|
271 |
|
---|
272 | void SERVER_DISPATCH_APIENTRY crServerDispatchGetUniformiv(GLuint program, GLint location, GLint *params)
|
---|
273 | {
|
---|
274 | int size = __GetUniformSize(program, location) * sizeof(GLint);
|
---|
275 | GLint *pLocal;
|
---|
276 |
|
---|
277 | pLocal = (GLint*) crAlloc(size);
|
---|
278 | if (!pLocal)
|
---|
279 | {
|
---|
280 | GLsizei zero=0;
|
---|
281 | crServerReturnValue(&zero, sizeof(zero));
|
---|
282 | }
|
---|
283 |
|
---|
284 | cr_server.head_spu->dispatch_table.GetUniformiv(program, location, pLocal);
|
---|
285 |
|
---|
286 | crServerReturnValue(pLocal, size);
|
---|
287 | crFree(pLocal);
|
---|
288 | }
|
---|
289 |
|
---|
290 | #endif /* #ifdef CR_OPENGL_VERSION_2_0 */
|
---|