1 | /* $Id: unpack_shaders.c 27244 2010-03-10 11:43:03Z 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 "unpacker.h"
|
---|
24 | #include "cr_error.h"
|
---|
25 | #include "cr_protocol.h"
|
---|
26 | #include "cr_mem.h"
|
---|
27 | #include "cr_string.h"
|
---|
28 | #include "cr_version.h"
|
---|
29 |
|
---|
30 | void crUnpackExtendBindAttribLocation(void)
|
---|
31 | {
|
---|
32 | GLuint program = READ_DATA(8, GLuint);
|
---|
33 | GLuint index = READ_DATA(12, GLuint);
|
---|
34 | const char *name = DATA_POINTER(16, const char);
|
---|
35 |
|
---|
36 | cr_unpackDispatch.BindAttribLocation(program, index, name);
|
---|
37 | }
|
---|
38 |
|
---|
39 | void crUnpackExtendShaderSource(void)
|
---|
40 | {
|
---|
41 | GLint *length = NULL;
|
---|
42 | GLuint shader = READ_DATA(8, GLuint);
|
---|
43 | GLsizei count = READ_DATA(12, GLsizei);
|
---|
44 | GLint hasNonLocalLen = READ_DATA(16, GLsizei);
|
---|
45 | GLint *pLocalLength = DATA_POINTER(20, GLint);
|
---|
46 | const char **ppStrings = NULL;
|
---|
47 | GLsizei i;
|
---|
48 | int pos=20+count*sizeof(*pLocalLength);
|
---|
49 |
|
---|
50 | if (hasNonLocalLen>0)
|
---|
51 | {
|
---|
52 | length = DATA_POINTER(pos, GLint);
|
---|
53 | pos += count*sizeof(*length);
|
---|
54 | }
|
---|
55 |
|
---|
56 | ppStrings = crAlloc(count*sizeof(char*));
|
---|
57 | if (!ppStrings) return;
|
---|
58 |
|
---|
59 | for (i=0; i<count; ++i)
|
---|
60 | {
|
---|
61 | ppStrings[i] = DATA_POINTER(pos, char);
|
---|
62 | pos += pLocalLength[i];
|
---|
63 | if (!length)
|
---|
64 | {
|
---|
65 | pLocalLength[i] -= 1;
|
---|
66 | }
|
---|
67 | }
|
---|
68 |
|
---|
69 | cr_unpackDispatch.ShaderSource(shader, count, ppStrings, length ? length : pLocalLength);
|
---|
70 | crFree(ppStrings);
|
---|
71 | }
|
---|
72 |
|
---|
73 | void crUnpackExtendUniform1fv(void)
|
---|
74 | {
|
---|
75 | GLint location = READ_DATA(8, GLint);
|
---|
76 | GLsizei count = READ_DATA(12, GLsizei);
|
---|
77 | const GLfloat *value = DATA_POINTER(16, const GLfloat);
|
---|
78 | cr_unpackDispatch.Uniform1fv(location, count, value);
|
---|
79 | }
|
---|
80 |
|
---|
81 | void crUnpackExtendUniform1iv(void)
|
---|
82 | {
|
---|
83 | GLint location = READ_DATA(8, GLint);
|
---|
84 | GLsizei count = READ_DATA(12, GLsizei);
|
---|
85 | const GLint *value = DATA_POINTER(16, const GLint);
|
---|
86 | cr_unpackDispatch.Uniform1iv(location, count, value);
|
---|
87 | }
|
---|
88 |
|
---|
89 | void crUnpackExtendUniform2fv(void)
|
---|
90 | {
|
---|
91 | GLint location = READ_DATA(8, GLint);
|
---|
92 | GLsizei count = READ_DATA(12, GLsizei);
|
---|
93 | const GLfloat *value = DATA_POINTER(16, const GLfloat);
|
---|
94 | cr_unpackDispatch.Uniform2fv(location, count, value);
|
---|
95 | }
|
---|
96 |
|
---|
97 | void crUnpackExtendUniform2iv(void)
|
---|
98 | {
|
---|
99 | GLint location = READ_DATA(8, GLint);
|
---|
100 | GLsizei count = READ_DATA(12, GLsizei);
|
---|
101 | const GLint *value = DATA_POINTER(16, const GLint);
|
---|
102 | cr_unpackDispatch.Uniform2iv(location, count, value);
|
---|
103 | }
|
---|
104 |
|
---|
105 | void crUnpackExtendUniform3fv(void)
|
---|
106 | {
|
---|
107 | GLint location = READ_DATA(8, GLint);
|
---|
108 | GLsizei count = READ_DATA(12, GLsizei);
|
---|
109 | const GLfloat *value = DATA_POINTER(16, const GLfloat);
|
---|
110 | cr_unpackDispatch.Uniform3fv(location, count, value);
|
---|
111 | }
|
---|
112 |
|
---|
113 | void crUnpackExtendUniform3iv(void)
|
---|
114 | {
|
---|
115 | GLint location = READ_DATA(8, GLint);
|
---|
116 | GLsizei count = READ_DATA(12, GLsizei);
|
---|
117 | const GLint *value = DATA_POINTER(16, const GLint);
|
---|
118 | cr_unpackDispatch.Uniform3iv(location, count, value);
|
---|
119 | }
|
---|
120 |
|
---|
121 | void crUnpackExtendUniform4fv(void)
|
---|
122 | {
|
---|
123 | GLint location = READ_DATA(8, GLint);
|
---|
124 | GLsizei count = READ_DATA(12, GLsizei);
|
---|
125 | const GLfloat *value = DATA_POINTER(16, const GLfloat);
|
---|
126 | cr_unpackDispatch.Uniform4fv(location, count, value);
|
---|
127 | }
|
---|
128 |
|
---|
129 | void crUnpackExtendUniform4iv(void)
|
---|
130 | {
|
---|
131 | GLint location = READ_DATA(8, GLint);
|
---|
132 | GLsizei count = READ_DATA(12, GLsizei);
|
---|
133 | const GLint *value = DATA_POINTER(16, const GLint);
|
---|
134 | cr_unpackDispatch.Uniform4iv(location, count, value);
|
---|
135 | }
|
---|
136 |
|
---|
137 | void crUnpackExtendUniformMatrix2fv(void)
|
---|
138 | {
|
---|
139 | GLint location = READ_DATA(8, GLint);
|
---|
140 | GLsizei count = READ_DATA(12, GLsizei);
|
---|
141 | GLboolean transpose = READ_DATA(16, GLboolean);
|
---|
142 | const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat);
|
---|
143 | cr_unpackDispatch.UniformMatrix2fv(location, count, transpose, value);
|
---|
144 | }
|
---|
145 |
|
---|
146 | void crUnpackExtendUniformMatrix3fv(void)
|
---|
147 | {
|
---|
148 | GLint location = READ_DATA(8, GLint);
|
---|
149 | GLsizei count = READ_DATA(12, GLsizei);
|
---|
150 | GLboolean transpose = READ_DATA(16, GLboolean);
|
---|
151 | const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat);
|
---|
152 | cr_unpackDispatch.UniformMatrix3fv(location, count, transpose, value);
|
---|
153 | }
|
---|
154 |
|
---|
155 | void crUnpackExtendUniformMatrix4fv(void)
|
---|
156 | {
|
---|
157 | GLint location = READ_DATA(8, GLint);
|
---|
158 | GLsizei count = READ_DATA(12, GLsizei);
|
---|
159 | GLboolean transpose = READ_DATA(16, GLboolean);
|
---|
160 | const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat);
|
---|
161 | cr_unpackDispatch.UniformMatrix4fv(location, count, transpose, value);
|
---|
162 | }
|
---|
163 |
|
---|
164 | void crUnpackExtendUniformMatrix2x3fv(void)
|
---|
165 | {
|
---|
166 | GLint location = READ_DATA(8, GLint);
|
---|
167 | GLsizei count = READ_DATA(12, GLsizei);
|
---|
168 | GLboolean transpose = READ_DATA(16, GLboolean);
|
---|
169 | const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat);
|
---|
170 | cr_unpackDispatch.UniformMatrix2x3fv(location, count, transpose, value);
|
---|
171 | }
|
---|
172 |
|
---|
173 | void crUnpackExtendUniformMatrix3x2fv(void)
|
---|
174 | {
|
---|
175 | GLint location = READ_DATA(8, GLint);
|
---|
176 | GLsizei count = READ_DATA(12, GLsizei);
|
---|
177 | GLboolean transpose = READ_DATA(16, GLboolean);
|
---|
178 | const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat);
|
---|
179 | cr_unpackDispatch.UniformMatrix3x2fv(location, count, transpose, value);
|
---|
180 | }
|
---|
181 |
|
---|
182 | void crUnpackExtendUniformMatrix2x4fv(void)
|
---|
183 | {
|
---|
184 | GLint location = READ_DATA(8, GLint);
|
---|
185 | GLsizei count = READ_DATA(12, GLsizei);
|
---|
186 | GLboolean transpose = READ_DATA(16, GLboolean);
|
---|
187 | const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat);
|
---|
188 | cr_unpackDispatch.UniformMatrix2x4fv(location, count, transpose, value);
|
---|
189 | }
|
---|
190 |
|
---|
191 | void crUnpackExtendUniformMatrix4x2fv(void)
|
---|
192 | {
|
---|
193 | GLint location = READ_DATA(8, GLint);
|
---|
194 | GLsizei count = READ_DATA(12, GLsizei);
|
---|
195 | GLboolean transpose = READ_DATA(16, GLboolean);
|
---|
196 | const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat);
|
---|
197 | cr_unpackDispatch.UniformMatrix4x2fv(location, count, transpose, value);
|
---|
198 | }
|
---|
199 |
|
---|
200 | void crUnpackExtendUniformMatrix3x4fv(void)
|
---|
201 | {
|
---|
202 | GLint location = READ_DATA(8, GLint);
|
---|
203 | GLsizei count = READ_DATA(12, GLsizei);
|
---|
204 | GLboolean transpose = READ_DATA(16, GLboolean);
|
---|
205 | const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat);
|
---|
206 | cr_unpackDispatch.UniformMatrix3x4fv(location, count, transpose, value);
|
---|
207 | }
|
---|
208 |
|
---|
209 | void crUnpackExtendUniformMatrix4x3fv(void)
|
---|
210 | {
|
---|
211 | GLint location = READ_DATA(8, GLint);
|
---|
212 | GLsizei count = READ_DATA(12, GLsizei);
|
---|
213 | GLboolean transpose = READ_DATA(16, GLboolean);
|
---|
214 | const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat);
|
---|
215 | cr_unpackDispatch.UniformMatrix4x3fv(location, count, transpose, value);
|
---|
216 | }
|
---|
217 |
|
---|
218 | void crUnpackExtendDrawBuffers(void)
|
---|
219 | {
|
---|
220 | GLsizei n = READ_DATA(8, GLsizei);
|
---|
221 | const GLenum *bufs = DATA_POINTER(8+sizeof(GLsizei), const GLenum);
|
---|
222 | cr_unpackDispatch.DrawBuffers(n, bufs);
|
---|
223 | }
|
---|
224 |
|
---|
225 | void crUnpackExtendGetActiveAttrib(void)
|
---|
226 | {
|
---|
227 | GLuint program = READ_DATA(8, GLuint);
|
---|
228 | GLuint index = READ_DATA(12, GLuint);
|
---|
229 | GLsizei bufSize = READ_DATA(16, GLsizei);
|
---|
230 | SET_RETURN_PTR(20);
|
---|
231 | SET_WRITEBACK_PTR(28);
|
---|
232 | cr_unpackDispatch.GetActiveAttrib(program, index, bufSize, NULL, NULL, NULL, NULL);
|
---|
233 | }
|
---|
234 |
|
---|
235 | void crUnpackExtendGetActiveUniform(void)
|
---|
236 | {
|
---|
237 | GLuint program = READ_DATA(8, GLuint);
|
---|
238 | GLuint index = READ_DATA(12, GLuint);
|
---|
239 | GLsizei bufSize = READ_DATA(16, GLsizei);
|
---|
240 | SET_RETURN_PTR(20);
|
---|
241 | SET_WRITEBACK_PTR(28);
|
---|
242 | cr_unpackDispatch.GetActiveUniform(program, index, bufSize, NULL, NULL, NULL, NULL);
|
---|
243 | }
|
---|
244 |
|
---|
245 | void crUnpackExtendGetAttachedShaders(void)
|
---|
246 | {
|
---|
247 | GLuint program = READ_DATA(8, GLuint);
|
---|
248 | GLsizei maxCount = READ_DATA(12, GLsizei);
|
---|
249 | SET_RETURN_PTR(16);
|
---|
250 | SET_WRITEBACK_PTR(24);
|
---|
251 | cr_unpackDispatch.GetAttachedShaders(program, maxCount, NULL, NULL);
|
---|
252 | }
|
---|
253 |
|
---|
254 | void crUnpackExtendGetAttachedObjectsARB(void)
|
---|
255 | {
|
---|
256 | GLhandleARB containerObj = READ_DATA(8, GLhandleARB);
|
---|
257 | GLsizei maxCount = READ_DATA(12, GLsizei);
|
---|
258 | SET_RETURN_PTR(16);
|
---|
259 | SET_WRITEBACK_PTR(24);
|
---|
260 | cr_unpackDispatch.GetAttachedObjectsARB(containerObj, maxCount, NULL, NULL);
|
---|
261 | }
|
---|
262 |
|
---|
263 | void crUnpackExtendGetInfoLogARB(void)
|
---|
264 | {
|
---|
265 | GLhandleARB obj = READ_DATA(8, GLhandleARB);
|
---|
266 | GLsizei maxLength = READ_DATA(12, GLsizei);
|
---|
267 | SET_RETURN_PTR(16);
|
---|
268 | SET_WRITEBACK_PTR(24);
|
---|
269 | cr_unpackDispatch.GetInfoLogARB(obj, maxLength, NULL, NULL);
|
---|
270 | }
|
---|
271 |
|
---|
272 | void crUnpackExtendGetProgramInfoLog(void)
|
---|
273 | {
|
---|
274 | GLuint program = READ_DATA(8, GLuint);
|
---|
275 | GLsizei bufSize = READ_DATA(12, GLsizei);
|
---|
276 | SET_RETURN_PTR(16);
|
---|
277 | SET_WRITEBACK_PTR(24);
|
---|
278 | cr_unpackDispatch.GetProgramInfoLog(program, bufSize, NULL, NULL);
|
---|
279 | }
|
---|
280 |
|
---|
281 | void crUnpackExtendGetShaderInfoLog(void)
|
---|
282 | {
|
---|
283 | GLuint shader = READ_DATA(8, GLuint);
|
---|
284 | GLsizei bufSize = READ_DATA(12, GLsizei);
|
---|
285 | SET_RETURN_PTR(16);
|
---|
286 | SET_WRITEBACK_PTR(24);
|
---|
287 | cr_unpackDispatch.GetShaderInfoLog(shader, bufSize, NULL, NULL);
|
---|
288 | }
|
---|
289 |
|
---|
290 | void crUnpackExtendGetShaderSource(void)
|
---|
291 | {
|
---|
292 | GLuint shader = READ_DATA(8, GLuint);
|
---|
293 | GLsizei bufSize = READ_DATA(12, GLsizei);
|
---|
294 | SET_RETURN_PTR(16);
|
---|
295 | SET_WRITEBACK_PTR(24);
|
---|
296 | cr_unpackDispatch.GetShaderSource(shader, bufSize, NULL, NULL);
|
---|
297 | }
|
---|
298 |
|
---|
299 | void crUnpackExtendGetAttribLocation(void)
|
---|
300 | {
|
---|
301 | int packet_length = READ_DATA(0, int);
|
---|
302 | GLuint program = READ_DATA(8, GLuint);
|
---|
303 | const char *name = DATA_POINTER(12, const char);
|
---|
304 | SET_RETURN_PTR(packet_length-16);
|
---|
305 | SET_WRITEBACK_PTR(packet_length-8);
|
---|
306 | cr_unpackDispatch.GetAttribLocation(program, name);
|
---|
307 | }
|
---|
308 |
|
---|
309 | void crUnpackExtendGetUniformLocation(void)
|
---|
310 | {
|
---|
311 | int packet_length = READ_DATA(0, int);
|
---|
312 | GLuint program = READ_DATA(8, GLuint);
|
---|
313 | const char *name = DATA_POINTER(12, const char);
|
---|
314 | SET_RETURN_PTR(packet_length-16);
|
---|
315 | SET_WRITEBACK_PTR(packet_length-8);
|
---|
316 | cr_unpackDispatch.GetUniformLocation(program, name);
|
---|
317 | }
|
---|
318 |
|
---|
319 | void crUnpackExtendGetUniformsLocations(void)
|
---|
320 | {
|
---|
321 | GLuint program = READ_DATA(8, GLuint);
|
---|
322 | GLsizei maxcbData = READ_DATA(12, GLsizei);
|
---|
323 | SET_RETURN_PTR(16);
|
---|
324 | SET_WRITEBACK_PTR(24);
|
---|
325 | cr_unpackDispatch.GetUniformsLocations(program, maxcbData, NULL, NULL);
|
---|
326 | }
|
---|