Changeset 21841 in vbox for trunk/src/VBox/GuestHost/OpenGL/packer/pack_texture.c
- Timestamp:
- Jul 28, 2009 1:38:34 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/OpenGL/packer/pack_texture.c
r15532 r21841 13 13 void PACK_APIENTRY 14 14 crPackTexImage1D(GLenum target, GLint level, 15 16 17 18 { 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 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 53 } 54 54 55 55 void PACK_APIENTRY 56 56 crPackTexImage2D(GLenum target, GLint level, 57 58 59 60 { 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 NULL,/* dst packing (use default params) */118 119 120 unpackstate);/* src packing */121 122 123 124 125 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 126 } 127 127 … … 133 133 const CRPixelPackState *unpackstate ) 134 134 { 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 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 197 } 198 198 #endif /* GL_EXT_texture3D */ … … 200 200 #ifdef CR_OPENGL_VERSION_1_2 201 201 void PACK_APIENTRY crPackTexImage3D(GLenum target, GLint level, 202 203 204 205 206 207 208 { 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 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 271 } 272 272 #endif /* CR_OPENGL_VERSION_1_2 */ … … 276 276 crPackDeleteTextures(GLsizei n, const GLuint * textures) 277 277 { 278 279 280 281 282 283 284 285 286 287 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 288 } 289 289 … … 291 291 __handleTexEnvData(GLenum target, GLenum pname, const GLfloat * params) 292 292 { 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 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 318 } 319 319 … … 322 322 crPackTexEnvfv(GLenum target, GLenum pname, const GLfloat * params) 323 323 { 324 325 326 324 GET_PACKER_CONTEXT(pc); 325 __handleTexEnvData(target, pname, params); 326 WRITE_OPCODE(pc, CR_TEXENVFV_OPCODE); 327 327 } 328 328 … … 330 330 crPackTexEnviv(GLenum target, GLenum pname, const GLint * params) 331 331 { 332 333 334 335 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 336 } 337 337 … … 339 339 crPackTexEnvf(GLenum target, GLenum pname, GLfloat param) 340 340 { 341 341 crPackTexEnvfv(target, pname, ¶m); 342 342 } 343 343 … … 345 345 crPackTexEnvi(GLenum target, GLenum pname, GLint param) 346 346 { 347 347 crPackTexEnviv(target, pname, ¶m); 348 348 } 349 349 … … 352 352 const GLclampf * priorities) 353 353 { 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 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 369 } 370 370 371 371 static void 372 372 __handleTexGenData(GLenum coord, GLenum pname, 373 374 { 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 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 391 } 392 392 … … 394 394 crPackTexGendv(GLenum coord, GLenum pname, const GLdouble * params) 395 395 { 396 397 398 396 GET_PACKER_CONTEXT(pc); 397 __handleTexGenData(coord, pname, sizeof(*params), params); 398 WRITE_OPCODE(pc, CR_TEXGENDV_OPCODE); 399 399 } 400 400 … … 402 402 crPackTexGenfv(GLenum coord, GLenum pname, const GLfloat * params) 403 403 { 404 405 406 404 GET_PACKER_CONTEXT(pc); 405 __handleTexGenData(coord, pname, sizeof(*params), params); 406 WRITE_OPCODE(pc, CR_TEXGENFV_OPCODE); 407 407 } 408 408 … … 410 410 crPackTexGeniv(GLenum coord, GLenum pname, const GLint * params) 411 411 { 412 413 414 412 GET_PACKER_CONTEXT(pc); 413 __handleTexGenData(coord, pname, sizeof(*params), params); 414 WRITE_OPCODE(pc, CR_TEXGENIV_OPCODE); 415 415 } 416 416 … … 418 418 crPackTexGend(GLenum coord, GLenum pname, GLdouble param) 419 419 { 420 420 crPackTexGendv(coord, pname, ¶m); 421 421 } 422 422 … … 424 424 crPackTexGenf(GLenum coord, GLenum pname, GLfloat param) 425 425 { 426 426 crPackTexGenfv(coord, pname, ¶m); 427 427 } 428 428 … … 430 430 crPackTexGeni(GLenum coord, GLenum pname, GLint param) 431 431 { 432 432 crPackTexGeniv(coord, pname, ¶m); 433 433 } 434 434 … … 436 436 __handleTexParameterData(GLenum target, GLenum pname, const GLfloat * params) 437 437 { 438 439 440 441 442 443 444 445 446 447 448 449 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 450 #ifdef GL_TEXTURE_PRIORITY 451 451 case GL_TEXTURE_PRIORITY: 452 452 #endif 453 454 455 456 457 458 459 460 461 462 463 464 465 466 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 467 #ifdef CR_ARB_shadow 468 469 470 471 468 case GL_TEXTURE_COMPARE_MODE_ARB: 469 case GL_TEXTURE_COMPARE_FUNC_ARB: 470 num_params = 1; 471 break; 472 472 #endif 473 473 #ifdef CR_ARB_shadow_ambient 474 475 476 474 case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: 475 num_params = 1; 476 break; 477 477 #endif 478 478 #ifdef CR_ARB_depth_texture 479 480 481 479 case GL_DEPTH_TEXTURE_MODE_ARB: 480 num_params = 1; 481 break; 482 482 #endif 483 483 #ifdef CR_SGIS_generate_mipmap 484 485 486 484 case GL_GENERATE_MIPMAP_SGIS: 485 num_params = 1; 486 break; 487 487 #endif 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 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 505 } 506 506 … … 508 508 crPackTexParameterfv(GLenum target, GLenum pname, const GLfloat * params) 509 509 { 510 511 512 510 GET_PACKER_CONTEXT(pc); 511 if (__handleTexParameterData(target, pname, params)) 512 WRITE_OPCODE(pc, CR_TEXPARAMETERFV_OPCODE); 513 513 } 514 514 … … 516 516 crPackTexParameteriv(GLenum target, GLenum pname, const GLint * params) 517 517 { 518 519 520 518 GET_PACKER_CONTEXT(pc); 519 if (__handleTexParameterData(target, pname, (GLfloat *) params)) 520 WRITE_OPCODE(pc, CR_TEXPARAMETERIV_OPCODE); 521 521 } 522 522 … … 524 524 crPackTexParameterf(GLenum target, GLenum pname, GLfloat param) 525 525 { 526 526 crPackTexParameterfv(target, pname, ¶m); 527 527 } 528 528 … … 530 530 crPackTexParameteri(GLenum target, GLenum pname, GLint param) 531 531 { 532 532 crPackTexParameteriv(target, pname, ¶m); 533 533 } 534 534 … … 536 536 void PACK_APIENTRY 537 537 crPackTexSubImage3D(GLenum target, GLint level, 538 539 540 541 542 { 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 crPixelCopy3D(width, height, depth, (GLvoid *) (data_ptr + 40), format, type, NULL,/* dst */571 pixels, format, type, unpackstate);/* src */572 573 574 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 575 } 576 576 #endif /* CR_OPENGL_VERSION_1_2 */ … … 578 578 void PACK_APIENTRY 579 579 crPackTexSubImage2D(GLenum target, GLint level, 580 581 582 583 584 { 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 crPixelCopy2D(width, height, (GLvoid *) (data_ptr + 32), format, type, NULL,/* dst */608 pixels, format, type, unpackstate);/* src */609 610 611 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 612 } 613 613 614 614 void PACK_APIENTRY 615 615 crPackTexSubImage1D(GLenum target, GLint level, 616 617 618 619 { 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 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 643 } 644 644 645 645 void PACK_APIENTRY 646 646 crPackAreTexturesResident(GLsizei n, const GLuint * textures, 647 648 649 { 650 651 652 653 654 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 661 662 663 664 665 666 667 WRITE_NETWORK_POINTER(12 + n * sizeof(*textures),(void *) residences);668 669 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 670 } 671 671 … … 677 677 void PACK_APIENTRY crPackCompressedTexImage1DARB( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imagesize, const GLvoid *data ) 678 678 { 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 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 719 } 720 720 721 721 void PACK_APIENTRY crPackCompressedTexImage2DARB( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imagesize, const GLvoid *data ) 722 722 { 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 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 766 } 767 767 768 768 void PACK_APIENTRY crPackCompressedTexImage3DARB( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imagesize, const GLvoid *data ) 769 769 { 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 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 813 } 814 814 815 815 void PACK_APIENTRY crPackCompressedTexSubImage1DARB( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imagesize, const GLvoid *data ) 816 816 { 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 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 856 } 857 857 858 858 void PACK_APIENTRY crPackCompressedTexSubImage2DARB( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imagesize, const GLvoid *data ) 859 859 { 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 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 903 } 904 904 905 905 void 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 906 { 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 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 954 } 955 955 956 956 void PACK_APIENTRY crPackGetCompressedTexImageARB( GLenum target, GLint level, GLvoid *img, int *writeback ) 957 957 { 958 959 960 961 962 963 964 965 } 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 }
Note:
See TracChangeset
for help on using the changeset viewer.