VirtualBox

Changeset 24925 in vbox for trunk


Ignore:
Timestamp:
Nov 24, 2009 10:59:37 PM (15 years ago)
Author:
vboxsync
Message:

2d video: fix VM reset issues

Location:
trunk
Files:
5 edited

Legend:

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

    r24646 r24925  
    320320
    321321#define VBOXVHWACMD_HEADSIZE() (RT_OFFSETOF(VBOXVHWACMD, body))
    322 #define VBOXVHWACMD_SIZE(_tCmd) (VBOXVHWACMD_HEADSIZE() + sizeof(_tCmd))
     322#define VBOXVHWACMD_SIZE_FROMBODYSIZE(_s) (VBOXVHWACMD_HEADSIZE() + (_s))
     323#define VBOXVHWACMD_SIZE(_tCmd) (VBOXVHWACMD_SIZE_FROMBODYSIZE(sizeof(_tCmd)))
    323324typedef unsigned int VBOXVHWACMD_LENGTH;
    324325typedef uint64_t VBOXVHWA_SURFHANDLE;
     
    734735    void * pVM;
    735736} VBOXVHWACMD_HH_CONSTRUCT;
     737
     738typedef DECLCALLBACK(void) FNVBOXVHWA_HH_CALLBACK(void*);
     739typedef FNVBOXVHWA_HH_CALLBACK *PFNVBOXVHWA_HH_CALLBACK;
     740
     741#define VBOXVHWA_HH_CALLBACK_SET(_pCmd, _pfn, _parg) \
     742    do { \
     743        (_pCmd)->GuestVBVAReserved1 = (uint64_t)(_pfn); \
     744        (_pCmd)->GuestVBVAReserved2 = (uint64_t)(_parg); \
     745    }while(0)
     746
     747#define VBOXVHWA_HH_CALLBACK_GET(_pCmd) ((PFNVBOXVHWA_HH_CALLBACK)(_pCmd)->GuestVBVAReserved1)
     748#define VBOXVHWA_HH_CALLBACK_GET_ARG(_pCmd) ((void*)(_pCmd)->GuestVBVAReserved2)
    736749
    737750#pragma pack()
  • trunk/src/VBox/Additions/WINNT/Graphics/Display/dd.c

    r24646 r24925  
    13421342            vboxVHWASurfDescFree(pDesc);
    13431343
    1344             lpSurfaceGlobal->dwReserved1 = NULL;
     1344            lpSurfaceGlobal->dwReserved1 = (ULONG_PTR)NULL;
    13451345
    13461346            lpDestroySurface->ddRVal = DD_OK;
  • trunk/src/VBox/Devices/Graphics/DevVGA_VBVA.cpp

    r24779 r24925  
    10451045}
    10461046
     1047static DECLCALLBACK(void) vbvaVHWAHHCommandSetEventCallback(void * pContext)
     1048{
     1049    RTSemEventSignal((RTSEMEVENT)pContext);
     1050}
     1051
    10471052static int vbvaVHWAHHCommandPost(PVGASTATE pVGAState, VBOXVHWACMD* pCmd)
    10481053{
     
    10541059        /* ensure the cmd is not deleted until we process it */
    10551060        vbvaVHWAHHCommandRetain (pCmd);
    1056         pCmd->GuestVBVAReserved1 = (uint64_t)hComplEvent;
     1061        VBOXVHWA_HH_CALLBACK_SET(pCmd, vbvaVHWAHHCommandSetEventCallback, (void*)hComplEvent);
    10571062        vbvaVHWAHandleCommand(pVGAState, NULL, pCmd);
    10581063        if((ASMAtomicReadU32((volatile uint32_t *)&pCmd->Flags)  & VBOXVHWACMD_FLAG_HG_ASYNCH) != 0)
     
    12491254    else
    12501255    {
    1251         if(pCmd->GuestVBVAReserved1)
    1252         {
    1253             RTSEMEVENT hComplEvent = (RTSEMEVENT)pCmd->GuestVBVAReserved1;
    1254             RTSemEventSignal(hComplEvent);
     1256        PFNVBOXVHWA_HH_CALLBACK pfn = VBOXVHWA_HH_CALLBACK_GET(pCmd);
     1257        if(pfn)
     1258        {
     1259            pfn(VBOXVHWA_HH_CALLBACK_GET_ARG(pCmd));
    12551260        }
    12561261        rc = VINF_SUCCESS;
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxFBOverlay.h

    r24861 r24925  
    11041104#endif
    11051105
     1106    int reset(VHWACommandList * pCmdList);
     1107
    11061108    ulong vboxBitsPerPixel() { return mDisplay.getVGA()->bitsPerPixel(); }
    11071109    ulong vboxBytesPerLine() { return mDisplay.getVGA() ? mDisplay.getVGA()->bytesPerLine() : 0; }
     
    14021404
    14031405    int reset();
     1406
     1407    int resetGl();
    14041408       
    14051409    void initGl();
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBOverlay.cpp

    r24867 r24925  
    165165static bool g_bVBoxVHWAChecked = false;
    166166static bool g_bVBoxVHWASupported = false;
     167
     168static struct _VBOXVHWACMD * vhwaHHCmdCreate(VBOXVHWACMD_TYPE type, size_t size)
     169{
     170    char *buf = (char*)malloc(VBOXVHWACMD_SIZE_FROMBODYSIZE(size));
     171    memset(buf, 0, size);
     172    VBOXVHWACMD * pCmd = (VBOXVHWACMD*)buf;
     173    pCmd->enmCmd = type;
     174    pCmd->Flags = VBOXVHWACMD_FLAG_HH_CMD;
     175    return pCmd;
     176}
    167177
    168178static const VBoxVHWAInfo & vboxVHWAGetSupportInfo(const QGLContext *pContext)
     
    28052815}
    28062816
     2817int VBoxGLWidget::reset(VHWACommandList * pCmdList)
     2818{
     2819    VBOXVHWACMD * pCmd;
     2820    const OverlayList & overlays = mDisplay.overlays();
     2821    for (OverlayList::const_iterator oIt = overlays.begin();
     2822            oIt != overlays.end(); ++ oIt)
     2823    {
     2824        VBoxVHWASurfList * pSurfList = *oIt;
     2825        if(pSurfList->current())
     2826        {
     2827            /* 1. hide overlay */
     2828            pCmd = vhwaHHCmdCreate(VBOXVHWACMD_TYPE_SURF_OVERLAY_UPDATE, sizeof(VBOXVHWACMD_SURF_OVERLAY_UPDATE));
     2829            VBOXVHWACMD_SURF_OVERLAY_UPDATE *pOUCmd = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_SURF_OVERLAY_UPDATE);
     2830            pOUCmd->u.in.hSrcSurf = pSurfList->current()->handle();
     2831            pOUCmd->u.in.flags = VBOXVHWA_OVER_HIDE;
     2832
     2833            pCmdList->push_back(pCmd);
     2834        }
     2835
     2836        /* 2. destroy overlay */
     2837        const SurfList & surfaces = pSurfList->surfaces();
     2838
     2839        for (SurfList::const_iterator sIt = surfaces.begin();
     2840                sIt != surfaces.end(); ++ sIt)
     2841        {
     2842            VBoxVHWASurfaceBase *pCurSurf = (*sIt);
     2843            pCmd = vhwaHHCmdCreate(VBOXVHWACMD_TYPE_SURF_DESTROY, sizeof(VBOXVHWACMD_SURF_DESTROY));
     2844            VBOXVHWACMD_SURF_DESTROY *pSDCmd = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_SURF_DESTROY);
     2845            pSDCmd->u.in.hSurf = pCurSurf->handle();
     2846
     2847            pCmdList->push_back(pCmd);
     2848        }
     2849    }
     2850
     2851    /* 3. destroy primaries */
     2852    const SurfList & surfaces = mDisplay.primaries().surfaces();
     2853    for (SurfList::const_iterator sIt = surfaces.begin();
     2854            sIt != surfaces.end(); ++ sIt)
     2855    {
     2856        VBoxVHWASurfaceBase *pCurSurf = (*sIt);
     2857        if(pCurSurf->handle() != VBOXVHWA_SURFHANDLE_INVALID)
     2858        {
     2859            pCmd = vhwaHHCmdCreate(VBOXVHWACMD_TYPE_SURF_DESTROY, sizeof(VBOXVHWACMD_SURF_DESTROY));
     2860            VBOXVHWACMD_SURF_DESTROY *pSDCmd = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_SURF_DESTROY);
     2861            pSDCmd->u.in.hSurf = pCurSurf->handle();
     2862
     2863            pCmdList->push_back(pCmd);
     2864        }
     2865    }
     2866
     2867    return VINF_SUCCESS;
     2868}
     2869
    28072870#ifdef VBOX_WITH_VIDEOHWACCEL
    28082871void VBoxGLWidget::vboxDoVHWACmd(void *cmd)
     
    39003963
    39013964    char *buf = (char*)malloc(VBOXVHWACMD_SIZE(VBOXVHWACMD_SURF_CREATE));
    3902     memset(buf, 0, sizeof(buf));
     3965    memset(buf, 0, sizeof(VBOXVHWACMD_SIZE(VBOXVHWACMD_SURF_CREATE)));
    39033966    VBOXVHWACMD * pCmd = (VBOXVHWACMD*)buf;
    39043967    pCmd->enmCmd = VBOXVHWACMD_TYPE_SURF_CREATE;
     
    40594122//    char buf[VBOXVHWACMD_SIZE(VBOXVHWACMD_SURF_OVERLAY_UPDATE)];
    40604123    char *buf = new char[VBOXVHWACMD_SIZE(VBOXVHWACMD_SURF_CREATE)];
    4061     memset(buf, 0, sizeof(buf));
     4124    memset(buf, 0, VBOXVHWACMD_SIZE(VBOXVHWACMD_SURF_CREATE));
    40624125    VBOXVHWACMD * pCmd = (VBOXVHWACMD*)buf;
    40634126    pCmd->enmCmd = VBOXVHWACMD_TYPE_SURF_OVERLAY_UPDATE;
     
    42334296    if(buf)
    42344297    {
    4235         memset(buf, 0, sizeof(buf));
     4298        memset(buf, 0, sizeof(VBOXVHWACMD));
    42364299        VBOXVHWACMD * pCmd = (VBOXVHWACMD*)buf;
    42374300        pCmd->enmCmd = VBOXVHWACMD_TYPE_ENABLE;
     
    50815144                break;
    50825145#endif
     5146            case VBOXVHWA_PIPECMD_PAINT:
     5147                break;
    50835148            default:
    50845149                /* should not happen, don't handle this for now */
     
    50885153        }
    50895154
    5090 #ifdef DEBUG
    50915155        VBoxVHWACommandElement *pTest = mCmdPipe.detachCmdList(pHead, pTail);
    50925156        Assert(!pTest);
    50935157        NOREF(pTest);
    5094 #endif
     5158    }
     5159
     5160    resetGl();
     5161
     5162    return VINF_SUCCESS;
     5163}
     5164
     5165static DECLCALLBACK(void) vbvaVHWAHHCommandFreeCmd(void * pContext)
     5166{
     5167    free(pContext);
     5168}
     5169
     5170int VBoxQGLOverlay::resetGl()
     5171{
     5172    if(mpOverlayWidget)
     5173    {
     5174        VHWACommandList list;
     5175        int rc = mpOverlayWidget->reset(&list);
     5176        if(RT_SUCCESS(rc))
     5177        {
     5178            for (VHWACommandList::const_iterator sIt = list.begin();
     5179                    sIt != list.end(); ++ sIt)
     5180            {
     5181                VBOXVHWACMD *pCmd = (*sIt);
     5182                VBOXVHWA_HH_CALLBACK_SET(pCmd, vbvaVHWAHHCommandFreeCmd, pCmd);
     5183                mCmdPipe.postCmd(VBOXVHWA_PIPECMD_VHWA, pCmd, 0);
     5184            }
     5185        }
    50955186    }
    50965187    return VINF_SUCCESS;
     
    51345225    mGlCurrent = false; /* just a fall-back */
    51355226    VBoxVHWACommandElement * pFirst = mCmdPipe.detachCmdList(NULL, NULL);
    5136     do
     5227    while(pFirst) /* pFirst can be zero right after reset when all pending commands are flushed,
     5228                   * while events for those commands may still come along */
    51375229    {
    51385230        VBoxVHWACommandElement * pLast = processCmdList(pFirst);
    51395231
    51405232        pFirst = mCmdPipe.detachCmdList(pFirst, pLast);
    5141     } while(pFirst);
     5233    }
    51425234
    51435235    mProcessingCommands = false;
     
    58725964    {
    58735965        Assert(pLast);
    5874         pHead = pFirst->pipe().detachList();
    58755966        VBoxVHWACommandElement * pCurHead;
    58765967        for(VBoxVHWACommandProcessEvent * pCur = pFirst; pCur ; pCur = pCur->mpNext)
Note: See TracChangeset for help on using the changeset viewer.

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