VirtualBox

Changeset 94635 in vbox


Ignore:
Timestamp:
Apr 19, 2022 3:26:18 PM (3 years ago)
Author:
vboxsync
Message:

WDDM: cleanup routines; submit pending buffers. bugref:9845

Location:
trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/gallium
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/gallium/Svga.cpp

    r94631 r94635  
    5555}
    5656
     57static NTSTATUS SvgaObjectTablesDestroy(VBOXWDDM_EXT_VMSVGA *pSvga)
     58{
     59    NTSTATUS Status = STATUS_SUCCESS;
     60    if (pSvga->hMemObjOTables != NIL_RTR0MEMOBJ)
     61    {
     62        for (uint32_t idOTable = 0; idOTable < SVGA_OTABLE_DX_MAX; idOTable++)
     63        {
     64            void *pvCmd = SvgaCmdBuf3dCmdReserve(pSvga, SVGA_3D_CMD_SET_OTABLE_BASE64, sizeof(SVGA3dCmdSetOTableBase64), SVGA3D_INVALID_ID);
     65            AssertBreakStmt(pvCmd, STATUS_INSUFFICIENT_RESOURCES);
     66
     67            SVGA3dCmdSetOTableBase64 *pCmd = (SVGA3dCmdSetOTableBase64 *)pvCmd;
     68            pCmd->type             = (SVGAOTableType)idOTable;
     69            pCmd->baseAddress      = 0;
     70            pCmd->sizeInBytes      = 0;
     71            pCmd->validSizeInBytes = 0;
     72            pCmd->ptDepth          = SVGA3D_MOBFMT_INVALID;
     73
     74            SvgaCmdBufCommit(pSvga, sizeof(SVGA3dCmdSetOTableBase64));
     75        }
     76
     77        if (NT_SUCCESS(Status))
     78            SvgaCmdBufFlush(pSvga);
     79
     80        int rc = RTR0MemObjFree(pSvga->hMemObjOTables, true);
     81        AssertRCStmt(rc, Status = STATUS_INVALID_PARAMETER);
     82        pSvga->hMemObjOTables = NIL_RTR0MEMOBJ;
     83    }
     84    return Status;
     85}
    5786
    5887static NTSTATUS svgaCBContextEnable(VBOXWDDM_EXT_VMSVGA *pSvga, SVGACBContext CBContext, bool fEnable)
     
    7099}
    71100
    72 
    73 static NTSTATUS svgaHwInit(VBOXWDDM_EXT_VMSVGA *pSvga)
     101static void svgaHwStop(VBOXWDDM_EXT_VMSVGA *pSvga)
     102{
     103    /* Undo svgaHwStart. */
     104
     105    /* Send commands to host. */
     106    if (pSvga->u32Caps & SVGA_CAP_GBOBJECTS)
     107        SvgaObjectTablesDestroy(pSvga);
     108
     109    /* Give the host some time to process them. */
     110    LARGE_INTEGER Interval;
     111    Interval.QuadPart = -(int64_t)100 /* ms */ * 10000;
     112    KeDelayExecutionThread(KernelMode, FALSE, &Interval);
     113
     114    /* Disable IRQs. */
     115    SVGARegWrite(pSvga, SVGA_REG_IRQMASK, 0);
     116
     117    if (pSvga->pCBState)
     118        svgaCBContextEnable(pSvga, SVGA_CB_CONTEXT_0, false);
     119
     120    /* Disable SVGA. */
     121    SVGARegWrite(pSvga, SVGA_REG_ENABLE, SVGA_REG_ENABLE_DISABLE);
     122
     123    if (pSvga->u32Caps & SVGA_CAP_COMMAND_BUFFERS)
     124        SvgaCmdBufDestroy(pSvga);
     125}
     126
     127static NTSTATUS svgaHwStart(VBOXWDDM_EXT_VMSVGA *pSvga)
    74128{
    75129    pSvga->u32Caps      = SVGARegRead(pSvga, SVGA_REG_CAPABILITIES);
     
    163217        }
    164218
    165         /** @todo svgaHwStop(VBOXWDDM_EXT_VMSVGA *pSvga) to undo svgaHwInit */
    166         if (pSvga->u32Caps & SVGA_CAP_COMMAND_BUFFERS)
    167         {
    168             /// @todo SvgaObjectTablesDestroy(pSvga);
    169             SvgaCmdBufDestroy(pSvga);
    170         }
    171 
    172         /* Disable SVGA device. */
    173         SVGARegWrite(pSvga, SVGA_REG_IRQMASK, 0);
    174         SVGARegWrite(pSvga, SVGA_REG_ENABLE, SVGA_REG_ENABLE_DISABLE);
     219        svgaHwStop(pSvga);
    175220
    176221        Status = pDxgkInterface->DxgkCbUnmapMemory(pDxgkInterface->DeviceHandle,
     
    223268        if (u32SvgaId == SVGA_ID_2)
    224269        {
    225             Status = svgaHwInit(pSvga);
    226 
     270            Status = svgaHwStart(pSvga);
    227271            if (NT_SUCCESS(Status))
    228272            {
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/gallium/Svga.h

    r94631 r94635  
    124124    RTLISTANCHOR         QueuePending;             /* Buffers which will be submitted to the host. */
    125125    RTLISTANCHOR         QueueSubmitted;           /* Buffers which are being processed by the host. */
    126     RTLISTANCHOR         QueuePreempted;           /* Preempted buffers. */
    127126    uint32_t             cSubmitted;               /* How many buffers were submitted to the host.
    128127                                                    * Less than SVGA_CB_MAX_QUEUED_PER_CONTEXT */
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/gallium/SvgaFifo.cpp

    r94631 r94635  
    785785            --pCBCtx->cSubmitted;
    786786        }
     787
     788        /* Try to submit pending buffers. */
     789        while (!RTListIsEmpty(&pCBCtx->QueuePending))
     790        {
     791            if (pCBCtx->cSubmitted >= SVGA_CB_MAX_QUEUED_PER_CONTEXT - 1)
     792                break;
     793
     794            PVMSVGACB pCB = RTListGetFirst(&pCBCtx->QueuePending, VMSVGACB, nodeQueue);
     795            RTListNodeRemove(&pCB->nodeQueue);
     796
     797            RTListAppend(&pCBCtx->QueueSubmitted, &pCB->nodeQueue);
     798            ++pCBCtx->cSubmitted;
     799            svgaCBSubmitHeader(pSvga, pCB->CBHeaderPhysAddr, (SVGACBContext)i);
     800            GALOG(("Submitted pending %p\n", pCB));
     801        }
    787802    }
    788803    KeReleaseSpinLock(&pCBState->SpinLock, OldIrql);
     
    828843NTSTATUS SvgaCmdBufDestroy(PVBOXWDDM_EXT_VMSVGA pSvga)
    829844{
    830     /** @todo implement */
    831845    PVMSVGACBSTATE pCBState = pSvga->pCBState;
    832846    if (pCBState == NULL)
     
    834848    pSvga->pCBState = NULL;
    835849
     850    for (unsigned i = 0; i < RT_ELEMENTS(pCBState->aCBContexts); ++i)
     851    {
     852        PVMSVGACBCONTEXT pCBCtx = &pCBState->aCBContexts[i];
     853        PVMSVGACB pIter, pNext;
     854        RTListForEachSafe(&pCBCtx->QueueSubmitted, pIter, pNext, VMSVGACB, nodeQueue)
     855        {
     856            RTListNodeRemove(&pIter->nodeQueue);
     857            svgaCBFree(pCBState, pIter);
     858        }
     859        RTListForEachSafe(&pCBCtx->QueuePending, pIter, pNext, VMSVGACB, nodeQueue)
     860        {
     861            RTListNodeRemove(&pIter->nodeQueue);
     862            svgaCBFree(pCBState, pIter);
     863        }
     864    }
     865
     866    if (pCBState->pCBCurrent)
     867    {
     868        svgaCBFree(pCBState, pCBState->pCBCurrent);
     869        pCBState->pCBCurrent = NULL;
     870    }
     871
     872    svgaCBHeaderPoolDestroy(&pCBState->HeaderPool);
     873
    836874    GaMemFree(pCBState);
    837875    return STATUS_SUCCESS;
     
    851889        RTListInit(&pCBCtx->QueuePending);
    852890        RTListInit(&pCBCtx->QueueSubmitted);
    853         RTListInit(&pCBCtx->QueuePreempted);
    854891        //pCBCtx->cSubmitted = 0;
    855892    }
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