VirtualBox

Ignore:
Timestamp:
Oct 9, 2010 4:01:01 PM (14 years ago)
Author:
vboxsync
Message:

Additions/WINNT/Graphics: more refactoring

File:
1 edited

Legend:

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

    r32989 r33022  
    120120    {
    121121        bool bLock = false;
    122         if(!(PrimaryExtension->u.primary.pHostFlags->u32HostFlags & HGSMIHOSTFLAGS_COMMANDS_PENDING))
     122        if(!(commonFromDeviceExt(PrimaryExtension)->pHostFlags->u32HostFlags & HGSMIHOSTFLAGS_COMMANDS_PENDING))
    123123        {
    124124            if(!bProcessing)
     
    126126                break;
    127127            }
    128             VBOX_HGSMI_LOCK(PrimaryExtension, &PrimaryExtension->u.primary.pSynchLock, flags, &OldIrql);
    129             if(!(PrimaryExtension->u.primary.pHostFlags->u32HostFlags & HGSMIHOSTFLAGS_COMMANDS_PENDING))
    130             {
    131                 Assert(PrimaryExtension->u.primary.bHostCmdProcessing);
    132                 PrimaryExtension->u.primary.bHostCmdProcessing = false;
    133                 VBOX_HGSMI_UNLOCK(PrimaryExtension, &PrimaryExtension->u.primary.pSynchLock, flags, OldIrql);
     128            VBOX_HGSMI_LOCK(PrimaryExtension, &commonFromDeviceExt(PrimaryExtension)->pSynchLock, flags, &OldIrql);
     129            if(!(commonFromDeviceExt(PrimaryExtension)->pHostFlags->u32HostFlags & HGSMIHOSTFLAGS_COMMANDS_PENDING))
     130            {
     131                Assert(commonFromDeviceExt(PrimaryExtension)->bHostCmdProcessing);
     132                commonFromDeviceExt(PrimaryExtension)->bHostCmdProcessing = false;
     133                VBOX_HGSMI_UNLOCK(PrimaryExtension, &commonFromDeviceExt(PrimaryExtension)->pSynchLock, flags, OldIrql);
    134134                break;
    135135            }
    136             VBOX_HGSMI_UNLOCK(PrimaryExtension, &PrimaryExtension->u.primary.pSynchLock, flags, OldIrql);
     136            VBOX_HGSMI_UNLOCK(PrimaryExtension, &commonFromDeviceExt(PrimaryExtension)->pSynchLock, flags, OldIrql);
    137137        }
    138138        else
     
    140140            if(!bProcessing)
    141141            {
    142                 VBOX_HGSMI_LOCK(PrimaryExtension, &PrimaryExtension->u.primary.pSynchLock, flags, &OldIrql);
    143                 if(!(PrimaryExtension->u.primary.pHostFlags->u32HostFlags & HGSMIHOSTFLAGS_COMMANDS_PENDING)
    144                         || PrimaryExtension->u.primary.bHostCmdProcessing)
     142                VBOX_HGSMI_LOCK(PrimaryExtension, &commonFromDeviceExt(PrimaryExtension)->pSynchLock, flags, &OldIrql);
     143                if(!(commonFromDeviceExt(PrimaryExtension)->pHostFlags->u32HostFlags & HGSMIHOSTFLAGS_COMMANDS_PENDING)
     144                        || commonFromDeviceExt(PrimaryExtension)->bHostCmdProcessing)
    145145                {
    146                     VBOX_HGSMI_UNLOCK(PrimaryExtension, &PrimaryExtension->u.primary.pSynchLock, flags, OldIrql);
     146                    VBOX_HGSMI_UNLOCK(PrimaryExtension, &commonFromDeviceExt(PrimaryExtension)->pSynchLock, flags, OldIrql);
    147147                    break;
    148148                }
    149                 Assert(!PrimaryExtension->u.primary.bHostCmdProcessing);
    150                 PrimaryExtension->u.primary.bHostCmdProcessing = true;
    151                 VBOX_HGSMI_UNLOCK(PrimaryExtension, &PrimaryExtension->u.primary.pSynchLock, flags, OldIrql);
     149                Assert(!commonFromDeviceExt(PrimaryExtension)->bHostCmdProcessing);
     150                commonFromDeviceExt(PrimaryExtension)->bHostCmdProcessing = true;
     151                VBOX_HGSMI_UNLOCK(PrimaryExtension, &commonFromDeviceExt(PrimaryExtension)->pSynchLock, flags, OldIrql);
    152152                bProcessing = true;
    153153            }
     
    155155
    156156        Assert(bProcessing);
    157         Assert(PrimaryExtension->u.primary.bHostCmdProcessing);
    158         Assert((PrimaryExtension->u.primary.pHostFlags->u32HostFlags & HGSMIHOSTFLAGS_COMMANDS_PENDING) != 0);
     157        Assert(commonFromDeviceExt(PrimaryExtension)->bHostCmdProcessing);
     158        Assert((commonFromDeviceExt(PrimaryExtension)->pHostFlags->u32HostFlags & HGSMIHOSTFLAGS_COMMANDS_PENDING) != 0);
    159159        bProcessing = true;
    160160
     
    164164
    165165/* Detect whether HGSMI is supported by the host. */
    166 BOOLEAN VBoxHGSMIIsSupported (PDEVICE_EXTENSION PrimaryExtension)
     166BOOLEAN VBoxHGSMIIsSupported (void)
    167167{
    168168    USHORT DispiId;
     
    404404    VBVAINFOHEAP *p = (VBVAINFOHEAP *)pvData;
    405405
    406     p->u32HeapOffset = PrimaryExtension->u.primary.cbVRAM
    407                        - PrimaryExtension->u.primary.cbMiniportHeap
     406    p->u32HeapOffset = commonFromDeviceExt(PrimaryExtension)->cbVRAM
     407                       - commonFromDeviceExt(PrimaryExtension)->cbMiniportHeap
    408408                       - VBVA_ADAPTER_INFORMATION_SIZE;
    409     p->u32HeapSize = PrimaryExtension->u.primary.cbMiniportHeap;
     409    p->u32HeapSize = commonFromDeviceExt(PrimaryExtension)->cbMiniportHeap;
    410410
    411411    return VINF_SUCCESS;
     
    417417    HGSMIBUFFERLOCATION *p = (HGSMIBUFFERLOCATION *)pvData;
    418418
    419     p->offLocation = PrimaryExtension->u.primary.cbVRAM - sizeof (HGSMIHOSTFLAGS);
     419    p->offLocation = commonFromDeviceExt(PrimaryExtension)->cbVRAM - sizeof (HGSMIHOSTFLAGS);
    420420    p->cbLocation = sizeof (HGSMIHOSTFLAGS);
    421421
     
    724724    /* Preinitialize the primary extension.
    725725     * Note: bVBoxVideoSupported is set to FALSE, because HGSMI is active instead.
     726     * Note 2: shouldn't be needed for WDDM.
    726727     */
    727728    PrimaryExtension->pNext                              = NULL;
     
    737738    PrimaryExtension->u.primary.cDisplays                = 1;
    738739#endif
    739     PrimaryExtension->u.primary.cbVRAM                   = AdapterMemorySize;
    740     PrimaryExtension->u.primary.cbMiniportHeap           = 0;
    741     PrimaryExtension->u.primary.pvMiniportHeap           = NULL;
    742     PrimaryExtension->u.primary.pvAdapterInformation     = NULL;
    743     PrimaryExtension->u.primary.pHostFlags               = NULL;
     740    commonFromDeviceExt(PrimaryExtension)->cbVRAM                   = AdapterMemorySize;
     741    commonFromDeviceExt(PrimaryExtension)->cbMiniportHeap           = 0;
     742    commonFromDeviceExt(PrimaryExtension)->pvMiniportHeap           = NULL;
     743    commonFromDeviceExt(PrimaryExtension)->pvAdapterInformation     = NULL;
     744    commonFromDeviceExt(PrimaryExtension)->pHostFlags               = NULL;
    744745    PrimaryExtension->u.primary.ulMaxFrameBufferSize     = 0;
    745     commonFromDeviceExt(PrimaryExtension)->bHGSMI         = VBoxHGSMIIsSupported (PrimaryExtension);
     746    commonFromDeviceExt(PrimaryExtension)->bHGSMI         = VBoxHGSMIIsSupported ();
    746747    VBoxVideoCmnMemZero(&commonFromDeviceExt(PrimaryExtension)->areaHostHeap, sizeof(HGSMIAREA));
    747748    VBoxVideoCmnMemZero(&PrimaryExtension->areaDisplay, sizeof(HGSMIAREA));
     
    756757        /* Map the adapter information. It will be needed for HGSMI IO. */
    757758        rc = VBoxMapAdapterMemory (PrimaryExtension,
    758                                    &PrimaryExtension->u.primary.pvAdapterInformation,
    759                                    PrimaryExtension->u.primary.cbVRAM - VBVA_ADAPTER_INFORMATION_SIZE,
     759                                   &commonFromDeviceExt(PrimaryExtension)->pvAdapterInformation,
     760                                   commonFromDeviceExt(PrimaryExtension)->cbVRAM - VBVA_ADAPTER_INFORMATION_SIZE,
    760761                                   VBVA_ADAPTER_INFORMATION_SIZE
    761762                                  );
     
    771772            /* Setup a HGSMI heap within the adapter information area. */
    772773            rc = HGSMIHeapSetup (&commonFromDeviceExt(PrimaryExtension)->hgsmiAdapterHeap,
    773                                  PrimaryExtension->u.primary.pvAdapterInformation,
     774                                 commonFromDeviceExt(PrimaryExtension)->pvAdapterInformation,
    774775                                 VBVA_ADAPTER_INFORMATION_SIZE - sizeof(HGSMIHOSTFLAGS),
    775                                  PrimaryExtension->u.primary.cbVRAM - VBVA_ADAPTER_INFORMATION_SIZE,
     776                                 commonFromDeviceExt(PrimaryExtension)->cbVRAM - VBVA_ADAPTER_INFORMATION_SIZE,
    776777                                 false /*fOffsetBased*/);
    777778
     
    785786            else
    786787            {
    787                     PrimaryExtension->u.primary.pHostFlags = (HGSMIHOSTFLAGS*)(((uint8_t*)PrimaryExtension->u.primary.pvAdapterInformation)
     788                    commonFromDeviceExt(PrimaryExtension)->pHostFlags = (HGSMIHOSTFLAGS*)(((uint8_t*)commonFromDeviceExt(PrimaryExtension)->pvAdapterInformation)
    788789                                                            + VBVA_ADAPTER_INFORMATION_SIZE - sizeof(HGSMIHOSTFLAGS));
    789790            }
     
    814815
    815816            /* Round up to 4096 bytes. */
    816             PrimaryExtension->u.primary.cbMiniportHeap = (cbMiniportHeap + 0xFFF) & ~0xFFF;
     817            commonFromDeviceExt(PrimaryExtension)->cbMiniportHeap = (cbMiniportHeap + 0xFFF) & ~0xFFF;
    817818
    818819            dprintf(("VBoxVideo::VBoxSetupDisplays: cbMiniportHeap = 0x%08X, PrimaryExtension->u.primary.cbMiniportHeap = 0x%08X, cbMiniportHeapMaxSize = 0x%08X\n",
    819                      cbMiniportHeap, PrimaryExtension->u.primary.cbMiniportHeap, cbMiniportHeapMaxSize));
     820                     cbMiniportHeap, commonFromDeviceExt(PrimaryExtension)->cbMiniportHeap, cbMiniportHeapMaxSize));
    820821
    821822            /* Map the heap region.
     
    826827             */
    827828            rc = VBoxMapAdapterMemory (PrimaryExtension,
    828                                        &PrimaryExtension->u.primary.pvMiniportHeap,
    829                                        PrimaryExtension->u.primary.cbVRAM
     829                                       &commonFromDeviceExt(PrimaryExtension)->pvMiniportHeap,
     830                                       commonFromDeviceExt(PrimaryExtension)->cbVRAM
    830831                                       - VBVA_ADAPTER_INFORMATION_SIZE
    831                                        - PrimaryExtension->u.primary.cbMiniportHeap,
    832                                        PrimaryExtension->u.primary.cbMiniportHeap
     832                                       - commonFromDeviceExt(PrimaryExtension)->cbMiniportHeap,
     833                                       commonFromDeviceExt(PrimaryExtension)->cbMiniportHeap
    833834                                      );
    834835            if (rc != NO_ERROR)
    835836            {
    836                 PrimaryExtension->u.primary.pvMiniportHeap = NULL;
    837                 PrimaryExtension->u.primary.cbMiniportHeap = 0;
     837                commonFromDeviceExt(PrimaryExtension)->pvMiniportHeap = NULL;
     838                commonFromDeviceExt(PrimaryExtension)->cbMiniportHeap = 0;
    838839                commonFromDeviceExt(PrimaryExtension)->bHGSMI = FALSE;
    839840            }
    840841            else
    841842            {
    842                 HGSMIOFFSET offBase = PrimaryExtension->u.primary.cbVRAM
     843                HGSMIOFFSET offBase = commonFromDeviceExt(PrimaryExtension)->cbVRAM
    843844                                      - VBVA_ADAPTER_INFORMATION_SIZE
    844                                       - PrimaryExtension->u.primary.cbMiniportHeap;
     845                                      - commonFromDeviceExt(PrimaryExtension)->cbMiniportHeap;
    845846
    846847                /* Init the host hap area. Buffers from the host will be placed there. */
    847848                HGSMIAreaInitialize (&commonFromDeviceExt(PrimaryExtension)->areaHostHeap,
    848                                      PrimaryExtension->u.primary.pvMiniportHeap,
    849                                      PrimaryExtension->u.primary.cbMiniportHeap,
     849                                     commonFromDeviceExt(PrimaryExtension)->pvMiniportHeap,
     850                                     commonFromDeviceExt(PrimaryExtension)->cbMiniportHeap,
    850851                                     offBase);
    851852            }
     
    854855        {
    855856            /* Host has not requested a heap. */
    856             PrimaryExtension->u.primary.pvMiniportHeap = NULL;
    857             PrimaryExtension->u.primary.cbMiniportHeap = 0;
     857            commonFromDeviceExt(PrimaryExtension)->pvMiniportHeap = NULL;
     858            commonFromDeviceExt(PrimaryExtension)->cbMiniportHeap = 0;
    858859        }
    859860    }
     
    953954    if (commonFromDeviceExt(PrimaryExtension)->bHGSMI)
    954955    {
    955         ULONG ulAvailable = PrimaryExtension->u.primary.cbVRAM
    956                             - PrimaryExtension->u.primary.cbMiniportHeap
     956        ULONG ulAvailable = commonFromDeviceExt(PrimaryExtension)->cbVRAM
     957                            - commonFromDeviceExt(PrimaryExtension)->cbMiniportHeap
    957958                            - VBVA_ADAPTER_INFORMATION_SIZE;
    958959
     
    10471048    {
    10481049        /* Unmap the memory if VBoxVideo is not supported. */
    1049         VBoxUnmapAdapterMemory (PrimaryExtension, &PrimaryExtension->u.primary.pvMiniportHeap, PrimaryExtension->u.primary.cbMiniportHeap);
     1050        VBoxUnmapAdapterMemory (PrimaryExtension, &commonFromDeviceExt(PrimaryExtension)->pvMiniportHeap, commonFromDeviceExt(PrimaryExtension)->cbMiniportHeap);
    10501051        VBoxUnmapAdapterInformation (PrimaryExtension);
    10511052
     
    10551056    if (commonFromDeviceExt(PrimaryExtension)->bHGSMI)
    10561057    {
    1057         VBoxVideoCmnSpinLockCreate(PrimaryExtension, &PrimaryExtension->u.primary.pSynchLock);
     1058        VBoxVideoCmnSpinLockCreate(PrimaryExtension, &commonFromDeviceExt(PrimaryExtension)->pSynchLock);
    10581059    }
    10591060
     
    10931094        if (RT_SUCCESS(rc))
    10941095        {
    1095             /*rc = */VBoxUnmapAdapterMemory(PrimaryExtension, &PrimaryExtension->u.primary.pvMiniportHeap, PrimaryExtension->u.primary.cbMiniportHeap);
     1096            /*rc = */VBoxUnmapAdapterMemory(PrimaryExtension, &commonFromDeviceExt(PrimaryExtension)->pvMiniportHeap, commonFromDeviceExt(PrimaryExtension)->cbMiniportHeap);
    10961097/*
    10971098            AssertRC(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