VirtualBox

Changeset 21253 in vbox


Ignore:
Timestamp:
Jul 6, 2009 2:29:39 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
49581
Message:

video hw accel: Blt fixes/enhances, Flip basis for Guest driver & QGLFramebuffer

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/VBoxVideo.h

    r21217 r21253  
    409409#define VBOXVHWA_SCAPS_VIDEOMEMORY      0x00000020
    410410#define VBOXVHWA_SCAPS_LOCALVIDMEM      0x00000040
     411#define VBOXVHWA_SCAPS_COMPLEX          0x00000080
    411412
    412413
     
    581582    } u;
    582583} VBOXVHWACMD_SURF_BLT;
     584
     585typedef 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;
    583602
    584603typedef struct _VBOXVHWACMD_SURF_OVERLAY_UPDATE
  • trunk/src/VBox/Additions/WINNT/Graphics/Display/dd.c

    r20985 r21253  
    4848static DECLCALLBACK(void) vboxVHWAFreeCmdCompletion(PPDEV ppdev, VBOXVHWACMD * pCmd, void * pContext);
    4949static DECLCALLBACK(void) vboxVHWASurfBltCompletion(PPDEV ppdev, VBOXVHWACMD * pCmd, void * pContext);
    50 
     50static DECLCALLBACK(void) vboxVHWASurfFlipCompletion(PPDEV ppdev, VBOXVHWACMD * pCmd, void * pContext);
    5151#endif
    5252
     
    10371037            if(ASMAtomicUoReadU32(&pDesc->cPendingBltsSrc)
    10381038                    || ASMAtomicUoReadU32(&pDesc->cPendingBltsDst)
    1039                     || ASMAtomicUoReadU32(&pDesc->cPendingFlips))
     1039                    || ASMAtomicUoReadU32(&pDesc->cPendingFlipsTarg)
     1040                    || ASMAtomicUoReadU32(&pDesc->cPendingFlipsCurr))
    10401041            {
    10411042                lpLock->ddRVal = DDERR_WASSTILLDRAWING;
     
    14711472DWORD APIENTRY DdFlip(PDD_FLIPDATA  lpFlip)
    14721473{
     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
    14731484    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    }
    14751540    return DDHAL_DRIVER_HANDLED;
     1541#else
     1542    DISPDBG((0, "%s\n", __FUNCTION__));
     1543    lpFlip->ddRVal = DDERR_GENERIC;
     1544    return DDHAL_DRIVER_NOTHANDLED;
     1545#endif
    14761546}
    14771547
    14781548DWORD APIENTRY DdGetBltStatus(PDD_GETBLTSTATUSDATA  lpGetBltStatus)
    14791549{
     1550    PPDEV pDev = (PPDEV)lpGetBltStatus->lpDD->dhpdev;
     1551
    14801552    DISPDBG((0, "%s\n", __FUNCTION__));
    14811553
     
    14841556        lpGetBltStatus->ddRVal = DD_OK;
    14851557    }
    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        }
    14891580    }
    14901581
     
    14941585DWORD APIENTRY DdGetFlipStatus(PDD_GETFLIPSTATUSDATA  lpGetFlipStatus)
    14951586{
     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
    14961592    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
    14981608    {
    14991609        lpGetFlipStatus->ddRVal = DD_OK;
    15001610    }
    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//    }
    15051620
    15061621    return DDHAL_DRIVER_HANDLED;
     
    18481963}
    18491964
     1965static 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
    18501977#endif
    18511978
  • trunk/src/VBox/Additions/WINNT/Graphics/Display/driver.h

    r20985 r21253  
    106106    volatile uint32_t cPendingBltsSrc;
    107107    volatile uint32_t cPendingBltsDst;
    108     volatile uint32_t cPendingFlips;
     108    volatile uint32_t cPendingFlipsCurr;
     109    volatile uint32_t cPendingFlipsTarg;
    109110    uint32_t cBitsPerPixel;
    110111}VBOXVHWASURFDESC, *PVBOXVHWASURFDESC;
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxFrameBuffer.h

    r20985 r21253  
    354354    }
    355355
     356    void add(const VBoxVHWADirtyRect & aRect)
     357    {
     358        if(aRect.isClear())
     359            return;
     360        add(aRect.rect());
     361    }
     362
    356363    void set(const QRect & aRect)
    357364    {
     
    464471};
    465472
     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 * */
    466488class VBoxVHWASurfaceBase
    467489{
    468490public:
    469     VBoxVHWASurfaceBase(GLsizei aWidth, GLsizei aHeight,
     491    VBoxVHWASurfaceBase(class VBoxVHWAGlContextState *aState, bool aIsYInverted, GLsizei aWidth, GLsizei aHeight,
    470492            VBoxVHWAColorFormat & aColorFormat,
    471493            VBoxVHWAColorKey * pSrcBltCKey, VBoxVHWAColorKey * pDstBltCKey,
     
    518540
    519541    /* clients should treat the returned texture as read-only */
    520     GLuint textureSynched(const QRect * aRect) { synchTexture(aRect); return mTexture; }
     542    GLuint textureSynched(const QRect * aRect) { synchTex(aRect); return mTexture; }
    521543
    522544    void setAddress(uchar * addr);
     
    529551//    virtual bool isMainFramebuffer() = 0;
    530552    virtual void makeCurrent() = 0;
     553    virtual void makeYInvertedCurrent() = 0;
     554
     555    bool isYInverted() {return mIsYInverted; }
     556
    531557#ifdef VBOX_WITH_VIDEOHWACCEL
    532558    virtual class VBoxVHWAGlProgramMngr * getGlProgramMngr() = 0;
     
    536562    void initDisplay();
    537563    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);
    540567    void synchMem(const QRect * aRect);
     568    void synchFB(const QRect * aRect);
     569
     570    void doTex2FB(const QRect * aRect);
     571
     572
    541573
    542574    QRect mRect;
     
    567599    int mLockCount;
    568600    /* 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;
    570604    /*in case of blit we blit from another surface's texture, so our current texture gets durty  */
    571605    VBoxVHWADirtyRect mUpdateFB2TexRect;
     
    574608
    575609    bool mFreeAddress;
     610
     611    bool mIsYInverted;
     612    typedef std::list <VBoxVHWASurfaceBase*> OverlayList;
     613    VBoxVHWASurfaceBase * mOverlayed;
     614    OverlayList mOverlays;
     615protected:
     616    virtual void init(uchar *pvMem, bool bInverted);
     617
     618    class VBoxVHWAGlContextState *mState;
     619
     620};
     621
     622class VBoxVHWAGlContextState
     623{
     624public:
     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
     679private:
     680
     681    class VBoxVHWASurfaceBase *mContext;
     682    bool mInverted;
    576683};
    577684
     
    579686{
    580687public:
    581     VBoxVHWASurfaceQGL(GLsizei aWidth, GLsizei aHeight,
     688    VBoxVHWASurfaceQGL(class VBoxVHWAGlContextState *aState, GLsizei aWidth, GLsizei aHeight,
    582689            VBoxVHWAColorFormat & aColorFormat,
    583690            VBoxVHWAColorKey * pSrcBltCKey, VBoxVHWAColorKey * pDstBltCKey,
    584691            VBoxVHWAColorKey * pSrcOverlayCKey, VBoxVHWAColorKey * pDstOverlayCKey,
    585692            class VBoxGLWidget *pWidget,
    586             bool bBackBuffer) :
    587                 VBoxVHWASurfaceBase(aWidth, aHeight,
     693            bool bInvisibleBuffer) :
     694                VBoxVHWASurfaceBase(aState, bInvisibleBuffer, aWidth, aHeight,
    588695                        aColorFormat,
    589696                        pSrcBltCKey, pDstBltCKey, pSrcOverlayCKey, pDstOverlayCKey),
    590697                mWidget(pWidget),
    591                 mCreateBuf(bBackBuffer)
     698                mBuffer(NULL)
    592699    {}
    593700
     701    ~VBoxVHWASurfaceQGL();
     702
    594703    void makeCurrent();
     704    void makeYInvertedCurrent();
    595705
    596706    void init(uchar *pvMem);
     707
     708    void uninit();
     709
     710    int flip(VBoxVHWASurfaceQGL * aCurrSurface);
    597711
    598712//    int unlock()
     
    609723    class VBoxGLWidget *mWidget;
    610724    class QGLPixelBuffer *mBuffer;
    611     bool mCreateBuf;
     725protected:
     726    virtual void init(uchar *pvMem, bool bInverted);
    612727};
    613728
     
    631746    void vboxPaintEvent (QPaintEvent *pe) {vboxPerformGLOp(&VBoxGLWidget::vboxDoPaint, pe);}
    632747    void vboxResizeEvent (VBoxResizeEvent *re) {vboxPerformGLOp(&VBoxGLWidget::vboxDoResize, re);}
     748#ifdef DEBUG_misha
     749    void vboxTestSurfaces () {vboxPerformGLOp(&VBoxGLWidget::vboxDoTestSurfaces, NULL);}
     750#endif
    633751#ifdef VBOX_WITH_VIDEOHWACCEL
    634752    void vboxVHWACmd (struct _VBOXVHWACMD * pCmd) {vboxPerformGLOp(&VBoxGLWidget::vboxDoVHWACmd, pCmd);}
     
    640758//    void resizeGL (int height, int width);
    641759
    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    }
    643771
    644772    void initializeGL();
     
    650778    void vboxDoResize(void *re);
    651779    void vboxDoPaint(void *rec);
     780#ifdef DEBUG_misha
     781    void vboxDoTestSurfaces(void *context);
     782#endif
    652783#ifdef VBOX_WITH_VIDEOHWACCEL
    653784    void vboxDoVHWACmd(void *cmd);
     
    669800    int vhwaSurfaceUnlock(struct _VBOXVHWACMD_SURF_UNLOCK *pCmd);
    670801    int vhwaSurfaceBlt(struct _VBOXVHWACMD_SURF_BLT *pCmd);
     802    int vhwaSurfaceFlip(struct _VBOXVHWACMD_SURF_FLIP *pCmd);
    671803    int vhwaQueryInfo1(struct _VBOXVHWACMD_QUERYINFO1 *pCmd);
    672804    int vhwaQueryInfo2(struct _VBOXVHWACMD_QUERYINFO2 *pCmd);
     
    674806
    675807    VBoxVHWASurfaceQGL * pDisplay;
     808
    676809    /* we need to do all opengl stuff in the paintGL context,
    677810     * submit the operation to be performed */
     
    684817    ulong  mPixelFormat;
    685818    bool   mUsesGuestVRAM;
     819
     820    VBoxVHWAGlContextState mState;
    686821
    687822#ifdef VBOX_WITH_VIDEOHWACCEL
     
    718853
    719854private:
    720     void vboxMakeCurrent();
     855//    void vboxMakeCurrent();
    721856    VBoxGLWidget * vboxWidget();
    722857};
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette