Changeset 21253 in vbox
- Timestamp:
- Jul 6, 2009 2:29:39 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 49581
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/VBoxVideo.h
r21217 r21253 409 409 #define VBOXVHWA_SCAPS_VIDEOMEMORY 0x00000020 410 410 #define VBOXVHWA_SCAPS_LOCALVIDMEM 0x00000040 411 #define VBOXVHWA_SCAPS_COMPLEX 0x00000080 411 412 412 413 … … 581 582 } u; 582 583 } VBOXVHWACMD_SURF_BLT; 584 585 typedef struct _VBOXVHWACMD_SURF_FLIP 586 { 587 uint64_t TargGuestSurfInfo; 588 uint64_t CurrGuestSurfInfo; 589 union 590 { 591 struct 592 { 593 VBOXVHWA_SURFHANDLE hTargSurf; 594 uint64_t offTargSurface; 595 VBOXVHWA_SURFHANDLE hCurrSurf; 596 uint64_t offCurrSurface; 597 uint32_t flags; 598 uint32_t reserved; 599 } in; 600 } u; 601 } VBOXVHWACMD_SURF_FLIP; 583 602 584 603 typedef struct _VBOXVHWACMD_SURF_OVERLAY_UPDATE -
trunk/src/VBox/Additions/WINNT/Graphics/Display/dd.c
r20985 r21253 48 48 static DECLCALLBACK(void) vboxVHWAFreeCmdCompletion(PPDEV ppdev, VBOXVHWACMD * pCmd, void * pContext); 49 49 static DECLCALLBACK(void) vboxVHWASurfBltCompletion(PPDEV ppdev, VBOXVHWACMD * pCmd, void * pContext); 50 50 static DECLCALLBACK(void) vboxVHWASurfFlipCompletion(PPDEV ppdev, VBOXVHWACMD * pCmd, void * pContext); 51 51 #endif 52 52 … … 1037 1037 if(ASMAtomicUoReadU32(&pDesc->cPendingBltsSrc) 1038 1038 || ASMAtomicUoReadU32(&pDesc->cPendingBltsDst) 1039 || ASMAtomicUoReadU32(&pDesc->cPendingFlips)) 1039 || ASMAtomicUoReadU32(&pDesc->cPendingFlipsTarg) 1040 || ASMAtomicUoReadU32(&pDesc->cPendingFlipsCurr)) 1040 1041 { 1041 1042 lpLock->ddRVal = DDERR_WASSTILLDRAWING; … … 1471 1472 DWORD APIENTRY DdFlip(PDD_FLIPDATA lpFlip) 1472 1473 { 1474 #ifdef VBOX_WITH_VIDEOHWACCEL 1475 PPDEV pDev = (PPDEV)lpFlip->lpDD->dhpdev; 1476 DD_SURFACE_LOCAL* lpTargSurfaceLocal = lpFlip->lpSurfTarg; 1477 DD_SURFACE_GLOBAL* lpTargSurfaceGlobal = lpTargSurfaceLocal->lpGbl; 1478 DD_SURFACE_LOCAL* lpCurrSurfaceLocal = lpFlip->lpSurfCurr; 1479 DD_SURFACE_GLOBAL* lpCurrSurfaceGlobal = lpCurrSurfaceLocal->lpGbl; 1480 PVBOXVHWASURFDESC pCurrDesc = (PVBOXVHWASURFDESC)lpCurrSurfaceGlobal->dwReserved1; 1481 PVBOXVHWASURFDESC pTargDesc = (PVBOXVHWASURFDESC)lpTargSurfaceGlobal->dwReserved1; 1482 VBOXVHWACMD* pCmd; 1483 1473 1484 DISPDBG((0, "%s\n", __FUNCTION__)); 1474 lpFlip->ddRVal = DD_OK; 1485 1486 /* ensure we have host cmds processed to update pending blits and flips */ 1487 vboxVHWACommandCheckHostCmds(pDev); 1488 1489 // if(VBOXDD_CHECKFLAG(lpLock, DDLOCK_DONOTWAIT)) 1490 { 1491 if( 1492 // ASMAtomicUoReadU32(&pDesc->cPendingBltsSrc) 1493 // || ASMAtomicUoReadU32(&pDesc->cPendingBltsDst) 1494 // || 1495 ASMAtomicUoReadU32(&pCurrDesc->cPendingFlipsTarg) 1496 || ASMAtomicUoReadU32(&pCurrDesc->cPendingFlipsCurr) 1497 || ASMAtomicUoReadU32(&pTargDesc->cPendingFlipsTarg) 1498 || ASMAtomicUoReadU32(&pTargDesc->cPendingFlipsCurr)) 1499 { 1500 lpFlip->ddRVal = DDERR_WASSTILLDRAWING; 1501 return DDHAL_DRIVER_HANDLED; 1502 } 1503 } 1504 1505 pCmd = vboxVHWACommandCreate (pDev, VBOXVHWACMD_TYPE_SURF_FLIP, sizeof(VBOXVHWACMD_SURF_FLIP)); 1506 // int rc = VERR_GENERAL_FAILURE; 1507 if(pCmd) 1508 { 1509 VBOXVHWACMD_SURF_FLIP * pBody = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_SURF_FLIP); 1510 1511 memset(pBody, 0, sizeof(VBOXVHWACMD_SURF_FLIP)); 1512 1513 pBody->u.in.offCurrSurface = (uint64_t)lpCurrSurfaceGlobal->fpVidMem; 1514 pBody->u.in.offTargSurface = (uint64_t)lpTargSurfaceGlobal->fpVidMem; 1515 1516 pBody->u.in.hTargSurf = pTargDesc->hHostHandle; 1517 pBody->u.in.hCurrSurf = pCurrDesc->hHostHandle; 1518 pBody->TargGuestSurfInfo = (uint64_t)pTargDesc; 1519 pBody->CurrGuestSurfInfo = (uint64_t)pCurrDesc; 1520 1521 // pBody->u.in.flags = vboxVHWAFromDDFLIPs(lpFlip->dwFlags); 1522 1523 ASMAtomicIncU32(&pCurrDesc->cPendingFlipsCurr); 1524 ASMAtomicIncU32(&pTargDesc->cPendingFlipsTarg); 1525 1526 // if(VBOXDD_CHECKFLAG(lpBlt->dwFlags, DDBLT_ASYNC)) 1527 // { 1528 vboxVHWACommandSubmitAsynch(pDev, pCmd, vboxVHWASurfFlipCompletion, NULL); 1529 // } 1530 // else 1531 // { 1532 // vboxVHWACommandSubmit(pDev, pCmd); 1533 // } 1534 lpFlip->ddRVal = DD_OK; 1535 } 1536 else 1537 { 1538 lpFlip->ddRVal = DDERR_GENERIC; 1539 } 1475 1540 return DDHAL_DRIVER_HANDLED; 1541 #else 1542 DISPDBG((0, "%s\n", __FUNCTION__)); 1543 lpFlip->ddRVal = DDERR_GENERIC; 1544 return DDHAL_DRIVER_NOTHANDLED; 1545 #endif 1476 1546 } 1477 1547 1478 1548 DWORD APIENTRY DdGetBltStatus(PDD_GETBLTSTATUSDATA lpGetBltStatus) 1479 1549 { 1550 PPDEV pDev = (PPDEV)lpGetBltStatus->lpDD->dhpdev; 1551 1480 1552 DISPDBG((0, "%s\n", __FUNCTION__)); 1481 1553 … … 1484 1556 lpGetBltStatus->ddRVal = DD_OK; 1485 1557 } 1486 else 1487 { 1488 lpGetBltStatus->ddRVal = DD_OK; 1558 else /* DDGBS_ISBLTDONE */ 1559 { 1560 DD_SURFACE_LOCAL* lpSurfaceLocal = lpGetBltStatus->lpDDSurface; 1561 DD_SURFACE_GLOBAL* lpSurfaceGlobal = lpSurfaceLocal->lpGbl; 1562 PVBOXVHWASURFDESC pDesc = (PVBOXVHWASURFDESC)lpSurfaceGlobal->dwReserved1; 1563 1564 /* ensure we have host cmds processed to update pending blits and flips */ 1565 vboxVHWACommandCheckHostCmds(pDev); 1566 1567 if( 1568 ASMAtomicUoReadU32(&pDesc->cPendingBltsSrc) 1569 || ASMAtomicUoReadU32(&pDesc->cPendingBltsDst) 1570 // || ASMAtomicUoReadU32(&pDesc->cPendingFlipsTarg) 1571 // || ASMAtomicUoReadU32(&pDesc->cPendingFlipsCurr) 1572 ) 1573 { 1574 lpGetBltStatus->ddRVal = DDERR_WASSTILLDRAWING; 1575 } 1576 else 1577 { 1578 lpGetBltStatus->ddRVal = DD_OK; 1579 } 1489 1580 } 1490 1581 … … 1494 1585 DWORD APIENTRY DdGetFlipStatus(PDD_GETFLIPSTATUSDATA lpGetFlipStatus) 1495 1586 { 1587 PPDEV pDev = (PPDEV)lpGetFlipStatus->lpDD->dhpdev; 1588 DD_SURFACE_LOCAL* lpSurfaceLocal = lpGetFlipStatus->lpDDSurface; 1589 DD_SURFACE_GLOBAL* lpSurfaceGlobal = lpSurfaceLocal->lpGbl; 1590 PVBOXVHWASURFDESC pDesc = (PVBOXVHWASURFDESC)lpSurfaceGlobal->dwReserved1; 1591 1496 1592 DISPDBG((0, "%s\n", __FUNCTION__)); 1497 if(lpGetFlipStatus->dwFlags == DDGFS_CANFLIP) 1593 1594 /* ensure we have host cmds processed to update pending blits and flips */ 1595 vboxVHWACommandCheckHostCmds(pDev); 1596 1597 if( 1598 // ASMAtomicUoReadU32(&pDesc->cPendingBltsSrc) 1599 // || ASMAtomicUoReadU32(&pDesc->cPendingBltsDst) 1600 // || 1601 ASMAtomicUoReadU32(&pDesc->cPendingFlipsTarg) 1602 || ASMAtomicUoReadU32(&pDesc->cPendingFlipsCurr) 1603 ) 1604 { 1605 lpGetFlipStatus->ddRVal = DDERR_WASSTILLDRAWING; 1606 } 1607 else 1498 1608 { 1499 1609 lpGetFlipStatus->ddRVal = DD_OK; 1500 1610 } 1501 else 1502 { 1503 lpGetFlipStatus->ddRVal = DD_OK; 1504 } 1611 1612 // if(lpGetFlipStatus->dwFlags == DDGFS_CANFLIP) 1613 // { 1614 // lpGetFlipStatus->ddRVal = DD_OK; 1615 // } 1616 // else 1617 // { 1618 // lpGetFlipStatus->ddRVal = DD_OK; 1619 // } 1505 1620 1506 1621 return DDHAL_DRIVER_HANDLED; … … 1848 1963 } 1849 1964 1965 static DECLCALLBACK(void) vboxVHWASurfFlipCompletion(PPDEV ppdev, VBOXVHWACMD * pCmd, void * pContext) 1966 { 1967 VBOXVHWACMD_SURF_FLIP * pBody = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_SURF_FLIP); 1968 PVBOXVHWASURFDESC pCurrDesc = (PVBOXVHWASURFDESC)pBody->CurrGuestSurfInfo; 1969 PVBOXVHWASURFDESC pTargDesc = (PVBOXVHWASURFDESC)pBody->TargGuestSurfInfo; 1970 1971 ASMAtomicDecU32(&pCurrDesc->cPendingFlipsCurr); 1972 ASMAtomicDecU32(&pTargDesc->cPendingFlipsTarg); 1973 1974 vboxVHWACommandFree(ppdev, pCmd); 1975 } 1976 1850 1977 #endif 1851 1978 -
trunk/src/VBox/Additions/WINNT/Graphics/Display/driver.h
r20985 r21253 106 106 volatile uint32_t cPendingBltsSrc; 107 107 volatile uint32_t cPendingBltsDst; 108 volatile uint32_t cPendingFlips; 108 volatile uint32_t cPendingFlipsCurr; 109 volatile uint32_t cPendingFlipsTarg; 109 110 uint32_t cBitsPerPixel; 110 111 }VBOXVHWASURFDESC, *PVBOXVHWASURFDESC; -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxFrameBuffer.h
r20985 r21253 354 354 } 355 355 356 void add(const VBoxVHWADirtyRect & aRect) 357 { 358 if(aRect.isClear()) 359 return; 360 add(aRect.rect()); 361 } 362 356 363 void set(const QRect & aRect) 357 364 { … … 464 471 }; 465 472 473 /* data flow: 474 * I. NON-Yinverted surface: 475 * 1.direct memory update (paint, lock/unlock): 476 * mem->tex->fb 477 * 2.blt 478 * srcTex->invFB->tex->fb 479 * |->mem 480 * 481 * II. Yinverted surface: 482 * 1.direct memory update (paint, lock/unlock): 483 * mem->tex->fb 484 * 2.blt 485 * srcTex->fb->tex 486 * |->mem 487 * */ 466 488 class VBoxVHWASurfaceBase 467 489 { 468 490 public: 469 VBoxVHWASurfaceBase( GLsizei aWidth, GLsizei aHeight,491 VBoxVHWASurfaceBase(class VBoxVHWAGlContextState *aState, bool aIsYInverted, GLsizei aWidth, GLsizei aHeight, 470 492 VBoxVHWAColorFormat & aColorFormat, 471 493 VBoxVHWAColorKey * pSrcBltCKey, VBoxVHWAColorKey * pDstBltCKey, … … 518 540 519 541 /* clients should treat the returned texture as read-only */ 520 GLuint textureSynched(const QRect * aRect) { synchTex ture(aRect); return mTexture; }542 GLuint textureSynched(const QRect * aRect) { synchTex(aRect); return mTexture; } 521 543 522 544 void setAddress(uchar * addr); … … 529 551 // virtual bool isMainFramebuffer() = 0; 530 552 virtual void makeCurrent() = 0; 553 virtual void makeYInvertedCurrent() = 0; 554 555 bool isYInverted() {return mIsYInverted; } 556 531 557 #ifdef VBOX_WITH_VIDEOHWACCEL 532 558 virtual class VBoxVHWAGlProgramMngr * getGlProgramMngr() = 0; … … 536 562 void initDisplay(); 537 563 void deleteDisplay(); 538 void updateTexture(const QRect * aRect); 539 void synchTexture(const QRect * aRect); 564 void synchTex(const QRect * aRect); 565 void synchTexMem(const QRect * aRect); 566 void synchTexFB(const QRect * aRect); 540 567 void synchMem(const QRect * aRect); 568 void synchFB(const QRect * aRect); 569 570 void doTex2FB(const QRect * aRect); 571 572 541 573 542 574 QRect mRect; … … 567 599 int mLockCount; 568 600 /* memory buffer not reflected in fm and texture, e.g if memory buffer is replaced or in case of lock/unlock */ 569 VBoxVHWADirtyRect mUpdateMemRect; 601 VBoxVHWADirtyRect mUpdateMem2TexRect; 602 /* memory buffer not reflected in fm and texture, e.g if memory buffer is replaced or in case of lock/unlock */ 603 VBoxVHWADirtyRect mUpdateTex2FBRect; 570 604 /*in case of blit we blit from another surface's texture, so our current texture gets durty */ 571 605 VBoxVHWADirtyRect mUpdateFB2TexRect; … … 574 608 575 609 bool mFreeAddress; 610 611 bool mIsYInverted; 612 typedef std::list <VBoxVHWASurfaceBase*> OverlayList; 613 VBoxVHWASurfaceBase * mOverlayed; 614 OverlayList mOverlays; 615 protected: 616 virtual void init(uchar *pvMem, bool bInverted); 617 618 class VBoxVHWAGlContextState *mState; 619 620 }; 621 622 class VBoxVHWAGlContextState 623 { 624 public: 625 VBoxVHWAGlContextState() : mContext(NULL), mInverted(false) {} 626 627 void assertCurrent(class VBoxVHWASurfaceBase *aContext, bool bInverted) 628 { 629 mContext = aContext; 630 if(aContext && aContext->isYInverted()) 631 { 632 mInverted = true; 633 } 634 else 635 { 636 mInverted = bInverted; 637 } 638 } 639 640 void makeYInvertedCurrent(class VBoxVHWASurfaceBase *aContext) 641 { 642 if(mContext != aContext) 643 { 644 // aContext->makeCurrent(); 645 aContext->makeYInvertedCurrent(); 646 assertCurrent(aContext, true); 647 } 648 else 649 { 650 if(!aContext->isYInverted() && !mInverted) 651 { 652 // aContext->makeCurrent(); 653 aContext->makeYInvertedCurrent(); 654 mInverted = true; 655 } 656 } 657 } 658 659 void makeCurrent(class VBoxVHWASurfaceBase *aContext) 660 { 661 if(mContext != aContext) 662 { 663 aContext->makeCurrent(); 664 assertCurrent(aContext, false); 665 } 666 else 667 { 668 if(!aContext->isYInverted() && mInverted) 669 { 670 aContext->makeCurrent(); 671 mInverted = false; 672 } 673 } 674 } 675 676 class VBoxVHWASurfaceBase * getCurrent() {return mContext; } 677 bool isCurrentYInverted() {return mInverted; } 678 679 private: 680 681 class VBoxVHWASurfaceBase *mContext; 682 bool mInverted; 576 683 }; 577 684 … … 579 686 { 580 687 public: 581 VBoxVHWASurfaceQGL( GLsizei aWidth, GLsizei aHeight,688 VBoxVHWASurfaceQGL(class VBoxVHWAGlContextState *aState, GLsizei aWidth, GLsizei aHeight, 582 689 VBoxVHWAColorFormat & aColorFormat, 583 690 VBoxVHWAColorKey * pSrcBltCKey, VBoxVHWAColorKey * pDstBltCKey, 584 691 VBoxVHWAColorKey * pSrcOverlayCKey, VBoxVHWAColorKey * pDstOverlayCKey, 585 692 class VBoxGLWidget *pWidget, 586 bool b BackBuffer) :587 VBoxVHWASurfaceBase(a Width, aHeight,693 bool bInvisibleBuffer) : 694 VBoxVHWASurfaceBase(aState, bInvisibleBuffer, aWidth, aHeight, 588 695 aColorFormat, 589 696 pSrcBltCKey, pDstBltCKey, pSrcOverlayCKey, pDstOverlayCKey), 590 697 mWidget(pWidget), 591 m CreateBuf(bBackBuffer)698 mBuffer(NULL) 592 699 {} 593 700 701 ~VBoxVHWASurfaceQGL(); 702 594 703 void makeCurrent(); 704 void makeYInvertedCurrent(); 595 705 596 706 void init(uchar *pvMem); 707 708 void uninit(); 709 710 int flip(VBoxVHWASurfaceQGL * aCurrSurface); 597 711 598 712 // int unlock() … … 609 723 class VBoxGLWidget *mWidget; 610 724 class QGLPixelBuffer *mBuffer; 611 bool mCreateBuf; 725 protected: 726 virtual void init(uchar *pvMem, bool bInverted); 612 727 }; 613 728 … … 631 746 void vboxPaintEvent (QPaintEvent *pe) {vboxPerformGLOp(&VBoxGLWidget::vboxDoPaint, pe);} 632 747 void vboxResizeEvent (VBoxResizeEvent *re) {vboxPerformGLOp(&VBoxGLWidget::vboxDoResize, re);} 748 #ifdef DEBUG_misha 749 void vboxTestSurfaces () {vboxPerformGLOp(&VBoxGLWidget::vboxDoTestSurfaces, NULL);} 750 #endif 633 751 #ifdef VBOX_WITH_VIDEOHWACCEL 634 752 void vboxVHWACmd (struct _VBOXVHWACMD * pCmd) {vboxPerformGLOp(&VBoxGLWidget::vboxDoVHWACmd, pCmd);} … … 640 758 // void resizeGL (int height, int width); 641 759 642 void paintGL() { (this->*mpfnOp)(mOpContext); } 760 void paintGL() 761 { 762 Assert(mState.getCurrent() == NULL); 763 /* we are called with QGLWidget context */ 764 mState.assertCurrent(pDisplay, false); 765 (this->*mpfnOp)(mOpContext); 766 /* restore the context */ 767 mState.makeCurrent(pDisplay); 768 /* clear*/ 769 mState.assertCurrent(NULL, false); 770 } 643 771 644 772 void initializeGL(); … … 650 778 void vboxDoResize(void *re); 651 779 void vboxDoPaint(void *rec); 780 #ifdef DEBUG_misha 781 void vboxDoTestSurfaces(void *context); 782 #endif 652 783 #ifdef VBOX_WITH_VIDEOHWACCEL 653 784 void vboxDoVHWACmd(void *cmd); … … 669 800 int vhwaSurfaceUnlock(struct _VBOXVHWACMD_SURF_UNLOCK *pCmd); 670 801 int vhwaSurfaceBlt(struct _VBOXVHWACMD_SURF_BLT *pCmd); 802 int vhwaSurfaceFlip(struct _VBOXVHWACMD_SURF_FLIP *pCmd); 671 803 int vhwaQueryInfo1(struct _VBOXVHWACMD_QUERYINFO1 *pCmd); 672 804 int vhwaQueryInfo2(struct _VBOXVHWACMD_QUERYINFO2 *pCmd); … … 674 806 675 807 VBoxVHWASurfaceQGL * pDisplay; 808 676 809 /* we need to do all opengl stuff in the paintGL context, 677 810 * submit the operation to be performed */ … … 684 817 ulong mPixelFormat; 685 818 bool mUsesGuestVRAM; 819 820 VBoxVHWAGlContextState mState; 686 821 687 822 #ifdef VBOX_WITH_VIDEOHWACCEL … … 718 853 719 854 private: 720 void vboxMakeCurrent();855 // void vboxMakeCurrent(); 721 856 VBoxGLWidget * vboxWidget(); 722 857 };
Note:
See TracChangeset
for help on using the changeset viewer.