VirtualBox

Ignore:
Timestamp:
Sep 29, 2010 4:50:53 PM (14 years ago)
Author:
vboxsync
Message:

wddm/2d: 2D video accel support fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVhwa.cpp

    r30973 r32823  
    1818#endif
    1919
     20#define VBOXVHWA_PRIMARY_ALLOCATION(_pSrc) ((_pSrc)->pPrimaryAllocation)
    2021
    2122
     
    342343}
    343344
     345DECLINLINE(VOID) vboxVhwaHlpOverlayListInit(PDEVICE_EXTENSION pDevExt, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId)
     346{
     347    PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[VidPnSourceId];
     348    pSource->cOverlays = 0;
     349    InitializeListHead(&pSource->OverlayList);
     350    KeInitializeSpinLock(&pSource->OverlayListLock);
     351}
     352
    344353static void vboxVhwaInitSrc(PDEVICE_EXTENSION pDevExt, D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId)
    345354{
     
    347356    VBOXVHWA_INFO *pSettings = &pDevExt->aSources[srcId].Vhwa.Settings;
    348357    memset (pSettings, 0, sizeof (VBOXVHWA_INFO));
     358
     359    vboxVhwaHlpOverlayListInit(pDevExt, srcId);
    349360
    350361    VBOXVHWACMD_QUERYINFO1* pInfo1 = vboxVhwaQueryHostInfo1(pDevExt, srcId);
     
    685696int vboxVhwaHlpDestroyPrimary(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_SOURCE pSource, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId)
    686697{
    687     PVBOXWDDM_ALLOCATION pFbSurf = VBOXWDDM_FB_ALLOCATION(pSource);
     698    PVBOXWDDM_ALLOCATION pFbSurf = VBOXVHWA_PRIMARY_ALLOCATION(pSource);
    688699
    689700    int rc = vboxVhwaHlpDestroySurface(pDevExt, pFbSurf, VidPnSourceId);
     
    694705int vboxVhwaHlpCreatePrimary(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_SOURCE pSource, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId)
    695706{
    696     PVBOXWDDM_ALLOCATION pFbSurf = VBOXWDDM_FB_ALLOCATION(pSource);
     707    PVBOXWDDM_ALLOCATION pFbSurf = VBOXVHWA_PRIMARY_ALLOCATION(pSource);
    697708    Assert(pSource->Vhwa.cOverlaysCreated == 1);
    698709    Assert(pFbSurf->hHostHandle == VBOXVHWA_SURFHANDLE_INVALID);
     
    739750    else
    740751    {
    741         PVBOXWDDM_ALLOCATION pFbSurf = VBOXWDDM_FB_ALLOCATION(pSource);
     752        PVBOXWDDM_ALLOCATION pFbSurf = VBOXVHWA_PRIMARY_ALLOCATION(pSource);
    742753        Assert(pFbSurf->hHostHandle);
    743754        if (pFbSurf->hHostHandle)
     
    789800    PVBOXWDDM_SOURCE pSource = &pOverlay->pDevExt->aSources[pOverlay->VidPnSourceId];
    790801    Assert(!!(pSource->Vhwa.Settings.fFlags & VBOXVHWA_F_ENABLED));
    791     PVBOXWDDM_ALLOCATION pFbSurf = VBOXWDDM_FB_ALLOCATION(pSource);
     802    PVBOXWDDM_ALLOCATION pFbSurf = VBOXVHWA_PRIMARY_ALLOCATION(pSource);
    792803    Assert(pFbSurf);
    793804    Assert(pFbSurf->hHostHandle);
     
    856867AssertCompile(RT_OFFSETOF(RECT, bottom) == RT_OFFSETOF(VBOXVHWA_RECTL, bottom));
    857868
     869int vboxVhwaHlpColorFill(PVBOXWDDM_OVERLAY pOverlay, PVBOXWDDM_DMA_PRIVATEDATA_CLRFILL pCF)
     870{
     871    PVBOXWDDM_ALLOCATION pAlloc = pCF->ClrFill.Alloc.pAlloc;
     872    Assert(pAlloc->pResource == pOverlay->pResource);
     873#ifdef VBOXWDDM_RENDER_FROM_SHADOW
     874    if (pAlloc->bAssigned)
     875    {
     876        /* check if this is a primary surf */
     877        PVBOXWDDM_SOURCE pSource = &pOverlay->pDevExt->aSources[pOverlay->VidPnSourceId];
     878        if (pSource->pPrimaryAllocation == pAlloc)
     879        {
     880            pAlloc = pSource->pShadowAllocation;
     881            Assert(pAlloc->pResource == pOverlay->pResource);
     882        }
     883    }
     884#endif
     885    Assert(pAlloc->hHostHandle);
     886    Assert(pAlloc->pResource);
     887    Assert(pAlloc->offVram != VBOXVIDEOOFFSET_VOID);
     888
     889    int rc;
     890    VBOXVHWACMD* pCmd = vboxVhwaCommandCreate(pOverlay->pDevExt, pOverlay->VidPnSourceId,
     891                VBOXVHWACMD_TYPE_SURF_FLIP, RT_OFFSETOF(VBOXVHWACMD_SURF_COLORFILL, u.in.aRects[pCF->ClrFill.Rects.cRects]));
     892    Assert(pCmd);
     893    if(pCmd)
     894    {
     895        VBOXVHWACMD_SURF_COLORFILL * pBody = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_SURF_COLORFILL);
     896
     897        memset(pBody, 0, sizeof(VBOXVHWACMD_SURF_COLORFILL));
     898
     899        pBody->u.in.hSurf = pAlloc->hHostHandle;
     900        pBody->u.in.offSurface = pAlloc->offVram;
     901        pBody->u.in.cRects = pCF->ClrFill.Rects.cRects;
     902        memcpy (pBody->u.in.aRects, pCF->ClrFill.Rects.aRects, pCF->ClrFill.Rects.cRects * sizeof (pCF->ClrFill.Rects.aRects[0]));
     903        vboxVhwaCommandSubmitAsynchAndComplete(pOverlay->pDevExt, pCmd);
     904
     905        rc = VINF_SUCCESS;
     906    }
     907    else
     908        rc = VERR_OUT_OF_RESOURCES;
     909
     910    return rc;
     911}
     912
     913static void vboxVhwaHlpOverlayDstRectSet(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_OVERLAY pOverlay, const RECT *pRect)
     914{
     915    PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[pOverlay->VidPnSourceId];
     916    KIRQL OldIrql;
     917    KeAcquireSpinLock(&pSource->OverlayListLock, &OldIrql);
     918    pOverlay->DstRect = *pRect;
     919    KeReleaseSpinLock(&pSource->OverlayListLock, OldIrql);
     920}
     921
     922AssertCompile(sizeof (RECT) == sizeof (VBOXVHWA_RECTL));
     923AssertCompile(RT_SIZEOFMEMB(RECT, left) == RT_SIZEOFMEMB(VBOXVHWA_RECTL, left));
     924AssertCompile(RT_SIZEOFMEMB(RECT, right) == RT_SIZEOFMEMB(VBOXVHWA_RECTL, right));
     925AssertCompile(RT_SIZEOFMEMB(RECT, top) == RT_SIZEOFMEMB(VBOXVHWA_RECTL, top));
     926AssertCompile(RT_SIZEOFMEMB(RECT, bottom) == RT_SIZEOFMEMB(VBOXVHWA_RECTL, bottom));
     927AssertCompile(RT_OFFSETOF(RECT, left) == RT_OFFSETOF(VBOXVHWA_RECTL, left));
     928AssertCompile(RT_OFFSETOF(RECT, right) == RT_OFFSETOF(VBOXVHWA_RECTL, right));
     929AssertCompile(RT_OFFSETOF(RECT, top) == RT_OFFSETOF(VBOXVHWA_RECTL, top));
     930AssertCompile(RT_OFFSETOF(RECT, bottom) == RT_OFFSETOF(VBOXVHWA_RECTL, bottom));
     931
    858932int vboxVhwaHlpOverlayUpdate(PVBOXWDDM_OVERLAY pOverlay, const DXGK_OVERLAYINFO *pOverlayInfo)
    859933{
     
    866940    PVBOXWDDM_SOURCE pSource = &pOverlay->pDevExt->aSources[pOverlay->VidPnSourceId];
    867941    Assert(!!(pSource->Vhwa.Settings.fFlags & VBOXVHWA_F_ENABLED));
    868     PVBOXWDDM_ALLOCATION pFbSurf = VBOXWDDM_FB_ALLOCATION(pSource);
     942    PVBOXWDDM_ALLOCATION pFbSurf = VBOXVHWA_PRIMARY_ALLOCATION(pSource);
    869943    Assert(pFbSurf);
    870944    Assert(pFbSurf->hHostHandle);
     
    924998            pOverlay->pCurentAlloc = pAlloc;
    925999
     1000            vboxVhwaHlpOverlayDstRectSet(pOverlay->pDevExt, pOverlay, &pOverlayInfo->DstRect);
     1001
    9261002            rc = VINF_SUCCESS;
    9271003        }
     
    10081084    return rc;
    10091085}
     1086
     1087BOOLEAN vboxVhwaHlpOverlayListIsEmpty(PDEVICE_EXTENSION pDevExt, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId)
     1088{
     1089    PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[VidPnSourceId];
     1090    return !ASMAtomicReadU32(&pSource->cOverlays);
     1091}
     1092
     1093void vboxVhwaHlpOverlayListAdd(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_OVERLAY pOverlay)
     1094{
     1095    PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[pOverlay->VidPnSourceId];
     1096    KIRQL OldIrql;
     1097    KeAcquireSpinLock(&pSource->OverlayListLock, &OldIrql);
     1098    ASMAtomicIncU32(&pSource->cOverlays);
     1099    InsertHeadList(&pSource->OverlayList, &pOverlay->ListEntry);
     1100    KeReleaseSpinLock(&pSource->OverlayListLock, OldIrql);
     1101}
     1102
     1103void vboxVhwaHlpOverlayListRemove(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_OVERLAY pOverlay)
     1104{
     1105    PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[pOverlay->VidPnSourceId];
     1106    KIRQL OldIrql;
     1107    KeAcquireSpinLock(&pSource->OverlayListLock, &OldIrql);
     1108    ASMAtomicDecU32(&pSource->cOverlays);
     1109    RemoveEntryList(&pOverlay->ListEntry);
     1110    KeReleaseSpinLock(&pSource->OverlayListLock, OldIrql);
     1111}
     1112
     1113#define VBOXWDDM_OVERLAY_FROM_ENTRY(_pEntry) ((PVBOXWDDM_OVERLAY)(((uint8_t*)(_pEntry)) - RT_OFFSETOF(VBOXWDDM_OVERLAY, ListEntry)))
     1114
     1115void vboxVhwaHlpOverlayDstRectUnion(PDEVICE_EXTENSION pDevExt, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId, RECT *pRect)
     1116{
     1117    if (vboxVhwaHlpOverlayListIsEmpty(pDevExt, VidPnSourceId))
     1118    {
     1119        memset(pRect, 0, sizeof (*pRect));
     1120        return;
     1121    }
     1122
     1123    PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[VidPnSourceId];
     1124    KIRQL OldIrql;
     1125    KeAcquireSpinLock(&pSource->OverlayListLock, &OldIrql);
     1126    if (pSource->cOverlays)
     1127    {
     1128        PVBOXWDDM_OVERLAY pOverlay = VBOXWDDM_OVERLAY_FROM_ENTRY(pSource->OverlayList.Flink);
     1129        *pRect = pOverlay->DstRect;
     1130        while (pOverlay->ListEntry.Flink != &pSource->OverlayList)
     1131        {
     1132            pOverlay = VBOXWDDM_OVERLAY_FROM_ENTRY(pOverlay->ListEntry.Flink);
     1133            vboxWddmRectUnite(pRect, &pOverlay->DstRect);
     1134        }
     1135    }
     1136    KeReleaseSpinLock(&pSource->OverlayListLock, OldIrql);
     1137}
     1138
     1139void vboxVhwaHlpOverlayDstRectGet(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_OVERLAY pOverlay, RECT *pRect)
     1140{
     1141    PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[pOverlay->VidPnSourceId];
     1142    KIRQL OldIrql;
     1143    KeAcquireSpinLock(&pSource->OverlayListLock, &OldIrql);
     1144    *pRect = pOverlay->DstRect;
     1145    KeReleaseSpinLock(&pSource->OverlayListLock, OldIrql);
     1146}
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