Changeset 78375 in vbox for trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_bufferobject.c
- Timestamp:
- May 3, 2019 9:51:02 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_bufferobject.c
r78116 r78375 28 28 } 29 29 30 void STATE_APIENTRY crStateGenBuffersARB( GLsizei n, GLuint *buffers)31 { 32 CRContext *g = GetCurrentContext( );30 void STATE_APIENTRY crStateGenBuffersARB(PCRStateTracker pState, GLsizei n, GLuint *buffers) 31 { 32 CRContext *g = GetCurrentContext(pState); 33 33 crStateGenNames(g, g->shared->buffersTable, n, buffers); 34 34 } 35 35 36 void crStateRegBuffers( GLsizei n, GLuint *buffers)37 { 38 CRContext *g = GetCurrentContext( );36 void crStateRegBuffers(PCRStateTracker pState, GLsizei n, GLuint *buffers) 37 { 38 CRContext *g = GetCurrentContext(pState); 39 39 crStateRegNames(g, g->shared->buffersTable, n, buffers); 40 40 } … … 61 61 } 62 62 63 GLboolean crStateIsBufferBound( GLenum target)64 { 65 CRContext *g = GetCurrentContext( );63 GLboolean crStateIsBufferBound(PCRStateTracker pState, GLenum target) 64 { 65 CRContext *g = GetCurrentContext(pState); 66 66 return crStateIsBufferBoundForCtx(g, target); 67 67 } … … 86 86 } 87 87 88 DECLEXPORT(GLboolean) STATE_APIENTRY crStateIsBufferARB( GLuint buffer )89 { 90 CRContext *g = GetCurrentContext( );88 DECLEXPORT(GLboolean) STATE_APIENTRY crStateIsBufferARB(PCRStateTracker pState, GLuint buffer ) 89 { 90 CRContext *g = GetCurrentContext(pState); 91 91 92 92 FLUSH(); 93 93 94 94 if (g->current.inBeginEnd) { 95 crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION,95 crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, 96 96 "glIsBufferARB called in begin/end"); 97 97 return GL_FALSE; … … 103 103 void crStateBufferObjectInit (CRContext *ctx) 104 104 { 105 CRStateBits *sb = GetCurrentBits( );105 CRStateBits *sb = GetCurrentBits(ctx->pStateTracker); 106 106 CRBufferObjectBits *bb = &sb->bufferobject; 107 107 CRBufferObjectState *b = &ctx->bufferobject; … … 114 114 RESET(bb->packBinding, ctx->bitid); 115 115 #endif 116 117 b->pStateTracker = ctx->pStateTracker; 116 118 117 119 #ifdef IN_GUEST … … 134 136 } 135 137 136 void crStateFreeBufferObject(void *data )138 void crStateFreeBufferObject(void *data, void *pvUser) 137 139 { 138 140 CRBufferObject *pObj = (CRBufferObject *)data; 141 PCRStateTracker pState = (PCRStateTracker)pvUser; 139 142 if (pObj->data) crFree(pObj->data); 140 143 141 144 #ifndef IN_GUEST 142 if ( diff_api.DeleteBuffersARB)143 { 144 diff_api.DeleteBuffersARB(1, &pObj->hwid);145 if (pState->diff_api.DeleteBuffersARB) 146 { 147 pState->diff_api.DeleteBuffersARB(1, &pObj->hwid); 145 148 } 146 149 #endif … … 165 168 } 166 169 167 DECLEXPORT(GLuint) STATE_APIENTRY crStateBufferHWIDtoID( GLuint hwid)168 { 169 CRContext *g = GetCurrentContext( );170 DECLEXPORT(GLuint) STATE_APIENTRY crStateBufferHWIDtoID(PCRStateTracker pState, GLuint hwid) 171 { 172 CRContext *g = GetCurrentContext(pState); 170 173 crCheckIDHWID_t parms; 171 174 … … 177 180 } 178 181 179 DECLEXPORT(GLuint) STATE_APIENTRY crStateGetBufferHWID( GLuint id)180 { 181 CRContext *g = GetCurrentContext( );182 DECLEXPORT(GLuint) STATE_APIENTRY crStateGetBufferHWID(PCRStateTracker pState, GLuint id) 183 { 184 CRContext *g = GetCurrentContext(pState); 182 185 CRBufferObject *pObj = (CRBufferObject *) crHashtableSearch(g->shared->buffersTable, id); 183 186 … … 186 189 187 190 void STATE_APIENTRY 188 crStateBindBufferARB ( GLenum target, GLuint buffer)189 { 190 CRContext *g = GetCurrentContext( );191 crStateBindBufferARB (PCRStateTracker pState, GLenum target, GLuint buffer) 192 { 193 CRContext *g = GetCurrentContext(pState); 191 194 CRBufferObjectState *b = &(g->bufferobject); 192 CRStateBits *sb = GetCurrentBits( );195 CRStateBits *sb = GetCurrentBits(pState); 193 196 CRBufferObjectBits *bb = &(sb->bufferobject); 194 197 CRBufferObject *oldObj, *newObj; 195 198 196 199 if (g->current.inBeginEnd) { 197 crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION,200 crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, 198 201 "glBindBufferARB called in begin/end"); 199 202 return; … … 205 208 if (!oldObj) 206 209 { 207 crStateError( __LINE__, __FILE__, GL_INVALID_ENUM, "glBindBufferARB(target)");210 crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "glBindBufferARB(target)"); 208 211 return; 209 212 } … … 219 222 CRSTATE_CHECKERR(!newObj, GL_OUT_OF_MEMORY, "glBindBuffer"); 220 223 #ifndef IN_GUEST 221 diff_api.GenBuffersARB(1, &newObj->hwid);224 pState->diff_api.GenBuffersARB(1, &newObj->hwid); 222 225 if (!newObj->hwid) 223 226 { … … 268 271 /*we shouldn't reach this point*/ 269 272 CRASSERT(false); 270 crHashtableDelete (g->shared->buffersTable, (unsigned long) oldObj->id, crStateFreeBufferObject);273 crHashtableDeleteEx(g->shared->buffersTable, (unsigned long) oldObj->id, crStateFreeBufferObject, pState); 271 274 } 272 275 … … 279 282 } 280 283 281 static void ctStateBuffersRefsCleanup( CRContext *ctx, CRBufferObject *obj, CRbitvalue *neg_bitid)284 static void ctStateBuffersRefsCleanup(PCRStateTracker pState, CRContext *ctx, CRBufferObject *obj, CRbitvalue *neg_bitid) 282 285 { 283 286 CRBufferObjectState *b = &(ctx->bufferobject); 284 CRStateBits *sb = GetCurrentBits( );287 CRStateBits *sb = GetCurrentBits(pState); 285 288 CRBufferObjectBits *bb = &(sb->bufferobject); 286 289 int j, k; … … 347 350 348 351 void STATE_APIENTRY 349 crStateDeleteBuffersARB( GLsizei n, const GLuint *buffers)350 { 351 CRContext *g = GetCurrentContext( );352 crStateDeleteBuffersARB(PCRStateTracker pState, GLsizei n, const GLuint *buffers) 353 { 354 CRContext *g = GetCurrentContext(pState); 352 355 int i; 353 356 … … 355 358 356 359 if (g->current.inBeginEnd) { 357 crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION,360 crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, 358 361 "glDeleteBuffersARB called in Begin/End"); 359 362 return; … … 361 364 362 365 if (n < 0) { 363 crStateError( __LINE__, __FILE__, GL_INVALID_VALUE,366 crStateError(pState, __LINE__, __FILE__, GL_INVALID_VALUE, 364 367 "glDeleteBuffersARB(n < 0)"); 365 368 return; … … 373 376 int j; 374 377 375 ctStateBuffersRefsCleanup( g, obj, g->neg_bitid);378 ctStateBuffersRefsCleanup(pState, g, obj, g->neg_bitid); 376 379 377 380 CR_STATE_SHAREDOBJ_USAGE_FOREACH_USED_IDX(obj, j) … … 381 384 * This is why g_pAvailableContexts[j] could be NULL 382 385 * also g_pAvailableContexts[0] will hold default context, which we should discard */ 383 CRContext *ctx = g_pAvailableContexts[j];386 CRContext *ctx = pState->apAvailableContexts[j]; 384 387 if (j && ctx) 385 388 { 386 ctStateBuffersRefsCleanup( ctx, obj, g->neg_bitid); /* <- yes, use g->neg_bitid, i.e. neg_bitid of the current context to ensure others bits get dirtified,387 * but not the current context ones*/389 ctStateBuffersRefsCleanup(pState, ctx, obj, g->neg_bitid); /* <- yes, use g->neg_bitid, i.e. neg_bitid of the current context to ensure others bits get dirtified, 390 * but not the current context ones*/ 388 391 } 389 392 else … … 391 394 } 392 395 393 crHashtableDelete (g->shared->buffersTable, buffers[i], crStateFreeBufferObject);396 crHashtableDeleteEx(g->shared->buffersTable, buffers[i], crStateFreeBufferObject, pState); 394 397 } 395 398 } … … 398 401 399 402 void STATE_APIENTRY 400 crStateBufferDataARB( GLenum target, GLsizeiptrARB size, const GLvoid * data, GLenum usage)401 { 402 CRContext *g = GetCurrentContext( );403 crStateBufferDataARB(PCRStateTracker pState, GLenum target, GLsizeiptrARB size, const GLvoid * data, GLenum usage) 404 { 405 CRContext *g = GetCurrentContext(pState); 403 406 CRBufferObjectState *b = &g->bufferobject; 404 407 CRBufferObject *obj; 405 CRStateBits *sb = GetCurrentBits( );408 CRStateBits *sb = GetCurrentBits(pState); 406 409 CRBufferObjectBits *bb = &sb->bufferobject; 407 410 … … 409 412 410 413 if (g->current.inBeginEnd) { 411 crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION,414 crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, 412 415 "glBufferDataARB called in begin/end"); 413 416 return; … … 415 418 416 419 if (size < 0) { 417 crStateError( __LINE__, __FILE__, GL_INVALID_VALUE,420 crStateError(pState, __LINE__, __FILE__, GL_INVALID_VALUE, 418 421 "glBufferDataARB(size < 0)"); 419 422 return; … … 433 436 break; 434 437 default: 435 crStateError( __LINE__, __FILE__, GL_INVALID_ENUM,438 crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, 436 439 "glBufferDataARB(usage)"); 437 440 return; … … 441 444 if (!obj) 442 445 { 443 crStateError( __LINE__, __FILE__, GL_INVALID_ENUM, "glBufferDataARB(target)");446 crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "glBufferDataARB(target)"); 444 447 return; 445 448 } 446 449 447 450 if (obj->id == 0) { 448 crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION, "glBufferDataARB");451 crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, "glBufferDataARB"); 449 452 return; 450 453 } 451 454 452 455 if (obj->pointer) { 453 crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION,456 crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, 454 457 "glBufferDataARB(buffer is mapped)"); 455 458 return; … … 469 472 obj->data = crAlloc(size); 470 473 if (!obj->data) { 471 crStateError( __LINE__, __FILE__, GL_OUT_OF_MEMORY, "glBufferDataARB");474 crStateError(pState, __LINE__, __FILE__, GL_OUT_OF_MEMORY, "glBufferDataARB"); 472 475 return; 473 476 } … … 484 487 485 488 void STATE_APIENTRY 486 crStateBufferSubDataARB( GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid * data)487 { 488 CRContext *g = GetCurrentContext( );489 crStateBufferSubDataARB(PCRStateTracker pState, GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid * data) 490 { 491 CRContext *g = GetCurrentContext(pState); 489 492 CRBufferObjectState *b = &g->bufferobject; 490 493 CRBufferObject *obj; 491 CRStateBits *sb = GetCurrentBits( );494 CRStateBits *sb = GetCurrentBits(pState); 492 495 CRBufferObjectBits *bb = &sb->bufferobject; 493 496 … … 495 498 496 499 if (g->current.inBeginEnd) { 497 crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION,500 crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, 498 501 "glBufferSubDataARB called in begin/end"); 499 502 return; … … 503 506 if (!obj) 504 507 { 505 crStateError( __LINE__, __FILE__, GL_INVALID_ENUM, "glBufferSubDataARB(target)");508 crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "glBufferSubDataARB(target)"); 506 509 return; 507 510 } 508 511 509 512 if (obj->id == 0) { 510 crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION,513 crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, 511 514 "glBufferSubDataARB"); 512 515 return; … … 514 517 515 518 if (obj->pointer) { 516 crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION,519 crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, 517 520 "glBufferSubDataARB(buffer is mapped)"); 518 521 return; … … 520 523 521 524 if (size < 0 || offset < 0 || (unsigned int)offset + size > obj->size) { 522 crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION,525 crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, 523 526 "glBufferSubDataARB(bad offset and/or size)"); 524 527 return; … … 540 543 541 544 void STATE_APIENTRY 542 crStateGetBufferSubDataARB( GLenum target, GLintptrARB offset, GLsizeiptrARB size, void * data)543 { 544 CRContext *g = GetCurrentContext( );545 crStateGetBufferSubDataARB(PCRStateTracker pState, GLenum target, GLintptrARB offset, GLsizeiptrARB size, void * data) 546 { 547 CRContext *g = GetCurrentContext(pState); 545 548 CRBufferObjectState *b = &g->bufferobject; 546 549 CRBufferObject *obj; … … 549 552 550 553 if (g->current.inBeginEnd) { 551 crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION,554 crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, 552 555 "glGetBufferSubDataARB called in begin/end"); 553 556 return; … … 557 560 if (!obj) 558 561 { 559 crStateError( __LINE__, __FILE__, GL_INVALID_ENUM, "glGetBufferSubDataARB(target)");562 crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "glGetBufferSubDataARB(target)"); 560 563 return; 561 564 } 562 565 563 566 if (obj->id == 0) { 564 crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION,567 crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, 565 568 "glGetBufferSubDataARB"); 566 569 return; … … 568 571 569 572 if (obj->pointer) { 570 crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION,573 crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, 571 574 "glGetBufferSubDataARB(buffer is mapped)"); 572 575 return; … … 574 577 575 578 if (size < 0 || offset < 0 || (unsigned int)offset + size > obj->size) { 576 crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION,579 crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, 577 580 "glGetBufferSubDataARB(bad offset and/or size)"); 578 581 return; … … 586 589 587 590 void * STATE_APIENTRY 588 crStateMapBufferARB( GLenum target, GLenum access)589 { 590 CRContext *g = GetCurrentContext( );591 crStateMapBufferARB(PCRStateTracker pState, GLenum target, GLenum access) 592 { 593 CRContext *g = GetCurrentContext(pState); 591 594 CRBufferObjectState *b = &g->bufferobject; 592 595 CRBufferObject *obj; … … 595 598 596 599 if (g->current.inBeginEnd) { 597 crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION,600 crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, 598 601 "glMapBufferARB called in begin/end"); 599 602 return NULL; … … 603 606 if (!obj) 604 607 { 605 crStateError( __LINE__, __FILE__, GL_INVALID_ENUM, "glMapBufferARB(target)");608 crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "glMapBufferARB(target)"); 606 609 return NULL; 607 610 } 608 611 609 612 if (obj->id == 0) { 610 crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION, "glMapBufferARB");613 crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, "glMapBufferARB"); 611 614 return GL_FALSE; 612 615 } … … 619 622 break; 620 623 default: 621 crStateError( __LINE__, __FILE__, GL_INVALID_ENUM,624 crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, 622 625 "glMapBufferARB(access)"); 623 626 return NULL; … … 632 635 633 636 GLboolean STATE_APIENTRY 634 crStateUnmapBufferARB( GLenum target)635 { 636 CRContext *g = GetCurrentContext( );637 crStateUnmapBufferARB(PCRStateTracker pState, GLenum target) 638 { 639 CRContext *g = GetCurrentContext(pState); 637 640 CRBufferObjectState *b = &g->bufferobject; 638 641 CRBufferObject *obj; 639 CRStateBits *sb = GetCurrentBits( );642 CRStateBits *sb = GetCurrentBits(pState); 640 643 CRBufferObjectBits *bb = &sb->bufferobject; 641 644 … … 643 646 644 647 if (g->current.inBeginEnd) { 645 crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION,648 crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, 646 649 "glUnmapBufferARB called in begin/end"); 647 650 return GL_FALSE; … … 651 654 if (!obj) 652 655 { 653 crStateError( __LINE__, __FILE__, GL_INVALID_ENUM, "glUnmapBufferARB(target)");656 crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "glUnmapBufferARB(target)"); 654 657 return GL_FALSE; 655 658 } 656 659 657 660 if (obj->id == 0) { 658 crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION, "glUnmapBufferARB");661 crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, "glUnmapBufferARB"); 659 662 return GL_FALSE; 660 663 } 661 664 662 665 if (!obj->pointer) { 663 crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION, "glUnmapBufferARB");666 crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, "glUnmapBufferARB"); 664 667 return GL_FALSE; 665 668 } … … 680 683 681 684 void STATE_APIENTRY 682 crStateGetBufferParameterivARB( GLenum target, GLenum pname, GLint *params)683 { 684 CRContext *g = GetCurrentContext( );685 crStateGetBufferParameterivARB(PCRStateTracker pState, GLenum target, GLenum pname, GLint *params) 686 { 687 CRContext *g = GetCurrentContext(pState); 685 688 CRBufferObjectState *b = &g->bufferobject; 686 689 CRBufferObject *obj; … … 689 692 690 693 if (g->current.inBeginEnd) { 691 crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION,694 crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, 692 695 "glGetBufferParameterivARB called in begin/end"); 693 696 return; … … 697 700 if (!obj) 698 701 { 699 crStateError( __LINE__, __FILE__, GL_INVALID_ENUM, "glGetBufferParameterivARB(target)");702 crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "glGetBufferParameterivARB(target)"); 700 703 return; 701 704 } … … 715 718 break; 716 719 default: 717 crStateError( __LINE__, __FILE__, GL_INVALID_ENUM,720 crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, 718 721 "glGetBufferParameterivARB(pname)"); 719 722 return; … … 723 726 724 727 void STATE_APIENTRY 725 crStateGetBufferPointervARB( GLenum target, GLenum pname, GLvoid **params)726 { 727 CRContext *g = GetCurrentContext( );728 crStateGetBufferPointervARB(PCRStateTracker pState, GLenum target, GLenum pname, GLvoid **params) 729 { 730 CRContext *g = GetCurrentContext(pState); 728 731 CRBufferObjectState *b = &g->bufferobject; 729 732 CRBufferObject *obj; … … 732 735 733 736 if (g->current.inBeginEnd) { 734 crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION,737 crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, 735 738 "glGetBufferPointervARB called in begin/end"); 736 739 return; … … 740 743 if (!obj) 741 744 { 742 crStateError( __LINE__, __FILE__, GL_INVALID_ENUM, "glGetBufferPointervARB(target)");745 crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "glGetBufferPointervARB(target)"); 743 746 return; 744 747 } 745 748 746 749 if (pname != GL_BUFFER_MAP_POINTER_ARB) { 747 crStateError( __LINE__, __FILE__, GL_INVALID_ENUM, "glGetBufferPointervARB(pname)");750 crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "glGetBufferPointervARB(pname)"); 748 751 return; 749 752 } … … 763 766 */ 764 767 static GLboolean 765 HaveBufferObjectExtension( void)768 HaveBufferObjectExtension(PCRStateTracker pState) 766 769 { 767 770 static GLint haveBufferObjectExt = -1; … … 772 775 * GetString into the diff'ing table in order for this to really work. 773 776 */ 774 if (! diff_api.GetString) {777 if (!pState->diff_api.GetString) { 775 778 haveBufferObjectExt = 0; 776 779 return 0; 777 780 } 778 CRASSERT( diff_api.GetString);779 ext = (const char *) diff_api.GetString(GL_EXTENSIONS);781 CRASSERT(pState->diff_api.GetString); 782 ext = (const char *) pState->diff_api.GetString(GL_EXTENSIONS); 780 783 if (crStrstr(ext, "GL_ARB_vertex_buffer_object") || 781 784 crStrstr(ext, "GL_ARB_pixel_buffer_object")) { … … 793 796 GLboolean bSwitch) 794 797 { 798 PCRStateTracker pState = fromCtx->pStateTracker; 795 799 CRBufferObjectState *from = &(fromCtx->bufferobject); 796 800 const CRBufferObjectState *to = &(toCtx->bufferobject); 797 801 802 CRASSERT(fromCtx->pStateTracker == toCtx->pStateTracker); 803 798 804 /* ARRAY_BUFFER */ 799 805 if (CHECKDIRTY(bb->arrayBinding, bitID)) … … 802 808 { 803 809 GLuint bufferID = to->arrayBuffer ? to->arrayBuffer->hwid : 0; 804 diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, bufferID);810 pState->diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, bufferID); 805 811 if (bSwitch) 806 812 { … … 825 831 { 826 832 /* update whole buffer */ 827 diff_api.BufferDataARB(GL_ARRAY_BUFFER_ARB, bufObj->size,828 bufObj->data, bufObj->usage);833 pState->diff_api.BufferDataARB(GL_ARRAY_BUFFER_ARB, bufObj->size, 834 bufObj->data, bufObj->usage); 829 835 } 830 836 else 831 837 { 832 838 /* update sub buffer */ 833 diff_api.BufferSubDataARB(GL_ARRAY_BUFFER_ARB,834 bufObj->dirtyStart, bufObj->dirtyLength,835 (char *) bufObj->data + bufObj->dirtyStart);839 pState->diff_api.BufferSubDataARB(GL_ARRAY_BUFFER_ARB, 840 bufObj->dirtyStart, bufObj->dirtyLength, 841 (char *) bufObj->data + bufObj->dirtyStart); 836 842 } 837 843 if (bSwitch) FILLDIRTY(bufObj->dirty); … … 845 851 { 846 852 GLuint bufferID = to->elementsBuffer ? to->elementsBuffer->hwid : 0; 847 diff_api.BindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, bufferID);853 pState->diff_api.BindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, bufferID); 848 854 if (bSwitch) 849 855 { … … 868 874 { 869 875 /* update whole buffer */ 870 diff_api.BufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, bufObj->size,871 bufObj->data, bufObj->usage);876 pState->diff_api.BufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, bufObj->size, 877 bufObj->data, bufObj->usage); 872 878 } 873 879 else 874 880 { 875 881 /* update sub buffer */ 876 diff_api.BufferSubDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB,877 bufObj->dirtyStart, bufObj->dirtyLength,878 (char *) bufObj->data + bufObj->dirtyStart);882 pState->diff_api.BufferSubDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 883 bufObj->dirtyStart, bufObj->dirtyLength, 884 (char *) bufObj->data + bufObj->dirtyStart); 879 885 } 880 886 if (bSwitch) FILLDIRTY(bufObj->dirty); … … 889 895 { 890 896 GLuint bufferID = to->packBuffer ? to->packBuffer->hwid : 0; 891 diff_api.BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, bufferID);897 pState->diff_api.BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, bufferID); 892 898 if (bSwitch) 893 899 { … … 912 918 { 913 919 /* update whole buffer */ 914 diff_api.BufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, bufObj->size,915 bufObj->data, bufObj->usage);920 pState->diff_api.BufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, bufObj->size, 921 bufObj->data, bufObj->usage); 916 922 } 917 923 else 918 924 { 919 925 /* update sub buffer */ 920 diff_api.BufferSubDataARB(GL_PIXEL_PACK_BUFFER_ARB,921 bufObj->dirtyStart, bufObj->dirtyLength,922 (char *) bufObj->data + bufObj->dirtyStart);926 pState->diff_api.BufferSubDataARB(GL_PIXEL_PACK_BUFFER_ARB, 927 bufObj->dirtyStart, bufObj->dirtyLength, 928 (char *) bufObj->data + bufObj->dirtyStart); 923 929 } 924 930 if (bSwitch) FILLDIRTY(bufObj->dirty); … … 932 938 { 933 939 GLuint bufferID = to->unpackBuffer ? to->unpackBuffer->hwid : 0; 934 diff_api.BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, bufferID);940 pState->diff_api.BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, bufferID); 935 941 if (bSwitch) 936 942 { … … 955 961 { 956 962 /* update whole buffer */ 957 diff_api.BufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, bufObj->size,958 bufObj->data, bufObj->usage);963 pState->diff_api.BufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, bufObj->size, 964 bufObj->data, bufObj->usage); 959 965 } 960 966 else 961 967 { 962 968 /* update sub buffer */ 963 diff_api.BufferSubDataARB(GL_PIXEL_UNPACK_BUFFER_ARB,964 bufObj->dirtyStart, bufObj->dirtyLength,965 (char *) bufObj->data + bufObj->dirtyStart);969 pState->diff_api.BufferSubDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, 970 bufObj->dirtyStart, bufObj->dirtyLength, 971 (char *) bufObj->data + bufObj->dirtyStart); 966 972 } 967 973 if (bSwitch) FILLDIRTY(bufObj->dirty); … … 974 980 CRContext *fromCtx, CRContext *toCtx) 975 981 { 976 /*CRBufferObjectState *from = &(fromCtx->bufferobject); - unused977 const CRBufferObjectState *to = &(toCtx->bufferobject); - unused */978 979 if (!HaveBufferObjectExtension( ))982 PCRStateTracker pState = fromCtx->pStateTracker; 983 CRASSERT(fromCtx->pStateTracker == toCtx->pStateTracker); 984 985 if (!HaveBufferObjectExtension(pState)) 980 986 return; 981 987 … … 991 997 if (pBufferObj->id && !pBufferObj->hwid) 992 998 { 993 diff_api.GenBuffersARB(1, &pBufferObj->hwid);999 pState->pStateTracker->diff_api.GenBuffersARB(1, &pBufferObj->hwid); 994 1000 CRASSERT(pBufferObj->hwid); 995 1001 } … … 1004 1010 hurt performance." 1005 1011 */ 1006 diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, pBufferObj->hwid);1007 diff_api.BufferDataARB(GL_ARRAY_BUFFER_ARB, pBufferObj->size, pBufferObj->data, pBufferObj->usage);1012 pState->pStateTracker->diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, pBufferObj->hwid); 1013 pState->pStateTracker->diff_api.BufferDataARB(GL_ARRAY_BUFFER_ARB, pBufferObj->size, pBufferObj->data, pBufferObj->usage); 1008 1014 1009 1015 if (!pState->retainBufferData) … … 1021 1027 CRContext *fromCtx, CRContext *toCtx) 1022 1028 { 1023 /*const CRBufferObjectState *from = &(fromCtx->bufferobject); - unused */1024 1029 CRBufferObjectState *to = &(toCtx->bufferobject); 1030 PCRStateTracker pState = fromCtx->pStateTracker; 1025 1031 int i; 1026 1032 1027 if (!HaveBufferObjectExtension()) 1033 CRASSERT(fromCtx->pStateTracker == toCtx->pStateTracker); 1034 1035 if (!HaveBufferObjectExtension(pState)) 1028 1036 return; 1029 1037 … … 1040 1048 if (cp->buffer && (cp->buffer->id || locked)) 1041 1049 { 1042 diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid);1043 diff_api.VertexPointer(cp->size, cp->type, cp->stride, cp->p CRVBOX_HOST_ONLY_PARAM(-1 /*fRealPtr*/));1050 pState->diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid); 1051 pState->diff_api.VertexPointer(cp->size, cp->type, cp->stride, cp->p CRVBOX_HOST_ONLY_PARAM(-1 /*fRealPtr*/)); 1044 1052 } 1045 1053 … … 1047 1055 if (cp->buffer && (cp->buffer->id || locked)) 1048 1056 { 1049 diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid);1050 diff_api.ColorPointer(cp->size, cp->type, cp->stride, cp->p CRVBOX_HOST_ONLY_PARAM(-1 /*fRealPtr*/));1057 pState->diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid); 1058 pState->diff_api.ColorPointer(cp->size, cp->type, cp->stride, cp->p CRVBOX_HOST_ONLY_PARAM(-1 /*fRealPtr*/)); 1051 1059 } 1052 1060 … … 1054 1062 if (cp->buffer && (cp->buffer->id || locked)) 1055 1063 { 1056 diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid);1057 diff_api.FogCoordPointerEXT(cp->type, cp->stride, cp->p CRVBOX_HOST_ONLY_PARAM(-1 /*fRealPtr*/));1064 pState->diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid); 1065 pState->diff_api.FogCoordPointerEXT(cp->type, cp->stride, cp->p CRVBOX_HOST_ONLY_PARAM(-1 /*fRealPtr*/)); 1058 1066 } 1059 1067 … … 1061 1069 if (cp->buffer && (cp->buffer->id || locked)) 1062 1070 { 1063 diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid);1064 diff_api.SecondaryColorPointerEXT(cp->size, cp->type, cp->stride, cp->p CRVBOX_HOST_ONLY_PARAM(-1 /*fRealPtr*/));1071 pState->diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid); 1072 pState->diff_api.SecondaryColorPointerEXT(cp->size, cp->type, cp->stride, cp->p CRVBOX_HOST_ONLY_PARAM(-1 /*fRealPtr*/)); 1065 1073 } 1066 1074 … … 1068 1076 if (cp->buffer && (cp->buffer->id || locked)) 1069 1077 { 1070 diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid);1071 diff_api.EdgeFlagPointer(cp->stride, cp->p CRVBOX_HOST_ONLY_PARAM(-1 /*fRealPtr*/));1078 pState->diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid); 1079 pState->diff_api.EdgeFlagPointer(cp->stride, cp->p CRVBOX_HOST_ONLY_PARAM(-1 /*fRealPtr*/)); 1072 1080 } 1073 1081 … … 1075 1083 if (cp->buffer && (cp->buffer->id || locked)) 1076 1084 { 1077 diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid);1078 diff_api.IndexPointer(cp->type, cp->stride, cp->p CRVBOX_HOST_ONLY_PARAM(-1 /*fRealPtr*/));1085 pState->diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid); 1086 pState->diff_api.IndexPointer(cp->type, cp->stride, cp->p CRVBOX_HOST_ONLY_PARAM(-1 /*fRealPtr*/)); 1079 1087 } 1080 1088 … … 1082 1090 if (cp->buffer && (cp->buffer->id || locked)) 1083 1091 { 1084 diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid);1085 diff_api.NormalPointer(cp->type, cp->stride, cp->p CRVBOX_HOST_ONLY_PARAM(-1 /*fRealPtr*/));1092 pState->diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid); 1093 pState->diff_api.NormalPointer(cp->type, cp->stride, cp->p CRVBOX_HOST_ONLY_PARAM(-1 /*fRealPtr*/)); 1086 1094 } 1087 1095 … … 1091 1099 if (cp->buffer && (cp->buffer->id || locked)) 1092 1100 { 1093 if ( diff_api.ActiveTextureARB)1094 diff_api.ActiveTextureARB(i+GL_TEXTURE0_ARB);1095 diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid);1096 diff_api.TexCoordPointer(cp->size, cp->type, cp->stride, cp->p CRVBOX_HOST_ONLY_PARAM(-1 /*fRealPtr*/));1097 } 1098 } 1099 1100 if ( diff_api.ActiveTextureARB)1101 diff_api.ActiveTextureARB(toCtx->client.curClientTextureUnit+GL_TEXTURE0_ARB);1101 if (pState->diff_api.ActiveTextureARB) 1102 pState->diff_api.ActiveTextureARB(i+GL_TEXTURE0_ARB); 1103 pState->diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid); 1104 pState->diff_api.TexCoordPointer(cp->size, cp->type, cp->stride, cp->p CRVBOX_HOST_ONLY_PARAM(-1 /*fRealPtr*/)); 1105 } 1106 } 1107 1108 if (pState->diff_api.ActiveTextureARB) 1109 pState->diff_api.ActiveTextureARB(toCtx->client.curClientTextureUnit+GL_TEXTURE0_ARB); 1102 1110 1103 1111 #ifdef CR_NV_vertex_program … … 1107 1115 if (cp->buffer && (cp->buffer->id || locked)) 1108 1116 { 1109 diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid);1110 diff_api.VertexAttribPointerARB(i, cp->size, cp->type, cp->normalized, cp->stride, cp->p CRVBOX_HOST_ONLY_PARAM(-1 /*fRealPtr*/));1111 } 1112 } 1113 #endif 1114 diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, to->arrayBuffer->hwid);1115 diff_api.BindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, to->elementsBuffer->hwid);1117 pState->diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid); 1118 pState->diff_api.VertexAttribPointerARB(i, cp->size, cp->type, cp->normalized, cp->stride, cp->p CRVBOX_HOST_ONLY_PARAM(-1 /*fRealPtr*/)); 1119 } 1120 } 1121 #endif 1122 pState->diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, to->arrayBuffer->hwid); 1123 pState->diff_api.BindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, to->elementsBuffer->hwid); 1116 1124 #ifdef CR_ARB_pixel_buffer_object 1117 diff_api.BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, to->packBuffer->hwid);1118 diff_api.BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, to->unpackBuffer->hwid);1125 pState->diff_api.BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, to->packBuffer->hwid); 1126 pState->diff_api.BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, to->unpackBuffer->hwid); 1119 1127 #endif 1120 1128 }
Note:
See TracChangeset
for help on using the changeset viewer.