VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/packer/pack_swap_texture.c@ 18171

最後變更 在這個檔案從18171是 15532,由 vboxsync 提交於 16 年 前

crOpenGL: export to OSE

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Id
檔案大小: 27.8 KB
 
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 "packer.h"
8#include "cr_pixeldata.h"
9#include "cr_error.h"
10#include "cr_string.h"
11#include "cr_version.h"
12
13void PACK_APIENTRY crPackTexImage1DSWAP(GLenum target, GLint level,
14 GLint internalformat, GLsizei width, GLint border, GLenum format,
15 GLenum type, const GLvoid *pixels, const CRPixelPackState *unpackstate )
16{
17 unsigned char *data_ptr;
18 int packet_length;
19 int isnull = (pixels == NULL);
20
21 packet_length =
22 sizeof( target ) +
23 sizeof( level ) +
24 sizeof( internalformat ) +
25 sizeof( width ) +
26 sizeof( border ) +
27 sizeof( format ) +
28 sizeof( type ) +
29 sizeof( int );
30
31 if (pixels)
32 {
33 packet_length += crImageSize( format, type, width, 1 );
34 }
35
36 data_ptr = (unsigned char *) crPackAlloc( packet_length );
37 WRITE_DATA( 0, GLenum, SWAP32(target) );
38 WRITE_DATA( 4, GLint, SWAP32(level) );
39 WRITE_DATA( 8, GLint, SWAP32(internalformat) );
40 WRITE_DATA( 12, GLsizei, SWAP32(width) );
41 WRITE_DATA( 16, GLint, SWAP32(border) );
42 WRITE_DATA( 20, GLenum, SWAP32(format) );
43 WRITE_DATA( 24, GLenum, SWAP32(type) );
44 WRITE_DATA( 28, int, SWAP32(isnull) );
45
46 if (pixels) {
47 CRPixelPackState tmpUnpackState = *unpackstate;
48 /* flip application-requested swapBytes state */
49 tmpUnpackState.swapBytes = unpackstate->swapBytes ? GL_FALSE : GL_TRUE;
50
51 crPixelCopy1D( (void *)(data_ptr + 32), format, type,
52 pixels, format, type, width, &tmpUnpackState );
53 }
54
55 crHugePacket( CR_TEXIMAGE1D_OPCODE, data_ptr );
56 crPackFree( data_ptr );
57}
58
59void PACK_APIENTRY crPackTexImage2DSWAP(GLenum target, GLint level,
60 GLint internalformat, GLsizei width, GLsizei height, GLint border,
61 GLenum format, GLenum type, const GLvoid *pixels,
62 const CRPixelPackState *unpackstate )
63{
64 unsigned char *data_ptr;
65 int packet_length;
66 int isnull = (pixels == NULL);
67
68 packet_length =
69 sizeof( target ) +
70 sizeof( level ) +
71 sizeof( internalformat ) +
72 sizeof( width ) +
73 sizeof( height ) +
74 sizeof( border ) +
75 sizeof( format ) +
76 sizeof( type ) +
77 sizeof( int );
78
79 if (pixels)
80 {
81 packet_length += crImageSize( format, type, width, height );
82 }
83
84 data_ptr = (unsigned char *) crPackAlloc( packet_length );
85 WRITE_DATA( 0, GLenum, SWAP32(target) );
86 WRITE_DATA( 4, GLint, SWAP32(level) );
87 WRITE_DATA( 8, GLint, SWAP32(internalformat) );
88 WRITE_DATA( 12, GLsizei, SWAP32(width) );
89 WRITE_DATA( 16, GLsizei, SWAP32(height) );
90 WRITE_DATA( 20, GLint, SWAP32(border) );
91 WRITE_DATA( 24, GLenum, SWAP32(format) );
92 WRITE_DATA( 28, GLenum, SWAP32(type) );
93 WRITE_DATA( 32, int, SWAP32(isnull) );
94
95 if (pixels)
96 {
97 CRPixelPackState tmpUnpackState = *unpackstate;
98 /* flip application-requested swapBytes state */
99 tmpUnpackState.swapBytes = unpackstate->swapBytes ? GL_FALSE : GL_TRUE;
100
101 crPixelCopy2D( width, height,
102 (void *)(data_ptr + 36), format, type, NULL, /* dst */
103 pixels, format, type, &tmpUnpackState ); /* src */
104 }
105
106 crHugePacket( CR_TEXIMAGE2D_OPCODE, data_ptr );
107 crPackFree( data_ptr );
108}
109
110#if defined( GL_EXT_texture3D )
111void PACK_APIENTRY crPackTexImage3DEXTSWAP(GLenum target, GLint level,
112 GLenum internalformat,
113 GLsizei width, GLsizei height, GLsizei depth, GLint border,
114 GLenum format, GLenum type, const GLvoid *pixels,
115 const CRPixelPackState *unpackstate )
116{
117 unsigned char *data_ptr;
118 int packet_length;
119 int isnull = (pixels == NULL);
120 int is_distrib = ( (type == GL_TRUE) || (type == GL_FALSE) ) ;
121 int distrib_buf_len = 0;
122 int tex_size = 0;
123
124 packet_length =
125 sizeof( target ) +
126 sizeof( level ) +
127 sizeof( internalformat ) +
128 sizeof( width ) +
129 sizeof( height ) +
130 sizeof( depth ) +
131 sizeof( border ) +
132 sizeof( format ) +
133 sizeof( type ) +
134 sizeof( int );
135
136 if (pixels)
137 {
138 if ( is_distrib )
139 {
140 distrib_buf_len = crStrlen( pixels ) + 1 +
141 ( (type == GL_TRUE) ? width*height*3 : 0 ) ;
142 packet_length += distrib_buf_len ;
143 }
144 else
145 {
146 tex_size = crTextureSize( format, type, width, height, depth );
147 packet_length += tex_size;
148 }
149 }
150
151 data_ptr = (unsigned char *) crPackAlloc( packet_length );
152 WRITE_DATA( 0, GLenum, SWAP32( target ) );
153 WRITE_DATA( 4, GLint, SWAP32( level ) );
154 WRITE_DATA( 8, GLint, SWAP32( internalformat ) );
155 WRITE_DATA( 12, GLsizei, SWAP32( width ) );
156 WRITE_DATA( 16, GLsizei, SWAP32( height ) );
157 WRITE_DATA( 20, GLsizei, SWAP32( depth ) );
158 WRITE_DATA( 24, GLint, SWAP32( border ) );
159 WRITE_DATA( 28, GLenum, SWAP32( format ) );
160 WRITE_DATA( 32, GLenum, SWAP32( type ) );
161 WRITE_DATA( 36, int, SWAP32( isnull ) );
162
163 if (pixels)
164 {
165 if ( is_distrib )
166 {
167 crMemcpy( (void*)(data_ptr + 40), pixels, distrib_buf_len ) ;
168 }
169 else
170 {
171 CRPixelPackState tmpUnpackState = *unpackstate;
172 /* flip application-requested swapBytes state */
173 tmpUnpackState.swapBytes = unpackstate->swapBytes ? GL_FALSE : GL_TRUE;
174
175 crPixelCopy3D( width, height, depth,
176 (void *)(data_ptr + 40), format, type, NULL,
177 pixels, format, type, &tmpUnpackState );
178 }
179 }
180
181 crHugePacket( CR_TEXIMAGE3DEXT_OPCODE, data_ptr );
182 crPackFree( data_ptr );
183}
184#endif /* GL_EXT_texture3D */
185
186#ifdef CR_OPENGL_VERSION_1_2
187void PACK_APIENTRY crPackTexImage3DSWAP(GLenum target, GLint level,
188 GLint internalformat,
189 GLsizei width, GLsizei height,
190 GLsizei depth, GLint border,
191 GLenum format, GLenum type,
192 const GLvoid *pixels,
193 const CRPixelPackState *unpackstate )
194{
195 unsigned char *data_ptr;
196 int packet_length;
197 int isnull = (pixels == NULL);
198 int is_distrib = ( (type == GL_TRUE) || (type == GL_FALSE) ) ;
199 int distrib_buf_len = 0;
200 int tex_size = 0;
201
202 packet_length =
203 sizeof( target ) +
204 sizeof( level ) +
205 sizeof( internalformat ) +
206 sizeof( width ) +
207 sizeof( height ) +
208 sizeof( depth ) +
209 sizeof( border ) +
210 sizeof( format ) +
211 sizeof( type ) +
212 sizeof( int );
213
214 if (pixels)
215 {
216 if ( is_distrib )
217 {
218 distrib_buf_len = crStrlen( pixels ) + 1 +
219 ( (type == GL_TRUE) ? width*height*3 : 0 ) ;
220 packet_length += distrib_buf_len ;
221 }
222 else
223 {
224 tex_size = crTextureSize( format, type, width, height, depth );
225 packet_length += tex_size;
226 }
227 }
228
229 data_ptr = (unsigned char *) crPackAlloc( packet_length );
230 WRITE_DATA( 0, GLenum, SWAP32( target ) );
231 WRITE_DATA( 4, GLint, SWAP32( level ) );
232 WRITE_DATA( 8, GLint, SWAP32( internalformat ) );
233 WRITE_DATA( 12, GLsizei, SWAP32( width ) );
234 WRITE_DATA( 16, GLsizei, SWAP32( height ) );
235 WRITE_DATA( 20, GLsizei, SWAP32( depth ) );
236 WRITE_DATA( 24, GLint, SWAP32( border ) );
237 WRITE_DATA( 28, GLenum, SWAP32( format ) );
238 WRITE_DATA( 32, GLenum, SWAP32( type ) );
239 WRITE_DATA( 36, int, SWAP32( isnull ) );
240
241 if (pixels)
242 {
243 if ( is_distrib )
244 {
245 crMemcpy( (void*)(data_ptr + 40), pixels, distrib_buf_len ) ;
246 }
247 else
248 {
249 CRPixelPackState tmpUnpackState = *unpackstate;
250 /* flip application-requested swapBytes state */
251 tmpUnpackState.swapBytes = unpackstate->swapBytes ? GL_FALSE : GL_TRUE;
252
253 crPixelCopy3D( width, height, depth,
254 (void *)(data_ptr + 40), format, type, NULL,
255 pixels, format, type, &tmpUnpackState );
256 }
257 }
258
259 crHugePacket( CR_TEXIMAGE3D_OPCODE, data_ptr );
260 crPackFree( data_ptr );
261}
262#endif /* CR_OPENGL_VERSION_1_2 */
263
264
265void PACK_APIENTRY crPackDeleteTexturesSWAP( GLsizei n, const GLuint *textures )
266{
267 unsigned char *data_ptr;
268 int i;
269
270 int packet_length =
271 sizeof( n ) +
272 n*sizeof( *textures );
273
274 data_ptr = (unsigned char *) crPackAlloc( packet_length );
275 WRITE_DATA( 0, GLsizei, SWAP32(n) );
276
277 for ( i = 0 ; i < n ; i++)
278 {
279 WRITE_DATA( i*sizeof(int) + 4, GLint, SWAP32(textures[i]) );
280 }
281 crHugePacket( CR_DELETETEXTURES_OPCODE, data_ptr );
282 crPackFree( data_ptr );
283}
284
285static void __handleTexEnvData( GLenum target, GLenum pname, const GLfloat *params )
286{
287 GET_PACKER_CONTEXT(pc);
288 unsigned char *data_ptr;
289 int num_params;
290 int i;
291
292 int packet_length =
293 sizeof( int ) +
294 sizeof( target ) +
295 sizeof( pname );
296
297 num_params = 1;
298 if ( pname == GL_TEXTURE_ENV_COLOR )
299 {
300 num_params = 4;
301 }
302
303 packet_length += num_params*sizeof(*params);
304
305 GET_BUFFERED_POINTER(pc, packet_length );
306 WRITE_DATA( 0, int, SWAP32(packet_length) );
307 WRITE_DATA( sizeof( int ) + 0, GLenum, SWAP32(target) );
308 WRITE_DATA( sizeof( int ) + 4, GLenum, SWAP32(pname) );
309 for ( i = 0 ; i < num_params ; i++)
310 {
311 WRITE_DATA( (i+1)*sizeof( int ) + 8, GLuint, SWAPFLOAT( params[i] ) );
312 }
313}
314
315
316void PACK_APIENTRY crPackTexEnvfvSWAP( GLenum target, GLenum pname,
317 const GLfloat *params )
318{
319 GET_PACKER_CONTEXT(pc);
320 __handleTexEnvData( target, pname, params );
321 WRITE_OPCODE( pc, CR_TEXENVFV_OPCODE );
322}
323
324void PACK_APIENTRY crPackTexEnvivSWAP( GLenum target, GLenum pname,
325 const GLint *params )
326{
327 /* floats and ints are the same size, so the packing should be the same */
328 GET_PACKER_CONTEXT(pc);
329 __handleTexEnvData( target, pname, (const GLfloat *) params );
330 WRITE_OPCODE( pc, CR_TEXENVIV_OPCODE );
331}
332
333void PACK_APIENTRY crPackTexEnviSWAP( GLenum target, GLenum pname, GLint param )
334{
335 crPackTexEnvivSWAP( target, pname, &param );
336}
337
338void PACK_APIENTRY crPackTexEnvfSWAP( GLenum target, GLenum pname, GLfloat param )
339{
340 crPackTexEnvfvSWAP( target, pname, &param );
341}
342
343void PACK_APIENTRY crPackPrioritizeTexturesSWAP( GLsizei n,
344 const GLuint *textures, const GLclampf *priorities )
345{
346 unsigned char *data_ptr;
347 int packet_length =
348 sizeof( n ) +
349 n*sizeof( *textures ) +
350 n*sizeof( *priorities );
351 int i;
352
353 data_ptr = (unsigned char *) crPackAlloc( packet_length );
354 WRITE_DATA( 0, GLsizei, SWAP32(n) );
355 for ( i = 0 ; i < n ; i++)
356 {
357 WRITE_DATA( i*sizeof(int) + 4, GLint, SWAP32(textures[i]));
358 }
359 for ( i = 0 ; i < n ; i++)
360 {
361 WRITE_DATA( i*sizeof(int) + 4 + n*sizeof( *textures ),
362 GLuint, SWAPFLOAT(priorities[i]));
363 }
364
365 crHugePacket( CR_PRIORITIZETEXTURES_OPCODE, data_ptr );
366 crPackFree( data_ptr );
367}
368
369static void __handleTexGenData( GLenum coord, GLenum pname,
370 int sizeof_param, const GLvoid *params )
371{
372 GET_PACKER_CONTEXT(pc);
373 unsigned char *data_ptr;
374 int packet_length = sizeof( int ) + sizeof( coord ) + sizeof( pname );
375 int num_params = 1;
376 int i;
377 if (pname == GL_OBJECT_PLANE || pname == GL_EYE_PLANE)
378 {
379 num_params = 4;
380 }
381 packet_length += num_params * sizeof_param;
382
383 GET_BUFFERED_POINTER(pc, packet_length );
384 WRITE_DATA( 0, int, SWAP32(packet_length) );
385 WRITE_DATA( sizeof( int ) + 0, GLenum, SWAP32(coord) );
386 WRITE_DATA( sizeof( int ) + 4, GLenum, SWAP32(pname) );
387 for ( i = 0 ; i < num_params ; i++)
388 {
389 WRITE_DATA( (i+1)*sizeof( int ) + 8, GLint, SWAP32(((GLint *)params)[i]) );
390 }
391}
392
393void PACK_APIENTRY crPackTexGendvSWAP( GLenum coord, GLenum pname,
394 const GLdouble *params )
395{
396 GET_PACKER_CONTEXT(pc);
397 __handleTexGenData( coord, pname, sizeof( *params ), params );
398 WRITE_OPCODE( pc, CR_TEXGENDV_OPCODE );
399}
400
401void PACK_APIENTRY crPackTexGenfvSWAP( GLenum coord, GLenum pname,
402 const GLfloat *params )
403{
404 GET_PACKER_CONTEXT(pc);
405 __handleTexGenData( coord, pname, sizeof( *params ), params );
406 WRITE_OPCODE( pc, CR_TEXGENFV_OPCODE );
407}
408
409void PACK_APIENTRY crPackTexGenivSWAP( GLenum coord, GLenum pname,
410 const GLint *params )
411{
412 GET_PACKER_CONTEXT(pc);
413 __handleTexGenData( coord, pname, sizeof( *params ), params );
414 WRITE_OPCODE( pc, CR_TEXGENIV_OPCODE );
415}
416
417void PACK_APIENTRY crPackTexGendSWAP( GLenum coord, GLenum pname, GLdouble param )
418{
419 crPackTexGendvSWAP( coord, pname, &param );
420}
421
422void PACK_APIENTRY crPackTexGenfSWAP( GLenum coord, GLenum pname, GLfloat param )
423{
424 crPackTexGenfvSWAP( coord, pname, &param );
425}
426
427void PACK_APIENTRY crPackTexGeniSWAP( GLenum coord, GLenum pname, GLint param )
428{
429 crPackTexGenivSWAP( coord, pname, &param );
430}
431
432static GLboolean __handleTexParameterData( GLenum target, GLenum pname, const GLfloat *params )
433{
434 GET_PACKER_CONTEXT(pc);
435 unsigned char *data_ptr;
436 int packet_length = sizeof( int ) + sizeof( target ) + sizeof( pname );
437 int num_params = 0;
438 int i;
439
440 switch( pname )
441 {
442
443 case GL_TEXTURE_MIN_FILTER:
444 case GL_TEXTURE_MAG_FILTER:
445 case GL_TEXTURE_WRAP_R:
446 case GL_TEXTURE_WRAP_S:
447 case GL_TEXTURE_WRAP_T:
448#ifdef GL_TEXTURE_PRIORITY
449 case GL_TEXTURE_PRIORITY:
450#endif
451 num_params = 1;
452 break;
453 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
454 num_params = 1;
455 break;
456 case GL_TEXTURE_MIN_LOD:
457 case GL_TEXTURE_MAX_LOD:
458 case GL_TEXTURE_BASE_LEVEL:
459 case GL_TEXTURE_MAX_LEVEL:
460 num_params = 1;
461 break;
462 case GL_TEXTURE_BORDER_COLOR:
463 num_params = 4;
464 break;
465#ifdef CR_ARB_shadow
466 case GL_TEXTURE_COMPARE_MODE_ARB:
467 case GL_TEXTURE_COMPARE_FUNC_ARB:
468 num_params = 1;
469 break;
470#endif
471#ifdef CR_ARB_shadow_ambient
472 case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB:
473 num_params = 1;
474 break;
475#endif
476#ifdef CR_ARB_depth_texture
477 case GL_DEPTH_TEXTURE_MODE_ARB:
478 num_params = 1;
479 break;
480#endif
481#ifdef CR_SGIS_generate_mipmap
482 case GL_GENERATE_MIPMAP_SGIS:
483 num_params = 1;
484 break;
485#endif
486 default:
487 num_params = __packTexParameterNumParams( pname );
488 if (!num_params)
489 {
490 __PackError( __LINE__, __FILE__, GL_INVALID_ENUM,
491 "crPackTexParameter(bad pname)" );
492 return GL_FALSE;
493 }
494 }
495 packet_length += num_params * sizeof(*params);
496
497 GET_BUFFERED_POINTER(pc, packet_length );
498 WRITE_DATA( 0, int, SWAP32(packet_length) );
499 WRITE_DATA( sizeof( int ) + 0, GLenum, SWAP32(target) );
500 WRITE_DATA( sizeof( int ) + 4, GLenum, SWAP32(pname) );
501 for ( i = 0 ; i < num_params ; i++)
502 {
503 WRITE_DATA( (i+1)*sizeof( int ) + 8, GLuint, SWAPFLOAT(params[i]) );
504 }
505 return GL_TRUE;
506}
507
508void PACK_APIENTRY crPackTexParameterfvSWAP( GLenum target, GLenum pname,
509 const GLfloat *params )
510{
511 GET_PACKER_CONTEXT(pc);
512 if (__handleTexParameterData( target, pname, params ))
513 WRITE_OPCODE( pc, CR_TEXPARAMETERFV_OPCODE );
514}
515
516void PACK_APIENTRY crPackTexParameterivSWAP( GLenum target, GLenum pname,
517 const GLint *params )
518{
519 GET_PACKER_CONTEXT(pc);
520 if (__handleTexParameterData( target, pname, (GLfloat *) params ))
521 WRITE_OPCODE( pc, CR_TEXPARAMETERIV_OPCODE );
522}
523
524void PACK_APIENTRY crPackTexParameterfSWAP( GLenum target, GLenum pname, GLfloat param )
525{
526 crPackTexParameterfvSWAP( target, pname, &param );
527}
528
529void PACK_APIENTRY crPackTexParameteriSWAP( GLenum target, GLenum pname, GLint param )
530{
531 crPackTexParameterivSWAP( target, pname, &param );
532}
533
534#ifdef CR_OPENGL_VERSION_1_2
535void PACK_APIENTRY crPackTexSubImage3DSWAP (GLenum target, GLint level,
536 GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
537 GLenum format, GLenum type, const GLvoid *pixels,
538 const CRPixelPackState *unpackstate )
539{
540 unsigned char *data_ptr;
541 int packet_length;
542
543 packet_length =
544 sizeof( target ) +
545 sizeof( level ) +
546 sizeof( xoffset ) +
547 sizeof( yoffset ) +
548 sizeof( zoffset ) +
549 sizeof( width ) +
550 sizeof( height ) +
551 sizeof( depth ) +
552 sizeof( format ) +
553 sizeof( type ) +
554 crTextureSize( format, type, width, height, depth );
555
556 data_ptr = (unsigned char *) crPackAlloc( packet_length );
557 WRITE_DATA( 0, GLenum, SWAP32(target) );
558 WRITE_DATA( 4, GLint, SWAP32(level) );
559 WRITE_DATA( 8, GLint, SWAP32(xoffset) );
560 WRITE_DATA( 12, GLint, SWAP32(yoffset) );
561 WRITE_DATA( 16, GLint, SWAP32(zoffset) );
562 WRITE_DATA( 20, GLsizei, SWAP32(width) );
563 WRITE_DATA( 24, GLsizei, SWAP32(height) );
564 WRITE_DATA( 28, GLsizei, SWAP32(depth) );
565 WRITE_DATA( 32, GLenum, SWAP32(format) );
566 WRITE_DATA( 36, GLenum, SWAP32(type) );
567
568 crPixelCopy3D( width, height, depth,
569 (GLvoid *) (data_ptr + 36), format, type, NULL, /* dst */
570 pixels, format, type, unpackstate ); /* src */
571
572 crHugePacket( CR_TEXSUBIMAGE3D_OPCODE, data_ptr );
573 crPackFree( data_ptr );
574}
575#endif /* CR_OPENGL_VERSION_1_2 */
576
577void PACK_APIENTRY crPackTexSubImage2DSWAP (GLenum target, GLint level,
578 GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
579 GLenum format, GLenum type, const GLvoid *pixels,
580 const CRPixelPackState *unpackstate )
581{
582 unsigned char *data_ptr;
583 int packet_length;
584
585 CRPixelPackState tmpUnpackState = *unpackstate;
586
587 packet_length =
588 sizeof( target ) +
589 sizeof( level ) +
590 sizeof( xoffset ) +
591 sizeof( yoffset ) +
592 sizeof( width ) +
593 sizeof( height ) +
594 sizeof( format ) +
595 sizeof( type ) +
596 crImageSize( format, type, width, height );
597
598 data_ptr = (unsigned char *) crPackAlloc( packet_length );
599 WRITE_DATA( 0, GLenum, SWAP32(target) );
600 WRITE_DATA( 4, GLint, SWAP32(level) );
601 WRITE_DATA( 8, GLint, SWAP32(xoffset) );
602 WRITE_DATA( 12, GLint, SWAP32(yoffset) );
603 WRITE_DATA( 16, GLsizei, SWAP32(width) );
604 WRITE_DATA( 20, GLsizei, SWAP32(height) );
605 WRITE_DATA( 24, GLenum, SWAP32(format) );
606 WRITE_DATA( 28, GLenum, SWAP32(type) );
607
608 /* flip application-requested swapBytes state */
609 tmpUnpackState.swapBytes = unpackstate->swapBytes ? GL_FALSE : GL_TRUE;
610
611 crPixelCopy2D( width, height,
612 (GLvoid *) (data_ptr + 32), format, type, NULL, /* dst */
613 pixels, format, type, &tmpUnpackState ); /* src */
614
615 crHugePacket( CR_TEXSUBIMAGE2D_OPCODE, data_ptr );
616 crPackFree( data_ptr );
617}
618
619void PACK_APIENTRY crPackTexSubImage1DSWAP (GLenum target, GLint level,
620 GLint xoffset, GLsizei width, GLenum format, GLenum type,
621 const GLvoid *pixels, const CRPixelPackState *unpackstate )
622{
623 unsigned char *data_ptr;
624 int packet_length;
625 CRPixelPackState tmpUnpackState = *unpackstate;
626
627 packet_length =
628 sizeof( target ) +
629 sizeof( level ) +
630 sizeof( xoffset ) +
631 sizeof( width ) +
632 sizeof( format ) +
633 sizeof( type ) +
634 crImageSize( format, type, width, 1 );
635
636 data_ptr = (unsigned char *) crPackAlloc( packet_length );
637 WRITE_DATA( 0, GLenum, SWAP32(target) );
638 WRITE_DATA( 4, GLint, SWAP32(level) );
639 WRITE_DATA( 8, GLint, SWAP32(xoffset) );
640 WRITE_DATA( 12, GLsizei, SWAP32(width) );
641 WRITE_DATA( 16, GLenum, SWAP32(format) );
642 WRITE_DATA( 20, GLenum, SWAP32(type) );
643
644 /* flip application-requested swapBytes state */
645 tmpUnpackState.swapBytes = unpackstate->swapBytes ? GL_FALSE : GL_TRUE;
646
647 crPixelCopy1D((GLvoid *) (data_ptr + 24), format, type,
648 pixels, format, type, width, &tmpUnpackState );
649
650 crHugePacket( CR_TEXSUBIMAGE1D_OPCODE, data_ptr );
651 crPackFree( data_ptr );
652}
653
654void PACK_APIENTRY crPackAreTexturesResidentSWAP( GLsizei n, const GLuint *textures, GLboolean *residences, GLboolean *return_val, int *writeback )
655{
656 GET_PACKER_CONTEXT(pc);
657 unsigned char *data_ptr;
658 int packet_length;
659 int i;
660
661 packet_length =
662 sizeof( int ) + /* packet length */
663 sizeof( GLenum ) + /* extend-o opcode */
664 sizeof( n ) + /* num_textures */
665 n*sizeof( *textures ) + /* textures */
666 8 + 8 + 8; /* return pointers */
667
668 GET_BUFFERED_POINTER(pc, packet_length);
669 WRITE_DATA( 0, int, SWAP32(packet_length) );
670 WRITE_DATA( sizeof( int ) + 0, GLenum, SWAP32(CR_ARETEXTURESRESIDENT_EXTEND_OPCODE) );
671 WRITE_DATA( sizeof( int ) + 4, GLsizei, SWAP32(n) );
672 for (i = 0 ; i < n ; i++)
673 {
674 WRITE_DATA( (i+1)*sizeof( int ) + 8, GLuint, SWAP32(textures[i]) );
675 }
676 WRITE_NETWORK_POINTER( sizeof( int ) + 8 + n*sizeof( *textures ), (void *) residences );
677 WRITE_NETWORK_POINTER( sizeof( int ) + 16 + n*sizeof( *textures ), (void *) return_val );
678 WRITE_NETWORK_POINTER( sizeof( int ) + 24 + n*sizeof( *textures ), (void *) writeback );
679 WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
680}
681
682
683/**********************************************************************
684 * Texture compression
685 */
686
687void PACK_APIENTRY crPackCompressedTexImage1DARBSWAP( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imagesize, const GLvoid *data )
688{
689 unsigned char *data_ptr;
690 int packet_length;
691 int isnull = (data == NULL);
692
693 /* All extended opcodes have their first 8 bytes predefined:
694 * the first four indicate the packet size, and the next four
695 * indicate the actual extended opcode.
696 */
697 packet_length =
698 sizeof( GLenum) + /* extended opcode */
699 sizeof( target ) +
700 sizeof( level ) +
701 sizeof( internalformat ) +
702 sizeof( width ) +
703 sizeof( border ) +
704 sizeof( imagesize ) +
705 sizeof( int );
706
707 if (data)
708 {
709 packet_length += imagesize;
710 }
711
712 data_ptr = (unsigned char *) crPackAlloc( packet_length );
713 WRITE_DATA( 0, GLenum, SWAP32(CR_COMPRESSEDTEXIMAGE1DARB_EXTEND_OPCODE) );
714 WRITE_DATA( 4, GLenum, SWAP32(target) );
715 WRITE_DATA( 8, GLint, SWAP32(level) );
716 WRITE_DATA( 12, GLint, SWAP32(internalformat) );
717 WRITE_DATA( 16, GLsizei, SWAP32(width) );
718 WRITE_DATA( 20, GLint, SWAP32(border) );
719 WRITE_DATA( 24, GLsizei, SWAP32(imagesize) );
720 WRITE_DATA( 28, int, SWAP32(isnull) );
721
722 if (data) {
723 crMemcpy( (void *)(data_ptr + 32), (void *)data, imagesize);
724 }
725
726 crHugePacket( CR_EXTEND_OPCODE, data_ptr );
727 crPackFree( data_ptr );
728}
729
730void PACK_APIENTRY crPackCompressedTexImage2DARBSWAP( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imagesize, const GLvoid *data )
731{
732 unsigned char *data_ptr;
733 int packet_length;
734 int isnull = (data == NULL);
735
736 /* All extended opcodes have their first 8 bytes predefined:
737 * the first four indicate the packet size, and the next four
738 * indicate the actual extended opcode.
739 */
740 packet_length =
741 sizeof( GLenum) + /* extended opcode */
742 sizeof( target ) +
743 sizeof( level ) +
744 sizeof( internalformat ) +
745 sizeof( width ) +
746 sizeof( height ) +
747 sizeof( border ) +
748 sizeof( imagesize ) +
749 sizeof( int ); /* isnull */
750
751 if (data)
752 {
753 packet_length += imagesize;
754 }
755
756 data_ptr = (unsigned char *) crPackAlloc( packet_length );
757 WRITE_DATA( 0, GLenum, SWAP32(CR_COMPRESSEDTEXIMAGE2DARB_EXTEND_OPCODE) );
758 WRITE_DATA( 4, GLenum, SWAP32(target) );
759 WRITE_DATA( 8, GLint, SWAP32(level) );
760 WRITE_DATA( 12, GLint, SWAP32(internalformat) );
761 WRITE_DATA( 16, GLsizei, SWAP32(width) );
762 WRITE_DATA( 20, GLsizei, SWAP32(height) );
763 WRITE_DATA( 24, GLint, SWAP32(border) );
764 WRITE_DATA( 28, GLsizei, SWAP32(imagesize) );
765 WRITE_DATA( 32, int, SWAP32(isnull) );
766
767 if (data) {
768 crMemcpy( (void *)(data_ptr + 36), (void *)data, imagesize);
769 }
770
771 crHugePacket( CR_EXTEND_OPCODE, data_ptr );
772 crPackFree( data_ptr );
773}
774
775void PACK_APIENTRY crPackCompressedTexImage3DARBSWAP( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imagesize, const GLvoid *data )
776{
777 unsigned char *data_ptr;
778 int packet_length;
779 int isnull = (data == NULL);
780
781 /* All extended opcodes have their first 8 bytes predefined:
782 * the first four indicate the packet size, and the next four
783 * indicate the actual extended opcode.
784 */
785 packet_length =
786 sizeof( GLenum) + /* extended opcode */
787 sizeof( target ) +
788 sizeof( level ) +
789 sizeof( internalformat ) +
790 sizeof( width ) +
791 sizeof( height ) +
792 sizeof( depth ) +
793 sizeof( border ) +
794 sizeof( imagesize ) +
795 sizeof( int ); /* isnull */
796
797 if (data)
798 {
799 packet_length += imagesize;
800 }
801
802 data_ptr = (unsigned char *) crPackAlloc( packet_length );
803 WRITE_DATA( 0, GLenum, SWAP32(CR_COMPRESSEDTEXIMAGE3DARB_EXTEND_OPCODE) );
804 WRITE_DATA( 4, GLenum, SWAP32(target) );
805 WRITE_DATA( 8, GLint, SWAP32(level) );
806 WRITE_DATA( 12, GLint, SWAP32(internalformat) );
807 WRITE_DATA( 16, GLsizei, SWAP32(width) );
808 WRITE_DATA( 20, GLsizei, SWAP32(height) );
809 WRITE_DATA( 24, GLsizei, SWAP32(depth) );
810 WRITE_DATA( 28, GLint, SWAP32(border) );
811 WRITE_DATA( 32, GLsizei, SWAP32(imagesize) );
812 WRITE_DATA( 36, int, SWAP32(isnull) );
813
814 if (data) {
815 crMemcpy( (void *)(data_ptr + 40), (void *)data, imagesize);
816 }
817
818 crHugePacket( CR_EXTEND_OPCODE, data_ptr );
819 crPackFree( data_ptr );
820}
821
822void PACK_APIENTRY crPackCompressedTexSubImage1DARBSWAP( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imagesize, const GLvoid *data )
823{
824 unsigned char *data_ptr;
825 int packet_length;
826 int isnull = (data == NULL);
827
828 /* All extended opcodes have their first 8 bytes predefined:
829 * the first four indicate the packet size, and the next four
830 * indicate the actual extended opcode.
831 */
832 packet_length =
833 sizeof( GLenum) + /* extended opcode */
834 sizeof( target ) +
835 sizeof( level ) +
836 sizeof( xoffset ) +
837 sizeof( width ) +
838 sizeof( format ) +
839 sizeof( imagesize ) +
840 sizeof( int ); /* isnull */
841
842 if (data)
843 {
844 packet_length += imagesize;
845 }
846
847 data_ptr = (unsigned char *) crPackAlloc( packet_length );
848 WRITE_DATA( 0, GLenum, SWAP32(CR_COMPRESSEDTEXSUBIMAGE1DARB_EXTEND_OPCODE) );
849 WRITE_DATA( 4, GLenum, SWAP32(target) );
850 WRITE_DATA( 8, GLint, SWAP32(level) );
851 WRITE_DATA( 12, GLint, SWAP32(xoffset) );
852 WRITE_DATA( 16, GLsizei, SWAP32(width) );
853 WRITE_DATA( 20, GLenum, SWAP32(format) );
854 WRITE_DATA( 24, GLsizei, SWAP32(imagesize) );
855 WRITE_DATA( 28, int, SWAP32(isnull) );
856
857 if (data) {
858 crMemcpy( (void *)(data_ptr + 32), (void *)data, imagesize);
859 }
860
861 crHugePacket( CR_EXTEND_OPCODE, data_ptr );
862 crPackFree( data_ptr );
863}
864
865void PACK_APIENTRY crPackCompressedTexSubImage2DARBSWAP( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imagesize, const GLvoid *data )
866{
867 unsigned char *data_ptr;
868 int packet_length;
869 int isnull = (data == NULL);
870
871 /* All extended opcodes have their first 8 bytes predefined:
872 * the first four indicate the packet size, and the next four
873 * indicate the actual extended opcode.
874 */
875 packet_length =
876 sizeof( GLenum) + /* extended opcode */
877 sizeof( target ) +
878 sizeof( level ) +
879 sizeof( xoffset ) +
880 sizeof( yoffset ) +
881 sizeof( width ) +
882 sizeof( height ) +
883 sizeof( format ) +
884 sizeof( imagesize ) +
885 sizeof( int ); /* isnull */
886
887 if (data)
888 {
889 packet_length += imagesize;
890 }
891
892 data_ptr = (unsigned char *) crPackAlloc( packet_length );
893 WRITE_DATA( 0, GLenum, SWAP32(CR_COMPRESSEDTEXSUBIMAGE2DARB_EXTEND_OPCODE) );
894 WRITE_DATA( 4, GLenum, SWAP32(target) );
895 WRITE_DATA( 8, GLint, SWAP32(level) );
896 WRITE_DATA( 12, GLint, SWAP32(xoffset) );
897 WRITE_DATA( 16, GLint, SWAP32(yoffset) );
898 WRITE_DATA( 20, GLsizei, SWAP32(width) );
899 WRITE_DATA( 24, GLsizei, SWAP32(height) );
900 WRITE_DATA( 28, GLenum, SWAP32(format) );
901 WRITE_DATA( 32, GLsizei, SWAP32(imagesize) );
902 WRITE_DATA( 36, int, SWAP32(isnull) );
903
904 if (data) {
905 crMemcpy( (void *)(data_ptr + 40), (void *)data, imagesize);
906 }
907
908 crHugePacket( CR_EXTEND_OPCODE, data_ptr );
909 crPackFree( data_ptr );
910}
911
912void PACK_APIENTRY crPackCompressedTexSubImage3DARBSWAP( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imagesize, const GLvoid *data )
913{
914 unsigned char *data_ptr;
915 int packet_length;
916 int isnull = (data == NULL);
917
918 /* All extended opcodes have their first 8 bytes predefined:
919 * the first four indicate the packet size, and the next four
920 * indicate the actual extended opcode.
921 */
922 packet_length =
923 sizeof( GLenum) + /* extended opcode */
924 sizeof( target ) +
925 sizeof( level ) +
926 sizeof( xoffset ) +
927 sizeof( yoffset ) +
928 sizeof( zoffset ) +
929 sizeof( width ) +
930 sizeof( height ) +
931 sizeof( depth ) +
932 sizeof( format ) +
933 sizeof( imagesize ) +
934 sizeof( int ); /* isnull */
935
936 if (data)
937 {
938 packet_length += imagesize;
939 }
940
941 data_ptr = (unsigned char *) crPackAlloc( packet_length );
942 WRITE_DATA( 0, GLenum, SWAP32(CR_COMPRESSEDTEXSUBIMAGE3DARB_EXTEND_OPCODE) );
943 WRITE_DATA( 4, GLenum, SWAP32(target) );
944 WRITE_DATA( 8, GLint, SWAP32(level) );
945 WRITE_DATA( 12, GLint, SWAP32(xoffset) );
946 WRITE_DATA( 16, GLint, SWAP32(yoffset) );
947 WRITE_DATA( 20, GLint, SWAP32(zoffset) );
948 WRITE_DATA( 24, GLsizei, SWAP32(width) );
949 WRITE_DATA( 28, GLsizei, SWAP32(height) );
950 WRITE_DATA( 32, GLsizei, SWAP32(depth) );
951 WRITE_DATA( 36, GLenum, SWAP32(format) );
952 WRITE_DATA( 40, GLsizei, SWAP32(imagesize) );
953 WRITE_DATA( 44, int, SWAP32(isnull) );
954
955 if (data) {
956 crMemcpy( (void *)(data_ptr + 48), (void *)data, imagesize);
957 }
958
959 crHugePacket( CR_EXTEND_OPCODE, data_ptr );
960 crPackFree( data_ptr );
961}
962
963void PACK_APIENTRY crPackGetCompressedTexImageARBSWAP( GLenum target, GLint level, GLvoid *img, int *writeback )
964{
965 GET_PACKER_CONTEXT(pc);
966 crError ( "GetCompressedTexImageARB needs to be special cased!");
967 (void) pc;
968 (void) target;
969 (void) level;
970 (void) img;
971 (void) writeback;
972}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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