VirtualBox

Changeset 50848 in vbox for trunk/src/VBox/Devices/Graphics


Ignore:
Timestamp:
Mar 24, 2014 10:15:41 AM (11 years ago)
Author:
vboxsync
Message:

crOpenGL: new command submission continued

Location:
trunk/src/VBox/Devices/Graphics
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Graphics/DevVGA.cpp

    r50804 r50848  
    59555955#endif
    59565956    pThis->IVBVACallbacks.pfnCrCtlSubmit = vboxCmdVBVACmdHostCtl;
     5957    pThis->IVBVACallbacks.pfnCrCtlSubmitSync = vboxCmdVBVACmdHostCtlSync;
    59575958
    59585959    /*
  • trunk/src/VBox/Devices/Graphics/DevVGA.h

    r50760 r50848  
    630630                                                               PFNCRCTLCOMPLETION pfnCompletion,
    631631                                                               void *pvCompletion);
     632int vboxCmdVBVACmdHostCtlSync(PPDMIDISPLAYVBVACALLBACKS pInterface,
     633                                                               struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd);
    632634
    633635int vboxVBVASaveStateExec (PPDMDEVINS pDevIns, PSSMHANDLE pSSM);
  • trunk/src/VBox/Devices/Graphics/DevVGA_VDMA.cpp

    r50831 r50848  
    605605    if ((enmSource == VBVAEXHOSTCTL_SOURCE_HOST_ENABLED) && !VBoxVBVAExHSIsEnabled(pCmdVbva))
    606606    {
    607         WARN(("cmd vbva not enabled\n"));
     607        Log(("cmd vbva not enabled\n"));
    608608        return VERR_INVALID_STATE;
    609609    }
     
    619619            if ((enmSource == VBVAEXHOSTCTL_SOURCE_HOST_ENABLED) && !VBoxVBVAExHSIsEnabled(pCmdVbva))
    620620            {
    621                 WARN(("cmd vbva not enabled\n"));
     621                Log(("cmd vbva not enabled\n"));
    622622                RTCritSectLeave(&pCmdVbva->CltCritSect);
    623623                return VERR_INVALID_STATE;
     
    669669    VBOXCRCMD_SVRINFO CrSrvInfo;
    670670    VBVAEXHOSTCTL* pCurRemainingHostCtl;
     671    RTSEMEVENTMULTI HostCrCtlCompleteEvent;
     672    int32_t volatile i32cHostCrCtlCompleted;
    671673#ifdef VBOX_VDMA_WITH_WATCHDOG
    672674    PTMTIMERR3 WatchDogTimer;
     
    21572159        pVdma->pVGAState = pVGAState;
    21582160
     2161        rc = RTSemEventMultiCreate(&pVdma->HostCrCtlCompleteEvent);
     2162        if (RT_SUCCESS(rc))
     2163        {
    21592164#ifdef VBOX_VDMA_WITH_WATCHDOG
    2160         rc = PDMDevHlpTMTimerCreate(pVGAState->pDevInsR3, TMCLOCK_REAL, vboxVDMAWatchDogTimer,
    2161                                     pVdma, TMTIMER_FLAGS_NO_CRIT_SECT,
    2162                                     "VDMA WatchDog Timer", &pVdma->WatchDogTimer);
    2163         AssertRC(rc);
     2165            rc = PDMDevHlpTMTimerCreate(pVGAState->pDevInsR3, TMCLOCK_REAL, vboxVDMAWatchDogTimer,
     2166                                        pVdma, TMTIMER_FLAGS_NO_CRIT_SECT,
     2167                                        "VDMA WatchDog Timer", &pVdma->WatchDogTimer);
     2168            AssertRC(rc);
    21642169#endif
    2165         rc = VBoxVBVAExHSInit(&pVdma->CmdVbva);
    2166         if (RT_SUCCESS(rc))
    2167         {
    2168             rc = VBoxVDMAThreadCreate(&pVdma->Thread, vboxVDMAWorkerThread, pVdma);
     2170            rc = VBoxVBVAExHSInit(&pVdma->CmdVbva);
    21692171            if (RT_SUCCESS(rc))
    21702172            {
    2171                 pVGAState->pVdma = pVdma;
     2173                rc = VBoxVDMAThreadCreate(&pVdma->Thread, vboxVDMAWorkerThread, pVdma);
     2174                if (RT_SUCCESS(rc))
     2175                {
     2176                    pVGAState->pVdma = pVdma;
    21722177#ifdef VBOX_WITH_CRHGSMI
    2173                 int rcIgnored = vboxVDMACrCtlHgsmiSetup(pVdma); NOREF(rcIgnored); /** @todo is this ignoring intentional? */
     2178                    int rcIgnored = vboxVDMACrCtlHgsmiSetup(pVdma); NOREF(rcIgnored); /** @todo is this ignoring intentional? */
    21742179#endif
    2175                 return VINF_SUCCESS;
     2180                    return VINF_SUCCESS;
     2181                }
     2182                else
     2183                    WARN(("VBoxVDMAThreadCreate faile %d\n", rc));
     2184
     2185                VBoxVBVAExHSTerm(&pVdma->CmdVbva);
    21762186            }
    21772187            else
    2178                 WARN(("VBoxVDMAThreadCreate faile %d\n", rc));
    2179 
    2180             VBoxVBVAExHSTerm(&pVdma->CmdVbva);
     2188                WARN(("VBoxVBVAExHSInit failed %d\n", rc));
     2189
     2190            RTSemEventMultiDestroy(pVdma->HostCrCtlCompleteEvent);
    21812191        }
    21822192        else
    2183             WARN(("VBoxVBVAExHSInit faile %d\n", rc));
     2193            WARN(("RTSemEventMultiCreate failed %d\n", rc));
     2194
    21842195
    21852196        RTMemFree(pVdma);
     
    22162227    VBoxVDMAThreadTerm(&pVdma->Thread);
    22172228    VBoxVBVAExHSTerm(&pVdma->CmdVbva);
     2229    RTSemEventMultiDestroy(pVdma->HostCrCtlCompleteEvent);
    22182230    RTMemFree(pVdma);
    22192231    return VINF_SUCCESS;
     
    23932405    }
    23942406    else
    2395         WARN(("VBoxVBVAExHCtlSubmit failed %d\n", rc));
     2407        Log(("VBoxVBVAExHCtlSubmit failed %d\n", rc));
    23962408
    23972409    return rc;
     
    24262438    if (!RT_SUCCESS(rc))
    24272439    {
    2428         WARN(("vdmaVBVACtlSubmit failed rc %d\n", rc));
     2440        Log(("vdmaVBVACtlSubmit failed rc %d\n", rc));
    24292441        return rc;;
    24302442    }
     
    24502462{
    24512463    VBOXCRCMDCTL* pVboxCtl = (VBOXCRCMDCTL*)pCtl->u.cmd.pu8Cmd;
    2452     if (pVboxCtl->pfnInternal)
    2453         ((PFNCRCTLCOMPLETION)pVboxCtl->pfnInternal)(pVboxCtl, pCtl->u.cmd.cbCmd, rc, pvCompletion);
     2464    if (pVboxCtl->u.pfnInternal)
     2465        ((PFNCRCTLCOMPLETION)pVboxCtl->u.pfnInternal)(pVboxCtl, pCtl->u.cmd.cbCmd, rc, pvCompletion);
    24542466    VBoxVBVAExHCtlFree(pVbva, pCtl);
    24552467}
     
    24592471        void *pvCompletion)
    24602472{
    2461     pCmd->pfnInternal = (void(*)())pfnCompletion;
     2473    pCmd->u.pfnInternal = (void(*)())pfnCompletion;
    24622474    int rc = vdmaVBVACtlOpaqueSubmit(pVdma, VBVAEXHOSTCTL_SOURCE_HOST_ENABLED, (uint8_t*)pCmd, cbCmd, vboxCmdVBVACmdCtlHostCompletion, pvCompletion);
    24632475    if (!RT_SUCCESS(rc))
     
    24652477        if (rc == VERR_INVALID_STATE)
    24662478        {
    2467             pCmd->pfnInternal = NULL;
     2479            pCmd->u.pfnInternal = NULL;
    24682480            PVGASTATE pVGAState = pVdma->pVGAState;
    24692481            rc = pVGAState->pDrv->pfnCrHgcmCtlSubmit(pVGAState->pDrv, pCmd, cbCmd, pfnCompletion, pvCompletion);
     
    25972609}
    25982610
     2611typedef struct VBOXCMDVBVA_CMDHOSTCTL_SYNC
     2612{
     2613    struct VBOXVDMAHOST *pVdma;
     2614    uint32_t fProcessing;
     2615    int rc;
     2616} VBOXCMDVBVA_CMDHOSTCTL_SYNC;
     2617
     2618static DECLCALLBACK(void) vboxCmdVBVACmdHostCtlSyncCb(struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd, int rc, void *pvCompletion)
     2619{
     2620    VBOXCMDVBVA_CMDHOSTCTL_SYNC *pData = (VBOXCMDVBVA_CMDHOSTCTL_SYNC*)pvCompletion;
     2621
     2622    pData->rc = rc;
     2623    pData->fProcessing = 0;
     2624
     2625    struct VBOXVDMAHOST *pVdma = pData->pVdma;
     2626
     2627    ASMAtomicIncS32(&pVdma->i32cHostCrCtlCompleted);
     2628
     2629    RTSemEventMultiSignal(pVdma->HostCrCtlCompleteEvent);
     2630}
     2631
     2632int vboxCmdVBVACmdHostCtlSync(PPDMIDISPLAYVBVACALLBACKS pInterface,
     2633                                                               struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd)
     2634{
     2635    PVGASTATE pVGAState = PPDMIDISPLAYVBVACALLBACKS_2_PVGASTATE(pInterface);
     2636    struct VBOXVDMAHOST *pVdma = pVGAState->pVdma;
     2637    VBOXCMDVBVA_CMDHOSTCTL_SYNC Data;
     2638    Data.pVdma = pVdma;
     2639    Data.fProcessing = 1;
     2640    Data.rc = VERR_INTERNAL_ERROR;
     2641    int rc = vdmaVBVACtlOpaqueHostSubmit(pVdma, pCmd, cbCmd, vboxCmdVBVACmdHostCtlSyncCb, &Data);
     2642    if (!RT_SUCCESS(rc))
     2643    {
     2644        WARN(("vdmaVBVACtlOpaqueHostSubmit failed %d", rc));
     2645        return rc;
     2646    }
     2647
     2648    while (Data.fProcessing)
     2649    {
     2650        /* Poll infrequently to make sure no completed message has been missed. */
     2651        RTSemEventMultiWait(pVdma->HostCrCtlCompleteEvent, 500);
     2652
     2653        if (Data.fProcessing)
     2654            RTThreadYield();
     2655    }
     2656
     2657    /* 'Our' message has been processed, so should reset the semaphore.
     2658     * There is still possible that another message has been processed
     2659     * and the semaphore has been signalled again.
     2660     * Reset only if there are no other messages completed.
     2661     */
     2662    int32_t c = ASMAtomicDecS32(&pVdma->i32cHostCrCtlCompleted);
     2663    Assert(c >= 0);
     2664    if (!c)
     2665        RTSemEventMultiReset(pVdma->HostCrCtlCompleteEvent);
     2666
     2667    rc = Data.rc;
     2668    if (!RT_SUCCESS(rc))
     2669        WARN(("host call failed %d", rc));
     2670
     2671    return rc;
     2672}
     2673
    25992674int vboxCmdVBVACmdCtl(PVGASTATE pVGAState, VBOXCMDVBVA_CTL *pCtl, uint32_t cbCtl)
    26002675{
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