Changeset 45201 in vbox
- Timestamp:
- Mar 27, 2013 10:23:49 AM (12 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/OpenGL/include/cr_blitter.h
r45132 r45201 54 54 struct CR_BLITTER; 55 55 56 typedef DECLCALLBACK(int) FNCRBLT_BLITTER(struct CR_BLITTER *pBlitter, VBOXVR_TEXTURE *pSrc, const RTRECT *paSrcRect, const RTRECTSIZE *pDstSize, const RTRECT *paDstRect, uint32_t cRects, uint32_t fFlags);56 typedef DECLCALLBACK(int) FNCRBLT_BLITTER(struct CR_BLITTER *pBlitter, const VBOXVR_TEXTURE *pSrc, const RTRECT *paSrcRect, const RTRECTSIZE *pDstSize, const RTRECT *paDstRect, uint32_t cRects, uint32_t fFlags); 57 57 typedef FNCRBLT_BLITTER *PFNCRBLT_BLITTER; 58 58 59 #define CRBLT_F_LINEAR 0x00000001 60 #define CRBLT_F_OFFSCREEN 0x00000002 59 #define CRBLT_F_LINEAR 0x00000001 60 #define CRBLT_F_INVERT_SRC_YCOORDS 0x00000002 61 #define CRBLT_F_INVERT_DST_YCOORDS 0x00000004 62 #define CRBLT_F_INVERT_YCOORDS (CRBLT_F_INVERT_SRC_YCOORDS | CRBLT_F_INVERT_DST_YCOORDS) 63 64 #define CRBLT_FLAGS_FROM_FILTER(_f) ( ((_f) & GL_LINEAR) ? CRBLT_F_LINEAR : 0) 65 #define CRBLT_FILTER_FROM_FLAGS(_f) (((_f) & CRBLT_F_LINEAR) ? GL_LINEAR : GL_NEAREST) 61 66 62 67 typedef struct CR_BLITTER_SPUITEM … … 85 90 CR_BLITTER_BUFFER Indicies; 86 91 RTRECTSIZE CurrentSetSize; 87 CR_BLITTER_WINDOW *pCurrentMural;92 CR_BLITTER_WINDOW CurrentMural; 88 93 CR_BLITTER_CONTEXT CtxInfo; 89 CR_BLITTER_CONTEXT *pRestoreCtxInfo;90 CR_BLITTER_WINDOW *pRestoreMural;94 const CR_BLITTER_CONTEXT *pRestoreCtxInfo; 95 const CR_BLITTER_WINDOW *pRestoreMural; 91 96 int32_t i32MakeCurrentUserData; 92 97 SPUDispatchTable *pDispatch; 93 98 } CR_BLITTER, *PCR_BLITTER; 94 99 95 VBOXBLITTERDECL(int) CrBltInit(PCR_BLITTER pBlitter, CR_BLITTER_CONTEXT *pCtxBase, bool fCreateNewCtx, SPUDispatchTable *pDispatch); 100 DECLINLINE(GLboolean) CrBltIsInitialized(PCR_BLITTER pBlitter) 101 { 102 return !!pBlitter->pDispatch; 103 } 104 105 VBOXBLITTERDECL(int) CrBltInit(PCR_BLITTER pBlitter, const CR_BLITTER_CONTEXT *pCtxBase, bool fCreateNewCtx, SPUDispatchTable *pDispatch); 96 106 VBOXBLITTERDECL(void) CrBltTerm(PCR_BLITTER pBlitter); 97 107 … … 116 126 } 117 127 118 VBOXBLITTERDECL(void) CrBltMuralSetCurrent(PCR_BLITTER pBlitter, CR_BLITTER_WINDOW *pMural);119 DECLINLINE( CR_BLITTER_WINDOW *) CrBltMuralGetCurrent(PCR_BLITTER pBlitter)128 VBOXBLITTERDECL(void) CrBltMuralSetCurrent(PCR_BLITTER pBlitter, const CR_BLITTER_WINDOW *pMural); 129 DECLINLINE(const CR_BLITTER_WINDOW *) CrBltMuralGetCurrentInfo(PCR_BLITTER pBlitter) 120 130 { 121 return pBlitter->pCurrentMural;131 return &pBlitter->CurrentMural; 122 132 } 123 133 124 134 VBOXBLITTERDECL(void) CrBltLeave(PCR_BLITTER pBlitter); 125 VBOXBLITTERDECL(int) CrBltEnter(PCR_BLITTER pBlitter, CR_BLITTER_CONTEXT *pRestoreCtxInfo,CR_BLITTER_WINDOW *pRestoreMural);126 VBOXBLITTERDECL(void) CrBltBlitTexMural(PCR_BLITTER pBlitter, VBOXVR_TEXTURE *pSrc, const RTRECT *paSrcRects, const RTRECT *paDstRects, uint32_t cRects, uint32_t fFlags);127 VBOXBLITTERDECL(void) CrBltBlitTexTex(PCR_BLITTER pBlitter, VBOXVR_TEXTURE *pSrc, const RTRECT *pSrcRect,VBOXVR_TEXTURE *pDst, const RTRECT *pDstRect, uint32_t cRects, uint32_t fFlags);135 VBOXBLITTERDECL(int) CrBltEnter(PCR_BLITTER pBlitter, const CR_BLITTER_CONTEXT *pRestoreCtxInfo, const CR_BLITTER_WINDOW *pRestoreMural); 136 VBOXBLITTERDECL(void) CrBltBlitTexMural(PCR_BLITTER pBlitter, const VBOXVR_TEXTURE *pSrc, const RTRECT *paSrcRects, const RTRECT *paDstRects, uint32_t cRects, uint32_t fFlags); 137 VBOXBLITTERDECL(void) CrBltBlitTexTex(PCR_BLITTER pBlitter, const VBOXVR_TEXTURE *pSrc, const RTRECT *pSrcRect, const VBOXVR_TEXTURE *pDst, const RTRECT *pDstRect, uint32_t cRects, uint32_t fFlags); 128 138 VBOXBLITTERDECL(void) CrBltPresent(PCR_BLITTER pBlitter); 129 139 /* */ -
trunk/src/VBox/GuestHost/OpenGL/include/cr_server.h
r45148 r45201 14 14 #include "cr_glstate.h" 15 15 #include "cr_vreg.h" 16 #include "cr_blitter.h" 16 17 #include "spu_dispatch_table.h" 17 18 … … 320 321 * we deal with the global RootVr data directly */ 321 322 RTPOINT RootVrCurPoint; 323 324 CR_BLITTER Blitter; 322 325 323 326 /** configuration options */ -
trunk/src/VBox/GuestHost/OpenGL/util/blitter.cpp
r45132 r45201 29 29 30 30 31 int CrBltInit(PCR_BLITTER pBlitter, CR_BLITTER_CONTEXT *pCtxBase, bool fCreateNewCtx, SPUDispatchTable *pDispatch) 32 { 33 memset(pBlitter, 0, sizeof (*pBlitter)); 34 35 pBlitter->pDispatch = pDispatch; 36 31 int CrBltInit(PCR_BLITTER pBlitter, const CR_BLITTER_CONTEXT *pCtxBase, bool fCreateNewCtx, SPUDispatchTable *pDispatch) 32 { 37 33 if (pCtxBase->Base.id == 0 || pCtxBase->Base.id < -1) 38 34 { … … 41 37 } 42 38 39 memset(pBlitter, 0, sizeof (*pBlitter)); 40 41 pBlitter->pDispatch = pDispatch; 43 42 pBlitter->CtxInfo = *pCtxBase; 44 43 if (fCreateNewCtx) … … 47 46 if (!pBlitter->CtxInfo.Base.id) 48 47 { 48 memset(pBlitter, 0, sizeof (*pBlitter)); 49 49 crWarning("CreateContext failed!"); 50 50 return VERR_GENERAL_FAILURE; … … 62 62 } 63 63 64 void CrBltMuralSetCurrent(PCR_BLITTER pBlitter, CR_BLITTER_WINDOW *pMural) 65 { 66 if (pBlitter->pCurrentMural == pMural) 67 return; 68 69 pBlitter->pCurrentMural = pMural; 64 void CrBltMuralSetCurrent(PCR_BLITTER pBlitter, const CR_BLITTER_WINDOW *pMural) 65 { 66 if (pMural) 67 { 68 if (!memcmp(&pBlitter->CurrentMural, pMural, sizeof (pBlitter->CurrentMural))) 69 return; 70 memcpy(&pBlitter->CurrentMural, pMural, sizeof (pBlitter->CurrentMural)); 71 } 72 else 73 { 74 if (!pBlitter->CurrentMural.Base.id) 75 return; 76 pBlitter->CurrentMural.Base.id = 0; 77 } 78 70 79 pBlitter->Flags.CurrentMuralChanged = 1; 71 80 … … 79 88 } 80 89 81 #define CRBLT_FILTER_FROM_FLAGS(_f) (((_f) & CRBLT_F_LINEAR) ? GL_LINEAR : GL_NEAREST) 82 83 static DECLCALLBACK(int) crBltBlitTexBufImplFbo(PCR_BLITTER pBlitter, VBOXVR_TEXTURE *pSrc, const RTRECT *paSrcRect, const RTRECTSIZE *pDstSize, const RTRECT *paDstRect, uint32_t cRects, uint32_t fFlags) 90 static DECLCALLBACK(int) crBltBlitTexBufImplFbo(PCR_BLITTER pBlitter, const VBOXVR_TEXTURE *pSrc, const RTRECT *paSrcRect, const RTRECTSIZE *pDstSize, const RTRECT *paDstRect, uint32_t cRects, uint32_t fFlags) 84 91 { 85 92 GLenum filter = CRBLT_FILTER_FROM_FLAGS(fFlags); … … 92 99 const RTRECT * pSrcRect = &paSrcRect[i]; 93 100 const RTRECT * pDstRect = &paDstRect[i]; 94 if (CRBLT_F_OFFSCREEN & fFlags) 95 { 96 pBlitter->pDispatch->BlitFramebufferEXT( 97 pSrcRect->xLeft, pSrcRect->yTop, pSrcRect->xRight, pSrcRect->yBottom, 98 pDstRect->xLeft, pDstRect->yTop, pDstRect->xRight, pDstRect->yBottom, 101 int32_t srcY1; 102 int32_t srcY2; 103 int32_t dstY1; 104 int32_t dstY2; 105 int32_t srcX1 = pSrcRect->xLeft; 106 int32_t srcX2 = pSrcRect->xRight; 107 int32_t dstX1 = pDstRect->xLeft; 108 int32_t dstX2 = pDstRect->xRight; 109 110 if (CRBLT_F_INVERT_SRC_YCOORDS & fFlags) 111 { 112 srcY1 = pSrc->height - pSrcRect->yTop; 113 srcY2 = pSrc->height - pSrcRect->yBottom; 114 } 115 else 116 { 117 srcY1 = pSrcRect->yTop; 118 srcY2 = pSrcRect->yBottom; 119 } 120 121 if (CRBLT_F_INVERT_DST_YCOORDS & fFlags) 122 { 123 dstY1 = pDstSize->cy - pDstRect->yTop; 124 dstY2 = pDstSize->cy - pDstRect->yBottom; 125 } 126 else 127 { 128 dstY1 = pDstRect->yTop; 129 dstY2 = pDstRect->yBottom; 130 } 131 132 if (srcY1 > srcY2) 133 { 134 if (dstY1 > dstY2) 135 { 136 /* use srcY1 < srcY2 && dstY1 < dstY2 whenever possible to avoid GPU driver bugs */ 137 int32_t tmp = srcY1; 138 srcY1 = srcY2; 139 srcY2 = tmp; 140 tmp = dstY1; 141 dstY1 = dstY2; 142 dstY2 = tmp; 143 } 144 } 145 146 if (srcX1 > srcX2) 147 { 148 if (dstX1 > dstX2) 149 { 150 /* use srcX1 < srcX2 && dstX1 < dstX2 whenever possible to avoid GPU driver bugs */ 151 int32_t tmp = srcX1; 152 srcX1 = srcX2; 153 srcX2 = tmp; 154 tmp = dstX1; 155 dstX1 = dstX2; 156 dstX2 = tmp; 157 } 158 } 159 160 pBlitter->pDispatch->BlitFramebufferEXT(srcX1, srcY1, srcX2, srcY2, 161 dstX1, dstY1, dstX2, dstY2, 99 162 GL_COLOR_BUFFER_BIT, filter); 100 }101 else102 {103 int32_t srcY1 = pSrc->height - pSrcRect->yTop;104 int32_t srcY2 = pSrc->height - pSrcRect->yBottom;105 int32_t dstY1 = pDstSize->cy - pDstRect->yTop;106 int32_t dstY2 = pDstSize->cy - pDstRect->yBottom;107 if (srcY1 > srcY2)108 {109 if (dstY1 > dstY2)110 {111 /* use srcY1 < srcY2 && dstY1 < dstY2 whenever possible to avoid GPU driver bugs */112 int32_t tmp = srcY1;113 srcY1 = srcY2;114 srcY2 = tmp;115 tmp = dstY1;116 dstY1 = dstY2;117 dstY2 = tmp;118 }119 }120 pBlitter->pDispatch->BlitFramebufferEXT(121 pSrcRect->xLeft, srcY1, pSrcRect->xRight, srcY2,122 pDstRect->xLeft, dstY1, pDstRect->xRight, dstY2,123 GL_COLOR_BUFFER_BIT, filter);124 }125 163 } 126 164 … … 271 309 static void crBltCheckSetupViewport(PCR_BLITTER pBlitter, const RTRECTSIZE *pDstSize, bool fFBODraw) 272 310 { 273 if (!pBlitter->Flags.LastWasFBODraw != !fFBODraw 274 || pBlitter->Flags.CurrentMuralChanged 275 || pBlitter->CurrentSetSize.cx != pDstSize->cx 311 bool fUpdateViewport = pBlitter->Flags.CurrentMuralChanged; 312 if (pBlitter->CurrentSetSize.cx != pDstSize->cx 276 313 || pBlitter->CurrentSetSize.cy != pDstSize->cy) 277 314 { 278 #if 0 279 const GLdouble aProjection[] = 280 { 281 2.0 / pDstSize->cx, 0.0, 0.0, 0.0, 282 0.0, 2.0 / pDstSize->cy, 0.0, 0.0, 283 0.0, 0.0, 2.0, 0.0, 284 -1.0, -1.0, -1.0, 1.0 285 }; 286 pBlitter->pDispatch->MatrixMode(GL_PROJECTION); 287 pBlitter->pDispatch->LoadMatrixd(aProjection); 288 pBlitter->pDispatch->Viewport(0, 0, pDstSize->cx, pDstSize->cy); 289 #else 315 pBlitter->CurrentSetSize = *pDstSize; 290 316 pBlitter->pDispatch->MatrixMode(GL_PROJECTION); 291 317 pBlitter->pDispatch->LoadIdentity(); 292 pBlitter->pDispatch->Viewport(0, 0, pDstSize->cx, pDstSize->cy);293 318 pBlitter->pDispatch->Ortho(0, pDstSize->cx, 0, pDstSize->cy, -1, 1); 294 pBlitter->pDispatch->MatrixMode(GL_TEXTURE); 295 pBlitter->pDispatch->LoadIdentity(); 296 pBlitter->pDispatch->MatrixMode(GL_MODELVIEW); 297 pBlitter->pDispatch->LoadIdentity(); 298 299 /* Clear background to transparent */ 300 pBlitter->pDispatch->ClearColor(0.0f, 0.0f, 0.0f, 0.0f); 301 #endif 302 pBlitter->CurrentSetSize.cx = pDstSize->cx; 303 pBlitter->CurrentSetSize.cy = pDstSize->cy; 304 pBlitter->Flags.LastWasFBODraw = fFBODraw; 305 if (!fFBODraw) 306 pBlitter->Flags.CurrentMuralChanged = 0; 307 } 308 } 309 310 static DECLCALLBACK(int) crBltBlitTexBufImplDraw2D(PCR_BLITTER pBlitter, VBOXVR_TEXTURE *pSrc, const RTRECT *paSrcRect, const RTRECTSIZE *pDstSize, const RTRECT *paDstRect, uint32_t cRects, uint32_t fFlags) 319 fUpdateViewport = true; 320 } 321 322 if (fUpdateViewport) 323 { 324 pBlitter->pDispatch->Viewport(0, 0, pBlitter->CurrentSetSize.cx, pBlitter->CurrentSetSize.cy); 325 pBlitter->Flags.CurrentMuralChanged = 0; 326 } 327 328 pBlitter->Flags.LastWasFBODraw = fFBODraw; 329 } 330 331 static DECLCALLBACK(int) crBltBlitTexBufImplDraw2D(PCR_BLITTER pBlitter, const VBOXVR_TEXTURE *pSrc, const RTRECT *paSrcRect, const RTRECTSIZE *pDstSize, const RTRECT *paDstRect, uint32_t cRects, uint32_t fFlags) 311 332 { 312 333 GLuint normalX, normalY; 313 uint32_t height = (fFlags & CRBLT_F_OFFSCREEN) ? 0 : pDstSize->cy; 334 uint32_t srcHeight = (fFlags & CRBLT_F_INVERT_SRC_YCOORDS) ? pSrc->height : 0; 335 uint32_t dstHeight = (fFlags & CRBLT_F_INVERT_DST_YCOORDS) ? pDstSize->cy : 0; 336 Assert(srcHeight == dstHeight); 314 337 315 338 switch (pSrc->target) … … 343 366 { 344 367 /* just optimizatino to draw a single rect with GL_TRIANGLE_FAN */ 345 bool bUseSameVerticies = paSrcRect == paDstRect && normalX == 1 && normalY == 1 ;368 bool bUseSameVerticies = paSrcRect == paDstRect && normalX == 1 && normalY == 1 && srcHeight == dstHeight; 346 369 GLfloat *pVerticies; 347 370 GLfloat *pTexCoords; … … 350 373 { 351 374 pVerticies = (GLfloat*)crBltBufGet(&pBlitter->Verticies, cElements * 2 * sizeof (*pVerticies)); 352 crBltVtRectTFNormalized(paDstRect, normalX, normalY, pVerticies, height);375 crBltVtRectTFNormalized(paDstRect, normalX, normalY, pVerticies, dstHeight); 353 376 pTexCoords = pVerticies; 354 377 } … … 356 379 { 357 380 pVerticies = (GLfloat*)crBltBufGet(&pBlitter->Verticies, cElements * 2 * 2 * sizeof (*pVerticies)); 358 pTexCoords = crBltVtRectTFNormalized(paDstRect, 1, 1, pVerticies, height);359 crBltVtRectTFNormalized(paSrcRect, normalX, normalY, pTexCoords, height);381 pTexCoords = crBltVtRectTFNormalized(paDstRect, 1, 1, pVerticies, dstHeight); 382 crBltVtRectTFNormalized(paSrcRect, normalX, normalY, pTexCoords, srcHeight); 360 383 } 361 384 … … 377 400 else 378 401 { 379 bool bUseSameVerticies = paSrcRect == paDstRect && normalX == 1 && normalY == 1 ;402 bool bUseSameVerticies = paSrcRect == paDstRect && normalX == 1 && normalY == 1 && srcHeight == dstHeight; 380 403 GLfloat *pVerticies; 381 404 GLfloat *pTexCoords; … … 387 410 { 388 411 pVerticies = (GLfloat*)crBltBufGet(&pBlitter->Verticies, cElements * 2 * sizeof (*pVerticies) + cIndicies * sizeof (*pIndicies)); 389 crBltVtRectsITNormalized(paDstRect, cRects, normalX, normalY, pVerticies, &pIndicies, &iIdxBase, height);412 crBltVtRectsITNormalized(paDstRect, cRects, normalX, normalY, pVerticies, &pIndicies, &iIdxBase, dstHeight); 390 413 pTexCoords = pVerticies; 391 414 } … … 393 416 { 394 417 pVerticies = (GLfloat*)crBltBufGet(&pBlitter->Verticies, cElements * 2 * 2 * sizeof (*pVerticies) + cIndicies * sizeof (*pIndicies)); 395 pTexCoords = crBltVtRectsITNormalized(paDstRect, cRects, 1, 1, pVerticies, &pIndicies, &iIdxBase, height);396 crBltVtRectsITNormalized(paSrcRect, cRects, normalX, normalY, pTexCoords, NULL, NULL, height);418 pTexCoords = crBltVtRectsITNormalized(paDstRect, cRects, 1, 1, pVerticies, &pIndicies, &iIdxBase, dstHeight); 419 crBltVtRectsITNormalized(paSrcRect, cRects, normalX, normalY, pTexCoords, NULL, NULL, srcHeight); 397 420 } 398 421 … … 441 464 } 442 465 466 /* defaults. but just in case */ 467 pBlitter->pDispatch->MatrixMode(GL_TEXTURE); 468 pBlitter->pDispatch->LoadIdentity(); 469 pBlitter->pDispatch->MatrixMode(GL_MODELVIEW); 470 pBlitter->pDispatch->LoadIdentity(); 471 443 472 return VINF_SUCCESS; 444 473 } … … 459 488 if (pBlitter->pRestoreCtxInfo != &pBlitter->CtxInfo) 460 489 { 461 462 pBlitter->pDispatch->MakeCurrent(pBlitter->pRestoreMural->Base.id, 0, 463 pBlitter->pRestoreCtxInfo->Base.id >= 0 464 ? pBlitter->pRestoreCtxInfo->Base.id : pBlitter->pRestoreCtxInfo->Base.id); 490 pBlitter->pDispatch->MakeCurrent(pBlitter->pRestoreMural->Base.id, 0, pBlitter->pRestoreCtxInfo->Base.id); 465 491 } 466 492 else … … 472 498 } 473 499 474 int CrBltEnter(PCR_BLITTER pBlitter, CR_BLITTER_CONTEXT *pRestoreCtxInfo,CR_BLITTER_WINDOW *pRestoreMural)475 { 476 if (!pBlitter-> pCurrentMural)500 int CrBltEnter(PCR_BLITTER pBlitter, const CR_BLITTER_CONTEXT *pRestoreCtxInfo, const CR_BLITTER_WINDOW *pRestoreMural) 501 { 502 if (!pBlitter->CurrentMural.Base.id) 477 503 { 478 504 crWarning("current mural not initialized!"); … … 498 524 } 499 525 500 pBlitter->pDispatch->MakeCurrent(pBlitter-> pCurrentMural->Base.id, pBlitter->i32MakeCurrentUserData, pBlitter->CtxInfo.Base.id);526 pBlitter->pDispatch->MakeCurrent(pBlitter->CurrentMural.Base.id, pBlitter->i32MakeCurrentUserData, pBlitter->CtxInfo.Base.id); 501 527 502 528 if (pBlitter->Flags.Initialized) … … 515 541 } 516 542 517 static void crBltBlitTexBuf(PCR_BLITTER pBlitter, VBOXVR_TEXTURE *pSrc, const RTRECT *paSrcRects, GLenum enmDstBuff, const RTRECTSIZE *pDstSize, const RTRECT *paDstRects, uint32_t cRects, uint32_t fFlags)543 static void crBltBlitTexBuf(PCR_BLITTER pBlitter, const VBOXVR_TEXTURE *pSrc, const RTRECT *paSrcRects, GLenum enmDstBuff, const RTRECTSIZE *pDstSize, const RTRECT *paDstRects, uint32_t cRects, uint32_t fFlags) 518 544 { 519 545 pBlitter->pDispatch->DrawBuffer(enmDstBuff); … … 521 547 crBltCheckSetupViewport(pBlitter, pDstSize, enmDstBuff == GL_DRAW_FRAMEBUFFER); 522 548 523 pBlitter->pfnBlt(pBlitter, pSrc, paSrcRects, pDstSize, paDstRects, cRects, fFlags & CRBLT_F_OFFSCREEN);524 } 525 526 void CrBltBlitTexMural(PCR_BLITTER pBlitter, VBOXVR_TEXTURE *pSrc, const RTRECT *paSrcRects, const RTRECT *paDstRects, uint32_t cRects, uint32_t fFlags)527 { 528 RTRECTSIZE DstSize = {pBlitter-> pCurrentMural->width, pBlitter->pCurrentMural->height};549 pBlitter->pfnBlt(pBlitter, pSrc, paSrcRects, pDstSize, paDstRects, cRects, fFlags); 550 } 551 552 void CrBltBlitTexMural(PCR_BLITTER pBlitter, const VBOXVR_TEXTURE *pSrc, const RTRECT *paSrcRects, const RTRECT *paDstRects, uint32_t cRects, uint32_t fFlags) 553 { 554 RTRECTSIZE DstSize = {pBlitter->CurrentMural.width, pBlitter->CurrentMural.height}; 529 555 530 556 pBlitter->pDispatch->BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, 0); 531 557 532 crBltBlitTexBuf(pBlitter, pSrc, paSrcRects, GL_BACK, &DstSize, paDstRects, cRects, fFlags & (~CRBLT_F_OFFSCREEN));533 } 534 535 void CrBltBlitTexTex(PCR_BLITTER pBlitter, VBOXVR_TEXTURE *pSrc, const RTRECT *pSrcRect,VBOXVR_TEXTURE *pDst, const RTRECT *pDstRect, uint32_t cRects, uint32_t fFlags)558 crBltBlitTexBuf(pBlitter, pSrc, paSrcRects, GL_BACK, &DstSize, paDstRects, cRects, fFlags); 559 } 560 561 void CrBltBlitTexTex(PCR_BLITTER pBlitter, const VBOXVR_TEXTURE *pSrc, const RTRECT *pSrcRect, const VBOXVR_TEXTURE *pDst, const RTRECT *pDstRect, uint32_t cRects, uint32_t fFlags) 536 562 { 537 563 RTRECTSIZE DstSize = {(uint32_t)pDst->width, (uint32_t)pDst->height}; … … 552 578 { 553 579 if (pBlitter->CtxInfo.Base.visualBits & CR_DOUBLE_BIT) 554 pBlitter->pDispatch->SwapBuffers(pBlitter-> pCurrentMural->Base.id, 0);580 pBlitter->pDispatch->SwapBuffers(pBlitter->CurrentMural.Base.id, 0); 555 581 else 556 582 pBlitter->pDispatch->Flush(); -
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_main.c
r45179 r45201 355 355 crMemset(&cr_server.RootVrCurPoint, 0, sizeof (cr_server.RootVrCurPoint)); 356 356 357 crMemset(&cr_server.Blitter, 0, sizeof (cr_server.Blitter)); 358 357 359 crServerInitDispatch(); 358 360 crStateDiffAPI( &(cr_server.head_spu->dispatch_table) ); … … 443 445 VBoxVrListInit(&cr_server.RootVr); 444 446 crMemset(&cr_server.RootVrCurPoint, 0, sizeof (cr_server.RootVrCurPoint)); 447 448 crMemset(&cr_server.Blitter, 0, sizeof (cr_server.Blitter)); 445 449 446 450 crServerSetVBoxConfigurationHGCM(); -
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_misc.c
r44196 r45201 625 625 #endif 626 626 627 PCR_BLITTER crServerVBoxBlitterGet() 628 { 629 if (!CrBltIsInitialized(&cr_server.Blitter)) 630 { 631 CR_BLITTER_CONTEXT Ctx; 632 int rc; 633 CRASSERT(cr_server.MainContextInfo.SpuContext); 634 Ctx.Base.id = cr_server.MainContextInfo.SpuContext; 635 Ctx.Base.visualBits = cr_server.MainContextInfo.CreateInfo.visualBits; 636 rc = CrBltInit(&cr_server.Blitter, &Ctx, true, &cr_server.head_spu->dispatch_table); 637 if (RT_SUCCESS(rc)) 638 { 639 CRASSERT(CrBltIsInitialized(&cr_server.Blitter)); 640 } 641 else 642 { 643 crWarning("CrBltInit failed, rc %d", rc); 644 CRASSERT(!CrBltIsInitialized(&cr_server.Blitter)); 645 return NULL; 646 } 647 } 648 return &cr_server.Blitter; 649 } 650 651 int crServerVBoxBlitterTexInit(CRContext *ctx, CRMuralInfo *mural, PVBOXVR_TEXTURE pTex, GLboolean fDraw) 652 { 653 CRTextureObj *tobj; 654 CRFramebufferObjectState *pBuf = &ctx->framebufferobject; 655 GLenum enmBuf; 656 CRFBOAttachmentPoint *pAp; 657 GLuint idx; 658 CRTextureLevel *tl; 659 CRFramebufferObject *pFBO = fDraw ? pBuf->drawFB : pBuf->readFB; 660 661 if (!pFBO) 662 { 663 GLuint hwid; 664 665 if (mural->fUseFBO == CR_SERVER_REDIR_NONE) 666 return VERR_NOT_IMPLEMENTED; 667 668 enmBuf = fDraw ? ctx->buffer.drawBuffer : ctx->buffer.readBuffer; 669 switch (enmBuf) 670 { 671 case GL_BACK: 672 case GL_BACK_RIGHT: 673 case GL_BACK_LEFT: 674 hwid = mural->aidColorTexs[CR_SERVER_FBO_BB_IDX(mural)]; 675 break; 676 case GL_FRONT: 677 case GL_FRONT_RIGHT: 678 case GL_FRONT_LEFT: 679 hwid = mural->aidColorTexs[CR_SERVER_FBO_FB_IDX(mural)]; 680 break; 681 default: 682 crWarning("unsupported enum buf"); 683 return VERR_NOT_IMPLEMENTED; 684 break; 685 } 686 687 if (!hwid) 688 { 689 crWarning("offscreen render tex hwid is null"); 690 return VERR_INVALID_STATE; 691 } 692 693 pTex->width = mural->width; 694 pTex->height = mural->height; 695 pTex->target = GL_TEXTURE_2D; 696 pTex->hwid = hwid; 697 return VINF_SUCCESS; 698 } 699 700 enmBuf = fDraw ? pFBO->drawbuffer[0] : pFBO->readbuffer; 701 idx = enmBuf - GL_COLOR_ATTACHMENT0_EXT; 702 if (idx >= CR_MAX_COLOR_ATTACHMENTS) 703 { 704 crWarning("idx is invalid %d, using 0", idx); 705 } 706 707 pAp = &pFBO->color[idx]; 708 709 if (!pAp->name) 710 { 711 crWarning("no collor draw attachment"); 712 return VERR_INVALID_STATE; 713 } 714 715 if (pAp->level) 716 { 717 crWarning("non-zero level not implemented"); 718 return VERR_NOT_IMPLEMENTED; 719 } 720 721 tobj = (CRTextureObj*)crHashtableSearch(ctx->shared->textureTable, pAp->name); 722 if (!tobj) 723 { 724 crWarning("no texture object found for name %d", pAp->name); 725 return VERR_INVALID_STATE; 726 } 727 728 if (tobj->target != GL_TEXTURE_2D && tobj->target != GL_TEXTURE_RECTANGLE_NV) 729 { 730 crWarning("non-texture[rect|2d] not implemented"); 731 return VERR_NOT_IMPLEMENTED; 732 } 733 734 CRASSERT(tobj->hwid); 735 736 tl = tobj->level[0]; 737 pTex->width = tl->width; 738 pTex->height = tl->height; 739 pTex->target = tobj->target; 740 pTex->hwid = tobj->hwid; 741 742 return VINF_SUCCESS; 743 } 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 int crServerVBoxBlitterBlitCurrentCtx(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, 754 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, 755 GLbitfield mask, GLenum filter) 756 { 757 PCR_BLITTER pBlitter; 758 CR_BLITTER_CONTEXT Ctx; 759 CRMuralInfo *mural; 760 CRContext *ctx = crStateGetCurrent(); 761 PVBOXVR_TEXTURE pDrawTex, pReadTex; 762 VBOXVR_TEXTURE DrawTex, ReadTex; 763 int rc; 764 GLuint idDrawFBO, idReadFBO; 765 CR_BLITTER_WINDOW BltInfo; 766 767 if (mask != GL_COLOR_BUFFER_BIT) 768 { 769 crWarning("not supported blit mask %d", mask); 770 return VERR_NOT_IMPLEMENTED; 771 } 772 773 if (!cr_server.curClient) 774 { 775 crWarning("no current client"); 776 return VERR_INVALID_STATE; 777 } 778 mural = cr_server.curClient->currentMural; 779 if (!mural) 780 { 781 crWarning("no current mural"); 782 return VERR_INVALID_STATE; 783 } 784 785 rc = crServerVBoxBlitterTexInit(ctx, mural, &DrawTex, GL_TRUE); 786 if (RT_SUCCESS(rc)) 787 { 788 pDrawTex = &DrawTex; 789 } 790 else 791 { 792 crWarning("crServerVBoxBlitterTexInit failed for draw"); 793 return rc; 794 } 795 796 rc = crServerVBoxBlitterTexInit(ctx, mural, &ReadTex, GL_FALSE); 797 if (RT_SUCCESS(rc)) 798 { 799 pReadTex = &ReadTex; 800 } 801 else 802 { 803 // crWarning("crServerVBoxBlitterTexInit failed for read"); 804 return rc; 805 } 806 807 pBlitter = crServerVBoxBlitterGet(); 808 if (!pBlitter) 809 { 810 crWarning("crServerVBoxBlitterGet failed"); 811 return VERR_GENERAL_FAILURE; 812 } 813 814 crServerVBoxBlitterWinInit(mural, &BltInfo); 815 816 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 823 idDrawFBO = mural->aidFBOs[mural->iCurDrawBuffer]; 824 idReadFBO = mural->aidFBOs[mural->iCurReadBuffer]; 825 826 crStateSwitchPrepare(NULL, ctx, idDrawFBO, idReadFBO); 827 828 rc = CrBltEnter(pBlitter, &Ctx, &BltInfo); 829 if (RT_SUCCESS(rc)) 830 { 831 RTRECT ReadRect, DrawRect; 832 ReadRect.xLeft = srcX0; 833 ReadRect.yTop = srcY0; 834 ReadRect.xRight = srcX1; 835 ReadRect.yBottom = srcY1; 836 DrawRect.xLeft = dstX0; 837 DrawRect.yTop = dstY0; 838 DrawRect.xRight = dstX1; 839 DrawRect.yBottom = dstY1; 840 CrBltBlitTexTex(pBlitter, pReadTex, &ReadRect, pDrawTex, &DrawRect, 1, CRBLT_FLAGS_FROM_FILTER(filter)); 841 CrBltLeave(pBlitter); 842 } 843 else 844 { 845 crWarning("CrBltEnter failed rc %d", rc); 846 } 847 848 crStateSwitchPostprocess(ctx, NULL, idDrawFBO, idReadFBO); 849 850 return rc; 851 } 852 627 853 void SERVER_DISPATCH_APIENTRY 628 854 crServerDispatchBlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, … … 631 857 { 632 858 CRContext *ctx = crStateGetCurrent(); 859 bool fTryBlitter = false; 633 860 #ifdef CR_CHECK_BLITS 634 861 // { … … 840 1067 #endif 841 1068 1069 if (srcY0 > srcY1) 1070 { 1071 if (dstY0 > dstY1) 1072 { 1073 /* use srcY1 < srcY2 && dstY1 < dstY2 whenever possible to avoid GPU driver bugs */ 1074 int32_t tmp = srcY0; 1075 srcY0 = srcY1; 1076 srcY1 = tmp; 1077 tmp = dstY0; 1078 dstY0 = dstY1; 1079 dstY1 = tmp; 1080 } 1081 else 1082 { 1083 fTryBlitter = true; 1084 } 1085 } 1086 1087 if (srcX0 > srcX1) 1088 { 1089 if (dstX0 > dstX1) 1090 { 1091 /* use srcX1 < srcX2 && dstX1 < dstX2 whenever possible to avoid GPU driver bugs */ 1092 int32_t tmp = srcX0; 1093 srcX0 = srcX1; 1094 srcX1 = tmp; 1095 tmp = dstX0; 1096 dstX0 = dstX1; 1097 dstX1 = tmp; 1098 } 1099 else 1100 { 1101 fTryBlitter = true; 1102 } 1103 } 1104 1105 /* @todo: enable for problematic platforms */ 1106 #if 0 1107 if (fTryBlitter) 1108 { 1109 int rc = crServerVBoxBlitterBlitCurrentCtx(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); 1110 if (RT_SUCCESS(rc)) 1111 goto my_exit; 1112 } 1113 #endif 1114 842 1115 if (ctx->viewport.scissorTest) 843 1116 cr_server.head_spu->dispatch_table.Disable(GL_SCISSOR_TEST); … … 849 1122 if (ctx->viewport.scissorTest) 850 1123 cr_server.head_spu->dispatch_table.Enable(GL_SCISSOR_TEST); 1124 1125 1126 my_exit: 1127 851 1128 //#ifdef CR_CHECK_BLITS 852 1129 // crDbgDumpTexImage2D("<== src tex:", GL_TEXTURE_2D, rtex, true); … … 861 1138 crFree(img); 862 1139 #endif 1140 return; 863 1141 } 864 1142 -
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_window.c
r45159 r45201 104 104 CR_STATE_SHAREDOBJ_USAGE_INIT(mural); 105 105 106 crServerSetupOutputRedirect(mural);107 108 106 Rect.xLeft = 0; 109 107 Rect.xRight = mural->width; … … 116 114 return -1; 117 115 } 116 117 crServerSetupOutputRedirect(mural); 118 118 119 119 if (mural->fRootVrOn) -
trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.c
r45148 r45201 683 683 DstRect.xRight = paDstRegions[i].xRight * scaleX; 684 684 DstRect.yBottom = paDstRegions[i].yBottom * scaleY; 685 CrBltBlitTexMural(pBlitter, &pEntry->Tex, &paSrcRegions[i], &DstRect, 1, CRBLT_F_LINEAR );685 CrBltBlitTexMural(pBlitter, &pEntry->Tex, &paSrcRegions[i], &DstRect, 1, CRBLT_F_LINEAR | CRBLT_F_INVERT_YCOORDS); 686 686 } 687 687 } … … 705 705 if (RT_SUCCESS(rc)) 706 706 { 707 CrBltBlitTexMural(pBlitter, &pEntry->Tex, paSrcRegions, paDstRegions, cRegions, CRBLT_F_LINEAR );707 CrBltBlitTexMural(pBlitter, &pEntry->Tex, paSrcRegions, paDstRegions, cRegions, CRBLT_F_LINEAR | CRBLT_F_INVERT_YCOORDS); 708 708 } 709 709 else … … 721 721 if (render_spu.blitterTable) 722 722 { 723 CR_BLITTER_WINDOW * pBltInfo = CrBltMuralGetCurrent(window->pBlitter);724 if (pBltInfo == &window->BltInfo)723 const CR_BLITTER_WINDOW * pBltInfo = CrBltMuralGetCurrentInfo(window->pBlitter); 724 if (pBltInfo->Base.id == window->BltInfo.Base.id) 725 725 { 726 726 CrBltMuralSetCurrent(window->pBlitter, NULL); … … 729 729 else 730 730 { 731 CRASSERT(CrBltMuralGetCurrent (window->pBlitter) == &window->BltInfo);731 CRASSERT(CrBltMuralGetCurrentInfo(window->pBlitter)->Base.id == window->BltInfo.Base.id); 732 732 CrBltMuralSetCurrent(window->pBlitter, NULL); 733 733 CrBltTerm(window->pBlitter);
Note:
See TracChangeset
for help on using the changeset viewer.