VirtualBox

source: vbox/trunk/src/VBox/HostServices/SharedOpenGL/dlm/dlm_pointers.c@ 64572

最後變更 在這個檔案從64572是 54905,由 vboxsync 提交於 10 年 前

Host 3D: Chromium server: add Expando SPU and DLM module in order to record and save OpenGL Display Lists (currently disabled).

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 36.5 KB
 
1/* $Id: dlm_pointers.c 54905 2015-03-23 11:20:58Z vboxsync $ */
2#include "cr_dlm.h"
3#include "cr_mem.h"
4#include "cr_pixeldata.h"
5#include "cr_string.h"
6#include "dlm.h"
7#include "dlm_pointers.h"
8
9/**
10 * These helper functions are used for GL functions that take a pointers,
11 * if the size of the arrays that the pointers refer to is not constant.
12 * These helper functions will determine, on a case-by-case basis,
13 * how much space is needed to store the array. If the buffer
14 * parameter is not NULL, they will also pack the data into the given
15 * array.
16 *
17 * Many of the functions included deal with pixel state (Bitmap, DrawPixels,
18 * etc.). In all these cases, when the function instance is stored in a
19 * display list, its data is read from memory (as per the parameters
20 * to PixelStore) and is stored in a tightly packed format (with no
21 * excess row length, no pixels skipped, no rows, skipped, and a byte
22 * alignment).
23 *
24 * When the instances are executed again, care must be taken to ensure
25 * that the PixelStore client state that unpacks them is set to reflect
26 * the tight packing actually used, instead of whatever the current
27 * client state indicates.
28 *
29 * So to do this, client PixelStore state is forced to known values
30 * before any instances in the display list are executed. The client
31 * state is then restored to known values afterwards. (The difficulty
32 * of this is somewhat mollified by the observation that PixelStore
33 * instances affect client state, and cannot be stored in a display list.)
34 *
35 */
36
37int crdlm_pointers_Bitmap( struct instanceBitmap *instance, GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap, CRClientState *c)
38{
39 unsigned int size = ((int)((width + 7) / 8)) * height;
40 /* glBitmap can be called with a NULL size 0 bitmap, say for
41 * an empty glyph that only moves the current raster position.
42 * crMemcpy will raise an exception with a NULL source pointer, even if
43 * the size to copy is 0. So make sure we don't ram into this.
44 * Also, the bitmap isn't necessarily just sitting in memory; the PixelStore
45 * client-side state affects how it is read from memory. It's easiest to just
46 * use the utility.
47 */
48 if (instance && size > 0) {
49 crBitmapCopy(width, height, instance->bitmap, bitmap,
50 &c->unpack);
51 }
52
53 return size;
54}
55
56int crdlm_pointers_DrawPixels( struct instanceDrawPixels *instance, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels, CRClientState *c )
57{
58 unsigned int size = crImageSize(format, type, width, height);
59
60 if (instance && size > 0) {
61 crPixelCopy2D(width, height,
62 instance->pixels, format, type, NULL,
63 pixels, format, type, &c->unpack);
64 }
65
66 return size;
67}
68int crdlm_pointers_Fogfv( struct instanceFogfv *instance, GLenum pname, const GLfloat *params )
69{
70 unsigned int size = (pname == GL_FOG_COLOR?4:1)*sizeof(GLfloat);
71 if (instance) crMemcpy(instance->params, params, size);
72 return size;
73}
74int crdlm_pointers_Fogiv( struct instanceFogiv *instance, GLenum pname, const GLint *params )
75{
76 unsigned int size = (pname == GL_FOG_COLOR?4:1)*sizeof(GLint);
77 if (instance) crMemcpy(instance->params, params, size);
78 return size;
79}
80int crdlm_pointers_LightModelfv( struct instanceLightModelfv *instance, GLenum pname, const GLfloat *params )
81{
82 unsigned int size = (pname == GL_LIGHT_MODEL_AMBIENT?4:1)*sizeof(GLfloat);
83 if (instance) crMemcpy(instance->params, params, size);
84 return size;
85}
86int crdlm_pointers_LightModeliv( struct instanceLightModeliv *instance, GLenum pname, const GLint *params )
87{
88 unsigned int size = (pname == GL_LIGHT_MODEL_AMBIENT?4:1)*sizeof(GLfloat);
89 if (instance) crMemcpy(instance->params, params, size);
90 return size;
91}
92int crdlm_pointers_Lightfv( struct instanceLightfv *instance, GLenum light, GLenum pname, const GLfloat *params )
93{
94 unsigned int size;
95 switch(pname) {
96 case GL_AMBIENT: case GL_DIFFUSE: case GL_SPECULAR: case GL_POSITION:
97 size = 4 * sizeof(GLfloat);
98 break;
99 case GL_SPOT_DIRECTION:
100 size = 3 * sizeof(GLfloat);
101 break;
102 default:
103 size = 1 * sizeof(GLfloat);
104 break;
105 }
106 if (instance) crMemcpy(instance->params, params, size);
107 return size;
108}
109int crdlm_pointers_Lightiv( struct instanceLightiv *instance, GLenum light, GLenum pname, const GLint *params )
110{
111 unsigned int size;
112 switch(pname) {
113 case GL_AMBIENT: case GL_DIFFUSE: case GL_SPECULAR: case GL_POSITION:
114 size = 4 * sizeof(GLint);
115 break;
116 case GL_SPOT_DIRECTION:
117 size = 3 * sizeof(GLint);
118 break;
119 default:
120 size = 1 * sizeof(GLint);
121 break;
122 }
123 if (instance) crMemcpy(instance->params, params, size);
124 return size;
125}
126
127/* This utility routine returns the number of components per
128 * mapping point for all the glMap* functions.
129 */
130static int map_num_components(GLenum target)
131{
132 switch(target) {
133 case GL_MAP1_INDEX: case GL_MAP1_TEXTURE_COORD_1:
134 return 1;
135 case GL_MAP1_TEXTURE_COORD_2:
136 return 2;
137 case GL_MAP1_VERTEX_3: case GL_MAP1_NORMAL:
138 case GL_MAP1_TEXTURE_COORD_3:
139 return 3;
140 case GL_MAP1_VERTEX_4: case GL_MAP1_COLOR_4:
141 case GL_MAP1_TEXTURE_COORD_4:
142 return 4;
143
144 case GL_MAP2_INDEX: case GL_MAP2_TEXTURE_COORD_1:
145 return 1;
146 case GL_MAP2_TEXTURE_COORD_2:
147 return 2;
148 case GL_MAP2_VERTEX_3: case GL_MAP2_NORMAL:
149 case GL_MAP2_TEXTURE_COORD_3:
150 return 3;
151 case GL_MAP2_VERTEX_4: case GL_MAP2_COLOR_4:
152 case GL_MAP2_TEXTURE_COORD_4:
153 return 4;
154 }
155 return 0;
156}
157
158
159int crdlm_pointers_Map1d( struct instanceMap1d *instance, GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points )
160{
161 unsigned int numValues = map_num_components(target);
162 unsigned int size = order * numValues * sizeof(GLdouble);
163 if (instance) {
164 /* This one's a little different - we rearrange the order to
165 * compress it, and change the instance's stride value to
166 * match.
167 */
168 const GLdouble *src = points;
169 GLdouble *dest = instance->points;
170 register int i;
171 for (i = 0; i < order; i++) {
172 crMemcpy(dest, src, numValues * sizeof(GLdouble));
173 dest += numValues;
174 src += stride;
175 }
176
177 /* We override the stride to show we've compressed the data */
178 instance->stride = numValues;
179 }
180 return size;
181}
182int crdlm_pointers_Map1f( struct instanceMap1f *instance, GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points )
183{
184 unsigned int numValues = map_num_components(target);
185 unsigned int size = order * numValues * sizeof(GLfloat);
186 if (instance) {
187 /* This one's a little different - we rearrange the order to
188 * compress it, and change the instance's stride value to
189 * match.
190 */
191 const GLfloat *src = points;
192 GLfloat *dest = instance->points;
193 register int i;
194 for (i = 0; i < order; i++) {
195 crMemcpy(dest, src, numValues * sizeof(GLfloat));
196 dest += numValues;
197 src += stride;
198 }
199
200 /* We override the stride to show we've compressed the data */
201 instance->stride = numValues;
202 }
203 return size;
204}
205int crdlm_pointers_Map2d( struct instanceMap2d *instance, GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points )
206{
207 unsigned int numValues = map_num_components(target);
208 unsigned int size = uorder * vorder * numValues * sizeof(GLdouble);
209 if (instance) {
210 register int v, u;
211 const GLdouble *src = points;
212 GLdouble *dest = instance->points;
213 for (v = 0; v < vorder; v++) {
214 for (u = 0; u < uorder; u++) {
215 crMemcpy(dest, src, numValues * sizeof(GLdouble));
216 dest += numValues;
217 src += ustride;
218 }
219 src += vstride - ustride*uorder;
220 }
221 /* We override the stride to show we've compressed the data */
222 instance->ustride = numValues;
223 instance->vstride = ustride * uorder;
224 }
225 return size;
226}
227int crdlm_pointers_Map2f( struct instanceMap2f *instance, GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points )
228{
229 unsigned int numValues = map_num_components(target);
230 unsigned int size = uorder * vorder * numValues * sizeof(GLfloat);
231 if (instance) {
232 register int v, u;
233 const GLfloat *src = points;
234 GLfloat *dest = instance->points;
235 for (v = 0; v < vorder; v++) {
236 for (u = 0; u < uorder; u++) {
237 crMemcpy(dest, src, numValues * sizeof(GLfloat));
238 dest += numValues;
239 src += ustride;
240 }
241 src += vstride - ustride*uorder;
242 }
243 /* We override the stride to show we've compressed the data */
244 instance->ustride = numValues;
245 instance->vstride = ustride * uorder;
246 }
247 return size;
248}
249
250int crdlm_pointers_Materialfv(struct instanceMaterialfv *instance, GLenum face, GLenum pname, const GLfloat *params)
251{
252 unsigned int size = 0;
253 switch(pname) {
254 case GL_AMBIENT_AND_DIFFUSE:
255 size = 8 * sizeof(GLfloat);
256 break;
257 case GL_AMBIENT:
258 case GL_DIFFUSE:
259 case GL_SPECULAR:
260 case GL_EMISSION:
261 size = 4 * sizeof(GLfloat);
262 break;
263 case GL_SHININESS:
264 size = 1 * sizeof(GLfloat);
265 break;
266 case GL_COLOR_INDEXES:
267 size = 3 * sizeof(GLfloat);
268 break;
269 default:
270 break;
271 }
272 if (instance && size > 0) crMemcpy(instance->params, params, size);
273 return size;
274}
275
276int crdlm_pointers_Materialiv(struct instanceMaterialiv *instance, GLenum face, GLenum pname, const GLint *params)
277{
278 unsigned int size = 0;
279 switch(pname) {
280 case GL_AMBIENT_AND_DIFFUSE:
281 size = 8 * sizeof(GLint);
282 break;
283 case GL_AMBIENT:
284 case GL_DIFFUSE:
285 case GL_SPECULAR:
286 case GL_EMISSION:
287 size = 4 * sizeof(GLint);
288 break;
289 case GL_SHININESS:
290 size = 1 * sizeof(GLint);
291 break;
292 case GL_COLOR_INDEXES:
293 size = 3 * sizeof(GLint);
294 break;
295 default:
296 break;
297 }
298 if (instance && size > 0) crMemcpy(instance->params, params, size);
299 return size;
300}
301
302int crdlm_pointers_PixelMapfv( struct instancePixelMapfv *instance, GLenum map, GLsizei mapsize, const GLfloat *values )
303{
304 unsigned int size = mapsize * sizeof(GLfloat);
305 if (instance && size > 0) crMemcpy(instance->values, values, size);
306 return size;
307}
308int crdlm_pointers_PixelMapuiv( struct instancePixelMapuiv *instance, GLenum map, GLsizei mapsize, const GLuint *values )
309{
310 unsigned int size = mapsize * sizeof(GLuint);
311 if (instance && size > 0) crMemcpy(instance->values, values, size);
312 return size;
313}
314int crdlm_pointers_PixelMapusv( struct instancePixelMapusv *instance, GLenum map, GLsizei mapsize, const GLushort *values )
315{
316 unsigned int size = mapsize * sizeof(GLushort);
317 if (instance && size > 0) crMemcpy(instance->values, values, size);
318 return size;
319}
320
321int crdlm_pointers_PointParameterfvARB( struct instancePointParameterfvARB *instance, GLenum pname, const GLfloat *params)
322{
323 unsigned int size = 0;
324 switch(pname) {
325 case GL_POINT_DISTANCE_ATTENUATION_ARB:
326 size = 3 * sizeof(GLfloat);
327 break;
328 default:
329 size = 1 * sizeof(GLfloat);
330 break;
331 }
332 return size;
333}
334
335int crdlm_pointers_PointParameteriv( struct instancePointParameteriv *instance, GLenum pname, const GLint *params)
336{
337 unsigned int size = 0;
338 switch(pname) {
339 case GL_POINT_DISTANCE_ATTENUATION_ARB:
340 size = 3 * sizeof(GLint);
341 break;
342 default:
343 size = 1 * sizeof(GLint);
344 break;
345 }
346 return size;
347}
348
349int crdlm_pointers_TexEnvfv( struct instanceTexEnvfv *instance, GLenum target, GLenum pname, const GLfloat *params )
350{
351 unsigned int size = (pname == GL_TEXTURE_ENV_COLOR?4:1)*sizeof(GLfloat);
352 if (instance) crMemcpy(instance->params, params, size);
353 return size;
354}
355int crdlm_pointers_TexEnviv( struct instanceTexEnviv *instance, GLenum target, GLenum pname, const GLint *params )
356{
357 unsigned int size = (pname == GL_TEXTURE_ENV_COLOR?4:1)*sizeof(GLint);
358 if (instance) crMemcpy(instance->params, params, size);
359 return size;
360}
361int crdlm_pointers_TexGendv( struct instanceTexGendv *instance, GLenum coord, GLenum pname, const GLdouble *params )
362{
363 unsigned int size = (pname == GL_OBJECT_PLANE||pname==GL_EYE_PLANE?4:1)*sizeof(GLdouble);
364 if (instance) crMemcpy(instance->params, params, size);
365 return size;
366}
367int crdlm_pointers_TexGenfv( struct instanceTexGenfv *instance, GLenum coord, GLenum pname, const GLfloat *params )
368{
369 unsigned int size = (pname == GL_OBJECT_PLANE||pname==GL_EYE_PLANE?4:1)*sizeof(GLfloat);
370 if (instance) crMemcpy(instance->params, params, size);
371 return size;
372}
373int crdlm_pointers_TexGeniv( struct instanceTexGeniv *instance, GLenum coord, GLenum pname, const GLint *params )
374{
375 unsigned int size = (pname == GL_OBJECT_PLANE||pname==GL_EYE_PLANE?4:1)*sizeof(GLint);
376 if (instance) crMemcpy(instance->params, params, size);
377 return size;
378}
379int crdlm_pointers_TexImage1D( struct instanceTexImage1D *instance, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels, CRClientState *c )
380{
381 unsigned int size = crImageSize(format, type, width, 1);
382
383 if (instance && size > 0) {
384 crPixelCopy1D(instance->pixels, format, type,
385 pixels, format, type, width, &c->unpack);
386 }
387
388 return size;
389}
390int crdlm_pointers_CompressedTexImage1DARB(struct instanceCompressedTexImage1DARB *instance, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imagesize, const GLvoid *data)
391{
392 unsigned int size = imagesize;
393
394 if (instance && size > 0) {
395 crMemcpy(instance->data, data, size);
396 }
397
398 return size;
399}
400
401int crdlm_pointers_TexImage2D( struct instanceTexImage2D *instance, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels, CRClientState *c )
402{
403 unsigned int size = crImageSize(format, type, width, height);
404
405 if (instance && size > 0) {
406 crPixelCopy2D(width, height,
407 instance->pixels, format, type, NULL,
408 pixels, format, type, &c->unpack);
409 }
410
411 return size;
412}
413int crdlm_pointers_CompressedTexImage2DARB(struct instanceCompressedTexImage2DARB *instance, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imagesize, const GLvoid *data)
414{
415 unsigned int size = imagesize;
416
417 if (instance && size > 0) {
418 crMemcpy(instance->data, data, size);
419 }
420
421 return size;
422}
423
424int crdlm_pointers_TexImage3D( struct instanceTexImage3D *instance, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels, CRClientState *c )
425{
426 unsigned int size;
427 int is_distrib = ((type == GL_TRUE) || (type == GL_FALSE));
428
429 if (pixels == NULL) {
430 size = 0;
431 }
432 else if (is_distrib) {
433 size = crStrlen(pixels) + 1 + (type==GL_TRUE?width*height*3:0);
434 }
435 else {
436 size = crTextureSize(format, type, width, height, depth);
437 }
438
439 if (instance && size > 0) {
440 if (is_distrib) {
441 crMemcpy(instance->pixels, pixels, size);
442 }
443 else {
444 crPixelCopy3D(width, height, depth,
445 instance->pixels, format, type, NULL,
446 pixels, format, type, &c->unpack);
447 }
448 }
449
450 return size;
451}
452int crdlm_pointers_TexImage3DEXT( struct instanceTexImage3DEXT *instance, GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels, CRClientState *c )
453{
454 unsigned int size;
455 int is_distrib = ((type == GL_TRUE) || (type == GL_FALSE));
456
457 if (pixels == NULL) {
458 size = 0;
459 }
460 else if (is_distrib) {
461 size = crStrlen(pixels) + 1 + (type==GL_TRUE?width*height*3:0);
462 }
463 else {
464 size = crTextureSize(format, type, width, height, depth);
465 }
466
467 if (instance && size > 0) {
468 if (is_distrib) {
469 crMemcpy(instance->pixels, pixels, size);
470 }
471 else {
472 crPixelCopy3D(width, height, depth,
473 instance->pixels, format, type, NULL,
474 pixels, format, type, &c->unpack);
475 }
476 }
477
478 return size;
479}
480
481int crdlm_pointers_CompressedTexImage3DARB(struct instanceCompressedTexImage3DARB *instance, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imagesize, const GLvoid *data)
482{
483 unsigned int size = imagesize;
484
485 if (instance && size > 0) {
486 crMemcpy(instance->data, data, size);
487 }
488
489 return size;
490}
491
492int crdlm_pointers_TexParameterfv( struct instanceTexParameterfv *instance, GLenum target, GLenum pname, const GLfloat *params )
493{
494 unsigned int size = (pname == GL_TEXTURE_BORDER_COLOR?4:1)*sizeof(GLfloat);
495 if (instance) crMemcpy(instance->params, params, size);
496 return size;
497}
498int crdlm_pointers_TexParameteriv( struct instanceTexParameteriv *instance, GLenum target, GLenum pname, const GLint *params )
499{
500 unsigned int size = (pname == GL_TEXTURE_BORDER_COLOR?4:1)*sizeof(GLfloat);
501 if (instance) crMemcpy(instance->params, params, size);
502 return size;
503}
504int crdlm_pointers_TexSubImage1D( struct instanceTexSubImage1D *instance, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels, CRClientState *c )
505{
506 unsigned int size = crImageSize(format, type, width, 1);
507
508 if (instance && size > 0) {
509 crPixelCopy1D(instance->pixels, format, type,
510 pixels, format, type, width, &c->unpack);
511 }
512
513 return size;
514}
515int crdlm_pointers_TexSubImage2D( struct instanceTexSubImage2D *instance, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels, CRClientState *c )
516{
517 unsigned int size = crImageSize(format, type, width, height);
518
519 if (instance && size > 0) {
520 crPixelCopy2D(width, height,
521 instance->pixels, format, type, NULL,
522 pixels, format, type, &c->unpack);
523 }
524
525 return size;
526}
527int crdlm_pointers_TexSubImage3D( struct instanceTexSubImage3D *instance, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels, CRClientState *c )
528{
529 unsigned int size;
530 int is_distrib = ((type == GL_TRUE) || (type == GL_FALSE));
531
532 if (pixels == NULL) {
533 size = 0;
534 }
535 else if (is_distrib) {
536 size = crStrlen(pixels) + 1 + (type==GL_TRUE?width*height*3:0);
537 }
538 else {
539 size = crTextureSize(format, type, width, height, depth);
540 }
541
542 if (instance && size > 0) {
543 if (is_distrib) {
544 crMemcpy(instance->pixels, pixels, size);
545 }
546 else {
547 crPixelCopy3D(width, height, depth,
548 instance->pixels, format, type, NULL,
549 pixels, format, type, &c->unpack);
550 }
551 }
552
553 return size;
554}
555
556int crdlm_pointers_CompressedTexSubImage1DARB(struct instanceCompressedTexSubImage1DARB *instance, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imagesize, const GLvoid *data)
557{
558 unsigned int size = imagesize;
559
560 if (instance && size > 0) {
561 crMemcpy(instance->data, data, size);
562 }
563
564 return size;
565}
566
567int crdlm_pointers_CompressedTexSubImage2DARB(struct instanceCompressedTexSubImage2DARB *instance, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imagesize, const GLvoid *data)
568{
569 unsigned int size = imagesize;
570
571 if (instance && size > 0) {
572 crMemcpy(instance->data, data, size);
573 }
574
575 return size;
576}
577int crdlm_pointers_CompressedTexSubImage3DARB(struct instanceCompressedTexSubImage3DARB *instance, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imagesize, const GLvoid *data)
578{
579 unsigned int size = imagesize;
580
581 if (instance && size > 0) {
582 crMemcpy(instance->data, data, size);
583 }
584
585 return size;
586}
587
588int crdlm_pointers_Rectdv(struct instanceRectdv *instance, const GLdouble *v1, const GLdouble *v2)
589{
590 unsigned int size = 4 * sizeof(GLdouble);
591 if (instance) {
592 instance->data[0] = v1[0];
593 instance->data[1] = v1[1];
594 instance->data[2] = v2[0];
595 instance->data[3] = v2[1];
596 instance->v1 = &instance->data[0];
597 instance->v2 = &instance->data[2];
598 }
599 return size;
600}
601int crdlm_pointers_Rectfv(struct instanceRectfv *instance, const GLfloat *v1, const GLfloat *v2)
602{
603 unsigned int size = 4 * sizeof(GLfloat);
604 if (instance) {
605 instance->data[0] = v1[0];
606 instance->data[1] = v1[1];
607 instance->data[2] = v2[0];
608 instance->data[3] = v2[1];
609 instance->v1 = &instance->data[0];
610 instance->v2 = &instance->data[2];
611 }
612 return size;
613}
614int crdlm_pointers_Rectiv(struct instanceRectiv *instance, const GLint *v1, const GLint *v2)
615{
616 unsigned int size = 4 * sizeof(GLint);
617 if (instance) {
618 instance->data[0] = v1[0];
619 instance->data[1] = v1[1];
620 instance->data[2] = v2[0];
621 instance->data[3] = v2[1];
622 instance->v1 = &instance->data[0];
623 instance->v2 = &instance->data[2];
624 }
625 return size;
626}
627int crdlm_pointers_Rectsv(struct instanceRectsv *instance, const GLshort *v1, const GLshort *v2)
628{
629 unsigned int size = 4 * sizeof(GLshort);
630 if (instance) {
631 instance->data[0] = v1[0];
632 instance->data[1] = v1[1];
633 instance->data[2] = v2[0];
634 instance->data[3] = v2[1];
635 instance->v1 = &instance->data[0];
636 instance->v2 = &instance->data[2];
637 }
638 return size;
639}
640
641int crdlm_pointers_PrioritizeTextures(struct instancePrioritizeTextures *instance, GLsizei n, const GLuint *textures, const GLclampf *priorities)
642{
643 unsigned int size = n * (sizeof(GLuint) + sizeof(GLclampf));
644 if (instance) {
645 instance->textures = (GLuint *)&instance->data[0];
646 instance->priorities = (GLclampf *)(((char *)&instance->data[0]) + n * sizeof(GLuint));
647 if (size > 0) {
648 crMemcpy(instance->textures, textures, n * sizeof(GLuint));
649 crMemcpy(instance->priorities, priorities, n * sizeof(GLclampf));
650 }
651 }
652
653 return size;
654}
655
656static int combiner_num_components(GLenum pname)
657{
658 switch(pname) {
659 case GL_CONSTANT_COLOR0_NV:
660 case GL_CONSTANT_COLOR1_NV:
661 return 4;
662 case GL_NUM_GENERAL_COMBINERS_NV:
663 case GL_COLOR_SUM_CLAMP_NV:
664 return 1;
665 }
666 return 0;
667}
668int crdlm_pointers_CombinerParameterivNV(struct instanceCombinerParameterivNV *instance, GLenum pname, const GLint *params)
669{
670 unsigned int size = combiner_num_components(pname) * sizeof(GLint);
671 if (instance && size > 0) crMemcpy(instance->params, params, size);
672 return size;
673}
674int crdlm_pointers_CombinerParameterfvNV(struct instanceCombinerParameterfvNV *instance, GLenum pname, const GLfloat *params)
675{
676 unsigned int size = combiner_num_components(pname) * sizeof(GLfloat);
677 if (instance && size > 0) crMemcpy(instance->params, params, size);
678 return size;
679}
680
681static int combinerstage_num_components(GLenum pname)
682{
683 switch(pname) {
684 case GL_CONSTANT_COLOR0_NV:
685 case GL_CONSTANT_COLOR1_NV:
686 return 4;
687 }
688 return 0;
689}
690int crdlm_pointers_CombinerStageParameterfvNV(struct instanceCombinerStageParameterfvNV *instance, GLenum stage, GLenum pname, const GLfloat *params)
691{
692 unsigned int size = combinerstage_num_components(pname) * sizeof(GLfloat);
693 if (instance && size > 0) crMemcpy(instance->params, params, size);
694 return size;
695}
696
697static int program_num_components(GLenum target)
698{
699 switch(target) {
700 case GL_VERTEX_STATE_PROGRAM_NV:
701 return 4;
702 }
703 return 0;
704}
705int crdlm_pointers_ExecuteProgramNV(struct instanceExecuteProgramNV *instance, GLenum target, GLuint id, const GLfloat *params)
706{
707 unsigned int size = program_num_components(target) * sizeof(GLfloat);
708 if (instance && size > 0) crMemcpy(instance->params, params, size);
709 return size;
710}
711
712int crdlm_pointers_RequestResidentProgramsNV(struct instanceRequestResidentProgramsNV *instance, GLsizei n, const GLuint *ids)
713{
714 unsigned int size = 4*sizeof(GLuint);
715 if (instance && size > 0) crMemcpy(instance->ids, ids, size);
716 return size;
717}
718
719int crdlm_pointers_LoadProgramNV(struct instanceLoadProgramNV *instance, GLenum target, GLuint id, GLsizei len, const GLubyte *program)
720{
721 unsigned int size = len*sizeof(GLubyte);
722 if (instance && size > 0) crMemcpy(instance->program, program, size);
723 return size;
724}
725
726int crdlm_pointers_ProgramNamedParameter4dNV(struct instanceProgramNamedParameter4dNV *instance, GLuint id, GLsizei len, const GLubyte * name, GLdouble x, GLdouble y, GLdouble z, GLdouble w)
727{
728 unsigned int size = len * sizeof(GLubyte);
729 /* XXX */
730 return size;
731}
732
733int crdlm_pointers_ProgramNamedParameter4dvNV(struct instanceProgramNamedParameter4dvNV *instance, GLuint id, GLsizei len, const GLubyte * name, const GLdouble * v)
734{
735 unsigned int size = len * sizeof(GLubyte);
736 /* XXX */
737 return size;
738}
739
740int crdlm_pointers_ProgramNamedParameter4fNV(struct instanceProgramNamedParameter4fNV *instance, GLuint id, GLsizei len, const GLubyte * name, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
741{
742 unsigned int size = len * sizeof(GLubyte);
743 /* XXX */
744 return size;
745}
746
747int crdlm_pointers_ProgramNamedParameter4fvNV(struct instanceProgramNamedParameter4fvNV *instance, GLuint id, GLsizei len, const GLubyte * name, const GLfloat * v)
748{
749 unsigned int size = len * sizeof(GLubyte);
750 /* XXX */
751 return size;
752}
753
754int crdlm_pointers_ProgramStringARB(struct instanceProgramStringARB *instance, GLenum target, GLenum format, GLsizei len, const GLvoid * string)
755{
756 unsigned int size = len*sizeof(GLubyte);
757 if (instance && size > 0) crMemcpy(instance->string, string, size);
758 return size;
759}
760
761int crdlm_pointers_CallLists(struct instanceCallLists *instance, GLsizei n, GLenum type, const GLvoid *lists )
762{
763 unsigned int size;
764 switch (type) {
765 case GL_BYTE:
766 size = sizeof(GLbyte);
767 break;
768 case GL_UNSIGNED_BYTE:
769 size = sizeof(GLubyte);
770 break;
771 case GL_SHORT:
772 size = sizeof(GLshort);
773 break;
774 case GL_UNSIGNED_SHORT:
775 size = sizeof(GLushort);
776 break;
777 case GL_INT:
778 size = sizeof(GLint);
779 break;
780 case GL_UNSIGNED_INT:
781 size = sizeof(GLuint);
782 break;
783 case GL_FLOAT:
784 size = sizeof(GLfloat);
785 break;
786 case GL_2_BYTES:
787 size = 2 * sizeof(GLbyte);
788 break;
789 case GL_3_BYTES:
790 size = 3 * sizeof(GLbyte);
791 break;
792 case GL_4_BYTES:
793 size = 4 * sizeof(GLbyte);
794 break;
795 default:
796 size = 0;
797 }
798 size *= n;
799 if (instance && size > 0) crMemcpy(instance->lists, lists, size);
800 return size;
801}
802
803
804int crdlm_pointers_VertexAttribs1dvNV(struct instanceVertexAttribs1dvNV *instance, GLuint index, GLsizei n, const GLdouble *v)
805{
806 return 1 * n * sizeof(GLdouble);
807}
808
809int crdlm_pointers_VertexAttribs1fvNV(struct instanceVertexAttribs1fvNV *instance, GLuint index, GLsizei n, const GLfloat *v)
810{
811 return 1 * n * sizeof(GLfloat);
812}
813
814int crdlm_pointers_VertexAttribs1svNV(struct instanceVertexAttribs1svNV *instance, GLuint index, GLsizei n, const GLshort *v)
815{
816 return 1 * n * sizeof(GLshort);
817}
818
819int crdlm_pointers_VertexAttribs2dvNV(struct instanceVertexAttribs2dvNV *instance, GLuint index, GLsizei n, const GLdouble *v)
820{
821 return 2 * n * sizeof(GLdouble);
822}
823
824int crdlm_pointers_VertexAttribs2fvNV(struct instanceVertexAttribs2fvNV *instance, GLuint index, GLsizei n, const GLfloat *v)
825{
826 return 2 * n * sizeof(GLfloat);
827}
828
829int crdlm_pointers_VertexAttribs2svNV(struct instanceVertexAttribs2svNV *instance, GLuint index, GLsizei n, const GLshort *v)
830{
831 return 2 * n * sizeof(GLshort);
832}
833
834int crdlm_pointers_VertexAttribs3dvNV(struct instanceVertexAttribs3dvNV *instance, GLuint index, GLsizei n, const GLdouble *v)
835{
836 return 3 * n * sizeof(GLdouble);
837}
838
839int crdlm_pointers_VertexAttribs3fvNV(struct instanceVertexAttribs3fvNV *instance, GLuint index, GLsizei n, const GLfloat *v)
840{
841 return 3 * n * sizeof(GLfloat);
842}
843
844int crdlm_pointers_VertexAttribs3svNV(struct instanceVertexAttribs3svNV *instance, GLuint index, GLsizei n, const GLshort *v)
845{
846 return 3 * n * sizeof(GLshort);
847}
848
849int crdlm_pointers_VertexAttribs4dvNV(struct instanceVertexAttribs4dvNV *instance, GLuint index, GLsizei n, const GLdouble *v)
850{
851 return 4 * n * sizeof(GLdouble);
852}
853
854int crdlm_pointers_VertexAttribs4fvNV(struct instanceVertexAttribs4fvNV *instance, GLuint index, GLsizei n, const GLfloat *v)
855{
856 return 4 * n * sizeof(GLfloat);
857}
858
859int crdlm_pointers_VertexAttribs4svNV(struct instanceVertexAttribs4svNV *instance, GLuint index, GLsizei n, const GLshort *v)
860{
861 return 4 * n * sizeof(GLshort);
862}
863
864int crdlm_pointers_VertexAttribs4ubvNV(struct instanceVertexAttribs4ubvNV *instance, GLuint index, GLsizei n, const GLubyte *v)
865{
866 return 4 * n * sizeof(GLubyte);
867}
868
869int crdlm_pointers_ZPixCR( struct instanceZPixCR *instance, GLsizei width,
870 GLsizei height, GLenum format, GLenum type,
871 GLenum ztype, GLint zparm, GLint length,
872 const GLvoid *pixels, CRClientState *c)
873{
874 unsigned int size = length;
875 if (instance && size > 0) {
876 crMemcpy(instance->pixels,pixels,length);
877 }
878
879 return size;
880}
881
882
883/*
884 * Prototypes for functions below are auto-generated and definded at out/<os.arch>/<build type>/obj/VBoxOGLgen/dlm_generated.h.
885 *
886 * All non-pointer structure fields are already assifned to *instance in out/<os.arch>/<build type>/obj/VBoxOGLgen/dlm_generated.c.
887 * Here we need to specify the additional size which is required to store data from pointers.
888 * This size will be added to sizeof(*instance) when dlm_generated.c will dynamically allocate memory for it. Also,
889 * data from pointers shouls be copied to *instance in case if instance != NULL. Each of functions below is called
890 * twice from dlm_generated.c:
891 * - first time with instance = NULL in order to get actual size of data provided by pointer
892 * - the second time with valid instance in order to copy data into it.
893 */
894
895int crdlm_pointers_BindAttribLocation(struct instanceBindAttribLocation *instance, GLuint program, GLuint index, const char * name)
896{
897 int cbExtraSpace = (name ? crStrlen(name) + 1 : 0);
898 if (instance && name && cbExtraSpace)
899 {
900 crMemcpy(instance->name, name, cbExtraSpace);
901 }
902
903 return cbExtraSpace;
904}
905
906int crdlm_pointers_DeleteFramebuffersEXT(struct instanceDeleteFramebuffersEXT *instance, GLsizei n, const GLuint * framebuffers)
907{
908 int cbExtraSpace = n * sizeof(GLuint);
909
910 if (instance && framebuffers && cbExtraSpace)
911 crMemcpy(instance->framebuffers, framebuffers, cbExtraSpace);
912
913 return cbExtraSpace;
914}
915
916int crdlm_pointers_DeleteRenderbuffersEXT(struct instanceDeleteRenderbuffersEXT *instance, GLsizei n, const GLuint * renderbuffers)
917{
918 int cbExtraSpace = n * sizeof(GLuint);
919
920 if (instance && renderbuffers && cbExtraSpace)
921 crMemcpy(instance->renderbuffers, renderbuffers, cbExtraSpace);
922
923 return cbExtraSpace;
924}
925
926int crdlm_pointers_DrawBuffers(struct instanceDrawBuffers *instance, GLsizei n, const GLenum* bufs)
927{
928 int cbExtraSpace = n * sizeof(GLenum);
929
930 if (instance && bufs && cbExtraSpace)
931 crMemcpy(instance->bufs, bufs, cbExtraSpace);
932
933 return cbExtraSpace;
934}
935
936int crdlm_pointers_ShaderSource(struct instanceShaderSource *instance, GLuint shader, GLsizei count, const char ** string, const GLint * length)
937{
938 int cbExtraSpace = 0;
939 int cbStrings = 0;
940 int cbLenghts = 0;
941 int i;
942
943 /* Calculate reported source code size. */
944 if (length && count)
945 for (i = 0; i < count; i++)
946 cbStrings += length[i] + /* termination character */ 1;
947
948 /* Calculate size of the rest of parameters. */
949 cbLenghts = count * sizeof(GLint);
950
951 /* Resulting size is a summ. */
952 cbExtraSpace = cbStrings + cbLenghts;
953
954 /* Copy data if requested. */
955 if (instance)
956 {
957 if (string && *string && cbStrings)
958 crMemcpy(instance->string, *string, cbStrings);
959 if (length && cbLenghts)
960 crMemcpy(instance->length, length, cbLenghts);
961 }
962
963 return cbExtraSpace;
964}
965
966int crdlm_pointers_StringMarkerGREMEDY(struct instanceStringMarkerGREMEDY *instance, GLsizei len, const GLvoid* string)
967{
968 /* @param len assumed to indicate string lenght in bytes. No termination character assumed. */
969 int cbExtraSpace = (string && len) ? len : 0;
970
971 if (instance && string && cbExtraSpace)
972 crMemcpy(instance->string, string, cbExtraSpace);
973
974 return cbExtraSpace;
975}
976
977/* Simplify things a bit. Use this macro instead of copy/paste to similar functions. */
978#define _VBOX_crdlm_pointers_UniformX(_uniformType) \
979 int cbExtraSpace = count * sizeof(_uniformType); \
980 if (instance && cbExtraSpace && value) \
981 crMemcpy(instance->value, value, cbExtraSpace); \
982 return cbExtraSpace;
983
984int crdlm_pointers_Uniform1fv(struct instanceUniform1fv *instance, GLint location, GLsizei count, const GLfloat * value)
985{
986 _VBOX_crdlm_pointers_UniformX(GLfloat);
987}
988
989int crdlm_pointers_Uniform1iv(struct instanceUniform1iv *instance, GLint location, GLsizei count, const GLint * value)
990{
991 _VBOX_crdlm_pointers_UniformX(GLint);
992}
993
994int crdlm_pointers_Uniform2fv(struct instanceUniform2fv *instance, GLint location, GLsizei count, const GLfloat * value)
995{
996 _VBOX_crdlm_pointers_UniformX(GLfloat);
997}
998
999int crdlm_pointers_Uniform2iv(struct instanceUniform2iv *instance, GLint location, GLsizei count, const GLint * value)
1000{
1001 _VBOX_crdlm_pointers_UniformX(GLint);
1002}
1003
1004int crdlm_pointers_Uniform3fv(struct instanceUniform3fv *instance, GLint location, GLsizei count, const GLfloat * value)
1005{
1006 _VBOX_crdlm_pointers_UniformX(GLfloat);
1007}
1008
1009int crdlm_pointers_Uniform3iv(struct instanceUniform3iv *instance, GLint location, GLsizei count, const GLint * value)
1010{
1011 _VBOX_crdlm_pointers_UniformX(GLint);
1012}
1013
1014int crdlm_pointers_Uniform4fv(struct instanceUniform4fv *instance, GLint location, GLsizei count, const GLfloat * value)
1015{
1016 _VBOX_crdlm_pointers_UniformX(GLfloat);
1017}
1018
1019int crdlm_pointers_Uniform4iv(struct instanceUniform4iv *instance, GLint location, GLsizei count, const GLint * value)
1020{
1021 _VBOX_crdlm_pointers_UniformX(GLint);
1022}
1023
1024#undef crdlm_pointers_Uniform4iv
1025
1026/* Now do the same for UniformMatrix. */
1027#define _VBOX_crdlm_pointers_UniformMatrixX(_uniformMatrixType) \
1028 int cbExtraSpace = count * sizeof(_uniformMatrixType); \
1029 if (instance && value && cbExtraSpace) \
1030 crMemcpy(instance->value, value, cbExtraSpace); \
1031 return cbExtraSpace;
1032
1033int crdlm_pointers_UniformMatrix2fv(struct instanceUniformMatrix2fv *instance, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
1034{
1035 _VBOX_crdlm_pointers_UniformMatrixX(GLfloat);
1036}
1037
1038int crdlm_pointers_UniformMatrix2x3fv(struct instanceUniformMatrix2x3fv *instance, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
1039{
1040 _VBOX_crdlm_pointers_UniformMatrixX(GLfloat);
1041}
1042
1043int crdlm_pointers_UniformMatrix2x4fv(struct instanceUniformMatrix2x4fv *instance, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
1044{
1045 _VBOX_crdlm_pointers_UniformMatrixX(GLfloat);
1046}
1047
1048int crdlm_pointers_UniformMatrix3fv(struct instanceUniformMatrix3fv *instance, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
1049{
1050 _VBOX_crdlm_pointers_UniformMatrixX(GLfloat);
1051}
1052
1053int crdlm_pointers_UniformMatrix3x2fv(struct instanceUniformMatrix3x2fv *instance, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
1054{
1055 _VBOX_crdlm_pointers_UniformMatrixX(GLfloat);
1056}
1057
1058int crdlm_pointers_UniformMatrix3x4fv(struct instanceUniformMatrix3x4fv *instance, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
1059{
1060 _VBOX_crdlm_pointers_UniformMatrixX(GLfloat);
1061}
1062
1063int crdlm_pointers_UniformMatrix4fv(struct instanceUniformMatrix4fv *instance, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
1064{
1065 _VBOX_crdlm_pointers_UniformMatrixX(GLfloat);
1066}
1067
1068int crdlm_pointers_UniformMatrix4x2fv(struct instanceUniformMatrix4x2fv *instance, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
1069{
1070 _VBOX_crdlm_pointers_UniformMatrixX(GLfloat);
1071}
1072
1073int crdlm_pointers_UniformMatrix4x3fv(struct instanceUniformMatrix4x3fv *instance, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
1074{
1075 _VBOX_crdlm_pointers_UniformMatrixX(GLfloat);
1076}
1077
1078#undef _VBOX_crdlm_pointers_UniformMatrixX
1079
1080#if 0
1081VBoxConCreate
1082VBoxCreateContext
1083VBoxPackSetInjectThread
1084VBoxPresentComposition
1085VBoxWindowCreate
1086#endif
1087
1088int crdlm_pointers_VBoxConCreate(struct instanceVBoxConCreate *instance, struct VBOXUHGSMI * pHgsmi)
1089{
1090 CRASSERT(0);
1091 return 0;
1092}
1093
1094int crdlm_pointers_VBoxCreateContext(struct instanceVBoxCreateContext *instance, GLint con, const char * dpyName, GLint visual, GLint shareCtx)
1095{
1096 int cbExtraSpace = (dpyName ? crStrlen(dpyName) + 1 : 0);
1097
1098 if (instance && dpyName && cbExtraSpace)
1099 crMemcpy(instance->dpyName, dpyName, cbExtraSpace);
1100
1101 return cbExtraSpace;
1102}
1103
1104int crdlm_pointers_VBoxPackSetInjectThread(struct instanceVBoxPackSetInjectThread *instance, struct VBOXUHGSMI * pHgsmi)
1105{
1106 CRASSERT(0);
1107 return 0;
1108}
1109
1110int crdlm_pointers_VBoxPresentComposition(struct instanceVBoxPresentComposition *instance, GLint win,
1111 const struct VBOXVR_SCR_COMPOSITOR * pCompositor, const struct VBOXVR_SCR_COMPOSITOR_ENTRY * pChangedEntry)
1112{
1113 CRASSERT(0);
1114 return 0;
1115}
1116
1117int crdlm_pointers_VBoxWindowCreate(struct instanceVBoxWindowCreate *instance, GLint con, const char * dpyName, GLint visBits)
1118{
1119 int cbExtraSpace = (dpyName ? crStrlen(dpyName) + 1 : 0);
1120
1121 if (instance && dpyName && cbExtraSpace)
1122 crMemcpy(instance->dpyName, dpyName, cbExtraSpace);
1123
1124 return cbExtraSpace;
1125}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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