VirtualBox

Changeset 22800 in vbox


Ignore:
Timestamp:
Sep 7, 2009 10:38:06 AM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
52006
Message:

video 2d accel: using ogl only when needed: saved state fixes

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxFrameBuffer.h

    r22798 r22800  
    911911typedef std::list <VBoxVHWASurfaceBase*> SurfList;
    912912typedef std::list <VBoxVHWASurfList*> OverlayList;
     913typedef std::list <struct _VBOXVHWACMD *> VHWACommandList;
    913914
    914915class VBoxVHWASurfList
     
    10651066typedef void (VBoxGLWidget::*PFNVBOXQGLOP)(void* );
    10661067
     1068typedef void (*PFNVBOXQGLFUNC)(void*, void*);
     1069
    10671070typedef enum
    10681071{
     
    10701073    VBOXVHWA_PIPECMD_VHWA,
    10711074    VBOXVHWA_PIPECMD_OP,
     1075    VBOXVHWA_PIPECMD_FUNC,
    10721076}VBOXVHWA_PIPECMD_TYPE;
    10731077
     
    10791083}VBOXVHWACALLBACKINFO;
    10801084
     1085typedef struct VBOXVHWAFUNCCALLBACKINFO
     1086{
     1087    PFNVBOXQGLFUNC pfnCallback;
     1088    void * pContext1;
     1089    void * pContext2;
     1090}VBOXVHWAFUNCCALLBACKINFO;
     1091
    10811092class VBoxVHWACommandElement
    10821093{
     
    10981109        mType = VBOXVHWA_PIPECMD_OP;
    10991110        u.mCallback = aOp;
     1111    }
     1112
     1113    void setFunc(const VBOXVHWAFUNCCALLBACKINFO & aOp)
     1114    {
     1115        mType = VBOXVHWA_PIPECMD_FUNC;
     1116        u.mFuncCallback = aOp;
    11001117    }
    11011118
     
    11131130            setOp(*((VBOXVHWACALLBACKINFO *)pvData));
    11141131            break;
     1132        case VBOXVHWA_PIPECMD_FUNC:
     1133            setFunc(*((VBOXVHWAFUNCCALLBACKINFO *)pvData));
     1134            break;
    11151135        default:
    11161136            Assert(0);
     
    11231143    struct _VBOXVHWACMD * vhwaCmd() const {return u.mpCmd;}
    11241144    const VBOXVHWACALLBACKINFO & op() const {return u.mCallback; }
     1145    const VBOXVHWAFUNCCALLBACKINFO & func() const {return u.mFuncCallback; }
    11251146
    11261147    VBoxVHWACommandElement * mpNext;
     
    11311152        struct _VBOXVHWACMD * mpCmd;
    11321153        VBOXVHWACALLBACKINFO mCallback;
     1154        VBOXVHWAFUNCCALLBACKINFO mFuncCallback;
    11331155    }u;
    11341156    QRect                 mRect;
     
    12271249};
    12281250
     1251class VBoxVHWACommandsQueue
     1252{
     1253public:
     1254    void enqueue(PFNVBOXQGLFUNC pfn, void* pContext1, void* pContext2);
     1255
     1256    VBoxVHWACommandElement * detachList();
     1257
     1258    void freeList(VBoxVHWACommandElement * pList);
     1259
     1260private:
     1261    VBoxVHWACommandElementPipe mCmds;
     1262};
    12291263
    12301264class VBoxGLWidget : public QGLWidget
     
    12451279
    12461280    void vhwaSaveExec(struct SSMHANDLE * pSSM);
    1247     int vhwaLoadExec(struct SSMHANDLE * pSSM, uint32_t u32Version);
     1281    int vhwaLoadExec(VHWACommandList * pCmdList, struct SSMHANDLE * pSSM, uint32_t u32Version);
    12481282
    12491283    int vhwaSurfaceCanCreate(struct _VBOXVHWACMD_SURF_CANCREATE *pCmd);
     
    12681302    ulong vboxBitsPerPixel() { return mDisplay.getVGA()->bitsPerPixel(); }
    12691303    ulong vboxBytesPerLine() { return mDisplay.getVGA() ? mDisplay.getVGA()->bytesPerLine() : 0; }
     1304    int vboxFbWidth() {return mDisplay.getVGA()->width(); }
     1305    int vboxFbHeight() {return mDisplay.getVGA()->height(); }
     1306    bool vboxIsInitialized() {return mDisplay.getVGA() != NULL; }
    12701307
    12711308//    void vboxPaintEvent (QPaintEvent *pe) {vboxPerformGLOp(&VBoxGLWidget::vboxDoPaint, pe); }
     
    13331370
    13341371    int vhwaSaveSurface(struct SSMHANDLE * pSSM, VBoxVHWASurfaceBase *pSurf, uint32_t surfCaps);
    1335     int vhwaLoadSurface(struct SSMHANDLE * pSSM, uint32_t u32Version);
     1372    int vhwaLoadSurface(VHWACommandList * pCmdList, struct SSMHANDLE * pSSM, uint32_t u32Version);
    13361373    int vhwaSaveOverlayData(struct SSMHANDLE * pSSM, VBoxVHWASurfaceBase *pSurf, bool bVisible);
    1337     int vhwaLoadOverlayData(struct SSMHANDLE * pSSM, uint32_t u32Version);
     1374    int vhwaLoadOverlayData(VHWACommandList * pCmdList, struct SSMHANDLE * pSSM, uint32_t u32Version);
    13381375    void vhwaDoSurfaceOverlayUpdate(VBoxVHWASurfaceBase *pDstSurf, VBoxVHWASurfaceBase *pSrcSurf, struct _VBOXVHWACMD_SURF_OVERLAY_UPDATE *pCmd);
    13391376#endif
     
    13551392//    /* posts op to UI thread */
    13561393//    int vboxExecOpSynch(PFNVBOXQGLOP pfn, void* pContext);
    1357     void vboxExecOnResize(PFNVBOXQGLOP pfn, void* pContext);
     1394//    void vboxExecOnResize(PFNVBOXQGLOP pfn, void* pContext);
    13581395
    13591396    void vboxDoProcessVHWACommands(void *pContext);
     
    13851422    /* this is used in saved state restore to postpone surface restoration
    13861423     * till the framebuffer size is restored */
    1387     VBoxVHWACommandElementPipe mResizePostProcessCmds;
     1424    VHWACommandList mOnResizeCmdList;
    13881425
    13891426    class VBoxVHWAGlProgramMngr *mpMngr;
     
    14491486
    14501487    void vboxUpdateRect(const QRect * pRect);
     1488
     1489    int vhwaLoadExec(struct SSMHANDLE * pSSM, uint32_t u32Version);
     1490    void vhwaSaveExec(struct SSMHANDLE * pSSM);
    14511491private:
    14521492    void makeCurrent()
     
    14911531    void vboxCheckUpdateOverlay(const QRect & rect);
    14921532    VBoxVHWACommandElement * processCmdList(VBoxVHWACommandElement * pCmd);
     1533
     1534    int vhwaConstruct(struct _VBOXVHWACMD_HH_CONSTRUCT *pCmd);
     1535
    14931536    VBoxGLWidget *mpOverlayWidget;
    14941537    bool mGlOn;
     
    15011544
    15021545    VBoxVHWACommandElementProcessor mCmdPipe;
     1546
     1547    /* this is used in saved state restore to postpone surface restoration
     1548     * till the framebuffer size is restored */
     1549    VHWACommandList mOnResizeCmdList;
    15031550};
    15041551#endif
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBQGL.cpp

    r22798 r22800  
    5858#define VBOXQGL_STATE_NAMEBASE "QGLVHWAData"
    5959#define VBOXQGL_STATE_VERSION 1
     60
     61//#define VBOXQGLOVERLAY_STATE_NAMEBASE "QGLOverlayVHWAData"
     62//#define VBOXQGLOVERLAY_STATE_VERSION 1
     63
    6064#ifdef DEBUG_misha
    6165# define VBOXQGL_STATE_DEBUG
     
    31283132            break;
    31293133        }
     3134        case VBOXVHWA_PIPECMD_FUNC:
     3135        {
     3136            const VBOXVHWAFUNCCALLBACKINFO & info = pCmd->func();
     3137            info.pfnCallback(info.pContext1, info.pContext2);
     3138            break;
     3139        }
    31303140#endif
    31313141        default:
     
    40754085    Assert(uPass == SSM_PASS_FINAL); NOREF(uPass);
    40764086    VBoxGLWidget * pw = (VBoxGLWidget*)pvUser;
    4077     return pw->vhwaLoadExec(pSSM, u32Version);
     4087    return pw->vhwaLoadExec(NULL, pSSM, u32Version);
    40784088}
    40794089
     
    41574167}
    41584168
    4159 int VBoxGLWidget::vhwaLoadSurface(struct SSMHANDLE * pSSM, uint32_t u32Version)
     4169int VBoxGLWidget::vhwaLoadSurface(VHWACommandList * pCmdList, struct SSMHANDLE * pSSM, uint32_t u32Version)
    41604170{
    41614171    Q_UNUSED(u32Version);
     
    42204230        }
    42214231
    4222         vboxExecOnResize(&VBoxGLWidget::vboxDoVHWACmdAndFree, pCmd); AssertRC(rc);
     4232        pCmdList->push_back(pCmd);
     4233//        vboxExecOnResize(&VBoxGLWidget::vboxDoVHWACmdAndFree, pCmd); AssertRC(rc);
    42234234//        if(RT_SUCCESS(rc))
    42244235//        {
     
    43084319}
    43094320
    4310 int VBoxGLWidget::vhwaLoadOverlayData(struct SSMHANDLE * pSSM, uint32_t u32Version)
     4321int VBoxGLWidget::vhwaLoadOverlayData(VHWACommandList * pCmdList, struct SSMHANDLE * pSSM, uint32_t u32Version)
    43114322{
    43124323    Q_UNUSED(u32Version);
     
    43644375        rc = SSMR3GetS32(pSSM, &pUpdateOverlay->u.in.srcRect.bottom); AssertRC(rc);
    43654376
    4366         vboxExecOnResize(&VBoxGLWidget::vboxDoVHWACmdAndFree, pCmd); AssertRC(rc);
     4377        pCmdList->push_back(pCmd);
     4378//        vboxExecOnResize(&VBoxGLWidget::vboxDoVHWACmdAndFree, pCmd); AssertRC(rc);
    43674379//        if(RT_SUCCESS(rc))
    43684380//        {
     
    44024414     *
    44034415     */
    4404     const SurfList & primaryList = mDisplay.getVGA()->getComplexList()->surfaces();
     4416    const SurfList & primaryList = mDisplay.primaries().surfaces();
    44054417    uint32_t cPrimary = (uint32_t)primaryList.size();
    44064418    Assert(cPrimary >= 1);
    4407     if(mDisplay.getVGA()->handle() == VBOXVHWA_SURFHANDLE_INVALID)
     4419    if(mDisplay.getVGA() == NULL || mDisplay.getVGA()->handle() == VBOXVHWA_SURFHANDLE_INVALID)
    44084420    {
    44094421        cPrimary -= 1;
     
    44724484}
    44734485
    4474 int VBoxGLWidget::vhwaLoadExec(struct SSMHANDLE * pSSM, uint32_t u32Version)
     4486int VBoxGLWidget::vhwaLoadExec(VHWACommandList * pCmdList, struct SSMHANDLE * pSSM, uint32_t u32Version)
    44754487{
    44764488    VBOXQGL_LOAD_START(pSSM);
     
    44794491    uint32_t u32;
    44804492
     4493    if(pCmdList == NULL)
     4494    {
     4495        /* use our own list */
     4496        pCmdList = &mOnResizeCmdList;
     4497    }
     4498
    44814499    rc = SSMR3GetU32(pSSM, &u32); AssertRC(rc);
    44824500    if(RT_SUCCESS(rc))
     
    44844502        for(uint32_t i = 0; i < u32; ++i)
    44854503        {
    4486             rc = vhwaLoadSurface(pSSM, u32Version);  AssertRC(rc);
     4504            rc = vhwaLoadSurface(pCmdList, pSSM, u32Version);  AssertRC(rc);
    44874505            if(RT_FAILURE(rc))
    44884506                break;
     
    45004518                    for(uint32_t j = 0; j < cSurfs; ++j)
    45014519                    {
    4502                         rc = vhwaLoadSurface(pSSM, u32Version);  AssertRC(rc);
     4520                        rc = vhwaLoadSurface(pCmdList, pSSM, u32Version);  AssertRC(rc);
    45034521                        if(RT_FAILURE(rc))
    45044522                            break;
     
    45074525                    if(RT_SUCCESS(rc))
    45084526                    {
    4509                         rc = vhwaLoadOverlayData(pSSM, u32Version);  AssertRC(rc);
     4527                        rc = vhwaLoadOverlayData(pCmdList, pSSM, u32Version);  AssertRC(rc);
    45104528                    }
    45114529
     
    49885006#endif
    49895007
    4990     VBoxVHWACommandElement * pPpCmd = mResizePostProcessCmds.detachList();
    4991     if(pPpCmd)
    4992     {
    4993         processCmdList(pPpCmd);
    4994         while(pPpCmd)
    4995         {
    4996             VBoxVHWACommandElement * pCur = pPpCmd;
    4997             pPpCmd = pCur->mpNext;
    4998             delete pCur;
    4999         }
     5008    if(!mOnResizeCmdList.empty())
     5009    {
     5010        for (VHWACommandList::const_iterator it = mOnResizeCmdList.begin();
     5011             it != mOnResizeCmdList.end(); ++ it)
     5012        {
     5013            VBOXVHWACMD * pCmd = (*it);
     5014            vboxDoVHWACmdExec(pCmd);
     5015            free(pCmd);
     5016        }
     5017        mOnResizeCmdList.clear();
    50005018    }
    50015019
     
    50335051//    delete pEl;
    50345052//}
    5035 
    5036 void VBoxGLWidget::vboxExecOnResize(PFNVBOXQGLOP pfn, void* pContext)
    5037 {
    5038     VBoxVHWACommandElement *pCmd = new VBoxVHWACommandElement();
    5039     VBOXVHWACALLBACKINFO info;
    5040     info.pThis = this;
    5041     info.pfnCallback = pfn;
    5042     info.pContext = pContext;
    5043     pCmd->setOp(info);
    5044     mResizePostProcessCmds.put(pCmd);
    5045 }
    50465053
    50475054//int VBoxGLWidget::vboxExecOpSynch(PFNVBOXQGLOP pfn, void* pContext)
     
    52445251    mOverlayWidgetVisible = true; /* to ensure it is set hidden with vboxShowOverlay */
    52455252    vboxShowOverlay(false);
     5253
     5254    resizeEvent (new VBoxResizeEvent (FramebufferPixelFormat_Opaque,
     5255                                      NULL, 0, 0, 640, 480));
    52465256}
    52475257
     
    53145324    VBoxQImageFrameBuffer::resizeEvent(re);
    53155325
     5326    bool bDoOpExit = false;
     5327
     5328    Assert(0);
     5329
    53165330    if(mGlOn)
    53175331    {
     
    53215335        /* need to ensure we're in synch */
    53225336        vboxSynchGl();
     5337        bDoOpExit = true;
     5338    }
     5339
     5340    if(!mOnResizeCmdList.empty())
     5341    {
     5342        for (VHWACommandList::const_iterator it = mOnResizeCmdList.begin();
     5343             it != mOnResizeCmdList.end(); ++ it)
     5344        {
     5345            VBOXVHWACMD * pCmd = (*it);
     5346            vboxDoVHWACmdExec(pCmd);
     5347            free(pCmd);
     5348        }
     5349        mOnResizeCmdList.clear();
     5350        bDoOpExit = true;
     5351    }
     5352
     5353    if(bDoOpExit)
     5354    {
    53235355        vboxOpExit();
    5324         Assert(mGlCurrent == false);
    5325     }
     5356    }
     5357    Assert(mGlCurrent == false);
     5358
    53265359}
    53275360
     
    53575390void VBoxQGLOverlayFrameBuffer::vboxSynchGl()
    53585391{
     5392    if(mpOverlayWidget->vboxIsInitialized()
     5393            && pixelFormat() == mpOverlayWidget->vboxPixelFormat()
     5394            && address() == mpOverlayWidget->vboxAddress()
     5395            && bitsPerPixel() == mpOverlayWidget->vboxBitsPerPixel()
     5396            && bytesPerLine() == mpOverlayWidget->vboxBytesPerLine()
     5397            && width() == mpOverlayWidget->vboxFbWidth()
     5398            && height() == mpOverlayWidget->vboxFbHeight())
     5399    {
     5400        return;
     5401    }
    53595402    /* create and issue a resize event to the gl widget to ensure we have all gl data initialized
    53605403     * and synchronized with the framebuffer */
     
    53965439void VBoxQGLOverlayFrameBuffer::vboxDoCheckUpdateViewport()
    53975440{
    5398     Assert(0);
     5441    if(!mOverlayVisible)
     5442    {
     5443        vboxShowOverlay(false);
     5444        return;
     5445    }
     5446
    53995447    int cX = mView->contentsX();
    54005448    int cY = mView->contentsY();
     
    54885536                    mOverlayViewport = mpOverlayWidget->overlaysRectUnion();
    54895537                }
     5538                vboxDoCheckUpdateViewport();
    54905539            }
    54915540        } break;
     
    55055554                    mOverlayViewport = mpOverlayWidget->overlaysRectUnion();
    55065555                }
     5556                vboxDoCheckUpdateViewport();
    55075557            }
    55085558        } break;
     
    55715621        {
    55725622            VBOXVHWACMD_HH_CONSTRUCT * pBody = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_HH_CONSTRUCT);
    5573             pCmd->rc = mpOverlayWidget->vhwaConstruct(pBody);
     5623            pCmd->rc = vhwaConstruct(pBody);
    55745624        } break;
    55755625        default:
     
    55785628            break;
    55795629    }
     5630}
     5631
     5632static DECLCALLBACK(void) vboxQGLOverlaySaveExec(PSSMHANDLE pSSM, void *pvUser)
     5633{
     5634    VBoxQGLOverlayFrameBuffer * fb = (VBoxQGLOverlayFrameBuffer*)pvUser;
     5635    fb->vhwaSaveExec(pSSM);
     5636}
     5637
     5638static DECLCALLBACK(int) vboxQGLOverlayLoadExec(PSSMHANDLE pSSM, void *pvUser, uint32_t u32Version, uint32_t uPass)
     5639{
     5640    Assert(uPass == SSM_PASS_FINAL); NOREF(uPass);
     5641    VBoxQGLOverlayFrameBuffer * fb = (VBoxQGLOverlayFrameBuffer*)pvUser;
     5642    return fb->vhwaLoadExec(pSSM, u32Version);
     5643}
     5644
     5645int VBoxQGLOverlayFrameBuffer::vhwaLoadExec(struct SSMHANDLE * pSSM, uint32_t u32Version)
     5646{
     5647//    bool bTmp;
     5648//    int rc = SSMR3GetBool(pSSM, &bTmp /*&mGlOn*/);         AssertRC(rc);
     5649//    rc = SSMR3GetBool(pSSM, &bTmp /*&mOverlayVisible*/);         AssertRC(rc);
     5650//    if(RT_SUCCESS(rc))
     5651    return mpOverlayWidget->vhwaLoadExec(&mOnResizeCmdList, pSSM, u32Version);
     5652//    return rc;
     5653}
     5654
     5655void VBoxQGLOverlayFrameBuffer::vhwaSaveExec(struct SSMHANDLE * pSSM)
     5656{
     5657//    int rc = SSMR3PutBool(pSSM, mGlOn);         AssertRC(rc);
     5658//    rc = SSMR3PutBool(pSSM, mOverlayVisible);         AssertRC(rc);
     5659//
     5660    mpOverlayWidget->vhwaSaveExec(pSSM);
     5661}
     5662
     5663int VBoxQGLOverlayFrameBuffer::vhwaConstruct(struct _VBOXVHWACMD_HH_CONSTRUCT *pCmd)
     5664{
     5665    PVM pVM = (PVM)pCmd->pVM;
     5666    uint32_t intsId = 0; /* @todo: set the proper id */
     5667
     5668    char nameFuf[sizeof(VBOXQGL_STATE_NAMEBASE) + 8];
     5669
     5670    char * pszName = nameFuf;
     5671    sprintf(pszName, "%s%d", VBOXQGL_STATE_NAMEBASE, intsId);
     5672    int rc = SSMR3RegisterExternal(
     5673            pVM,                    /* The VM handle*/
     5674            pszName,                /* Data unit name. */
     5675            intsId,                 /* The instance identifier of the data unit.
     5676                                     * This must together with the name be unique. */
     5677            VBOXQGL_STATE_VERSION,   /* Data layout version number. */
     5678            128,             /* The approximate amount of data in the unit.
     5679                              * Only for progress indicators. */
     5680            NULL, NULL, NULL, /* pfnLiveXxx */
     5681            NULL,            /* Prepare save callback, optional. */
     5682            vboxQGLOverlaySaveExec, /* Execute save callback, optional. */
     5683            NULL,            /* Done save callback, optional. */
     5684            NULL,            /* Prepare load callback, optional. */
     5685            vboxQGLOverlayLoadExec, /* Execute load callback, optional. */
     5686            NULL,            /* Done load callback, optional. */
     5687            this             /* User argument. */
     5688            );
     5689    Assert(RT_SUCCESS(rc));
     5690    return rc;
    55805691}
    55815692
     
    55995710            const VBOXVHWACALLBACKINFO & info = pCmd->op();
    56005711            (info.pThis->*(info.pfnCallback))(info.pContext);
     5712            break;
     5713        }
     5714        case VBOXVHWA_PIPECMD_FUNC:
     5715        {
     5716            const VBOXVHWAFUNCCALLBACKINFO & info = pCmd->func();
     5717            info.pfnCallback(info.pContext1, info.pContext2);
    56015718            break;
    56025719        }
     
    57215838}
    57225839
    5723 #endif
     5840
     5841void VBoxVHWACommandsQueue::enqueue(PFNVBOXQGLFUNC pfn, void* pContext1, void* pContext2)
     5842{
     5843    VBoxVHWACommandElement *pCmd = new VBoxVHWACommandElement();
     5844    VBOXVHWAFUNCCALLBACKINFO info;
     5845    info.pfnCallback = pfn;
     5846    info.pContext1 = pContext1;
     5847    info.pContext2 = pContext2;
     5848    pCmd->setFunc(info);
     5849    mCmds.put(pCmd);
     5850}
     5851
     5852VBoxVHWACommandElement * VBoxVHWACommandsQueue::detachList()
     5853{
     5854    return mCmds.detachList();
     5855}
     5856
     5857void VBoxVHWACommandsQueue::freeList(VBoxVHWACommandElement * pList)
     5858{
     5859    while(pList)
     5860    {
     5861        VBoxVHWACommandElement * pCur = pList;
     5862        pList = pCur->mpNext;
     5863        delete pCur;
     5864    }
     5865}
     5866#endif
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