1 | /* Copyright (c) 2001, Stanford University
|
---|
2 | * All rights reserved
|
---|
3 | *
|
---|
4 | * See the file LICENSE.txt for information on redistributing this software.
|
---|
5 | */
|
---|
6 |
|
---|
7 | #include "unpacker.h"
|
---|
8 | #include "cr_error.h"
|
---|
9 | #include "cr_protocol.h"
|
---|
10 | #include "cr_mem.h"
|
---|
11 | #include "cr_version.h"
|
---|
12 |
|
---|
13 |
|
---|
14 | void crUnpackExtendProgramParameter4dvNV(void)
|
---|
15 | {
|
---|
16 | GLenum target = READ_DATA(8, GLenum);
|
---|
17 | GLuint index = READ_DATA(12, GLuint);
|
---|
18 | GLdouble params[4];
|
---|
19 | params[0] = READ_DOUBLE(16);
|
---|
20 | params[1] = READ_DOUBLE(24);
|
---|
21 | params[2] = READ_DOUBLE(32);
|
---|
22 | params[3] = READ_DOUBLE(40);
|
---|
23 | cr_unpackDispatch.ProgramParameter4dvNV(target, index, params);
|
---|
24 | }
|
---|
25 |
|
---|
26 |
|
---|
27 | void crUnpackExtendProgramParameter4fvNV(void)
|
---|
28 | {
|
---|
29 | GLenum target = READ_DATA(8, GLenum);
|
---|
30 | GLuint index = READ_DATA(12, GLuint);
|
---|
31 | GLfloat params[4];
|
---|
32 | params[0] = READ_DATA(16, GLfloat);
|
---|
33 | params[1] = READ_DATA(20, GLfloat);
|
---|
34 | params[2] = READ_DATA(24, GLfloat);
|
---|
35 | params[3] = READ_DATA(28, GLfloat);
|
---|
36 | cr_unpackDispatch.ProgramParameter4fvNV(target, index, params);
|
---|
37 | }
|
---|
38 |
|
---|
39 |
|
---|
40 | void crUnpackExtendProgramParameters4dvNV(void)
|
---|
41 | {
|
---|
42 | GLenum target = READ_DATA(8, GLenum);
|
---|
43 | GLuint index = READ_DATA(12, GLuint);
|
---|
44 | GLuint num = READ_DATA(16, GLuint);
|
---|
45 | GLdouble *params;
|
---|
46 |
|
---|
47 | if (num <= 0 || num >= INT32_MAX / (4 * sizeof(GLdouble)))
|
---|
48 | {
|
---|
49 | crError("crUnpackExtendProgramParameters4dvNV: parameter 'num' is out of range");
|
---|
50 | return;
|
---|
51 | }
|
---|
52 |
|
---|
53 | params = (GLdouble *)crAlloc(num * 4 * sizeof(GLdouble));
|
---|
54 |
|
---|
55 | if (params) {
|
---|
56 | GLuint i;
|
---|
57 | for (i = 0; i < 4 * num; i++) {
|
---|
58 | params[i] = READ_DATA(20 + i * sizeof(GLdouble), GLdouble);
|
---|
59 | }
|
---|
60 | cr_unpackDispatch.ProgramParameters4dvNV(target, index, num, params);
|
---|
61 | crFree(params);
|
---|
62 | }
|
---|
63 | }
|
---|
64 |
|
---|
65 |
|
---|
66 | void crUnpackExtendProgramParameters4fvNV(void)
|
---|
67 | {
|
---|
68 | GLenum target = READ_DATA(8, GLenum);
|
---|
69 | GLuint index = READ_DATA(12, GLuint);
|
---|
70 | GLuint num = READ_DATA(16, GLuint);
|
---|
71 | GLfloat *params;
|
---|
72 |
|
---|
73 | if (num <= 0 || num >= INT32_MAX / (4 * sizeof(GLfloat)))
|
---|
74 | {
|
---|
75 | crError("crUnpackExtendProgramParameters4fvNV: parameter 'num' is out of range");
|
---|
76 | return;
|
---|
77 | }
|
---|
78 |
|
---|
79 | params = (GLfloat *)crAlloc(num * 4 * sizeof(GLfloat));
|
---|
80 |
|
---|
81 | if (params) {
|
---|
82 | GLuint i;
|
---|
83 | for (i = 0; i < 4 * num; i++) {
|
---|
84 | params[i] = READ_DATA(20 + i * sizeof(GLfloat), GLfloat);
|
---|
85 | }
|
---|
86 | cr_unpackDispatch.ProgramParameters4fvNV(target, index, num, params);
|
---|
87 | crFree(params);
|
---|
88 | }
|
---|
89 | }
|
---|
90 |
|
---|
91 |
|
---|
92 | void crUnpackExtendAreProgramsResidentNV(void)
|
---|
93 | {
|
---|
94 | GLsizei n = READ_DATA(8, GLsizei);
|
---|
95 | const GLuint *programs = DATA_POINTER(12, const GLuint);
|
---|
96 |
|
---|
97 | if (n <= 0 || n >= INT32_MAX / sizeof(GLuint) / 4 || !DATA_POINTER_CHECK(20 + n * sizeof(GLuint)))
|
---|
98 | {
|
---|
99 | crError("crUnpackExtendAreProgramsResidentNV: %d is out of range", n);
|
---|
100 | return;
|
---|
101 | }
|
---|
102 |
|
---|
103 | SET_RETURN_PTR(12 + n * sizeof(GLuint));
|
---|
104 | SET_WRITEBACK_PTR(20 + n * sizeof(GLuint));
|
---|
105 | (void) cr_unpackDispatch.AreProgramsResidentNV(n, programs, NULL);
|
---|
106 | }
|
---|
107 |
|
---|
108 |
|
---|
109 | void crUnpackExtendLoadProgramNV(void)
|
---|
110 | {
|
---|
111 | GLenum target = READ_DATA(8, GLenum);
|
---|
112 | GLuint id = READ_DATA(12, GLuint);
|
---|
113 | GLsizei len = READ_DATA(16, GLsizei);
|
---|
114 | GLvoid *program = DATA_POINTER(20, GLvoid);
|
---|
115 | cr_unpackDispatch.LoadProgramNV(target, id, len, program);
|
---|
116 | }
|
---|
117 |
|
---|
118 |
|
---|
119 | void crUnpackExtendExecuteProgramNV(void)
|
---|
120 | {
|
---|
121 | GLenum target = READ_DATA(8, GLenum);
|
---|
122 | GLuint id = READ_DATA(12, GLuint);
|
---|
123 | GLfloat params[4];
|
---|
124 | params[0] = READ_DATA(16, GLfloat);
|
---|
125 | params[1] = READ_DATA(20, GLfloat);
|
---|
126 | params[2] = READ_DATA(24, GLfloat);
|
---|
127 | params[3] = READ_DATA(28, GLfloat);
|
---|
128 | cr_unpackDispatch.ExecuteProgramNV(target, id, params);
|
---|
129 | }
|
---|
130 |
|
---|
131 | void crUnpackExtendRequestResidentProgramsNV(void)
|
---|
132 | {
|
---|
133 | GLsizei n = READ_DATA(8, GLsizei);
|
---|
134 | crError("RequestResidentProgramsNV needs to be special cased!");
|
---|
135 | cr_unpackDispatch.RequestResidentProgramsNV(n, NULL);
|
---|
136 | }
|
---|
137 |
|
---|
138 |
|
---|
139 | void crUnpackExtendProgramLocalParameter4fvARB(void)
|
---|
140 | {
|
---|
141 | GLenum target = READ_DATA(8, GLenum);
|
---|
142 | GLuint index = READ_DATA(12, GLuint);
|
---|
143 | GLfloat params[4];
|
---|
144 | params[0] = READ_DATA(16, GLfloat);
|
---|
145 | params[1] = READ_DATA(20, GLfloat);
|
---|
146 | params[2] = READ_DATA(24, GLfloat);
|
---|
147 | params[3] = READ_DATA(28, GLfloat);
|
---|
148 | cr_unpackDispatch.ProgramLocalParameter4fvARB(target, index, params);
|
---|
149 | }
|
---|
150 |
|
---|
151 |
|
---|
152 | void crUnpackExtendProgramLocalParameter4dvARB(void)
|
---|
153 | {
|
---|
154 | GLenum target = READ_DATA(8, GLenum);
|
---|
155 | GLuint index = READ_DATA(12, GLuint);
|
---|
156 | GLdouble params[4];
|
---|
157 | params[0] = READ_DOUBLE(16);
|
---|
158 | params[1] = READ_DOUBLE(24);
|
---|
159 | params[2] = READ_DOUBLE(32);
|
---|
160 | params[3] = READ_DOUBLE(40);
|
---|
161 | cr_unpackDispatch.ProgramLocalParameter4dvARB(target, index, params);
|
---|
162 | }
|
---|
163 |
|
---|
164 |
|
---|
165 |
|
---|
166 | void crUnpackExtendProgramNamedParameter4dvNV(void)
|
---|
167 | {
|
---|
168 | GLuint id = READ_DATA(8, GLuint);
|
---|
169 | GLsizei len = READ_DATA(12, GLsizei);
|
---|
170 | GLdouble params[4];
|
---|
171 | GLubyte *name = crAlloc(len);
|
---|
172 | params[0] = READ_DOUBLE(16);
|
---|
173 | params[1] = READ_DOUBLE(24);
|
---|
174 | params[2] = READ_DOUBLE(32);
|
---|
175 | params[3] = READ_DOUBLE(40);
|
---|
176 | crMemcpy(name, DATA_POINTER(48, GLubyte), len);
|
---|
177 | cr_unpackDispatch.ProgramNamedParameter4dvNV(id, len, name, params);
|
---|
178 | }
|
---|
179 |
|
---|
180 | void crUnpackExtendProgramNamedParameter4dNV(void)
|
---|
181 | {
|
---|
182 | GLuint id = READ_DATA(8, GLuint);
|
---|
183 | GLsizei len = READ_DATA(12, GLsizei);
|
---|
184 | GLdouble params[4];
|
---|
185 | GLubyte *name = crAlloc (len);
|
---|
186 | params[0] = READ_DOUBLE(16);
|
---|
187 | params[1] = READ_DOUBLE(24);
|
---|
188 | params[2] = READ_DOUBLE(32);
|
---|
189 | params[3] = READ_DOUBLE(40);
|
---|
190 | crMemcpy(name, DATA_POINTER(48, GLubyte), len);
|
---|
191 | cr_unpackDispatch.ProgramNamedParameter4dNV(id, len, name, params[0], params[1], params[2], params[3]);
|
---|
192 | }
|
---|
193 |
|
---|
194 | void crUnpackExtendProgramNamedParameter4fNV(void)
|
---|
195 | {
|
---|
196 | GLenum id = READ_DATA(8, GLuint);
|
---|
197 | GLsizei len = READ_DATA(12, GLsizei);
|
---|
198 | GLfloat params[4];
|
---|
199 | GLubyte *name = crAlloc(len);
|
---|
200 | params[0] = READ_DATA(16, GLfloat);
|
---|
201 | params[1] = READ_DATA(20, GLfloat);
|
---|
202 | params[2] = READ_DATA(24, GLfloat);
|
---|
203 | params[3] = READ_DATA(28, GLfloat);
|
---|
204 | crMemcpy(name, DATA_POINTER(32, GLubyte), len);
|
---|
205 | cr_unpackDispatch.ProgramNamedParameter4fNV(id, len, name, params[0], params[1], params[2], params[3]);
|
---|
206 | }
|
---|
207 |
|
---|
208 | void crUnpackExtendProgramNamedParameter4fvNV(void)
|
---|
209 | {
|
---|
210 | GLenum id = READ_DATA(8, GLuint);
|
---|
211 | GLsizei len = READ_DATA(12, GLsizei);
|
---|
212 | GLfloat params[4];
|
---|
213 | GLubyte *name = crAlloc(len);
|
---|
214 | params[0] = READ_DATA(16, GLfloat);
|
---|
215 | params[1] = READ_DATA(20, GLfloat);
|
---|
216 | params[2] = READ_DATA(24, GLfloat);
|
---|
217 | params[3] = READ_DATA(28, GLfloat);
|
---|
218 | crMemcpy(name, DATA_POINTER(32, GLubyte), len);
|
---|
219 | cr_unpackDispatch.ProgramNamedParameter4fvNV(id, len, name, params);
|
---|
220 | }
|
---|
221 |
|
---|
222 | void crUnpackExtendGetProgramNamedParameterdvNV(void)
|
---|
223 | {
|
---|
224 | GLuint id = READ_DATA(8, GLuint);
|
---|
225 | GLsizei len = READ_DATA(12, GLsizei);
|
---|
226 | const GLubyte *name = DATA_POINTER(16, GLubyte);
|
---|
227 |
|
---|
228 | if (len <= 0 || len >= INT32_MAX / 4 || !DATA_POINTER_CHECK(16 + len + 8))
|
---|
229 | {
|
---|
230 | crError("crUnpackExtendGetProgramNamedParameterdvNV: len %d is out of range", len);
|
---|
231 | return;
|
---|
232 | }
|
---|
233 |
|
---|
234 | SET_RETURN_PTR(16+len);
|
---|
235 | SET_WRITEBACK_PTR(16+len+8);
|
---|
236 | cr_unpackDispatch.GetProgramNamedParameterdvNV(id, len, name, NULL);
|
---|
237 | }
|
---|
238 |
|
---|
239 | void crUnpackExtendGetProgramNamedParameterfvNV(void)
|
---|
240 | {
|
---|
241 | GLuint id = READ_DATA(8, GLuint);
|
---|
242 | GLsizei len = READ_DATA(12, GLsizei);
|
---|
243 | const GLubyte *name = DATA_POINTER(16, GLubyte);
|
---|
244 |
|
---|
245 | if (len <= 0 || len >= INT32_MAX / 4 || !DATA_POINTER_CHECK(16 + len + 8))
|
---|
246 | {
|
---|
247 | crError("crUnpackExtendGetProgramNamedParameterfvNV: len %d is out of range", len);
|
---|
248 | return;
|
---|
249 | }
|
---|
250 |
|
---|
251 | SET_RETURN_PTR(16+len);
|
---|
252 | SET_WRITEBACK_PTR(16+len+8);
|
---|
253 | cr_unpackDispatch.GetProgramNamedParameterfvNV(id, len, name, NULL);
|
---|
254 | }
|
---|
255 |
|
---|
256 | void crUnpackExtendProgramStringARB(void)
|
---|
257 | {
|
---|
258 | GLenum target = READ_DATA(8, GLenum);
|
---|
259 | GLenum format = READ_DATA(12, GLuint);
|
---|
260 | GLsizei len = READ_DATA(16, GLsizei);
|
---|
261 | GLvoid *program = DATA_POINTER(20, GLvoid);
|
---|
262 | cr_unpackDispatch.ProgramStringARB(target, format, len, program);
|
---|
263 | }
|
---|
264 |
|
---|
265 | void crUnpackExtendGetProgramStringARB(void)
|
---|
266 | {
|
---|
267 | }
|
---|
268 |
|
---|
269 | void crUnpackExtendProgramEnvParameter4dvARB(void)
|
---|
270 | {
|
---|
271 | GLenum target = READ_DATA(8, GLenum);
|
---|
272 | GLuint index = READ_DATA(12, GLuint);
|
---|
273 | GLdouble params[4];
|
---|
274 | params[0] = READ_DOUBLE(16);
|
---|
275 | params[1] = READ_DOUBLE(24);
|
---|
276 | params[2] = READ_DOUBLE(32);
|
---|
277 | params[3] = READ_DOUBLE(40);
|
---|
278 | cr_unpackDispatch.ProgramEnvParameter4dvARB(target, index, params);
|
---|
279 | }
|
---|
280 |
|
---|
281 | void crUnpackExtendProgramEnvParameter4fvARB(void)
|
---|
282 | {
|
---|
283 | GLenum target = READ_DATA(8, GLenum);
|
---|
284 | GLuint index = READ_DATA(12, GLuint);
|
---|
285 | GLfloat params[4];
|
---|
286 | params[0] = READ_DATA(16, GLfloat);
|
---|
287 | params[1] = READ_DATA(20, GLfloat);
|
---|
288 | params[2] = READ_DATA(24, GLfloat);
|
---|
289 | params[3] = READ_DATA(28, GLfloat);
|
---|
290 | cr_unpackDispatch.ProgramEnvParameter4fvARB(target, index, params);
|
---|
291 | }
|
---|
292 |
|
---|
293 | void crUnpackExtendDeleteProgramsARB(void)
|
---|
294 | {
|
---|
295 | GLsizei n = READ_DATA(8, GLsizei);
|
---|
296 | const GLuint *programs = DATA_POINTER(12, GLuint);
|
---|
297 | cr_unpackDispatch.DeleteProgramsARB(n, programs);
|
---|
298 | }
|
---|
299 |
|
---|
300 | void crUnpackVertexAttrib4NbvARB(void)
|
---|
301 | {
|
---|
302 | GLuint index = READ_DATA(0, GLuint);
|
---|
303 | const GLbyte *v = DATA_POINTER(4, const GLbyte);
|
---|
304 | cr_unpackDispatch.VertexAttrib4NbvARB(index, v);
|
---|
305 | INCR_DATA_PTR(8);
|
---|
306 | }
|
---|
307 |
|
---|
308 | void crUnpackVertexAttrib4NivARB(void)
|
---|
309 | {
|
---|
310 | GLuint index = READ_DATA(0, GLuint);
|
---|
311 | const GLint *v = DATA_POINTER(4, const GLint);
|
---|
312 | cr_unpackDispatch.VertexAttrib4NivARB(index, v);
|
---|
313 | INCR_DATA_PTR(20);
|
---|
314 | }
|
---|
315 |
|
---|
316 | void crUnpackVertexAttrib4NsvARB(void)
|
---|
317 | {
|
---|
318 | GLuint index = READ_DATA(0, GLuint);
|
---|
319 | const GLshort *v = DATA_POINTER(4, const GLshort);
|
---|
320 | cr_unpackDispatch.VertexAttrib4NsvARB(index, v);
|
---|
321 | INCR_DATA_PTR(12);
|
---|
322 | }
|
---|
323 |
|
---|
324 | void crUnpackVertexAttrib4NubvARB(void)
|
---|
325 | {
|
---|
326 | GLuint index = READ_DATA(0, GLuint);
|
---|
327 | const GLubyte *v = DATA_POINTER(4, const GLubyte);
|
---|
328 | cr_unpackDispatch.VertexAttrib4NubvARB(index, v);
|
---|
329 | INCR_DATA_PTR(8);
|
---|
330 | }
|
---|
331 |
|
---|
332 | void crUnpackVertexAttrib4NuivARB(void)
|
---|
333 | {
|
---|
334 | GLuint index = READ_DATA(0, GLuint);
|
---|
335 | const GLuint *v = DATA_POINTER(4, const GLuint);
|
---|
336 | cr_unpackDispatch.VertexAttrib4NuivARB(index, v);
|
---|
337 | INCR_DATA_PTR(20);
|
---|
338 | }
|
---|
339 |
|
---|
340 | void crUnpackVertexAttrib4NusvARB(void)
|
---|
341 | {
|
---|
342 | GLuint index = READ_DATA(0, GLuint);
|
---|
343 | const GLushort *v = DATA_POINTER(4, const GLushort);
|
---|
344 | cr_unpackDispatch.VertexAttrib4NusvARB(index, v);
|
---|
345 | INCR_DATA_PTR(12);
|
---|
346 | }
|
---|
347 |
|
---|
348 | void crUnpackVertexAttrib4bvARB(void)
|
---|
349 | {
|
---|
350 | GLuint index = READ_DATA(0, GLuint);
|
---|
351 | const GLbyte *v = DATA_POINTER(4, const GLbyte);
|
---|
352 | cr_unpackDispatch.VertexAttrib4bvARB(index, v);
|
---|
353 | INCR_DATA_PTR(8);
|
---|
354 | }
|
---|
355 |
|
---|
356 | void crUnpackVertexAttrib4ivARB(void)
|
---|
357 | {
|
---|
358 | GLuint index = READ_DATA(0, GLuint);
|
---|
359 | const GLint *v = DATA_POINTER(4, const GLint);
|
---|
360 | cr_unpackDispatch.VertexAttrib4ivARB(index, v);
|
---|
361 | INCR_DATA_PTR(20);
|
---|
362 | }
|
---|
363 |
|
---|
364 | void crUnpackVertexAttrib4ubvARB(void)
|
---|
365 | {
|
---|
366 | GLuint index = READ_DATA(0, GLuint);
|
---|
367 | const GLubyte *v = DATA_POINTER(4, const GLubyte);
|
---|
368 | cr_unpackDispatch.VertexAttrib4ubvARB(index, v);
|
---|
369 | INCR_DATA_PTR(8);
|
---|
370 | }
|
---|
371 |
|
---|
372 | void crUnpackVertexAttrib4uivARB(void)
|
---|
373 | {
|
---|
374 | GLuint index = READ_DATA(0, GLuint);
|
---|
375 | const GLuint *v = DATA_POINTER(4, const GLuint);
|
---|
376 | cr_unpackDispatch.VertexAttrib4uivARB(index, v);
|
---|
377 | INCR_DATA_PTR(20);
|
---|
378 | }
|
---|
379 |
|
---|
380 | void crUnpackVertexAttrib4usvARB(void)
|
---|
381 | {
|
---|
382 | GLuint index = READ_DATA(0, GLuint);
|
---|
383 | const GLushort *v = DATA_POINTER(4, const GLushort);
|
---|
384 | cr_unpackDispatch.VertexAttrib4usvARB(index, v);
|
---|
385 | INCR_DATA_PTR(12);
|
---|
386 | }
|
---|