VirtualBox

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

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

crOpenGL: export to OSE

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

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