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