Changeset 45348 in vbox for trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_muralfbo.c
- Timestamp:
- Apr 4, 2013 7:46:29 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_muralfbo.c
r45248 r45348 204 204 fPresentMode &= ~CR_SERVER_REDIR_F_DISPLAY; 205 205 else if (overlappingScreenCount > 1) 206 fPresentMode = (fPresentMode | CR_SERVER_REDIR_F_FBO_RAM_VMFB ) & ~CR_SERVER_REDIR_F_DISPLAY;206 fPresentMode = (fPresentMode | CR_SERVER_REDIR_F_FBO_RAM_VMFB | cr_server.fVramPresentModeDefault) & ~CR_SERVER_REDIR_F_DISPLAY; 207 207 208 208 fPresentMode = crServerRedirModeAdjust(fPresentMode); … … 261 261 } 262 262 263 static void crServerPresentMuralVRAM(CRMuralInfo *mural, char *pixels); 264 265 #define CR_SERVER_MURAL_FROM_RPW_ENTRY(_pEntry) ((CRMuralInfo*)(((uint8_t*)(_pEntry)) - RT_OFFSETOF(CRMuralInfo, RpwEntry))) 266 267 static DECLCALLBACK(void) crServerMuralRpwDataCB(const struct CR_SERVER_RPW_ENTRY* pEntry, void *pvEntryTexData) 268 { 269 CRMuralInfo *pMural = CR_SERVER_MURAL_FROM_RPW_ENTRY(pEntry); 270 271 Assert(&pMural->RpwEntry == pEntry); 272 273 crServerPresentMuralVRAM(pMural, pvEntryTexData); 274 } 275 263 276 static void crServerCreateMuralFBO(CRMuralInfo *mural); 264 277 265 void crServerEnableDisplayMuralFBO(CRMuralInfo *mural, GLboolean fEnable)278 static bool crServerEnableMuralRpw(CRMuralInfo *mural, GLboolean fEnable) 266 279 { 267 280 if (!mural->CreateInfo.externalID) 268 return; 281 { 282 crWarning("trying to change Rpw setting for internal mural %d", mural->spuWindow); 283 return !fEnable; 284 } 285 286 if (fEnable) 287 { 288 if (!(mural->fPresentMode & CR_SERVER_REDIR_F_FBO_RPW)) 289 { 290 int rc; 291 if (!crServerRpwIsInitialized(&cr_server.RpwWorker)) 292 { 293 rc = crServerRpwInit(&cr_server.RpwWorker); 294 if (!RT_SUCCESS(rc)) 295 { 296 crWarning("crServerRpwInit failed rc %d", rc); 297 return false; 298 } 299 } 300 301 CRASSERT(!mural->RpwEntry.Size.cx); 302 CRASSERT(!mural->RpwEntry.Size.cy); 303 304 if (!crServerRpwEntryIsInitialized(&mural->RpwEntry)) 305 { 306 rc = crServerRpwEntryInit(&cr_server.RpwWorker, &mural->RpwEntry, mural->width, mural->height, crServerMuralRpwDataCB); 307 if (!RT_SUCCESS(rc)) 308 { 309 crWarning("crServerRpwEntryInit failed rc %d", rc); 310 return false; 311 } 312 } 313 else 314 { 315 rc = crServerRpwEntryResize(&cr_server.RpwWorker, &mural->RpwEntry, mural->width, mural->height); 316 if (!RT_SUCCESS(rc)) 317 { 318 crWarning("crServerRpwEntryResize failed rc %d", rc); 319 return false; 320 } 321 } 322 323 mural->fPresentMode |= CR_SERVER_REDIR_F_FBO_RPW; 324 } 325 } 326 else 327 { 328 if ((mural->fPresentMode & CR_SERVER_REDIR_F_FBO_RPW)) 329 { 330 // crServerRpwEntryCleanup(&cr_server.RpwWorker, &mural->RpwEntry); 331 mural->fPresentMode &= ~CR_SERVER_REDIR_F_FBO_RPW; 332 } 333 } 334 335 return true; 336 } 337 338 static void crServerEnableDisplayMuralFBO(CRMuralInfo *mural, GLboolean fEnable) 339 { 340 if (!mural->CreateInfo.externalID) 341 { 342 crWarning("trying to change display setting for internal mural %d", mural->spuWindow); 343 return; 344 } 269 345 270 346 if (fEnable) … … 290 366 void crServerRedirMuralFBO(CRMuralInfo *mural, GLuint redir) 291 367 { 368 if (!mural->CreateInfo.externalID) 369 { 370 crWarning("trying to change redir setting for internal mural %d", mural->spuWindow); 371 return; 372 } 373 292 374 if (mural->fPresentMode == redir) 293 375 { … … 344 426 } 345 427 } 428 429 crServerEnableMuralRpw(mural, !!(redir & CR_SERVER_REDIR_F_FBO_RPW)); 346 430 347 431 crServerEnableDisplayMuralFBO(mural, !!(redir & CR_SERVER_REDIR_F_DISPLAY)); … … 383 467 mural->iBbBuffer = 0; 384 468 /*Color texture*/ 469 470 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB)) 471 { 472 gl->BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0); 473 } 474 385 475 for (i = 0; i < mural->cBuffers; ++i) 386 476 { … … 391 481 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); 392 482 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); 393 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))394 {395 gl->BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0);396 }397 483 gl->TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, mural->width, mural->height, 398 484 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL); … … 463 549 } 464 550 551 if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB)) 552 { 553 gl->BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, ctx->bufferobject.packBuffer->hwid); 554 } 555 else 556 { 557 gl->BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0); 558 } 559 465 560 CRASSERT(mural->aidColorTexs[CR_SERVER_FBO_FB_IDX(mural)]); 466 561 … … 502 597 503 598 mural->cBuffers = 0; 599 600 if (crServerRpwEntryIsInitialized(&mural->RpwEntry)) 601 crServerRpwEntryCleanup(&cr_server.RpwWorker, &mural->RpwEntry); 504 602 } 505 603 … … 560 658 CRContextInfo *curCtxInfo = cr_server.currentCtxInfo; 561 659 GLuint idDrawFBO, idReadFBO; 562 CRContext *curCtx = curCtxInfo ->pContext;660 CRContext *curCtx = curCtxInfo ? curCtxInfo->pContext : NULL; 563 661 564 662 CRASSERT(curCtx == crStateGetCurrent()); … … 655 753 } 656 754 657 void crServerPresentFBO(CRMuralInfo *mural) 658 { 659 char *pixels=NULL, *tmppixels; 755 static void crServerPresentMuralVRAM(CRMuralInfo *mural, char *pixels) 756 { 757 char *tmppixels; 758 CRrecti rect, rectwr, sectr; 660 759 int i, j; 661 CRrecti rect, rectwr, sectr;662 GLuint idPBO;663 CRContext *ctx = crStateGetCurrent();664 VBOXVR_TEXTURE Tex;665 666 CRASSERT(mural->fPresentMode & CR_SERVER_REDIR_F_FBO);667 CRASSERT(cr_server.pfnPresentFBO || (mural->fPresentMode & CR_SERVER_REDIR_F_DISPLAY));668 669 if (!crServerVBoxCompositionPresentNeeded(mural))670 return;671 672 if (mural->fPresentMode & CR_SERVER_REDIR_F_DISPLAY)673 {674 crServerVBoxCompositionPresentPerform(mural);675 }676 677 mural->fDataPresented = GL_TRUE;678 679 if (!(mural->fPresentMode & CR_SERVER_REDIR_FGROUP_REQUIRE_FBO_RAM))680 return;681 682 Tex.width = mural->width;683 Tex.height = mural->height;684 Tex.target = GL_TEXTURE_2D;685 Tex.hwid = mural->aidColorTexs[CR_SERVER_FBO_FB_IDX(mural)];686 CRASSERT(Tex.hwid);687 688 if (cr_server.bUsePBOForReadback && !mural->idPBO)689 {690 crWarning("Mural doesn't have PBO even though bUsePBOForReadback is set!");691 }692 693 idPBO = cr_server.bUsePBOForReadback ? mural->idPBO : 0;694 if (idPBO)695 {696 CRASSERT(mural->fboWidth == mural->width);697 CRASSERT(mural->fboHeight == mural->height);698 }699 700 pixels = CrHlpGetTexImage(ctx, &Tex, idPBO, GL_BGRA);701 if (!pixels)702 {703 crWarning("CrHlpGetTexImage failed in crServerPresentFBO");704 return;705 }706 760 707 761 if (mural->fPresentMode & CR_SERVER_REDIR_F_FBO_RAM_VMFB) … … 766 820 4 * mural->fboWidth * mural->fboHeight); 767 821 } 822 } 823 824 void crServerPresentFBO(CRMuralInfo *mural) 825 { 826 char *pixels=NULL; 827 GLuint idPBO; 828 CRContext *ctx = crStateGetCurrent(); 829 VBOXVR_TEXTURE Tex; 830 831 CRASSERT(mural->fPresentMode & CR_SERVER_REDIR_F_FBO); 832 CRASSERT(cr_server.pfnPresentFBO || (mural->fPresentMode & CR_SERVER_REDIR_F_DISPLAY)); 833 834 if (!crServerVBoxCompositionPresentNeeded(mural)) 835 return; 836 837 if (mural->fPresentMode & CR_SERVER_REDIR_F_DISPLAY) 838 { 839 crServerVBoxCompositionPresentPerform(mural); 840 } 841 842 mural->fDataPresented = GL_TRUE; 843 844 if (!(mural->fPresentMode & CR_SERVER_REDIR_FGROUP_REQUIRE_FBO_RAM)) 845 return; 846 847 Tex.width = mural->width; 848 Tex.height = mural->height; 849 Tex.target = GL_TEXTURE_2D; 850 Tex.hwid = mural->aidColorTexs[CR_SERVER_FBO_FB_IDX(mural)]; 851 CRASSERT(Tex.hwid); 852 853 if (mural->fPresentMode & CR_SERVER_REDIR_F_FBO_RPW) 854 { 855 /* 1. blit to RPW entry draw texture */ 856 CRMuralInfo *pCurrentMural = cr_server.currentMural; 857 CRContextInfo *pCurCtxInfo = cr_server.currentCtxInfo; 858 PCR_BLITTER pBlitter = crServerVBoxBlitterGet(); 859 CRMuralInfo *pBlitterMural; 860 CR_SERVER_CTX_SWITCH CtxSwitch; 861 RTRECT Rect; 862 VBOXVR_TEXTURE DstTex; 863 CR_BLITTER_WINDOW BlitterBltInfo, CurrentBltInfo; 864 CR_BLITTER_CONTEXT CtxBltInfo; 865 int rc; 866 867 Rect.xLeft = 0; 868 Rect.yTop = 0; 869 Rect.xRight = Tex.width; 870 Rect.yBottom = Tex.height; 871 872 if (pCurrentMural && pCurrentMural->CreateInfo.visualBits == CrBltGetVisBits(pBlitter)) 873 { 874 pBlitterMural = pCurrentMural; 875 } 876 else 877 { 878 pBlitterMural = crServerGetDummyMural(pCurrentMural->CreateInfo.visualBits); 879 if (!pBlitterMural) 880 { 881 crWarning("crServerGetDummyMural failed for blitter mural"); 882 return; 883 } 884 } 885 886 crServerRpwEntryDrawSettingsToTex(&mural->RpwEntry, &DstTex); 887 888 cr_serverCtxSwitchPrepare(&CtxSwitch, NULL); 889 890 crServerVBoxBlitterWinInit(&CurrentBltInfo, pCurrentMural); 891 crServerVBoxBlitterWinInit(&BlitterBltInfo, pBlitterMural); 892 crServerVBoxBlitterCtxInit(&CtxBltInfo, pCurCtxInfo); 893 894 CrBltMuralSetCurrent(pBlitter, &BlitterBltInfo); 895 896 rc = CrBltEnter(pBlitter, &CtxBltInfo, &CurrentBltInfo); 897 if (RT_SUCCESS(rc)) 898 { 899 CrBltBlitTexTex(pBlitter, &Tex, &Rect, &DstTex, &Rect, 1, 0); 900 CrBltLeave(pBlitter); 901 } 902 else 903 { 904 crWarning("CrBltEnter failed rc %d", rc); 905 } 906 907 cr_serverCtxSwitchPostprocess(&CtxSwitch); 908 909 if (RT_SUCCESS(rc)) 910 { 911 /* 2. submit RPW entry */ 912 rc = crServerRpwEntrySubmit(&cr_server.RpwWorker, &mural->RpwEntry); 913 if (!RT_SUCCESS(rc)) 914 { 915 crWarning("crServerRpwEntrySubmit failed rc %d", rc); 916 } 917 } 918 919 return; 920 } 921 922 if (cr_server.bUsePBOForReadback && !mural->idPBO) 923 { 924 crWarning("Mural doesn't have PBO even though bUsePBOForReadback is set!"); 925 } 926 927 idPBO = cr_server.bUsePBOForReadback ? mural->idPBO : 0; 928 if (idPBO) 929 { 930 CRASSERT(mural->fboWidth == mural->width); 931 CRASSERT(mural->fboHeight == mural->height); 932 } 933 934 pixels = CrHlpGetTexImage(ctx, &Tex, idPBO, GL_BGRA); 935 if (!pixels) 936 { 937 crWarning("CrHlpGetTexImage failed in crServerPresentFBO"); 938 return; 939 } 940 941 crServerPresentMuralVRAM(mural, pixels); 768 942 769 943 CrHlpFreeTexImage(ctx, idPBO, pixels);
Note:
See TracChangeset
for help on using the changeset viewer.