VirtualBox

Ignore:
Timestamp:
Nov 2, 2010 9:48:55 PM (14 years ago)
Author:
vboxsync
Message:

Additions/WINNT/Graphics: more refactoring

Location:
trunk/src/VBox/Additions/WINNT/Graphics/Miniport
Files:
6 edited

Legend:

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

    r33676 r33711  
    14751475}
    14761476
    1477 BOOLEAN VBoxUnmapAdpInfoCallback(PVOID ext)
    1478 {
    1479     PDEVICE_EXTENSION   PrimaryExtension = (PDEVICE_EXTENSION)ext;
    1480     Assert(PrimaryExtension);
    1481 
    1482     commonFromDeviceExt(PrimaryExtension)->pHostFlags = NULL;
    1483     return TRUE;
    1484 }
    1485 
    1486 void VBoxUnmapAdapterInformation(PDEVICE_EXTENSION PrimaryExtension)
    1487 {
    1488     void                *ppv;
    1489 
    1490     dprintf(("VBoxVideo::VBoxUnmapAdapterInformation\n"));
    1491 
    1492     ppv = commonFromDeviceExt(PrimaryExtension)->pvAdapterInformation;
    1493     if (ppv)
    1494     {
     1477bool VBoxSyncToVideoIRQ(PVBOXVIDEO_COMMON pCommon, PFNVIDEOIRQSYNC pfnSync,
     1478                        void *pvUser)
     1479{
     1480    PDEVICE_EXTENSION PrimaryExtension = commonToPrimaryExt(pCommon);
     1481    PMINIPORT_SYNCHRONIZE_ROUTINE pfnSyncMiniport;
     1482    pfnSyncMiniport = (PMINIPORT_SYNCHRONIZE_ROUTINE) pfnSync;
    14951483#ifndef VBOX_WITH_WDDM
    1496         /* The pHostFlags field is mapped through pvAdapterInformation. It must be cleared first,
    1497          * and it must be done in a way which avoids races with the interrupt handler.
    1498          */
    1499         VideoPortSynchronizeExecution(PrimaryExtension, VpMediumPriority,
    1500                                       VBoxUnmapAdpInfoCallback, PrimaryExtension);
    1501         VideoPortUnmapMemory(PrimaryExtension, ppv, NULL);
     1484    return !!VideoPortSynchronizeExecution(PrimaryExtension, VpMediumPriority,
     1485                                           pfnSyncMiniport, pvUser);
    15021486#else
    1503         BOOLEAN bRet;
    1504         NTSTATUS ntStatus = PrimaryExtension->u.primary.DxgkInterface.DxgkCbSynchronizeExecution(PrimaryExtension->u.primary.DxgkInterface.DeviceHandle,
    1505                 VBoxUnmapAdpInfoCallback, PrimaryExtension,
    1506                 0, &bRet);
    1507         Assert(ntStatus == STATUS_SUCCESS);
    1508         ntStatus = PrimaryExtension->u.primary.DxgkInterface.DxgkCbUnmapMemory(PrimaryExtension->u.primary.DxgkInterface.DeviceHandle,
    1509                 ppv);
    1510         Assert(ntStatus == STATUS_SUCCESS);
    1511 #endif
    1512         commonFromDeviceExt(PrimaryExtension)->pvAdapterInformation = NULL;
    1513     }
    1514 }
    1515 
    1516 void VBoxUnmapAdapterMemory (PDEVICE_EXTENSION PrimaryExtension, void **ppv)
     1487    BOOLEAN fRet;
     1488    DXGKCB_SYNCHRONIZE_EXECUTION pfnDxgkCbSync =
     1489        PrimaryExtension->u.primary.DxgkInterface.DxgkCbSynchronizeExecution;
     1490    HANDLE hDev = PrimaryExtension->u.primary.DxgkInterface.DeviceHandle;
     1491    NTSTATUS ntStatus = pfnDxgkCbSync(hDev, pfnSyncMiniport, pvUser, 0, &fRet);
     1492    AssertReturn(ntStatus == STATUS_SUCCESS, false);
     1493    return !!fRet;
     1494#endif
     1495}
     1496
     1497void VBoxUnmapAdapterMemory (PVBOXVIDEO_COMMON pCommon, void **ppv)
    15171498{
    15181499    dprintf(("VBoxVideo::VBoxUnmapAdapterMemory\n"));
     1500
     1501    PDEVICE_EXTENSION PrimaryExtension = commonToPrimaryExt(pCommon);
    15191502
    15201503    if (*ppv)
     
    26912674    VbglTerminate ();
    26922675
    2693     VBoxFreeDisplaysHGSMI(pDevExt);
     2676    VBoxFreeDisplaysHGSMI(commonFromDeviceExt(pDevExt));
    26942677    /** @note using this callback instead of doing things manually adds an
    26952678     *        additional call to HGSMIHeapDestroy().  I assume that call was
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h

    r33676 r33711  
    807807                          ULONG ulSize);
    808808
    809 void VBoxUnmapAdapterMemory (PDEVICE_EXTENSION PrimaryExtension,
    810                              void **ppv);
    811 void VBoxUnmapAdapterInformation (PDEVICE_EXTENSION PrimaryExtension);
     809void VBoxUnmapAdapterMemory (PVBOXVIDEO_COMMON pCommon, void **ppv);
     810
     811typedef bool(*PFNVIDEOIRQSYNC)(void *);
     812bool VBoxSyncToVideoIRQ(PVBOXVIDEO_COMMON pCommon, PFNVIDEOIRQSYNC pfnSync,
     813                        void *pvUser);
    812814
    813815void VBoxComputeFrameBufferSizes (PDEVICE_EXTENSION PrimaryExtension);
     
    850852                                uint32_t cbLength);
    851853
    852 void VBoxFreeDisplaysHGSMI(PDEVICE_EXTENSION PrimaryExtension);
     854void VBoxFreeDisplaysHGSMI(PVBOXVIDEO_COMMON pCommon);
    853855#ifndef VBOX_WITH_WDDM
    854856DECLCALLBACK(void) hgsmiHostCmdComplete (HVBOXVIDEOHGSMI hHGSMI, struct _VBVAHOSTCMD * pCmd);
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideoHGSMI.cpp

    r33628 r33711  
    539539    }
    540540
    541 #ifdef VBOX_WITH_WDDM
    542     /* For WDDM, we simply store the number of monitors as we will deal with
    543      * VidPN stuff later */
    544     if (commonFromDeviceExt(PrimaryExtension)->bHGSMI)
    545     {
    546         ULONG ulAvailable = commonFromDeviceExt(PrimaryExtension)->cbVRAM
    547                             - commonFromDeviceExt(PrimaryExtension)->cbMiniportHeap
    548                             - VBVA_ADAPTER_INFORMATION_SIZE;
    549 
    550         ULONG ulSize;
    551         ULONG offset;
    552 #ifdef VBOX_WITH_VDMA
    553         ulSize = ulAvailable / 2;
    554         if (ulSize > VBOXWDDM_C_VDMA_BUFFER_SIZE)
    555             ulSize = VBOXWDDM_C_VDMA_BUFFER_SIZE;
    556 
    557         /* Align down to 4096 bytes. */
    558         ulSize &= ~0xFFF;
    559         offset = ulAvailable - ulSize;
    560 
    561         Assert(!(offset & 0xFFF));
    562 #else
    563         offset = ulAvailable;
    564 #endif
    565         rc = vboxVdmaCreate (PrimaryExtension, &PrimaryExtension->u.primary.Vdma
    566 #ifdef VBOX_WITH_VDMA
    567                 , offset, ulSize
    568 #endif
    569                 );
    570         AssertRC(rc);
    571         if (RT_SUCCESS(rc))
    572         {
    573             /* can enable it right away since the host does not need any screen/FB info
    574              * for basic DMA functionality */
    575             rc = vboxVdmaEnable(PrimaryExtension, &PrimaryExtension->u.primary.Vdma);
    576             AssertRC(rc);
    577             if (RT_FAILURE(rc))
    578                 vboxVdmaDestroy(PrimaryExtension, &PrimaryExtension->u.primary.Vdma);
    579         }
    580 
    581         ulAvailable = offset;
    582         ulSize = ulAvailable/2;
    583         offset = ulAvailable - ulSize;
    584 
    585         NTSTATUS Status = vboxVideoAMgrCreate(PrimaryExtension, &PrimaryExtension->AllocMgr, offset, ulSize);
    586         Assert(Status == STATUS_SUCCESS);
    587         if (Status != STATUS_SUCCESS)
    588         {
    589             offset = ulAvailable;
    590         }
    591 
    592 #ifdef VBOXWDDM_RENDER_FROM_SHADOW
    593         if (RT_SUCCESS(rc))
    594         {
    595             ulAvailable = offset;
    596             ulSize = ulAvailable / 2;
    597             ulSize /= commonFromDeviceExt(PrimaryExtension)->cDisplays;
    598             Assert(ulSize > VBVA_MIN_BUFFER_SIZE);
    599             if (ulSize > VBVA_MIN_BUFFER_SIZE)
    600             {
    601                 ULONG ulRatio = ulSize/VBVA_MIN_BUFFER_SIZE;
    602                 ulRatio >>= 4; /* /= 16; */
    603                 if (ulRatio)
    604                     ulSize = VBVA_MIN_BUFFER_SIZE * ulRatio;
    605                 else
    606                     ulSize = VBVA_MIN_BUFFER_SIZE;
    607             }
    608             else
    609             {
    610                 /* todo: ?? */
    611             }
    612 
    613             ulSize &= ~0xFFF;
    614             Assert(ulSize);
    615 
    616             Assert(ulSize * commonFromDeviceExt(PrimaryExtension)->cDisplays < ulAvailable);
    617 
    618             for (int i = commonFromDeviceExt(PrimaryExtension)->cDisplays-1; i >= 0; --i)
    619             {
    620                 offset -= ulSize;
    621                 rc = vboxVbvaCreate(PrimaryExtension, &PrimaryExtension->aSources[i].Vbva, offset, ulSize, i);
    622                 AssertRC(rc);
    623                 if (RT_SUCCESS(rc))
    624                 {
    625                     rc = vboxVbvaEnable(PrimaryExtension, &PrimaryExtension->aSources[i].Vbva);
    626                     AssertRC(rc);
    627                     if (RT_FAILURE(rc))
    628                     {
    629                         /* @todo: de-initialize */
    630                     }
    631                 }
    632             }
    633         }
    634 #endif
    635 
    636         rc = VBoxMapAdapterMemory(commonFromDeviceExt(PrimaryExtension), (void**)&PrimaryExtension->pvVisibleVram,
    637                                        0,
    638                                        vboxWddmVramCpuVisibleSize(PrimaryExtension));
    639         Assert(rc == VINF_SUCCESS);
    640         if (rc != VINF_SUCCESS)
    641             PrimaryExtension->pvVisibleVram = NULL;
    642 
    643         if (RT_FAILURE(rc))
    644             commonFromDeviceExt(PrimaryExtension)->bHGSMI = FALSE;
    645     }
    646 #endif
    647 
    648541    if (!commonFromDeviceExt(PrimaryExtension)->bHGSMI)
    649         VBoxFreeDisplaysHGSMI(PrimaryExtension);
     542        VBoxFreeDisplaysHGSMI(commonFromDeviceExt(PrimaryExtension));
    650543
    651544    dprintf(("VBoxVideo::VBoxSetupDisplays: finished\n"));
    652545}
    653546
    654 void VBoxFreeDisplaysHGSMI(PDEVICE_EXTENSION PrimaryExtension)
    655 {
    656     VBoxUnmapAdapterMemory(PrimaryExtension, &commonFromDeviceExt(PrimaryExtension)->pvMiniportHeap);
    657     HGSMIHeapDestroy(&commonFromDeviceExt(PrimaryExtension)->hgsmiAdapterHeap);
     547static bool VBoxUnmapAdpInfoCallback(PVOID pvCommon)
     548{
     549    PVBOXVIDEO_COMMON pCommon = (PVBOXVIDEO_COMMON)pvCommon;
     550
     551    pCommon->pHostFlags = NULL;
     552    return TRUE;
     553}
     554
     555void VBoxFreeDisplaysHGSMI(PVBOXVIDEO_COMMON pCommon)
     556{
     557    VBoxUnmapAdapterMemory(pCommon, &pCommon->pvMiniportHeap);
     558    HGSMIHeapDestroy(&pCommon->hgsmiAdapterHeap);
    658559
    659560    /* Unmap the adapter information needed for HGSMI IO. */
    660     VBoxUnmapAdapterInformation(PrimaryExtension);
     561    VBoxSyncToVideoIRQ(pCommon, VBoxUnmapAdpInfoCallback, pCommon);
     562    VBoxUnmapAdapterMemory(pCommon, &pCommon->pvAdapterInformation);
    661563}
    662564
     
    746648    uint32_t cbData = 0;
    747649
    748     if (pointerAttr->Enable & VBOX_MOUSE_POINTER_SHAPE)
     650    if (!pointerAttr->Enable & VBOX_MOUSE_POINTER_SHAPE)
    749651    {
    750652        /* Size of the pointer data: sizeof (AND mask) + sizeof (XOR_MASK) */
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVbva.cpp

    r33628 r33711  
    125125{
    126126    int rc = VINF_SUCCESS;
    127     VBoxUnmapAdapterMemory(pDevExt, (void**)&pVbva->pVBVA);
     127    VBoxUnmapAdapterMemory(commonFromDeviceExt(pDevExt), (void**)&pVbva->pVBVA);
    128128    memset(pVbva, 0, sizeof(VBOXVBVAINFO));
    129129    return rc;
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVdma.cpp

    r33684 r33711  
    11161116            drprintf((__FUNCTION__": HGSMIHeapSetup failed rc = 0x%x\n", rc));
    11171117
    1118         VBoxUnmapAdapterMemory(pDevExt, &pvBuffer);
     1118        VBoxUnmapAdapterMemory(commonFromDeviceExt(pDevExt), &pvBuffer);
    11191119    }
    11201120    else
     
    11891189            rc = vboxVdmaDisable (pDevExt, pInfo);
    11901190#ifdef VBOX_WITH_VDMA
    1191         VBoxUnmapAdapterMemory (pDevExt, (void**)&pInfo->CmdHeap.area.pu8Base);
     1191        VBoxUnmapAdapterMemory (commonFromDeviceExt(pDevExt), (void**)&pInfo->CmdHeap.area.pu8Base);
    11921192#endif
    11931193    }
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp

    r33684 r33711  
    609609    Assert(pDevExt->pvVisibleVram);
    610610    if (pDevExt->pvVisibleVram)
    611         VBoxUnmapAdapterMemory(pDevExt, (void**)&pDevExt->pvVisibleVram);
     611        VBoxUnmapAdapterMemory(commonFromDeviceExt(pDevExt), (void**)&pDevExt->pvVisibleVram);
    612612
    613613    for (int i = commonFromDeviceExt(pDevExt)->cDisplays-1; i >= 0; --i)
     
    739739                    vboxWddmSetupDisplays(pContext);
    740740                    if (!commonFromDeviceExt(pContext)->bHGSMI)
    741                         VBoxFreeDisplaysHGSMI(pContext);
     741                        VBoxFreeDisplaysHGSMI(commonFromDeviceExt(pContext));
    742742                }
    743743                if (commonFromDeviceExt(pContext)->bHGSMI)
     
    813813    int rc = vboxWddmFreeDisplays(pDevExt);
    814814    if (RT_SUCCESS(rc))
    815         VBoxFreeDisplaysHGSMI(pDevExt);
     815        VBoxFreeDisplaysHGSMI(commonFromDeviceExt(pDevExt));
    816816    AssertRC(rc);
    817817    if (RT_SUCCESS(rc))
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