VirtualBox

source: vbox/trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_getshaders.c@ 20327

Last change on this file since 20327 was 20179, checked in by vboxsync, 16 years ago

crOpenGL: added todo comment

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 7.0 KB
Line 
1/* $Id: server_getshaders.c 20179 2009-06-02 08:40:38Z vboxsync $ */
2
3/** @file
4 * VBox OpenGL DRI driver functions
5 */
6
7/*
8 * Copyright (C) 2009 Sun Microsystems, Inc.
9 *
10 * Sun Microsystems, Inc. confidential
11 * All rights reserved
12 */
13
14#include "cr_spu.h"
15#include "chromium.h"
16#include "cr_error.h"
17#include "cr_mem.h"
18#include "cr_net.h"
19#include "server_dispatch.h"
20#include "server.h"
21
22#ifdef CR_OPENGL_VERSION_2_0
23
24typedef struct _crGetActive_t
25{
26 GLsizei length;
27 GLint size;
28 GLenum type;
29} crGetActive_t;
30
31/*@todo: most of those functions would fail. Either need to support more than 1 cr_server.return_ptr(s) or
32 * change pack_spu to pack output args into single buffer.
33 */
34
35void SERVER_DISPATCH_APIENTRY crServerDispatchGetActiveAttrib(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, char *name)
36{
37 crGetActive_t *pLocal;
38
39 pLocal = (crGetActive_t*) crAlloc(bufSize+sizeof(crGetActive_t));
40 if (!pLocal)
41 {
42 crGetActive_t zero;
43 zero.length = 0;
44 crServerReturnValue(&zero, sizeof(zero));
45 }
46 cr_server.head_spu->dispatch_table.GetActiveAttrib(program, index, bufSize, &pLocal->length, &pLocal->size, &pLocal->type, (char*)&pLocal[1]);
47 crServerReturnValue(pLocal, pLocal->length+1+sizeof(crGetActive_t));
48 crFree(pLocal);
49}
50
51void SERVER_DISPATCH_APIENTRY crServerDispatchGetActiveUniform(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, char *name)
52{
53 crGetActive_t *pLocal;
54
55 pLocal = (crGetActive_t*) crAlloc(bufSize+sizeof(crGetActive_t));
56 if (!pLocal)
57 {
58 crGetActive_t zero;
59 zero.length = 0;
60 crServerReturnValue(&zero, sizeof(zero));
61 }
62 cr_server.head_spu->dispatch_table.GetActiveUniform(program, index, bufSize, &pLocal->length, &pLocal->size, &pLocal->type, (char*)&pLocal[1]);
63 crServerReturnValue(pLocal, pLocal->length+1+sizeof(crGetActive_t));
64 crFree(pLocal);
65}
66
67void SERVER_DISPATCH_APIENTRY crServerDispatchGetAttachedShaders(GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders)
68{
69 GLsizei *pLocal;
70
71 pLocal = (GLsizei*) crAlloc(maxCount*sizeof(GLuint)+sizeof(GLsizei));
72 if (!pLocal)
73 {
74 GLsizei zero=0;
75 crServerReturnValue(&zero, sizeof(zero));
76 }
77 cr_server.head_spu->dispatch_table.GetAttachedShaders(program, maxCount, pLocal, (GLuint*)&pLocal[1]);
78 crServerReturnValue(pLocal, (*pLocal)*sizeof(GLuint)+sizeof(GLsizei));
79 crFree(pLocal);
80}
81
82void SERVER_DISPATCH_APIENTRY crServerDispatchGetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei *length, char *infoLog)
83{
84 GLsizei *pLocal;
85
86 pLocal = (GLsizei*) crAlloc(bufSize+sizeof(GLsizei));
87 if (!pLocal)
88 {
89 GLsizei zero=0;
90 crServerReturnValue(&zero, sizeof(zero));
91 }
92 cr_server.head_spu->dispatch_table.GetShaderInfoLog(shader, bufSize, pLocal, (char*)&pLocal[1]);
93 crServerReturnValue(pLocal, (*pLocal)+1+sizeof(GLsizei));
94 crFree(pLocal);
95}
96
97void SERVER_DISPATCH_APIENTRY crServerDispatchGetProgramInfoLog(GLuint program, GLsizei bufSize, GLsizei *length, char *infoLog)
98{
99 GLsizei *pLocal;
100
101 pLocal = (GLsizei*) crAlloc(bufSize+sizeof(GLsizei));
102 if (!pLocal)
103 {
104 GLsizei zero=0;
105 crServerReturnValue(&zero, sizeof(zero));
106 }
107 cr_server.head_spu->dispatch_table.GetProgramInfoLog(program, bufSize, pLocal, (char*)&pLocal[1]);
108 crServerReturnValue(pLocal, (*pLocal)+1+sizeof(GLsizei));
109 crFree(pLocal);
110}
111
112void SERVER_DISPATCH_APIENTRY crServerDispatchGetShaderSource(GLuint shader, GLsizei bufSize, GLsizei *length, char *source)
113{
114 GLsizei *pLocal;
115
116 pLocal = (GLsizei*) crAlloc(bufSize+sizeof(GLsizei));
117 if (!pLocal)
118 {
119 GLsizei zero=0;
120 crServerReturnValue(&zero, sizeof(zero));
121 }
122 cr_server.head_spu->dispatch_table.GetShaderSource(shader, bufSize, pLocal, (char*)pLocal+1);
123 crServerReturnValue(pLocal, (*pLocal)+1+sizeof(GLsizei));
124 crFree(pLocal);
125}
126
127static GLint __GetUniformSize(GLuint program, GLint location)
128{
129 GLint size;
130 GLenum type;
131
132 /*@todo: check if index and location is the same*/
133 cr_server.head_spu->dispatch_table.GetActiveUniform(program, location, 0, NULL, &size, &type, NULL);
134
135 switch (type)
136 {
137 case GL_FLOAT:
138 size = 1;
139 break;
140 case GL_FLOAT_VEC2:
141 size = 2;
142 break;
143 case GL_FLOAT_VEC3:
144 size = 3;
145 break;
146 case GL_FLOAT_VEC4:
147 size = 4;
148 break;
149 case GL_INT:
150 size = 1;
151 break;
152 case GL_INT_VEC2:
153 size = 2;
154 break;
155 case GL_INT_VEC3:
156 size = 3;
157 break;
158 case GL_INT_VEC4:
159 size = 4;
160 break;
161 case GL_BOOL:
162 size = 1;
163 break;
164 case GL_BOOL_VEC2:
165 size = 2;
166 break;
167 case GL_BOOL_VEC3:
168 size = 3;
169 break;
170 case GL_BOOL_VEC4:
171 size = 4;
172 break;
173 case GL_FLOAT_MAT2:
174 size = 8;
175 break;
176 case GL_FLOAT_MAT3:
177 size = 12;
178 break;
179 case GL_FLOAT_MAT4:
180 size = 16;
181 break;
182 case GL_SAMPLER_1D:
183 case GL_SAMPLER_2D:
184 case GL_SAMPLER_3D:
185 case GL_SAMPLER_CUBE:
186 case GL_SAMPLER_1D_SHADOW:
187 case GL_SAMPLER_2D_SHADOW:
188 size = 1;
189 break;
190#ifdef CR_OPENGL_VERSION_2_1
191 case GL_FLOAT_MAT2x3:
192 size = 8;
193 break;
194 case GL_FLOAT_MAT2x4:
195 size = 8;
196 break;
197 case GL_FLOAT_MAT3x2:
198 size = 12;
199 break;
200 case GL_FLOAT_MAT3x4:
201 size = 12;
202 break;
203 case GL_FLOAT_MAT4x2:
204 size = 16;
205 break;
206 case GL_FLOAT_MAT4x3:
207 size = 16;
208 break;
209#endif
210 default:
211 crWarning("__GetUniformSize: unknown uniform type 0x%x", (GLint)type);
212 size = 16;
213 break;
214 }
215
216 return size;
217}
218
219void SERVER_DISPATCH_APIENTRY crServerDispatchGetUniformfv(GLuint program, GLint location, GLfloat *params)
220{
221 int size = __GetUniformSize(program, location) * sizeof(GLfloat);
222 GLfloat *pLocal;
223
224 pLocal = (GLfloat*) crAlloc(size);
225 if (!pLocal)
226 {
227 GLsizei zero=0;
228 crServerReturnValue(&zero, sizeof(zero));
229 }
230
231 cr_server.head_spu->dispatch_table.GetUniformfv(program, location, pLocal);
232
233 crServerReturnValue(pLocal, size);
234 crFree(pLocal);
235}
236
237void SERVER_DISPATCH_APIENTRY crServerDispatchGetUniformiv(GLuint program, GLint location, GLint *params)
238{
239 int size = __GetUniformSize(program, location) * sizeof(GLint);
240 GLint *pLocal;
241
242 pLocal = (GLint*) crAlloc(size);
243 if (!pLocal)
244 {
245 GLsizei zero=0;
246 crServerReturnValue(&zero, sizeof(zero));
247 }
248
249 cr_server.head_spu->dispatch_table.GetUniformiv(program, location, pLocal);
250
251 crServerReturnValue(pLocal, size);
252 crFree(pLocal);
253}
254
255#endif /* #ifdef CR_OPENGL_VERSION_2_0 */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette