- 時間撮記:
- 2012-12-12 下午02:21:32 (12 年 以前)
- 位置:
- trunk/src/VBox/GuestHost/OpenGL/state_tracker
- 檔案:
-
- 修改 4 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_bufferobject.c
r44105 r44108 372 372 CR_STATE_SHAREDOBJ_USAGE_FOREACH_USED_IDX(obj, j) 373 373 { 374 /* saved state version <= SHCROGL_SSM_VERSION_BEFORE_CTXUSAGE_BITS does not have usage bits info, 375 * so on restore, we set mark bits as used. 376 * This is why g_pAvailableContexts[j] could be NULL 377 * also g_pAvailableContexts[0] will hold default context, which we should discard */ 374 378 CRContext *ctx = g_pAvailableContexts[j]; 375 CRASSERT(ctx); 376 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, 377 * but not the current context ones*/ 379 if (j && ctx) 380 { 381 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, 382 * but not the current context ones*/ 383 } 384 else 385 CR_STATE_SHAREDOBJ_USAGE_CLEAR_IDX(obj, j); 378 386 } 379 387 -
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_client.c
r44105 r44108 111 111 } 112 112 113 void crStateClientInit(CRContext * g)114 { 115 CRClientState *c = &( g->client);113 void crStateClientInit(CRContext *ctx) 114 { 115 CRClientState *c = &(ctx->client); 116 116 unsigned int i; 117 117 … … 153 153 c->array.v.enabled = 0; 154 154 #ifdef CR_ARB_vertex_buffer_object 155 c->array.v.buffer = g ? g->bufferobject.arrayBuffer : NULL;155 c->array.v.buffer = ctx->bufferobject.arrayBuffer; 156 156 if (c->array.v.buffer) 157 157 ++c->array.v.buffer->refCount; … … 170 170 c->array.c.enabled = 0; 171 171 #ifdef CR_ARB_vertex_buffer_object 172 c->array.c.buffer = g ? g->bufferobject.arrayBuffer : NULL;172 c->array.c.buffer = ctx->bufferobject.arrayBuffer; 173 173 if (c->array.c.buffer) 174 174 ++c->array.c.buffer->refCount; … … 187 187 c->array.f.enabled = 0; 188 188 #ifdef CR_ARB_vertex_buffer_object 189 c->array.f.buffer = g ? g->bufferobject.arrayBuffer : NULL;189 c->array.f.buffer = ctx->bufferobject.arrayBuffer; 190 190 if (c->array.f.buffer) 191 191 ++c->array.f.buffer->refCount; … … 204 204 c->array.s.enabled = 0; 205 205 #ifdef CR_ARB_vertex_buffer_object 206 c->array.s.buffer = g ? g->bufferobject.arrayBuffer : NULL;206 c->array.s.buffer = ctx->bufferobject.arrayBuffer; 207 207 if (c->array.s.buffer) 208 208 ++c->array.s.buffer->refCount; … … 221 221 c->array.e.enabled = 0; 222 222 #ifdef CR_ARB_vertex_buffer_object 223 c->array.e.buffer = g ? g->bufferobject.arrayBuffer : NULL;223 c->array.e.buffer = ctx->bufferobject.arrayBuffer; 224 224 if (c->array.e.buffer) 225 225 ++c->array.e.buffer->refCount; … … 238 238 c->array.i.enabled = 0; 239 239 #ifdef CR_ARB_vertex_buffer_object 240 c->array.i.buffer = g ? g->bufferobject.arrayBuffer : NULL;240 c->array.i.buffer = ctx->bufferobject.arrayBuffer; 241 241 if (c->array.i.buffer) 242 242 ++c->array.i.buffer->refCount; … … 255 255 c->array.n.enabled = 0; 256 256 #ifdef CR_ARB_vertex_buffer_object 257 c->array.n.buffer = g ? g->bufferobject.arrayBuffer : NULL;257 c->array.n.buffer = ctx->bufferobject.arrayBuffer; 258 258 if (c->array.n.buffer) 259 259 ++c->array.n.buffer->refCount; … … 274 274 c->array.t[i].enabled = 0; 275 275 #ifdef CR_ARB_vertex_buffer_object 276 c->array.t[i].buffer = g ? g->bufferobject.arrayBuffer : NULL;276 c->array.t[i].buffer = ctx->bufferobject.arrayBuffer; 277 277 if (c->array.t[i].buffer) 278 278 ++c->array.t[i].buffer->refCount; … … 293 293 c->array.a[i].stride = 0; 294 294 #ifdef CR_ARB_vertex_buffer_object 295 c->array.a[i].buffer = g ? g->bufferobject.arrayBuffer : NULL;295 c->array.a[i].buffer = ctx->bufferobject.arrayBuffer; 296 296 if (c->array.a[i].buffer) 297 297 ++c->array.a[i].buffer->refCount; -
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_framebuffer.c
r44083 r44108 203 203 } 204 204 205 static void ctStateRenderbufferRefsCleanup(CRContext *g, GLuint fboId, CRRenderbufferObject *rbo) 206 { 207 CRFramebufferObjectState *fbo = &g->framebufferobject; 208 209 if (fbo->renderbuffer==rbo) 210 { 211 fbo->renderbuffer = NULL; 212 } 213 214 /* check the attachments of current framebuffers */ 215 crStateCheckFBOAttachments(fbo->readFB, fboId, GL_READ_FRAMEBUFFER); 216 crStateCheckFBOAttachments(fbo->drawFB, fboId, GL_DRAW_FRAMEBUFFER); 217 218 #ifndef IN_GUEST 219 CR_STATE_SHAREDOBJ_USAGE_CLEAR(rbo, g); 220 #endif 221 } 222 205 223 DECLEXPORT(void) STATE_APIENTRY 206 224 crStateDeleteRenderbuffersEXT(GLsizei n, const GLuint *renderbuffers) … … 221 239 if (rbo) 222 240 { 223 if (fbo->renderbuffer==rbo) 241 #ifndef IN_GUEST 242 int j; 243 #endif 244 ctStateRenderbufferRefsCleanup(g, renderbuffers[i], rbo); 245 #ifndef IN_GUEST 246 CR_STATE_SHAREDOBJ_USAGE_FOREACH_USED_IDX(rbo, j) 224 247 { 225 fbo->renderbuffer = NULL; 248 /* saved state version <= SHCROGL_SSM_VERSION_BEFORE_CTXUSAGE_BITS does not have usage bits info, 249 * so on restore, we set mark bits as used. 250 * This is why g_pAvailableContexts[j] could be NULL 251 * also g_pAvailableContexts[0] will hold default context, which we should discard */ 252 CRContext *ctx = g_pAvailableContexts[j]; 253 if (j && ctx) 254 { 255 CRFramebufferObjectState *ctxFbo; 256 CRASSERT(ctx); 257 ctxFbo = &ctx->framebufferobject; 258 if (ctxFbo->renderbuffer==rbo) 259 crWarning("deleting RBO being used by another context %d", ctx->id); 260 261 ctStateRenderbufferRefsCleanup(ctx, renderbuffers[i], rbo); 262 } 263 else 264 CR_STATE_SHAREDOBJ_USAGE_CLEAR_IDX(rbo, j); 226 265 } 227 228 /* check the attachments of current framebuffers */ 229 crStateCheckFBOAttachments(fbo->readFB, renderbuffers[i], GL_READ_FRAMEBUFFER); 230 crStateCheckFBOAttachments(fbo->drawFB, renderbuffers[i], GL_DRAW_FRAMEBUFFER); 231 266 #endif 232 267 crHashtableDelete(g->shared->rbTable, renderbuffers[i], crStateFreeRBO); 233 268 } … … 380 415 } 381 416 417 static void ctStateFramebufferRefsCleanup(CRContext *g, CRFramebufferObject *fb) 418 { 419 CRFramebufferObjectState *fbo = &g->framebufferobject; 420 if (fbo->readFB==fb) 421 { 422 fbo->readFB = NULL; 423 } 424 if (fbo->drawFB==fb) 425 { 426 fbo->drawFB = NULL; 427 } 428 429 CR_STATE_SHAREDOBJ_USAGE_CLEAR(fb, g); 430 } 431 382 432 DECLEXPORT(void) STATE_APIENTRY 383 433 crStateDeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers) 384 434 { 385 435 CRContext *g = GetCurrentContext(); 386 CRFramebufferObjectState *fbo = &g->framebufferobject;387 436 int i; 388 437 … … 398 447 if (fb) 399 448 { 400 if (fbo->readFB==fb) 449 #ifndef IN_GUEST 450 int j; 451 #endif 452 ctStateFramebufferRefsCleanup(g, fb); 453 #ifndef IN_GUEST 454 CR_STATE_SHAREDOBJ_USAGE_FOREACH_USED_IDX(fb, j) 401 455 { 402 fbo->readFB = NULL; 456 /* saved state version <= SHCROGL_SSM_VERSION_BEFORE_CTXUSAGE_BITS does not have usage bits info, 457 * so on restore, we set mark bits as used. 458 * This is why g_pAvailableContexts[j] could be NULL 459 * also g_pAvailableContexts[0] will hold default context, which we should discard */ 460 CRContext *ctx = g_pAvailableContexts[j]; 461 if (j && ctx) 462 { 463 CRFramebufferObjectState *ctxFbo; 464 CRASSERT(ctx); 465 ctxFbo = &ctx->framebufferobject; 466 if (ctxFbo->readFB==fb) 467 crWarning("deleting FBO being used as read buffer by another context %d", ctx->id); 468 469 if (ctxFbo->drawFB==fb) 470 crWarning("deleting FBO being used as draw buffer by another context %d", ctx->id); 471 472 ctStateFramebufferRefsCleanup(ctx, fb); 473 } 474 else 475 CR_STATE_SHAREDOBJ_USAGE_CLEAR_IDX(fb, j); 403 476 } 404 if (fbo->drawFB==fb) 405 { 406 fbo->drawFB = NULL; 407 } 477 #endif 408 478 crHashtableDelete(g->shared->fbTable, framebuffers[i], crStateFreeFBO); 409 479 } … … 470 540 CRFramebufferObjectState *fbo = &g->framebufferobject; 471 541 CRFramebufferObject *apFBOs[2]; 472 GLuint c PBOs = 0, i;542 GLuint cFBOs = 0, i; 473 543 GLuint maxtexsizelog2; 474 475 544 476 545 CRSTATE_CHECKERR_RET(g->current.inBeginEnd, GL_INVALID_OPERATION, "called in begin/end", 0); … … 478 547 GL_INVALID_ENUM, "invalid target", 0); 479 548 480 cPBOs = crStateFramebufferGet(fbo, target, apFBOs); 481 CRSTATE_CHECKERR_RET(!cPBOs, GL_INVALID_ENUM, "unexpected target", 0); 482 483 Assert(cPBOs); 484 Assert(cPBOs <= 2); 485 486 for (i = 0; i < cPBOs; ++i) 487 { 488 CRSTATE_CHECKERR_RET(!apFBOs[i], GL_INVALID_OPERATION, "no fbo bound", 0); 549 cFBOs = crStateFramebufferGet(fbo, target, apFBOs); 550 CRSTATE_CHECKERR_RET(!cFBOs, GL_INVALID_ENUM, "unexpected target", 0); 551 for (i = 0; i < cFBOs; ++i) 552 { 553 CRSTATE_CHECKERR_RET(!apFBOs[i], GL_INVALID_OPERATION, "zero fbo bound", 0); 554 } 555 556 Assert(cFBOs); 557 Assert(cFBOs <= 2); 558 559 for (i = 0; i < cFBOs; ++i) 560 { 489 561 CRSTATE_CHECKERR_RET(!crStateGetFBOAttachmentPoint(apFBOs[i], attachment, &aap[i]), GL_INVALID_ENUM, "invalid attachment", 0); 490 562 } … … 492 564 if (!texture) 493 565 { 494 return c PBOs;566 return cFBOs; 495 567 } 496 568 … … 534 606 535 607 #ifdef IN_GUEST 536 for (i = 0; i < c PBOs; ++i)608 for (i = 0; i < cFBOs; ++i) 537 609 { 538 610 if ((aap[i])->type!=GL_TEXTURE || (aap[i])->name!=texture || (aap[i])->level!=level) … … 543 615 #endif 544 616 545 Assert(c PBOs);546 Assert(c PBOs <= 2);547 548 return c PBOs;617 Assert(cFBOs); 618 Assert(cFBOs <= 2); 619 620 return cFBOs; 549 621 } 550 622 … … 668 740 CRContext *g = GetCurrentContext(); 669 741 CRFramebufferObjectState *fbo = &g->framebufferobject; 670 CRFramebufferObject *pFBO; 671 CRFBOAttachmentPoint *ap; 742 CRFramebufferObject *apFBOs[2]; 743 GLuint cFBOs, i; 744 CRFBOAttachmentPoint *aap[2]; 672 745 CRRenderbufferObject *rb; 673 746 … … 675 748 CRSTATE_CHECKERR(((target!=GL_FRAMEBUFFER_EXT) && (target!=GL_READ_FRAMEBUFFER) && (target!=GL_DRAW_FRAMEBUFFER)), 676 749 GL_INVALID_ENUM, "invalid target"); 677 pFBO = GL_READ_FRAMEBUFFER==target ? fbo->readFB : fbo->drawFB; 678 CRSTATE_CHECKERR(!pFBO, GL_INVALID_OPERATION, "no fbo bound"); 679 CRSTATE_CHECKERR(!crStateGetFBOAttachmentPoint(pFBO, attachment, &ap), GL_INVALID_ENUM, "invalid attachment"); 750 cFBOs = crStateFramebufferGet(fbo, target, apFBOs); 751 CRSTATE_CHECKERR(!cFBOs, GL_INVALID_OPERATION, "no fbo bound"); 752 for (i = 0; i < cFBOs; ++i) 753 { 754 CRSTATE_CHECKERR(!apFBOs[i], GL_INVALID_OPERATION, "zero fbo bound"); 755 } 756 757 for (i = 0; i < cFBOs; ++i) 758 { 759 CRSTATE_CHECKERR(!crStateGetFBOAttachmentPoint(apFBOs[i], attachment, &aap[i]), GL_INVALID_ENUM, "invalid attachment"); 760 } 680 761 681 762 if (!renderbuffer) 682 763 { 764 for (i = 0; i < cFBOs; ++i) 765 { 683 766 #ifdef IN_GUEST 684 if (ap->type!=GL_NONE) 685 { 686 pFBO->status = GL_FRAMEBUFFER_UNDEFINED; 687 } 688 #endif 689 crStateInitFBOAttachmentPoint(ap); 767 if (&aap[i]->type!=GL_NONE) 768 { 769 apFBOs[i]->status = GL_FRAMEBUFFER_UNDEFINED; 770 } 771 #endif 772 crStateInitFBOAttachmentPoint(aap[i]); 773 } 690 774 return; 691 775 } … … 698 782 } 699 783 784 #ifndef IN_GUEST 785 CR_STATE_SHAREDOBJ_USAGE_SET(rb, g); 786 #endif 787 788 for (i = 0; i < cFBOs; ++i) 789 { 700 790 #ifdef IN_GUEST 701 if (ap->type!=GL_RENDERBUFFER_EXT || ap->name!=renderbuffer) 702 { 703 pFBO->status = GL_FRAMEBUFFER_UNDEFINED; 704 } 705 #endif 706 crStateInitFBOAttachmentPoint(ap); 707 ap->type = GL_RENDERBUFFER_EXT; 708 ap->name = renderbuffer; 791 if (aap[i]->type!=GL_RENDERBUFFER_EXT || aap[i]->name!=renderbuffer) 792 { 793 apFBOs[i]->status = GL_FRAMEBUFFER_UNDEFINED; 794 } 795 #endif 796 crStateInitFBOAttachmentPoint(aap[i]); 797 aap[i]->type = GL_RENDERBUFFER_EXT; 798 aap[i]->name = renderbuffer; 799 } 709 800 } 710 801 … … 725 816 726 817 CRSTATE_CHECKERR(!cFBOs, GL_INVALID_OPERATION, "no fbo bound"); 727 728 818 for (i = 0; i < cFBOs; ++i) 819 { 820 CRSTATE_CHECKERR(!apFBOs[i], GL_INVALID_OPERATION, "zero fbo bound"); 821 } 822 823 if(cFBOs != 1) 824 { 825 crWarning("different FBPs attached to draw and read buffers, returning info for the read buffer"); 826 } 827 828 for (i = 0; i < 1; ++i) 729 829 { 730 830 CRSTATE_CHECKERR(!crStateGetFBOAttachmentPoint(apFBOs[i], attachment, &ap), GL_INVALID_ENUM, "invalid attachment"); -
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_texture.c
r44105 r44108 776 776 CR_STATE_SHAREDOBJ_USAGE_FOREACH_USED_IDX(tObj, j) 777 777 { 778 /* saved state version <= SHCROGL_SSM_VERSION_BEFORE_CTXUSAGE_BITS does not have usage bits info, 779 * so on restore, we set mark bits as used. 780 * This is why g_pAvailableContexts[j] could be NULL 781 * also g_pAvailableContexts[0] will hold default context, which we should discard */ 778 782 CRContext *ctx = g_pAvailableContexts[j]; 779 crStateCleanupTextureRefs(ctx, tObj); 783 if (j && ctx) 784 crStateCleanupTextureRefs(ctx, tObj); 785 else 786 CR_STATE_SHAREDOBJ_USAGE_CLEAR_IDX(tObj, j); 780 787 } 781 788
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器