Changeset 23094 in vbox for trunk/src/VBox/GuestHost/OpenGL/state_tracker
- Timestamp:
- Sep 17, 2009 1:48:46 PM (15 years ago)
- Location:
- trunk/src/VBox/GuestHost/OpenGL/state_tracker
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_diff.c
r22363 r23094 236 236 #endif 237 237 #ifdef CR_EXT_framebuffer_object 238 /*Note, this should go after crStateTextureSwitch*/ 238 239 crStateFramebufferObjectSwitch(from, to); 239 240 #endif -
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_framebuffer.c
r22832 r23094 42 42 fbo->framebuffers = crAllocHashtable(); 43 43 fbo->renderbuffers = crAllocHashtable(); 44 fbo->bResyncNeeded = GL_FALSE; 44 45 } 45 46 … … 51 52 if (diff_api.DeleteFramebuffersEXT) 52 53 { 53 diff_api.DeleteFramebuffersEXT(1, &pObj-> id);54 diff_api.DeleteFramebuffersEXT(1, &pObj->hwid); 54 55 } 55 56 #endif … … 65 66 if (diff_api.DeleteRenderbuffersEXT) 66 67 { 67 diff_api.DeleteRenderbuffersEXT(1, &pObj-> id);68 diff_api.DeleteRenderbuffersEXT(1, &pObj->hwid); 68 69 } 69 70 #endif … … 101 102 CRSTATE_FBO_CHECKERR(!fbo->renderbuffer, GL_OUT_OF_MEMORY, "glBindRenderbufferEXT"); 102 103 fbo->renderbuffer->id = renderbuffer; 104 fbo->renderbuffer->hwid = renderbuffer; 103 105 fbo->renderbuffer->internalformat = GL_RGBA; 104 106 crHashtableAdd(fbo->renderbuffers, renderbuffer, fbo->renderbuffer); … … 158 160 } 159 161 160 crHashtableDelete(fbo->renderbuffers, renderbuffers[i], cr Free);162 crHashtableDelete(fbo->renderbuffers, renderbuffers[i], crStateFreeRBO); 161 163 } 162 164 } … … 173 175 CRSTATE_FBO_CHECKERR(g->current.inBeginEnd, GL_INVALID_OPERATION, "called in begin/end"); 174 176 CRSTATE_FBO_CHECKERR(target!=GL_RENDERBUFFER_EXT, GL_INVALID_ENUM, "invalid target"); 175 CRSTATE_FBO_CHECKERR( rb, GL_INVALID_OPERATION, "no bound renderbuffer");177 CRSTATE_FBO_CHECKERR(!rb, GL_INVALID_OPERATION, "no bound renderbuffer"); 176 178 177 179 rb->width = width; … … 189 191 CRSTATE_FBO_CHECKERR(g->current.inBeginEnd, GL_INVALID_OPERATION, "called in begin/end"); 190 192 CRSTATE_FBO_CHECKERR(target!=GL_RENDERBUFFER_EXT, GL_INVALID_ENUM, "invalid target"); 191 CRSTATE_FBO_CHECKERR( rb, GL_INVALID_OPERATION, "no bound renderbuffer");193 CRSTATE_FBO_CHECKERR(!rb, GL_INVALID_OPERATION, "no bound renderbuffer"); 192 194 193 195 switch (pname) … … 276 278 CRSTATE_FBO_CHECKERR(!fbo->framebuffer, GL_OUT_OF_MEMORY, "glBindFramebufferEXT"); 277 279 fbo->framebuffer->id = framebuffer; 280 fbo->framebuffer->hwid = framebuffer; 278 281 crStateInitFrameBuffer(fbo->framebuffer); 279 282 crHashtableAdd(fbo->framebuffers, framebuffer, fbo->framebuffer); … … 305 308 fbo->framebuffer = NULL; 306 309 } 307 crHashtableDelete(fbo->framebuffers, framebuffers[i], cr Free);310 crHashtableDelete(fbo->framebuffers, framebuffers[i], crStateFreeFBO); 308 311 } 309 312 } … … 544 547 } 545 548 549 static void crStateSyncRenderbuffersCB(unsigned long key, void *data1, void *data2) 550 { 551 CRRenderbufferObject *pRBO = (CRRenderbufferObject*) data1; 552 553 diff_api.GenRenderbuffersEXT(1, &pRBO->hwid); 554 555 diff_api.BindRenderbufferEXT(GL_RENDERBUFFER_EXT, pRBO->hwid); 556 diff_api.RenderbufferStorageEXT(GL_RENDERBUFFER_EXT, pRBO->internalformat, pRBO->width, pRBO->height); 557 } 558 559 static void crStateSyncAP(CRFBOAttachmentPoint *pAP, GLenum ap, CRContext *ctx) 560 { 561 CRRenderbufferObject *pRBO; 562 CRTextureObj *tobj; 563 564 switch (pAP->type) 565 { 566 case GL_TEXTURE: 567 CRASSERT(pAP->name!=0); 568 569 tobj = (CRTextureObj *) crHashtableSearch(ctx->shared->textureTable, pAP->name); 570 if (tobj) 571 { 572 switch (tobj->target) 573 { 574 case GL_TEXTURE_1D: 575 diff_api.FramebufferTexture1DEXT(GL_FRAMEBUFFER_EXT, ap, tobj->target, pAP->name, pAP->level); 576 break; 577 case GL_TEXTURE_2D: 578 case GL_TEXTURE_RECTANGLE_ARB: 579 diff_api.FramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, ap, tobj->target, pAP->name, pAP->level); 580 break; 581 case GL_TEXTURE_CUBE_MAP_ARB: 582 diff_api.FramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, ap, pAP->face, pAP->name, pAP->level); 583 break; 584 case GL_TEXTURE_3D: 585 diff_api.FramebufferTexture3DEXT(GL_FRAMEBUFFER_EXT, ap, tobj->target, pAP->name, pAP->level, pAP->zoffset); 586 break; 587 default: 588 crWarning("Unexpected textarget %d", tobj->target); 589 } 590 } 591 else 592 { 593 crWarning("Unknown texture id %d", pAP->name); 594 } 595 break; 596 case GL_RENDERBUFFER_EXT: 597 pRBO = (CRRenderbufferObject*) crHashtableSearch(ctx->framebufferobject.renderbuffers, pAP->name); 598 diff_api.FramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, ap, GL_RENDERBUFFER_EXT, pRBO->hwid); 599 break; 600 case GL_NONE: 601 /* Intentionally left blank */ 602 break; 603 default: crWarning("Invalid attachment point type %d (ap: %i)", pAP->type, ap); 604 } 605 } 606 607 static void crStateSyncFramebuffersCB(unsigned long key, void *data1, void *data2) 608 { 609 CRFramebufferObject *pFBO = (CRFramebufferObject*) data1; 610 CRContext *ctx = (CRContext*) data2; 611 GLint i; 612 613 diff_api.GenFramebuffersEXT(1, &pFBO->hwid); 614 615 diff_api.BindFramebufferEXT(GL_FRAMEBUFFER_EXT, pFBO->hwid); 616 617 for (i=0; i<CR_MAX_COLOR_ATTACHMENTS; ++i) 618 { 619 crStateSyncAP(&pFBO->color[i], GL_COLOR_ATTACHMENT0_EXT+i, ctx); 620 } 621 622 crStateSyncAP(&pFBO->depth, GL_DEPTH_ATTACHMENT_EXT, ctx); 623 crStateSyncAP(&pFBO->stencil, GL_STENCIL_ATTACHMENT_EXT, ctx); 624 } 625 546 626 DECLEXPORT(void) STATE_APIENTRY 547 627 crStateFramebufferObjectSwitch(CRContext *from, CRContext *to) 548 628 { 549 if (to->framebufferobject.framebuffer!=from->framebufferobject.framebuffer) 550 { 629 if (to->framebufferobject.bResyncNeeded) 630 { 631 to->framebufferobject.bResyncNeeded = GL_FALSE; 632 633 crHashtableWalk(to->framebufferobject.renderbuffers, crStateSyncRenderbuffersCB, NULL); 634 crHashtableWalk(to->framebufferobject.framebuffers, crStateSyncFramebuffersCB, to); 635 551 636 diff_api.BindFramebufferEXT(GL_FRAMEBUFFER_EXT, to->framebufferobject.framebuffer? 552 to->framebufferobject.framebuffer->id:0); 553 } 554 } 637 to->framebufferobject.framebuffer->hwid:0); 638 639 diff_api.BindRenderbufferEXT(GL_RENDERBUFFER_EXT, to->framebufferobject.renderbuffer? 640 to->framebufferobject.renderbuffer->hwid:0); 641 } 642 else 643 { 644 if (to->framebufferobject.framebuffer!=from->framebufferobject.framebuffer) 645 { 646 diff_api.BindFramebufferEXT(GL_FRAMEBUFFER_EXT, to->framebufferobject.framebuffer? 647 to->framebufferobject.framebuffer->hwid:0); 648 } 649 650 if (to->framebufferobject.renderbuffer!=from->framebufferobject.renderbuffer) 651 { 652 diff_api.BindRenderbufferEXT(GL_RENDERBUFFER_EXT, to->framebufferobject.renderbuffer? 653 to->framebufferobject.renderbuffer->hwid:0); 654 } 655 } 656 } 657 658 DECLEXPORT(GLuint) STATE_APIENTRY crStateGetFramebufferHWID(GLuint id) 659 { 660 CRContext *g = GetCurrentContext(); 661 CRFramebufferObject *pFBO = (CRFramebufferObject*) crHashtableSearch(g->framebufferobject.framebuffers, id); 662 663 return pFBO ? pFBO->hwid : 0; 664 } 665 666 DECLEXPORT(GLuint) STATE_APIENTRY crStateGetRenderbufferHWID(GLuint id) 667 { 668 CRContext *g = GetCurrentContext(); 669 CRRenderbufferObject *pRBO = (CRRenderbufferObject*) crHashtableSearch(g->framebufferobject.renderbuffers, id); 670 671 return pRBO ? pRBO->hwid : 0; 672 } -
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_snapshot.c
r16970 r23094 466 466 } 467 467 468 static void crStateSaveFramebuffersCB(unsigned long key, void *data1, void *data2) 469 { 470 CRFramebufferObject *pFBO = (CRFramebufferObject*) data1; 471 PSSMHANDLE pSSM = (PSSMHANDLE) data2; 472 int32_t rc; 473 474 rc = SSMR3PutMem(pSSM, &key, sizeof(key)); 475 CRASSERT(rc == VINF_SUCCESS); 476 477 rc = SSMR3PutMem(pSSM, pFBO, sizeof(*pFBO)); 478 CRASSERT(rc == VINF_SUCCESS); 479 } 480 481 static void crStateSaveRenderbuffersCB(unsigned long key, void *data1, void *data2) 482 { 483 CRRenderbufferObject *pRBO = (CRRenderbufferObject*) data1; 484 PSSMHANDLE pSSM = (PSSMHANDLE) data2; 485 int32_t rc; 486 487 rc = SSMR3PutMem(pSSM, &key, sizeof(key)); 488 CRASSERT(rc == VINF_SUCCESS); 489 490 rc = SSMR3PutMem(pSSM, pRBO, sizeof(*pRBO)); 491 CRASSERT(rc == VINF_SUCCESS); 492 } 493 468 494 static int32_t crStateLoadProgram(CRProgram **ppProgram, PSSMHANDLE pSSM) 469 495 { … … 712 738 /* This one is unused it seems*/ 713 739 CRASSERT(!pContext->program.errorString); 740 741 #ifdef CR_EXT_framebuffer_object 742 /* Save FBOs */ 743 ui32 = crHashtableNumElements(pContext->framebufferobject.framebuffers); 744 rc = SSMR3PutU32(pSSM, ui32); 745 AssertRCReturn(rc, rc); 746 crHashtableWalk(pContext->framebufferobject.framebuffers, crStateSaveFramebuffersCB, pSSM); 747 ui32 = crHashtableNumElements(pContext->framebufferobject.renderbuffers); 748 rc = SSMR3PutU32(pSSM, ui32); 749 AssertRCReturn(rc, rc); 750 crHashtableWalk(pContext->framebufferobject.renderbuffers, crStateSaveRenderbuffersCB, pSSM); 751 rc = SSMR3PutU32(pSSM, pContext->framebufferobject.framebuffer?pContext->framebufferobject.framebuffer->id:0); 752 AssertRCReturn(rc, rc); 753 rc = SSMR3PutU32(pSSM, pContext->framebufferobject.renderbuffer?pContext->framebufferobject.renderbuffer->id:0); 754 AssertRCReturn(rc, rc); 755 #endif 714 756 715 757 return VINF_SUCCESS; … … 852 894 } 853 895 896 SLC_COPYPTR(framebufferobject.framebuffers); 897 SLC_COPYPTR(framebufferobject.renderbuffers); 898 854 899 /* Have to preserve original context id */ 855 900 CRASSERT(pTmpContext->id == pContext->id); … … 1099 1144 pContext->program.bResyncNeeded = GL_TRUE; 1100 1145 1146 #ifdef CR_EXT_framebuffer_object 1147 /* Load FBOs */ 1148 rc = SSMR3GetU32(pSSM, &uiNumElems); 1149 AssertRCReturn(rc, rc); 1150 for (ui=0; ui<uiNumElems; ++ui) 1151 { 1152 CRFramebufferObject *pFBO; 1153 pFBO = crAlloc(sizeof(*pFBO)); 1154 if (!pFBO) return VERR_NO_MEMORY; 1155 1156 rc = SSMR3GetMem(pSSM, &key, sizeof(key)); 1157 AssertRCReturn(rc, rc); 1158 1159 rc = SSMR3GetMem(pSSM, pFBO, sizeof(*pFBO)); 1160 AssertRCReturn(rc, rc); 1161 1162 crHashtableAdd(pContext->framebufferobject.framebuffers, key, pFBO); 1163 } 1164 1165 rc = SSMR3GetU32(pSSM, &uiNumElems); 1166 AssertRCReturn(rc, rc); 1167 for (ui=0; ui<uiNumElems; ++ui) 1168 { 1169 CRRenderbufferObject *pRBO; 1170 pRBO = crAlloc(sizeof(*pRBO)); 1171 if (!pRBO) return VERR_NO_MEMORY; 1172 1173 rc = SSMR3GetMem(pSSM, &key, sizeof(key)); 1174 AssertRCReturn(rc, rc); 1175 1176 rc = SSMR3GetMem(pSSM, pRBO, sizeof(*pRBO)); 1177 AssertRCReturn(rc, rc); 1178 1179 crHashtableAdd(pContext->framebufferobject.renderbuffers, key, pRBO); 1180 } 1181 1182 rc = SSMR3GetU32(pSSM, &ui); 1183 AssertRCReturn(rc, rc); 1184 pContext->framebufferobject.framebuffer = ui==0 ? NULL 1185 : crHashtableSearch(pContext->framebufferobject.framebuffers, ui); 1186 1187 rc = SSMR3GetU32(pSSM, &ui); 1188 AssertRCReturn(rc, rc); 1189 pContext->framebufferobject.renderbuffer = ui==0 ? NULL 1190 : crHashtableSearch(pContext->framebufferobject.renderbuffers, ui); 1191 1192 /* Mark FBOs/RBOs for resending to GPU */ 1193 pContext->framebufferobject.bResyncNeeded = GL_TRUE; 1194 #endif 1195 1101 1196 return VINF_SUCCESS; 1102 1197 }
Note:
See TracChangeset
for help on using the changeset viewer.