VirtualBox

source: vbox/trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_program.cpp@ 78264

Last change on this file since 78264 was 78263, checked in by vboxsync, 6 years ago

Config.kmk,GuestHost\OpenGL,HostServices\SharedOpenGL: Fix a bunch of compiler warnings and enable them again

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 14.7 KB
Line 
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
14void crUnpackExtendProgramParameter4dvNV(PCrUnpackerState pState)
15{
16 CHECK_BUFFER_SIZE_STATIC_LAST(pState, 40, GLdouble);
17
18 GLenum target = READ_DATA(pState, 8, GLenum);
19 GLuint index = READ_DATA(pState, 12, GLuint);
20 GLdouble params[4];
21 params[0] = READ_DOUBLE(pState, 16);
22 params[1] = READ_DOUBLE(pState, 24);
23 params[2] = READ_DOUBLE(pState, 32);
24 params[3] = READ_DOUBLE(pState, 40);
25 pState->pDispatchTbl->ProgramParameter4dvNV(target, index, params);
26}
27
28
29void crUnpackExtendProgramParameter4fvNV(PCrUnpackerState pState)
30{
31 CHECK_BUFFER_SIZE_STATIC_LAST(pState, 28, GLfloat);
32
33 GLenum target = READ_DATA(pState, 8, GLenum);
34 GLuint index = READ_DATA(pState, 12, GLuint);
35 GLfloat params[4];
36 params[0] = READ_DATA(pState, 16, GLfloat);
37 params[1] = READ_DATA(pState, 20, GLfloat);
38 params[2] = READ_DATA(pState, 24, GLfloat);
39 params[3] = READ_DATA(pState, 28, GLfloat);
40 pState->pDispatchTbl->ProgramParameter4fvNV(target, index, params);
41}
42
43
44void crUnpackExtendProgramParameters4dvNV(PCrUnpackerState pState)
45{
46 CHECK_BUFFER_SIZE_STATIC_LAST(pState, 16, GLuint);
47
48 GLenum target = READ_DATA(pState, 8, GLenum);
49 GLuint index = READ_DATA(pState, 12, GLuint);
50 GLuint num = READ_DATA(pState, 16, GLuint);
51
52 if (num <= 0 || num >= INT32_MAX / (4 * sizeof(GLdouble)))
53 {
54 crError("crUnpackExtendProgramParameters4dvNV: parameter 'num' is out of range");
55 pState->rcUnpack = VERR_INVALID_PARAMETER;
56 return;
57 }
58
59 GLdouble *params = DATA_POINTER(pState, 20, GLdouble);
60 CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, 4 * num, GLdouble);
61
62 pState->pDispatchTbl->ProgramParameters4dvNV(target, index, num, params);
63}
64
65
66void crUnpackExtendProgramParameters4fvNV(PCrUnpackerState pState)
67{
68 CHECK_BUFFER_SIZE_STATIC_LAST(pState, 16, GLuint);
69
70 GLenum target = READ_DATA(pState, 8, GLenum);
71 GLuint index = READ_DATA(pState, 12, GLuint);
72 GLuint num = READ_DATA(pState, 16, GLuint);
73
74 if (num <= 0 || num >= INT32_MAX / (4 * sizeof(GLfloat)))
75 {
76 crError("crUnpackExtendProgramParameters4fvNV: parameter 'num' is out of range");
77 pState->rcUnpack = VERR_INVALID_PARAMETER;
78 return;
79 }
80
81 GLfloat *params = DATA_POINTER(pState, 20, GLfloat);
82 CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, 4 * num, GLfloat);
83
84 pState->pDispatchTbl->ProgramParameters4fvNV(target, index, num, params);
85}
86
87
88void crUnpackExtendAreProgramsResidentNV(PCrUnpackerState pState)
89{
90 CHECK_BUFFER_SIZE_STATIC_LAST(pState, 8, GLsizei);
91 GLsizei n = READ_DATA(pState, 8, GLsizei);
92 const GLuint *programs = DATA_POINTER(pState, 12, const GLuint);
93
94 if (n <= 0 || n >= INT32_MAX / sizeof(GLuint) / 4 || !DATA_POINTER_CHECK(pState, 20 + n * sizeof(GLuint)))
95 {
96 crError("crUnpackExtendAreProgramsResidentNV: %d is out of range", n);
97 pState->rcUnpack = VERR_INVALID_PARAMETER;
98 return;
99 }
100 CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, programs, n, GLuint);
101 CHECK_BUFFER_SIZE_STATIC_UPDATE_LAST(pState, 20 + n * sizeof(GLuint), CRNetworkPointer);
102
103 SET_RETURN_PTR(pState, 12 + n * sizeof(GLuint));
104 SET_WRITEBACK_PTR(pState, 20 + n * sizeof(GLuint));
105 (void) pState->pDispatchTbl->AreProgramsResidentNV(n, programs, NULL);
106}
107
108
109void crUnpackExtendLoadProgramNV(PCrUnpackerState pState)
110{
111 CHECK_BUFFER_SIZE_STATIC_LAST(pState, 16, GLsizei);
112
113 GLenum target = READ_DATA(pState, 8, GLenum);
114 GLuint id = READ_DATA(pState, 12, GLuint);
115 GLsizei len = READ_DATA(pState, 16, GLsizei);
116
117 GLvoid *program = DATA_POINTER(pState, 20, GLvoid);
118 CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, program, len, GLubyte);
119 pState->pDispatchTbl->LoadProgramNV(target, id, len, (GLubyte *)program);
120}
121
122
123void crUnpackExtendExecuteProgramNV(PCrUnpackerState pState)
124{
125 CHECK_BUFFER_SIZE_STATIC_LAST(pState, 20, GLfloat);
126
127 GLenum target = READ_DATA(pState, 8, GLenum);
128 GLuint id = READ_DATA(pState, 12, GLuint);
129 GLfloat params[4];
130 params[0] = READ_DATA(pState, 16, GLfloat);
131 params[1] = READ_DATA(pState, 20, GLfloat);
132 params[2] = READ_DATA(pState, 24, GLfloat);
133 params[3] = READ_DATA(pState, 28, GLfloat);
134 pState->pDispatchTbl->ExecuteProgramNV(target, id, params);
135}
136
137void crUnpackExtendRequestResidentProgramsNV(PCrUnpackerState pState)
138{
139 CHECK_BUFFER_SIZE_STATIC_LAST(pState, 8, GLsizei);
140
141 GLsizei n = READ_DATA(pState, 8, GLsizei);
142 crError("RequestResidentProgramsNV needs to be special cased!");
143 pState->pDispatchTbl->RequestResidentProgramsNV(n, NULL);
144}
145
146
147void crUnpackExtendProgramLocalParameter4fvARB(PCrUnpackerState pState)
148{
149 CHECK_BUFFER_SIZE_STATIC_LAST(pState, 28, GLfloat);
150
151 GLenum target = READ_DATA(pState, 8, GLenum);
152 GLuint index = READ_DATA(pState, 12, GLuint);
153 GLfloat params[4];
154 params[0] = READ_DATA(pState, 16, GLfloat);
155 params[1] = READ_DATA(pState, 20, GLfloat);
156 params[2] = READ_DATA(pState, 24, GLfloat);
157 params[3] = READ_DATA(pState, 28, GLfloat);
158 pState->pDispatchTbl->ProgramLocalParameter4fvARB(target, index, params);
159}
160
161
162void crUnpackExtendProgramLocalParameter4dvARB(PCrUnpackerState pState)
163{
164 CHECK_BUFFER_SIZE_STATIC_LAST(pState, 40, GLdouble);
165
166 GLenum target = READ_DATA(pState, 8, GLenum);
167 GLuint index = READ_DATA(pState, 12, GLuint);
168 GLdouble params[4];
169 params[0] = READ_DOUBLE(pState, 16);
170 params[1] = READ_DOUBLE(pState, 24);
171 params[2] = READ_DOUBLE(pState, 32);
172 params[3] = READ_DOUBLE(pState, 40);
173 pState->pDispatchTbl->ProgramLocalParameter4dvARB(target, index, params);
174}
175
176
177
178void crUnpackExtendProgramNamedParameter4dvNV(PCrUnpackerState pState)
179{
180 CHECK_BUFFER_SIZE_STATIC_LAST(pState, 40, GLdouble);
181
182 GLuint id = READ_DATA(pState, 8, GLuint);
183 GLsizei len = READ_DATA(pState, 12, GLsizei);
184 GLdouble *params = DATA_POINTER(pState, 16, GLdouble);
185 GLubyte *name = DATA_POINTER(pState, 48, GLubyte);
186 CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, name, len, GLubyte);
187 pState->pDispatchTbl->ProgramNamedParameter4dvNV(id, len, name, params);
188}
189
190void crUnpackExtendProgramNamedParameter4dNV(PCrUnpackerState pState)
191{
192 CHECK_BUFFER_SIZE_STATIC_LAST(pState, 40, GLdouble);
193
194 GLuint id = READ_DATA(pState, 8, GLuint);
195 GLsizei len = READ_DATA(pState, 12, GLsizei);
196 GLdouble params[4];
197 params[0] = READ_DOUBLE(pState, 16);
198 params[1] = READ_DOUBLE(pState, 24);
199 params[2] = READ_DOUBLE(pState, 32);
200 params[3] = READ_DOUBLE(pState, 40);
201
202 GLubyte *name = DATA_POINTER(pState, 48, GLubyte);
203 CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, name, len, GLubyte);
204 pState->pDispatchTbl->ProgramNamedParameter4dNV(id, len, name, params[0], params[1], params[2], params[3]);
205}
206
207void crUnpackExtendProgramNamedParameter4fNV(PCrUnpackerState pState)
208{
209 CHECK_BUFFER_SIZE_STATIC_LAST(pState, 28, GLfloat);
210
211 GLenum id = READ_DATA(pState, 8, GLuint);
212 GLsizei len = READ_DATA(pState, 12, GLsizei);
213 GLfloat params[4];
214 params[0] = READ_DATA(pState, 16, GLfloat);
215 params[1] = READ_DATA(pState, 20, GLfloat);
216 params[2] = READ_DATA(pState, 24, GLfloat);
217 params[3] = READ_DATA(pState, 28, GLfloat);
218
219 GLubyte *name = DATA_POINTER(pState, 32, GLubyte);
220 CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, name, len, GLubyte);
221 pState->pDispatchTbl->ProgramNamedParameter4fNV(id, len, name, params[0], params[1], params[2], params[3]);
222}
223
224void crUnpackExtendProgramNamedParameter4fvNV(PCrUnpackerState pState)
225{
226 CHECK_BUFFER_SIZE_STATIC_LAST(pState, 28, GLfloat);
227
228 GLenum id = READ_DATA(pState, 8, GLuint);
229 GLsizei len = READ_DATA(pState, 12, GLsizei);
230 GLfloat *params = DATA_POINTER(pState, 16, GLfloat);
231 GLubyte *name = DATA_POINTER(pState, 32, GLubyte);
232
233 CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, name, len, GLubyte);
234 pState->pDispatchTbl->ProgramNamedParameter4fvNV(id, len, name, params);
235}
236
237void crUnpackExtendGetProgramNamedParameterdvNV(PCrUnpackerState pState)
238{
239 CHECK_BUFFER_SIZE_STATIC_LAST(pState, 12, GLsizei);
240
241 GLuint id = READ_DATA(pState, 8, GLuint);
242 GLsizei len = READ_DATA(pState, 12, GLsizei);
243 const GLubyte *name = DATA_POINTER(pState, 16, GLubyte);
244
245 if (len <= 0 || len >= INT32_MAX / 4)
246 {
247 crError("crUnpackExtendGetProgramNamedParameterdvNV: len %d is out of range", len);
248 pState->rcUnpack = VERR_INVALID_PARAMETER;
249 return;
250 }
251 CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, name, len, GLubyte);
252 CHECK_BUFFER_SIZE_STATIC_UPDATE_LAST(pState, 16 + len + sizeof(CRNetworkPointer), CRNetworkPointer);
253
254 SET_RETURN_PTR(pState, 16+len);
255 SET_WRITEBACK_PTR(pState, 16+len+8);
256 pState->pDispatchTbl->GetProgramNamedParameterdvNV(id, len, name, NULL);
257}
258
259void crUnpackExtendGetProgramNamedParameterfvNV(PCrUnpackerState pState)
260{
261 CHECK_BUFFER_SIZE_STATIC_LAST(pState, 12, GLsizei);
262
263 GLuint id = READ_DATA(pState, 8, GLuint);
264 GLsizei len = READ_DATA(pState, 12, GLsizei);
265 const GLubyte *name = DATA_POINTER(pState, 16, GLubyte);
266
267 if (len <= 0 || len >= INT32_MAX / 4)
268 {
269 crError("crUnpackExtendGetProgramNamedParameterfvNV: len %d is out of range", len);
270 pState->rcUnpack = VERR_INVALID_PARAMETER;
271 return;
272 }
273
274 CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, name, len, GLubyte);
275 CHECK_BUFFER_SIZE_STATIC_UPDATE_LAST(pState, 16 + len + sizeof(CRNetworkPointer), CRNetworkPointer);
276 SET_RETURN_PTR(pState, 16+len);
277 SET_WRITEBACK_PTR(pState, 16+len+8);
278 pState->pDispatchTbl->GetProgramNamedParameterfvNV(id, len, name, NULL);
279}
280
281void crUnpackExtendProgramStringARB(PCrUnpackerState pState)
282{
283 CHECK_BUFFER_SIZE_STATIC_LAST(pState, 16, GLsizei);
284
285 GLenum target = READ_DATA(pState, 8, GLenum);
286 GLenum format = READ_DATA(pState, 12, GLuint);
287 GLsizei len = READ_DATA(pState, 16, GLsizei);
288 GLvoid *program = DATA_POINTER(pState, 20, GLvoid);
289
290 CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, program, len, GLubyte);
291 pState->pDispatchTbl->ProgramStringARB(target, format, len, program);
292}
293
294void crUnpackExtendGetProgramStringARB(PCrUnpackerState pState)
295{
296 RT_NOREF(pState);
297}
298
299void crUnpackExtendProgramEnvParameter4dvARB(PCrUnpackerState pState)
300{
301 CHECK_BUFFER_SIZE_STATIC_LAST(pState, 40, GLdouble);
302
303 GLenum target = READ_DATA(pState, 8, GLenum);
304 GLuint index = READ_DATA(pState, 12, GLuint);
305 GLdouble params[4];
306 params[0] = READ_DOUBLE(pState, 16);
307 params[1] = READ_DOUBLE(pState, 24);
308 params[2] = READ_DOUBLE(pState, 32);
309 params[3] = READ_DOUBLE(pState, 40);
310 pState->pDispatchTbl->ProgramEnvParameter4dvARB(target, index, params);
311}
312
313void crUnpackExtendProgramEnvParameter4fvARB(PCrUnpackerState pState)
314{
315 CHECK_BUFFER_SIZE_STATIC_LAST(pState, 28, GLfloat);
316
317 GLenum target = READ_DATA(pState, 8, GLenum);
318 GLuint index = READ_DATA(pState, 12, GLuint);
319 GLfloat params[4];
320 params[0] = READ_DATA(pState, 16, GLfloat);
321 params[1] = READ_DATA(pState, 20, GLfloat);
322 params[2] = READ_DATA(pState, 24, GLfloat);
323 params[3] = READ_DATA(pState, 28, GLfloat);
324 pState->pDispatchTbl->ProgramEnvParameter4fvARB(target, index, params);
325}
326
327void crUnpackExtendDeleteProgramsARB(PCrUnpackerState pState)
328{
329 CHECK_BUFFER_SIZE_STATIC_LAST(pState, 8, GLsizei);
330
331 GLsizei n = READ_DATA(pState, 8, GLsizei);
332 const GLuint *programs = DATA_POINTER(pState, 12, GLuint);
333
334 CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, programs, n, GLuint);
335 pState->pDispatchTbl->DeleteProgramsARB(n, programs);
336}
337
338void crUnpackVertexAttrib4NbvARB(PCrUnpackerState pState)
339{
340 CHECK_BUFFER_SIZE_STATIC(pState, 8);
341
342 GLuint index = READ_DATA(pState, 0, GLuint);
343 const GLbyte *v = DATA_POINTER(pState, 4, const GLbyte);
344
345 pState->pDispatchTbl->VertexAttrib4NbvARB(index, v);
346 INCR_DATA_PTR(pState, 8);
347}
348
349void crUnpackVertexAttrib4NivARB(PCrUnpackerState pState)
350{
351 CHECK_BUFFER_SIZE_STATIC(pState, 20);
352
353 GLuint index = READ_DATA(pState, 0, GLuint);
354 const GLint *v = DATA_POINTER(pState, 4, const GLint);
355
356 pState->pDispatchTbl->VertexAttrib4NivARB(index, v);
357 INCR_DATA_PTR(pState, 20);
358}
359
360void crUnpackVertexAttrib4NsvARB(PCrUnpackerState pState)
361{
362 CHECK_BUFFER_SIZE_STATIC(pState, 12);
363
364 GLuint index = READ_DATA(pState, 0, GLuint);
365 const GLshort *v = DATA_POINTER(pState, 4, const GLshort);
366
367 pState->pDispatchTbl->VertexAttrib4NsvARB(index, v);
368 INCR_DATA_PTR(pState, 12);
369}
370
371void crUnpackVertexAttrib4NubvARB(PCrUnpackerState pState)
372{
373 CHECK_BUFFER_SIZE_STATIC(pState, 8);
374
375 GLuint index = READ_DATA(pState, 0, GLuint);
376 const GLubyte *v = DATA_POINTER(pState, 4, const GLubyte);
377
378 pState->pDispatchTbl->VertexAttrib4NubvARB(index, v);
379 INCR_DATA_PTR(pState, 8);
380}
381
382void crUnpackVertexAttrib4NuivARB(PCrUnpackerState pState)
383{
384 CHECK_BUFFER_SIZE_STATIC(pState, 20);
385
386 GLuint index = READ_DATA(pState, 0, GLuint);
387 const GLuint *v = DATA_POINTER(pState, 4, const GLuint);
388
389 pState->pDispatchTbl->VertexAttrib4NuivARB(index, v);
390 INCR_DATA_PTR(pState, 20);
391}
392
393void crUnpackVertexAttrib4NusvARB(PCrUnpackerState pState)
394{
395 CHECK_BUFFER_SIZE_STATIC(pState, 12);
396
397 GLuint index = READ_DATA(pState, 0, GLuint);
398 const GLushort *v = DATA_POINTER(pState, 4, const GLushort);
399
400 pState->pDispatchTbl->VertexAttrib4NusvARB(index, v);
401 INCR_DATA_PTR(pState, 12);
402}
403
404void crUnpackVertexAttrib4bvARB(PCrUnpackerState pState)
405{
406 CHECK_BUFFER_SIZE_STATIC(pState, 8);
407
408 GLuint index = READ_DATA(pState, 0, GLuint);
409 const GLbyte *v = DATA_POINTER(pState, 4, const GLbyte);
410
411 pState->pDispatchTbl->VertexAttrib4bvARB(index, v);
412 INCR_DATA_PTR(pState, 8);
413}
414
415void crUnpackVertexAttrib4ivARB(PCrUnpackerState pState)
416{
417 CHECK_BUFFER_SIZE_STATIC(pState, 20);
418
419 GLuint index = READ_DATA(pState, 0, GLuint);
420 const GLint *v = DATA_POINTER(pState, 4, const GLint);
421
422 pState->pDispatchTbl->VertexAttrib4ivARB(index, v);
423 INCR_DATA_PTR(pState, 20);
424}
425
426void crUnpackVertexAttrib4ubvARB(PCrUnpackerState pState)
427{
428 CHECK_BUFFER_SIZE_STATIC(pState, 8);
429
430 GLuint index = READ_DATA(pState, 0, GLuint);
431 const GLubyte *v = DATA_POINTER(pState, 4, const GLubyte);
432
433 pState->pDispatchTbl->VertexAttrib4ubvARB(index, v);
434 INCR_DATA_PTR(pState, 8);
435}
436
437void crUnpackVertexAttrib4uivARB(PCrUnpackerState pState)
438{
439 CHECK_BUFFER_SIZE_STATIC(pState, 20);
440
441 GLuint index = READ_DATA(pState, 0, GLuint);
442 const GLuint *v = DATA_POINTER(pState, 4, const GLuint);
443
444 pState->pDispatchTbl->VertexAttrib4uivARB(index, v);
445 INCR_DATA_PTR(pState, 20);
446}
447
448void crUnpackVertexAttrib4usvARB(PCrUnpackerState pState)
449{
450 CHECK_BUFFER_SIZE_STATIC(pState, 12);
451
452 GLuint index = READ_DATA(pState, 0, GLuint);
453 const GLushort *v = DATA_POINTER(pState, 4, const GLushort);
454
455 pState->pDispatchTbl->VertexAttrib4usvARB(index, v);
456 INCR_DATA_PTR(pState, 12);
457}
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