1 | /* $Id: server_getshaders.c 23399 2009-09-29 05:04:38Z vboxsync $ */
|
---|
2 |
|
---|
3 | /** @file
|
---|
4 | * VBox OpenGL GLSL related get 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(crStateGetProgramHWID(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(crStateGetProgramHWID(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(crStateGetProgramHWID(program), maxCount, pLocal, (GLuint*)&pLocal[1]);
|
---|
83 |
|
---|
84 | {
|
---|
85 | GLsizei i;
|
---|
86 | GLuint *ids=(GLuint*)&pLocal[1];
|
---|
87 |
|
---|
88 | for (i=0; i<*pLocal; ++i);
|
---|
89 | ids[i] = crStateGLSLShaderHWIDtoID(ids[i]);
|
---|
90 | }
|
---|
91 |
|
---|
92 | crServerReturnValue(pLocal, (*pLocal)*sizeof(GLuint)+sizeof(GLsizei));
|
---|
93 | crFree(pLocal);
|
---|
94 | }
|
---|
95 |
|
---|
96 | void SERVER_DISPATCH_APIENTRY crServerDispatchGetAttachedObjectsARB(GLhandleARB containerObj, GLsizei maxCount, GLsizei * count, GLhandleARB * obj)
|
---|
97 | {
|
---|
98 | GLsizei *pLocal;
|
---|
99 |
|
---|
100 | pLocal = (GLsizei*) crAlloc(maxCount*sizeof(GLhandleARB)+sizeof(GLsizei));
|
---|
101 | if (!pLocal)
|
---|
102 | {
|
---|
103 | GLsizei zero=0;
|
---|
104 | crServerReturnValue(&zero, sizeof(zero));
|
---|
105 | }
|
---|
106 | cr_server.head_spu->dispatch_table.GetAttachedObjectsARB(crStateGetProgramHWID(containerObj), maxCount, pLocal, (GLhandleARB*)&pLocal[1]);
|
---|
107 |
|
---|
108 | {
|
---|
109 | GLsizei i;
|
---|
110 | GLuint *ids=(GLuint*)&pLocal[1];
|
---|
111 |
|
---|
112 | for (i=0; i<*pLocal; ++i);
|
---|
113 | ids[i] = crStateGLSLShaderHWIDtoID(ids[i]);
|
---|
114 | }
|
---|
115 |
|
---|
116 | crServerReturnValue(pLocal, (*pLocal)*sizeof(GLhandleARB)+sizeof(GLsizei));
|
---|
117 | crFree(pLocal);
|
---|
118 | }
|
---|
119 |
|
---|
120 | void SERVER_DISPATCH_APIENTRY crServerDispatchGetInfoLogARB(GLhandleARB obj, GLsizei maxLength, GLsizei * length, GLcharARB * infoLog)
|
---|
121 | {
|
---|
122 | GLsizei *pLocal;
|
---|
123 | GLuint hwid;
|
---|
124 |
|
---|
125 | pLocal = (GLsizei*) crAlloc(maxLength+sizeof(GLsizei));
|
---|
126 | if (!pLocal)
|
---|
127 | {
|
---|
128 | GLsizei zero=0;
|
---|
129 | crServerReturnValue(&zero, sizeof(zero));
|
---|
130 | }
|
---|
131 | /*@todo: recheck*/
|
---|
132 | hwid = crStateGetProgramHWID(obj);
|
---|
133 | if (!hwid) hwid = crStateGetShaderHWID(obj);
|
---|
134 | cr_server.head_spu->dispatch_table.GetInfoLogARB(hwid, maxLength, pLocal, (char*)&pLocal[1]);
|
---|
135 | crServerReturnValue(pLocal, (*pLocal)+1+sizeof(GLsizei));
|
---|
136 | crFree(pLocal);
|
---|
137 | }
|
---|
138 |
|
---|
139 | void SERVER_DISPATCH_APIENTRY crServerDispatchGetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei *length, char *infoLog)
|
---|
140 | {
|
---|
141 | GLsizei *pLocal;
|
---|
142 |
|
---|
143 | pLocal = (GLsizei*) crAlloc(bufSize+sizeof(GLsizei));
|
---|
144 | if (!pLocal)
|
---|
145 | {
|
---|
146 | GLsizei zero=0;
|
---|
147 | crServerReturnValue(&zero, sizeof(zero));
|
---|
148 | }
|
---|
149 | cr_server.head_spu->dispatch_table.GetShaderInfoLog(crStateGetShaderHWID(shader), bufSize, pLocal, (char*)&pLocal[1]);
|
---|
150 | crServerReturnValue(pLocal, (*pLocal)+1+sizeof(GLsizei));
|
---|
151 | crFree(pLocal);
|
---|
152 | }
|
---|
153 |
|
---|
154 | void SERVER_DISPATCH_APIENTRY crServerDispatchGetProgramInfoLog(GLuint program, GLsizei bufSize, GLsizei *length, char *infoLog)
|
---|
155 | {
|
---|
156 | GLsizei *pLocal;
|
---|
157 |
|
---|
158 | pLocal = (GLsizei*) crAlloc(bufSize+sizeof(GLsizei));
|
---|
159 | if (!pLocal)
|
---|
160 | {
|
---|
161 | GLsizei zero=0;
|
---|
162 | crServerReturnValue(&zero, sizeof(zero));
|
---|
163 | }
|
---|
164 | cr_server.head_spu->dispatch_table.GetProgramInfoLog(crStateGetProgramHWID(program), bufSize, pLocal, (char*)&pLocal[1]);
|
---|
165 | crServerReturnValue(pLocal, (*pLocal)+1+sizeof(GLsizei));
|
---|
166 | crFree(pLocal);
|
---|
167 | }
|
---|
168 |
|
---|
169 | void SERVER_DISPATCH_APIENTRY crServerDispatchGetShaderSource(GLuint shader, GLsizei bufSize, GLsizei *length, char *source)
|
---|
170 | {
|
---|
171 | GLsizei *pLocal;
|
---|
172 |
|
---|
173 | pLocal = (GLsizei*) crAlloc(bufSize+sizeof(GLsizei));
|
---|
174 | if (!pLocal)
|
---|
175 | {
|
---|
176 | GLsizei zero=0;
|
---|
177 | crServerReturnValue(&zero, sizeof(zero));
|
---|
178 | }
|
---|
179 | cr_server.head_spu->dispatch_table.GetShaderSource(crStateGetShaderHWID(shader), bufSize, pLocal, (char*)&pLocal[1]);
|
---|
180 | crServerReturnValue(pLocal, (*pLocal)+1+sizeof(GLsizei));
|
---|
181 | crFree(pLocal);
|
---|
182 | }
|
---|
183 |
|
---|
184 | void SERVER_DISPATCH_APIENTRY
|
---|
185 | crServerDispatchGetUniformsLocations(GLuint program, GLsizei maxcbData, GLsizei * cbData, GLvoid * pData)
|
---|
186 | {
|
---|
187 | GLsizei *pLocal;
|
---|
188 |
|
---|
189 | (void) cbData;
|
---|
190 | (void) pData;
|
---|
191 |
|
---|
192 | pLocal = (GLsizei*) crAlloc(maxcbData+sizeof(GLsizei));
|
---|
193 | if (!pLocal)
|
---|
194 | {
|
---|
195 | GLsizei zero=0;
|
---|
196 | crServerReturnValue(&zero, sizeof(zero));
|
---|
197 | }
|
---|
198 |
|
---|
199 | crStateGLSLProgramCacheUniforms(program, maxcbData, pLocal, (char*)&pLocal[1]);
|
---|
200 |
|
---|
201 | crServerReturnValue(pLocal, (*pLocal)+sizeof(GLsizei));
|
---|
202 | crFree(pLocal);
|
---|
203 | }
|
---|
204 |
|
---|
205 | static GLint __GetUniformSize(GLuint program, GLint location)
|
---|
206 | {
|
---|
207 | GLint size;
|
---|
208 | GLenum type;
|
---|
209 |
|
---|
210 | /*@todo: check if index and location is the same*/
|
---|
211 | cr_server.head_spu->dispatch_table.GetActiveUniform(crStateGetProgramHWID(program), location, 0, NULL, &size, &type, NULL);
|
---|
212 |
|
---|
213 | return crStateGetUniformSize(type);
|
---|
214 | }
|
---|
215 |
|
---|
216 | void SERVER_DISPATCH_APIENTRY crServerDispatchGetUniformfv(GLuint program, GLint location, GLfloat *params)
|
---|
217 | {
|
---|
218 | int size = __GetUniformSize(program, location) * sizeof(GLfloat);
|
---|
219 | GLfloat *pLocal;
|
---|
220 |
|
---|
221 | pLocal = (GLfloat*) crAlloc(size);
|
---|
222 | if (!pLocal)
|
---|
223 | {
|
---|
224 | GLsizei zero=0;
|
---|
225 | crServerReturnValue(&zero, sizeof(zero));
|
---|
226 | }
|
---|
227 |
|
---|
228 | cr_server.head_spu->dispatch_table.GetUniformfv(crStateGetProgramHWID(program), location, pLocal);
|
---|
229 |
|
---|
230 | crServerReturnValue(pLocal, size);
|
---|
231 | crFree(pLocal);
|
---|
232 | }
|
---|
233 |
|
---|
234 | void SERVER_DISPATCH_APIENTRY crServerDispatchGetUniformiv(GLuint program, GLint location, GLint *params)
|
---|
235 | {
|
---|
236 | int size = __GetUniformSize(program, location) * sizeof(GLint);
|
---|
237 | GLint *pLocal;
|
---|
238 |
|
---|
239 | pLocal = (GLint*) crAlloc(size);
|
---|
240 | if (!pLocal)
|
---|
241 | {
|
---|
242 | GLsizei zero=0;
|
---|
243 | crServerReturnValue(&zero, sizeof(zero));
|
---|
244 | }
|
---|
245 |
|
---|
246 | cr_server.head_spu->dispatch_table.GetUniformiv(crStateGetProgramHWID(program), location, pLocal);
|
---|
247 |
|
---|
248 | crServerReturnValue(pLocal, size);
|
---|
249 | crFree(pLocal);
|
---|
250 | }
|
---|
251 |
|
---|
252 | GLuint SERVER_DISPATCH_APIENTRY crServerDispatchCreateShader(GLenum type)
|
---|
253 | {
|
---|
254 | GLuint retval;
|
---|
255 | retval = cr_server.head_spu->dispatch_table.CreateShader(type);
|
---|
256 | crStateCreateShader(retval, type);
|
---|
257 | crServerReturnValue(&retval, sizeof(retval));
|
---|
258 | return retval; /* ignored */
|
---|
259 | }
|
---|
260 |
|
---|
261 | GLuint SERVER_DISPATCH_APIENTRY crServerDispatchCreateProgram(void)
|
---|
262 | {
|
---|
263 | GLuint retval;
|
---|
264 | retval = cr_server.head_spu->dispatch_table.CreateProgram();
|
---|
265 | crStateCreateProgram(retval);
|
---|
266 | crServerReturnValue(&retval, sizeof(retval));
|
---|
267 | return retval; /* ignored */
|
---|
268 | }
|
---|
269 |
|
---|
270 | GLboolean SERVER_DISPATCH_APIENTRY crServerDispatchIsShader(GLuint shader)
|
---|
271 | {
|
---|
272 | GLboolean retval;
|
---|
273 | retval = cr_server.head_spu->dispatch_table.IsShader(crStateGetShaderHWID(shader));
|
---|
274 | crServerReturnValue(&retval, sizeof(retval));
|
---|
275 | return retval; /* ignored */
|
---|
276 | }
|
---|
277 |
|
---|
278 | GLboolean SERVER_DISPATCH_APIENTRY crServerDispatchIsProgram(GLuint program)
|
---|
279 | {
|
---|
280 | GLboolean retval;
|
---|
281 | retval = cr_server.head_spu->dispatch_table.IsProgram(crStateGetProgramHWID(program));
|
---|
282 | crServerReturnValue(&retval, sizeof(retval));
|
---|
283 | return retval; /* ignored */
|
---|
284 | }
|
---|
285 |
|
---|
286 | #endif /* #ifdef CR_OPENGL_VERSION_2_0 */
|
---|