VirtualBox

Ignore:
Timestamp:
Nov 24, 2009 8:11:58 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
55209
Message:

More VBVA lock code (disabled, xTracker 4463)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/DisplayImpl.cpp

    r24890 r24924  
    106106    int rc = RTCritSectInit (&mVBVALock);
    107107    AssertRC (rc);
     108    mfu32PendingVideoAccelDisable = false;
    108109#endif /* VBOX_WITH_OLD_VBVA_LOCK */
    109110
     
    419420
    420421        /* SSM code is executed on EMT(0), therefore no need to use VMR3ReqCallWait. */
     422#ifdef VBOX_WITH_OLD_VBVA_LOCK
     423        int rc = Display::displayTakeScreenshotEMT(that, &pu8Data, &cbData, &cx, &cy);
     424#else
    421425        int rc = that->mpDrv->pUpPort->pfnTakeScreenshot (that->mpDrv->pUpPort, &pu8Data, &cbData, &cx, &cy);
     426#endif /* !VBOX_WITH_OLD_VBVA_LOCK */
    422427
    423428        if (RT_SUCCESS(rc))
     
    978983 *  @thread EMT
    979984 */
     985void Display::handleDisplayUpdate (int x, int y, int w, int h)
     986{
    980987#ifdef VBOX_WITH_OLD_VBVA_LOCK
    981 /*
    982  * Always runs under VBVA or DevVGA lock.
    983  * Safe to use VBVA vars and take the framebuffer lock.
    984  */
     988    /*
     989     * Always runs under VBVA or DevVGA lock.
     990     * Safe to use VBVA vars and take the framebuffer lock.
     991     */
     992#ifdef DEBUG_sunlover
     993    /* This assert is here for testing only. */
     994    Assert(RTCritSectIsOwner(&mVBVALock));
     995#endif /* DEBUG_sunlover */
    985996#endif /* VBOX_WITH_OLD_VBVA_LOCK */
    986 void Display::handleDisplayUpdate (int x, int y, int w, int h)
    987 {
     997
    988998#ifdef DEBUG_sunlover
    989999    LogFlowFunc (("%d,%d %dx%d (%d,%d)\n",
     
    11811191}
    11821192
     1193#ifdef VBOX_WITH_OLD_VBVA_LOCK
     1194int Display::vbvaLock(void)
     1195{
     1196    return RTCritSectEnter(&mVBVALock);
     1197}
     1198
     1199void Display::vbvaUnlock(void)
     1200{
     1201    RTCritSectLeave(&mVBVALock);
     1202}
     1203#endif /* VBOX_WITH_OLD_VBVA_LOCK */
     1204   
    11831205/**
    11841206 * @thread EMT
     
    11881210{
    11891211    int rc;
    1190     RTCritSectEnter(&mVBVALock);
     1212    vbvaLock();
    11911213    rc = videoAccelEnable (fEnable, pVbvaMemory);
    1192     RTCritSectLeave(&mVBVALock);
     1214    vbvaUnlock();
    11931215    return rc;
    11941216}
     
    13171339void Display::VideoAccelVRDP (bool fEnable)
    13181340{
     1341#ifdef VBOX_WITH_OLD_VBVA_LOCK
     1342    vbvaLock();
     1343#endif /* VBOX_WITH_OLD_VBVA_LOCK */
     1344
    13191345    int c = fEnable?
    13201346                ASMAtomicIncS32 (&mcVideoAccelVRDPRefs):
     
    13591385        Assert (mfVideoAccelVRDP == true);
    13601386    }
     1387#ifdef VBOX_WITH_OLD_VBVA_LOCK
     1388    vbvaUnlock();
     1389#endif /* VBOX_WITH_OLD_VBVA_LOCK */
    13611390}
    13621391#endif /* VBOX_WITH_VRDP */
     
    16361665void Display::VideoAccelFlush (void)
    16371666{
    1638     RTCritSectEnter(&mVBVALock);
     1667    vbvaLock();
    16391668    videoAccelFlush();
    1640     RTCritSectLeave(&mVBVALock);
     1669    vbvaUnlock();
    16411670}
    16421671#endif /* VBOX_WITH_OLD_VBVA_LOCK */
     
    17831812}
    17841813
     1814#ifdef VBOX_WITH_OLD_VBVA_LOCK
     1815int Display::videoAccelRefreshProcess(void)
     1816{
     1817    int rc = VWRN_INVALID_STATE; /* Default is to do a display update in VGA device. */
     1818
     1819#ifdef DEBUG_sunlover
     1820    LogFlowFunc(("\n"));
     1821#endif
     1822
     1823    vbvaLock();
     1824
     1825    if (ASMAtomicCmpXchgU32(&mfu32PendingVideoAccelDisable, false, true))
     1826    {
     1827        videoAccelEnable (false, NULL);
     1828    }
     1829    else if (mfPendingVideoAccelEnable)
     1830    {
     1831        /* Acceleration was enabled while machine was not yet running
     1832         * due to restoring from saved state. Update entire display and
     1833         * actually enable acceleration.
     1834         */
     1835        Assert(mpPendingVbvaMemory);
     1836
     1837        /* Acceleration can not be yet enabled.*/
     1838        Assert(mpVbvaMemory == NULL);
     1839        Assert(!mfVideoAccelEnabled);
     1840
     1841        if (mfMachineRunning)
     1842        {
     1843            videoAccelEnable (mfPendingVideoAccelEnable,
     1844                              mpPendingVbvaMemory);
     1845
     1846            /* Reset the pending state. */
     1847            mfPendingVideoAccelEnable = false;
     1848            mpPendingVbvaMemory = NULL;
     1849        }
     1850
     1851        rc = VINF_TRY_AGAIN;
     1852    }
     1853    else
     1854    {
     1855        Assert(mpPendingVbvaMemory == NULL);
     1856
     1857        if (mfVideoAccelEnabled)
     1858        {
     1859            Assert(mpVbvaMemory);
     1860            videoAccelFlush ();
     1861
     1862            rc = VINF_SUCCESS; /* VBVA processed, no need to a display update. */
     1863        }
     1864    }
     1865
     1866    vbvaUnlock();
     1867
     1868#ifdef DEBUG_sunlover
     1869    LogFlowFunc(("rc = %d\n"));
     1870#endif
     1871
     1872    return rc;
     1873}
     1874#endif /* VBOX_WITH_OLD_VBVA_LOCK */
     1875
    17851876
    17861877// IDisplay properties
     
    19922083}
    19932084
     2085#ifdef VBOX_WITH_OLD_VBVA_LOCK
     2086int Display::displayTakeScreenshotEMT(Display *pDisplay, uint8_t **ppu8Data, size_t *pcbData, uint32_t *pu32Width, uint32_t *pu32Height)
     2087{
     2088   int rc;
     2089   pDisplay->vbvaLock();
     2090   rc = pDisplay->mpDrv->pUpPort->pfnTakeScreenshot(pDisplay->mpDrv->pUpPort, ppu8Data, pcbData, pu32Width, pu32Height);
     2091   pDisplay->vbvaUnlock();
     2092   return rc;
     2093}
     2094#endif /* VBOX_WITH_OLD_VBVA_LOCK */
     2095
     2096#ifdef VBOX_WITH_OLD_VBVA_LOCK
     2097static int displayTakeScreenshot(PVM pVM, Display *pDisplay, struct DRVMAINDISPLAY *pDrv, BYTE *address, ULONG width, ULONG height)
     2098#else
    19942099static int displayTakeScreenshot(PVM pVM, struct DRVMAINDISPLAY *pDrv, BYTE *address, ULONG width, ULONG height)
     2100#endif /* !VBOX_WITH_OLD_VBVA_LOCK */
    19952101{
    19962102    uint8_t *pu8Data = NULL;
     
    19992105    uint32_t cy = 0;
    20002106
     2107#ifdef VBOX_WITH_OLD_VBVA_LOCK
     2108    int vrc = VMR3ReqCallWait(pVM, VMCPUID_ANY, (PFNRT)Display::displayTakeScreenshotEMT, 5,
     2109                              pDisplay, &pu8Data, &cbData, &cx, &cy);
     2110#else
    20012111    /* @todo pfnTakeScreenshot is probably callable from any thread, because it uses the VGA device lock. */
    20022112    int vrc = VMR3ReqCallWait(pVM, VMCPUID_ANY, (PFNRT)pDrv->pUpPort->pfnTakeScreenshot, 5,
    20032113                              pDrv->pUpPort, &pu8Data, &cbData, &cx, &cy);
     2114#endif /* !VBOX_WITH_OLD_VBVA_LOCK */
    20042115
    20052116    if (RT_SUCCESS(vrc))
     
    20762187    alock.leave();
    20772188
     2189#ifdef VBOX_WITH_OLD_VBVA_LOCK
     2190    int vrc = displayTakeScreenshot(pVM, this, mpDrv, address, width, height);
     2191#else
    20782192    int vrc = displayTakeScreenshot(pVM, mpDrv, address, width, height);
     2193#endif /* !VBOX_WITH_OLD_VBVA_LOCK */
    20792194
    20802195    if (vrc == VERR_NOT_IMPLEMENTED)
     
    21282243        return E_OUTOFMEMORY;
    21292244
     2245#ifdef VBOX_WITH_OLD_VBVA_LOCK
     2246    int vrc = displayTakeScreenshot(pVM, this, mpDrv, pu8Data, width, height);
     2247#else
    21302248    int vrc = displayTakeScreenshot(pVM, mpDrv, pu8Data, width, height);
     2249#endif /* !VBOX_WITH_OLD_VBVA_LOCK */
    21312250
    21322251    if (RT_SUCCESS(vrc))
     
    21942313     * dirty conversion work.
    21952314     */
     2315#ifdef VBOX_WITH_OLD_VBVA_LOCK
     2316    int rcVBox = 0;
     2317// @todo vbva   int rcVBox = VMR3ReqCallWait(pVM, VMCPUID_ANY, (PFNRT)Display::DrawToScreenEMT, 6,
     2318//                                  this, address, x, y, width, height);
     2319#else
    21962320    int rcVBox = VMR3ReqCallWait(pVM, VMCPUID_ANY, (PFNRT)mpDrv->pUpPort->pfnDisplayBlt, 6,
    21972321                                 mpDrv->pUpPort, address, x, y, width, height);
     2322#endif /* !VBOX_WITH_OLD_VBVA_LOCK */
    21982323
    21992324    /*
     
    22502375
    22512376    /* pdm.h says that this has to be called from the EMT thread */
     2377#ifdef VBOX_WITH_OLD_VBVA_LOCK
     2378    int rcVBox = 0;
     2379// #todo vbva    int rcVBox = VMR3ReqCallVoidWait(pVM, VMCPUID_ANY, (PFNRT)Display::InvalidateAndUpdateEMT,
     2380//                                     1, this);
     2381#else
    22522382    int rcVBox = VMR3ReqCallVoidWait(pVM, VMCPUID_ANY,
    22532383                                     (PFNRT)mpDrv->pUpPort->pfnUpdateDisplayAll, 1, mpDrv->pUpPort);
     2384#endif /* !VBOX_WITH_OLD_VBVA_LOCK */
    22542385    alock.enter ();
    22552386
     
    25472678                /* Repaint the display because VM continued to run during the framebuffer resize. */
    25482679                if (!pFBInfo->pFramebuffer.isNull())
     2680#ifdef VBOX_WITH_OLD_VBVA_LOCK
     2681                {
     2682                    pDisplay->vbvaLock();
     2683#endif /* VBOX_WITH_OLD_VBVA_LOCK */
    25492684                    pDrv->pUpPort->pfnUpdateDisplayAll(pDrv->pUpPort);
     2685#ifdef VBOX_WITH_OLD_VBVA_LOCK
     2686                    pDisplay->vbvaUnlock();
     2687                }
     2688#endif /* VBOX_WITH_OLD_VBVA_LOCK */
    25502689            }
    25512690        }
     
    25612700    if (!fNoUpdate)
    25622701    {
     2702#ifdef VBOX_WITH_OLD_VBVA_LOCK
     2703        int rc = pDisplay->videoAccelRefreshProcess();
     2704
     2705        if (rc != VINF_TRY_AGAIN) /* Means 'do nothing' here. */
     2706        {
     2707            if (rc == VWRN_INVALID_STATE)
     2708            {
     2709                /* No VBVA do a display update. */
     2710                DISPLAYFBINFO *pFBInfo = &pDisplay->maFramebuffers[VBOX_VIDEO_PRIMARY_SCREEN];
     2711                if (!pFBInfo->pFramebuffer.isNull())
     2712                {
     2713                    Assert(pDrv->Connector.pu8Data);
     2714                    Assert(pFBInfo->u32ResizeStatus == ResizeStatus_Void);
     2715                    pDrv->pUpPort->pfnUpdateDisplay(pDrv->pUpPort);
     2716                }
     2717            }
     2718
     2719            /* Inform the VRDP server that the current display update sequence is
     2720             * completed. At this moment the framebuffer memory contains a definite
     2721             * image, that is synchronized with the orders already sent to VRDP client.
     2722             * The server can now process redraw requests from clients or initial
     2723             * fullscreen updates for new clients.
     2724             */
     2725            for (uScreenId = 0; uScreenId < pDisplay->mcMonitors; uScreenId++)
     2726            {
     2727                DISPLAYFBINFO *pFBInfo = &pDisplay->maFramebuffers[uScreenId];
     2728
     2729                if (!pFBInfo->pFramebuffer.isNull() && pFBInfo->u32ResizeStatus == ResizeStatus_Void)
     2730                {
     2731                    Assert (pDisplay->mParent && pDisplay->mParent->consoleVRDPServer());
     2732                    pDisplay->mParent->consoleVRDPServer()->SendUpdate (uScreenId, NULL, 0);
     2733                }
     2734            }
     2735        }
     2736#else
    25632737        if (pDisplay->mfPendingVideoAccelEnable)
    25642738        {
     
    26202794            }
    26212795        }
     2796#endif /* !VBOX_WITH_OLD_VBVA_LOCK */
    26222797    }
    26232798
     
    26602835    /* Disable VBVA mode in any case. The guest driver reenables VBVA mode if necessary. */
    26612836#ifdef VBOX_WITH_OLD_VBVA_LOCK
    2662     /* This is called under DevVGA lock. Postpone disabling VBVA. */
    2663     /* @todo vbva */
     2837    /* This is called under DevVGA lock. Postpone disabling VBVA, do it in the refresh timer. */
     2838    ASMAtomicWriteU32(&pDrv->pDisplay->mfu32PendingVideoAccelDisable, true);
    26642839#else
    26652840    pDrv->pDisplay->VideoAccelEnable (false, NULL);
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