Changeset 45348 in vbox for trunk/src/VBox/HostServices/SharedOpenGL
- Timestamp:
- Apr 4, 2013 7:46:29 PM (12 years ago)
- Location:
- trunk/src/VBox/HostServices/SharedOpenGL
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedOpenGL/Makefile.kmk
r44740 r45348 135 135 crserverlib/server_texture.c \ 136 136 crserverlib/server_presenter.cpp \ 137 crserverlib/server_rpw.cpp \ 137 138 $(VBOX_PATH_CROGL_GENFILES)/server_dispatch.c \ 138 139 $(VBOX_PATH_CROGL_GENFILES)/server_retval.c \ -
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server.h
r45248 r45348 136 136 #define CR_SERVER_REDIR_F_FBO 0x02 137 137 /* used with CR_SERVER_REDIR_F_FBO only 138 * makes a separate texture to be used for maintaining the window framebuffer presented data */139 #define CR_SERVER_REDIR_F_FBO_VMFB_TEX 0x04140 /* used with CR_SERVER_REDIR_F_FBO only141 138 * indicates that FBO data should be copied to RAM for further processing */ 142 #define CR_SERVER_REDIR_F_FBO_RAM 0x0 8139 #define CR_SERVER_REDIR_F_FBO_RAM 0x04 143 140 /* used with CR_SERVER_REDIR_F_FBO_RAM only 144 141 * indicates that FBO data should be passed to VRDP backend */ 145 #define CR_SERVER_REDIR_F_FBO_RAM_VRDP 0x 10142 #define CR_SERVER_REDIR_F_FBO_RAM_VRDP 0x08 146 143 /* used with CR_SERVER_REDIR_F_FBO_RAM only 147 144 * indicates that FBO data should be passed to VM Framebuffer */ 148 #define CR_SERVER_REDIR_F_FBO_RAM_VMFB 0x20 145 #define CR_SERVER_REDIR_F_FBO_RAM_VMFB 0x10 146 /* used with CR_SERVER_REDIR_F_FBO_RAM only 147 * makes the RPW (Read Pixels Worker) mechanism to be used for GPU memory aquisition */ 148 #define CR_SERVER_REDIR_F_FBO_RPW 0x20 149 149 150 150 151 #define CR_SERVER_REDIR_F_ALL 0x3f 151 152 152 153 #define CR_SERVER_REDIR_FGROUP_REQUIRE_FBO (CR_SERVER_REDIR_F_ALL & ~CR_SERVER_REDIR_F_DISPLAY) 153 #define CR_SERVER_REDIR_FGROUP_REQUIRE_FBO_RAM (CR_SERVER_REDIR_F_FBO_RAM_VRDP | CR_SERVER_REDIR_F_FBO_RAM_VMFB )154 #define CR_SERVER_REDIR_FGROUP_REQUIRE_FBO_RAM (CR_SERVER_REDIR_F_FBO_RAM_VRDP | CR_SERVER_REDIR_F_FBO_RAM_VMFB | CR_SERVER_REDIR_F_FBO_RPW) 154 155 155 156 DECLINLINE(GLuint) crServerRedirModeAdjust(GLuint value) … … 168 169 int32_t crServerSetOffscreenRenderingMode(GLuint value); 169 170 void crServerRedirMuralFBO(CRMuralInfo *mural, GLuint redir); 170 void crServerEnableDisplayMuralFBO(CRMuralInfo *mural, GLboolean fEnable);171 171 void crServerDeleteMuralFBO(CRMuralInfo *mural); 172 172 void crServerPresentFBO(CRMuralInfo *mural); … … 195 195 void crServerPerformMakeCurrent( CRMuralInfo *mural, CRContextInfo *ctxInfo ); 196 196 197 PCR_BLITTER crServerVBoxBlitterGet(); 198 199 DECLINLINE(void) crServerVBoxBlitterWinInit(CR_BLITTER_WINDOW *win, CRMuralInfo *mural) 200 { 201 win->Base.id = mural->spuWindow; 202 win->Base.visualBits = mural->CreateInfo.visualBits; 203 win->width = mural->width; 204 win->height = mural->height; 205 } 206 207 DECLINLINE(void) crServerVBoxBlitterCtxInit(CR_BLITTER_CONTEXT *ctx, CRContextInfo *ctxInfo) 208 { 209 ctx->Base.id = ctxInfo->SpuContext; 210 if (ctx->Base.id < 0) 211 ctx->Base.id = cr_server.MainContextInfo.SpuContext; 212 ctx->Base.visualBits = cr_server.curClient->currentCtxInfo->CreateInfo.visualBits; 213 } 214 215 /* display worker thread. 216 * see comments for CR_SERVER_RPW struct definition in cr_server.h */ 217 DECLINLINE(void) crServerXchgI8(int8_t *pu8Val1, int8_t *pu8Val2) 218 { 219 int8_t tmp; 220 tmp = *pu8Val1; 221 *pu8Val1 = *pu8Val2; 222 *pu8Val2 = tmp; 223 } 224 225 #ifdef DEBUG_misha 226 # define CR_SERVER_RPW_DEBUG 227 #endif 228 /* * 229 * _name : Draw, Submitted, Worker, Gpu 230 */ 231 232 #ifdef CR_SERVER_RPW_DEBUG 233 # define crServerRpwEntryDbgVerify(_pE) crServerRpwEntryDbgDoVerify(_pE) 234 #else 235 # define crServerRpwEntryDbgVerify(_pE) do {} while (0) 236 #endif 237 238 239 #define CR_SERVER_RPW_ENTRY_TEX_IS_VALID(_pEntry, _name) ((_pEntry)->iTex##_name > 0) 240 241 #define CR_SERVER_RPW_ENTRY_TEX_INVALIDATE(_pEntry, _name) do { \ 242 crServerRpwEntryDbgVerify(_pEntry); \ 243 Assert(CR_SERVER_RPW_ENTRY_TEX_IS_VALID(_pEntry, _name)); \ 244 (_pEntry)->iTex##_name = -(_pEntry)->iTex##_name; \ 245 crServerRpwEntryDbgVerify(_pEntry); \ 246 } while (0) 247 248 #define CR_SERVER_RPW_ENTRY_TEX_PROMOTE(_pEntry, _fromName, _toName) do { \ 249 crServerRpwEntryDbgVerify(_pEntry); \ 250 Assert(CR_SERVER_RPW_ENTRY_TEX_IS_VALID(_pEntry, _fromName)); \ 251 Assert(!CR_SERVER_RPW_ENTRY_TEX_IS_VALID(_pEntry, _toName)); \ 252 crServerXchgI8(&(_pEntry)->iTex##_fromName, &(_pEntry)->iTex##_toName); \ 253 crServerRpwEntryDbgVerify(_pEntry); \ 254 } while (0) 255 256 #define CR_SERVER_RPW_ENTRY_TEX_XCHG_VALID(_pEntry, _fromName, _toName) do { \ 257 crServerRpwEntryDbgVerify(_pEntry); \ 258 Assert(CR_SERVER_RPW_ENTRY_TEX_IS_VALID(_pEntry, _fromName)); \ 259 Assert(CR_SERVER_RPW_ENTRY_TEX_IS_VALID(_pEntry, _toName)); \ 260 crServerXchgI8(&(_pEntry)->iTex##_fromName, &(_pEntry)->iTex##_toName); \ 261 Assert(CR_SERVER_RPW_ENTRY_TEX_IS_VALID(_pEntry, _fromName)); \ 262 Assert(CR_SERVER_RPW_ENTRY_TEX_IS_VALID(_pEntry, _toName)); \ 263 crServerRpwEntryDbgVerify(_pEntry); \ 264 } while (0) 265 266 267 #define CR_SERVER_RPW_ENTRY_TEX_PROMOTE_KEEPVALID(_pEntry, _fromName, _toName) do { \ 268 crServerRpwEntryDbgVerify(_pEntry); \ 269 Assert(CR_SERVER_RPW_ENTRY_TEX_IS_VALID(_pEntry, _fromName)); \ 270 Assert(!CR_SERVER_RPW_ENTRY_TEX_IS_VALID(_pEntry, _toName)); \ 271 crServerXchgI8(&(_pEntry)->iTex##_fromName, &(_pEntry)->iTex##_toName); \ 272 (_pEntry)->iTex##_fromName = -(_pEntry)->iTex##_fromName; \ 273 Assert(CR_SERVER_RPW_ENTRY_TEX_IS_VALID(_pEntry, _fromName)); \ 274 Assert(CR_SERVER_RPW_ENTRY_TEX_IS_VALID(_pEntry, _toName)); \ 275 crServerRpwEntryDbgVerify(_pEntry); \ 276 } while (0) 277 278 #define CR_SERVER_RPW_ENTRY_TEX(_pEntry, _name) ((_pEntry)->aidWorkerTexs[(_pEntry)->iTex##_name - 1]) 279 280 #define CR_SERVER_RPW_ENTRY_PBO_NEXT_ID(_i) (((_i) + 1) % 2) 281 #define CR_SERVER_RPW_ENTRY_PBO_IS_ACTIVE(_pEntry) ((_pEntry)->iCurPBO >= 0) 282 #define CR_SERVER_RPW_ENTRY_PBO_CUR(_pEntry) ((_pEntry)->aidPBOs[(_pEntry)->iCurPBO]) 283 #define CR_SERVER_RPW_ENTRY_PBO_COMPLETED(_pEntry) ((_pEntry)->aidPBOs[CR_SERVER_RPW_ENTRY_PBO_NEXT_ID((_pEntry)->iCurPBO)]) 284 #define CR_SERVER_RPW_ENTRY_PBO_FLIP(_pEntry) do { \ 285 (_pEntry)->iCurPBO = CR_SERVER_RPW_ENTRY_PBO_NEXT_ID((_pEntry)->iCurPBO); \ 286 } while (0) 287 288 #ifdef CR_SERVER_RPW_DEBUG 289 DECLINLINE(void) crServerRpwEntryDbgDoVerify(CR_SERVER_RPW_ENTRY *pEntry) 290 { 291 int tstMask = 0; 292 int8_t iVal; 293 Assert(CR_SERVER_RPW_ENTRY_TEX_IS_VALID(pEntry, Draw)); 294 295 #define CR_VERVER_RPW_ENTRY_DBG_CHECKVAL(_v) do { \ 296 iVal = RT_ABS(_v); \ 297 Assert(iVal > 0); \ 298 Assert(iVal < 5); \ 299 Assert(!(tstMask & (1 << iVal))); \ 300 tstMask |= (1 << iVal); \ 301 } while (0) 302 303 CR_VERVER_RPW_ENTRY_DBG_CHECKVAL(pEntry->iTexDraw); 304 CR_VERVER_RPW_ENTRY_DBG_CHECKVAL(pEntry->iTexSubmitted); 305 CR_VERVER_RPW_ENTRY_DBG_CHECKVAL(pEntry->iTexWorker); 306 CR_VERVER_RPW_ENTRY_DBG_CHECKVAL(pEntry->iTexGpu); 307 Assert(tstMask == 0x1E); 308 } 309 #endif 310 311 DECLINLINE(bool) crServerRpwIsInitialized(const CR_SERVER_RPW *pWorker) 312 { 313 return !!pWorker->ctxId; 314 } 315 int crServerRpwInit(CR_SERVER_RPW *pWorker); 316 int crServerRpwTerm(CR_SERVER_RPW *pWorker); 317 DECLINLINE(bool) crServerRpwEntryIsInitialized(const CR_SERVER_RPW_ENTRY *pEntry) 318 { 319 return !!pEntry->pfnData; 320 } 321 int crServerRpwEntryInit(CR_SERVER_RPW *pWorker, CR_SERVER_RPW_ENTRY *pEntry, uint32_t width, uint32_t height, PFNCR_SERVER_RPW_DATA pfnData); 322 int crServerRpwEntryCleanup(CR_SERVER_RPW *pWorker, CR_SERVER_RPW_ENTRY *pEntry); 323 int crServerRpwEntryResize(CR_SERVER_RPW *pWorker, CR_SERVER_RPW_ENTRY *pEntry, uint32_t width, uint32_t height); 324 int crServerRpwEntrySubmit(CR_SERVER_RPW *pWorker, CR_SERVER_RPW_ENTRY *pEntry); 325 int crServerRpwEntryWaitComplete(CR_SERVER_RPW *pWorker, CR_SERVER_RPW_ENTRY *pEntry); 326 int crServerRpwEntryCancel(CR_SERVER_RPW *pWorker, CR_SERVER_RPW_ENTRY *pEntry); 327 DECLINLINE(void) crServerRpwEntryDrawSettingsToTex(const CR_SERVER_RPW_ENTRY *pEntry, VBOXVR_TEXTURE *pTex) 328 { 329 pTex->width = pEntry->Size.cx; 330 pTex->height = pEntry->Size.cy; 331 pTex->target = GL_TEXTURE_2D; 332 CR_SERVER_RPW_ENTRY_TEX_IS_VALID(pEntry, Draw); 333 pTex->hwid = CR_SERVER_RPW_ENTRY_TEX(pEntry, Draw); 334 } 335 /**/ 336 337 typedef struct CR_SERVER_CTX_SWITCH 338 { 339 GLuint idDrawFBO, idReadFBO; 340 CRContext *pNewCtx; 341 CRContext *pOldCtx; 342 } CR_SERVER_CTX_SWITCH; 343 344 DECLINLINE(void) cr_serverCtxSwitchPrepare(CR_SERVER_CTX_SWITCH *pData, CRContext *pNewCtx) 345 { 346 CRMuralInfo *pCurrentMural = cr_server.currentMural; 347 CRContextInfo *pCurCtxInfo = cr_server.currentCtxInfo; 348 GLuint idDrawFBO, idReadFBO; 349 CRContext *pCurCtx = pCurCtxInfo ? pCurCtxInfo->pContext : NULL; 350 351 CRASSERT(pCurCtx == crStateGetCurrent()); 352 353 if (pCurrentMural) 354 { 355 idDrawFBO = pCurrentMural->aidFBOs[pCurrentMural->iCurDrawBuffer]; 356 idReadFBO = pCurrentMural->aidFBOs[pCurrentMural->iCurReadBuffer]; 357 } 358 else 359 { 360 idDrawFBO = 0; 361 idReadFBO = 0; 362 } 363 364 crStateSwitchPrepare(pNewCtx, pCurCtx, idDrawFBO, idReadFBO); 365 366 pData->idDrawFBO = idDrawFBO; 367 pData->idReadFBO = idReadFBO; 368 pData->pNewCtx = pNewCtx; 369 pData->pOldCtx = pCurCtx; 370 } 371 372 DECLINLINE(void) cr_serverCtxSwitchPostprocess(CR_SERVER_CTX_SWITCH *pData) 373 { 374 crStateSwitchPostprocess(pData->pOldCtx, pData->pNewCtx, pData->idDrawFBO, pData->idReadFBO); 375 } 197 376 RT_C_DECLS_END 198 377 -
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_config.c
r45248 r45348 54 54 cr_server.fPresentMode = CR_SERVER_REDIR_F_NONE; 55 55 cr_server.fPresentModeDefault = cr_server.fPresentMode; 56 cr_server.fVramPresentModeDefault = CR_SERVER_REDIR_F_FBO_RAM; 56 57 cr_server.bUsePBOForReadback = GL_FALSE; 57 58 cr_server.bUseOutputRedirect = GL_FALSE; … … 234 235 #endif 235 236 cr_server.fPresentModeDefault = cr_server.fPresentMode; 237 cr_server.fVramPresentModeDefault = CR_SERVER_REDIR_F_FBO_RAM/* | CR_SERVER_REDIR_F_FBO_RPW*/; 236 238 237 239 /* Need to do this as early as possible */ … … 377 379 #endif 378 380 cr_server.fPresentModeDefault = cr_server.fPresentMode; 381 cr_server.fVramPresentModeDefault = CR_SERVER_REDIR_F_FBO_RAM/* | CR_SERVER_REDIR_F_FBO_RPW*/; 379 382 380 383 cr_server.head_spu->dispatch_table.GetChromiumParametervCR(GL_WINDOW_POSITION_CR, 0, GL_INT, 2, &dims[0]); -
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_main.c
r45252 r45348 206 206 cr_server.pCleanupClient = NULL; 207 207 208 if (crServerRpwIsInitialized(&cr_server.RpwWorker)) 209 { 210 crServerRpwTerm(&cr_server.RpwWorker); 211 } 212 208 213 #if 1 209 214 /* disable these two lines if trying to get stack traces with valgrind */ … … 361 366 crMemset(&cr_server.RootVrCurPoint, 0, sizeof (cr_server.RootVrCurPoint)); 362 367 368 crMemset(&cr_server.RpwWorker, 0, sizeof (cr_server.RpwWorker)); 369 363 370 env = crGetenv("CR_SERVER_BFB"); 364 371 if (env) … … 460 467 VBoxVrListInit(&cr_server.RootVr); 461 468 crMemset(&cr_server.RootVrCurPoint, 0, sizeof (cr_server.RootVrCurPoint)); 469 470 crMemset(&cr_server.RpwWorker, 0, sizeof (cr_server.RpwWorker)); 462 471 463 472 env = crGetenv("CR_SERVER_BFB"); … … 2543 2552 { 2544 2553 return crServerSetOffscreenRenderingMode(value ? 2545 cr_server.fPresentModeDefault | CR_SERVER_REDIR_F_FBO_RAM_VRDP 2554 cr_server.fPresentModeDefault | CR_SERVER_REDIR_F_FBO_RAM_VRDP | cr_server.fVramPresentModeDefault 2546 2555 : cr_server.fPresentModeDefault); 2547 2556 } -
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_misc.c
r45248 r45348 743 743 } 744 744 745 void crServerVBoxBlitterWinInit(CRMuralInfo *mural, CR_BLITTER_WINDOW *win)746 {747 win->Base.id = mural->spuWindow;748 win->Base.visualBits = mural->CreateInfo.visualBits;749 win->width = mural->width;750 win->height = mural->height;751 }752 753 745 int crServerVBoxBlitterBlitCurrentCtx(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, 754 746 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, … … 812 804 } 813 805 814 crServerVBoxBlitterWinInit(mural, &BltInfo); 806 crServerVBoxBlitterWinInit(&BltInfo, mural); 807 808 crServerVBoxBlitterCtxInit(&Ctx, cr_server.curClient->currentCtxInfo); 815 809 816 810 CrBltMuralSetCurrent(pBlitter, &BltInfo); 817 818 Ctx.Base.id = cr_server.curClient->currentCtxInfo->SpuContext;819 if (Ctx.Base.id < 0)820 Ctx.Base.id = cr_server.MainContextInfo.SpuContext;821 Ctx.Base.visualBits = cr_server.curClient->currentCtxInfo->CreateInfo.visualBits;822 811 823 812 idDrawFBO = mural->aidFBOs[mural->iCurDrawBuffer]; -
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.