Index: trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp	(revision 30167)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp	(revision 30169)
@@ -942,5 +942,5 @@
         if (DeviceExtension->CurrentMode == 0)
 #else
-        if (!DeviceExtension->cSources || !DeviceExtension->aSources[0].pPrimaryAllocation)
+        if (!DeviceExtension->u.primary.cDisplays || !DeviceExtension->aSources[0].pPrimaryAllocation)
 #endif
         {
@@ -982,5 +982,5 @@
         }
 #else
-        if (DeviceExtension->cSources && DeviceExtension->aSources[0].pPrimaryAllocation)
+        if (DeviceExtension->u.primary.cDisplays && DeviceExtension->aSources[0].pPrimaryAllocation)
         {
             if (!xres)
@@ -1041,5 +1041,5 @@
                 if (DeviceExtension->CurrentMode != 0)
 #else
-                if (DeviceExtension->cSources && DeviceExtension->aSources[0].pPrimaryAllocation)
+                if (DeviceExtension->u.primary.cDisplays && DeviceExtension->aSources[0].pPrimaryAllocation)
 #endif
 #ifndef VBOX_WITH_MULTIMONITOR_FIX
@@ -1147,5 +1147,5 @@
                 if (DeviceExtension->CurrentMode == 0)
 #else
-                if (!DeviceExtension->cSources || !DeviceExtension->aSources[0].pPrimaryAllocation)
+                if (!DeviceExtension->u.primary.cDisplays || !DeviceExtension->aSources[0].pPrimaryAllocation)
 #endif
                 {
Index: trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h	(revision 30167)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h	(revision 30169)
@@ -178,4 +178,11 @@
 } VBOXWDDM_SOURCE, *PVBOXWDDM_SOURCE;
 
+typedef struct VBOXWDDM_TARGET
+{
+    uint32_t ScanLineState;
+    uint32_t HeightVisible;
+    uint32_t HeightTotal;
+} VBOXWDDM_TARGET, *PVBOXWDDM_TARGET;
+
 #endif
 
@@ -211,7 +218,7 @@
 
            BOOLEAN bVBoxVideoSupported;        /* TRUE if VBoxVideo extensions, including DualView, are supported by the host. */
-#ifndef VBOXWDDM
+
            int cDisplays;                      /* Number of displays. */
-#endif
+
            ULONG cbVRAM;                       /* The VRAM size. */
 
@@ -268,4 +275,6 @@
            VBOXVIDEOPORTPROCS VideoPortProcs;
 # else
+           /* committed VidPn handle */
+           D3DKMDT_HVIDPN hCommittedVidPn;
            /* Display Port handle and callbacks */
            DXGKRNL_INTERFACE DxgkInterface;
@@ -295,12 +304,6 @@
    BOOL bNotifyDxDpc;
 
-   ULONG cSources;
-   /* currently we define the array for the max possible size since we do not know
-    * the monitor count at the DxgkDdiAddDevice,
-    * i.e. we obtain the monitor count in DxgkDdiStartDevice due to implementation of the currently re-used XPDM functionality
-    *
-    * @todo: use the dynamic array size calculated at DxgkDdiAddDevice
-    * */
    VBOXWDDM_SOURCE aSources[VBOX_VIDEO_MAX_SCREENS];
+   VBOXWDDM_TARGET aTargets[VBOX_VIDEO_MAX_SCREENS];
 #endif
 } DEVICE_EXTENSION, *PDEVICE_EXTENSION;
Index: trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideoHGSMI.cpp
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideoHGSMI.cpp	(revision 30167)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideoHGSMI.cpp	(revision 30169)
@@ -923,5 +923,5 @@
 #else
             /* simply store the number of monitors, we will deal with VidPN stuff later */
-            PrimaryExtension->cSources = cDisplays;
+            PrimaryExtension->u.primary.cDisplays = cDisplays;
 #endif
         }
@@ -984,5 +984,5 @@
             ulAvailable = offset;
             ulSize = ulAvailable / 2;
-            ulSize /= PrimaryExtension->cSources;
+            ulSize /= PrimaryExtension->u.primary.cDisplays;
             Assert(ulSize > VBVA_MIN_BUFFER_SIZE);
             if (ulSize > VBVA_MIN_BUFFER_SIZE)
@@ -1003,7 +1003,7 @@
             Assert(ulSize);
 
-            Assert(ulSize * PrimaryExtension->cSources < ulAvailable);
-
-            for (int i = PrimaryExtension->cSources-1; i >= 0; --i)
+            Assert(ulSize * PrimaryExtension->u.primary.cDisplays < ulAvailable);
+
+            for (int i = PrimaryExtension->u.primary.cDisplays-1; i >= 0; --i)
             {
                 offset -= ulSize;
@@ -1049,5 +1049,5 @@
 {
     int rc = VINF_SUCCESS;
-    for (int i = PrimaryExtension->cSources-1; i >= 0; --i)
+    for (int i = PrimaryExtension->u.primary.cDisplays-1; i >= 0; --i)
     {
         rc = vboxVbvaDisable(PrimaryExtension, &PrimaryExtension->aSources[i].Vbva);
@@ -1300,5 +1300,5 @@
     uint32_t cDisplays = (uint32_t)PrimaryExtension->u.primary.cDisplays;
 #else
-    uint32_t cDisplays = (uint32_t)PrimaryExtension->cSources;
+    uint32_t cDisplays = (uint32_t)PrimaryExtension->u.primary.cDisplays;
 #endif
     const size_t size = RT_OFFSETOF(VBVA_CHANNELCONTEXTS, aContexts[cDisplays]);
Index: trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVhwa.cpp
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVhwa.cpp	(revision 30167)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVhwa.cpp	(revision 30169)
@@ -335,5 +335,5 @@
 static void vboxVHWAInitSrc(PDEVICE_EXTENSION pDevExt, D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId)
 {
-    Assert(srcId < pDevExt->cSources);
+    Assert(srcId < pDevExt->u.primary.cDisplays);
     VBOXVHWA_INFO *pSettings = &pDevExt->aSources[srcId].Vhwa.Settings;
     memset (pSettings, 0, sizeof (VBOXVHWA_INFO));
@@ -398,7 +398,7 @@
 void vboxVHWAInit(PDEVICE_EXTENSION pDevExt)
 {
-    for (uint32_t i = 0; i < pDevExt->cSources; ++i)
-    {
-        vboxVHWAInitSrc(pDevExt, i);
+    for (int i = 0; i < pDevExt->u.primary.cDisplays; ++i)
+    {
+        vboxVHWAInitSrc(pDevExt, (D3DDDI_VIDEO_PRESENT_SOURCE_ID)i);
     }
 }
@@ -408,5 +408,5 @@
     /* we do not allocate/map anything, just issue a Disable command
      * to ensure all pending commands are flushed */
-    for (uint32_t i = 0; i < pDevExt->cSources; ++i)
+    for (uint32_t i = 0; i < pDevExt->u.primary.cDisplays; ++i)
     {
         vboxVHWADisable(pDevExt, i);
@@ -660,5 +660,5 @@
 int vboxVhwaHlpGetSurfInfo(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pSurf)
 {
-    for (uint32_t i = 0; i < pDevExt->cSources; ++i)
+    for (uint32_t i = 0; i < pDevExt->u.primary.cDisplays; ++i)
     {
         PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[i];
@@ -708,6 +708,6 @@
 int vboxVhwaHlpCheckInit(PDEVICE_EXTENSION pDevExt, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId)
 {
-    Assert(VidPnSourceId < pDevExt->cSources);
-    if (VidPnSourceId >= pDevExt->cSources)
+    Assert(VidPnSourceId < pDevExt->u.primary.cDisplays);
+    if (VidPnSourceId >= pDevExt->u.primary.cDisplays)
         return VERR_INVALID_PARAMETER;
 
@@ -748,6 +748,6 @@
 int vboxVhwaHlpCheckTerm(PDEVICE_EXTENSION pDevExt, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId)
 {
-    Assert(VidPnSourceId < pDevExt->cSources);
-    if (VidPnSourceId >= pDevExt->cSources)
+    Assert(VidPnSourceId < pDevExt->u.primary.cDisplays);
+    if (VidPnSourceId >= pDevExt->u.primary.cDisplays)
         return VERR_INVALID_PARAMETER;
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVidPn.cpp
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVidPn.cpp	(revision 30167)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVidPn.cpp	(revision 30169)
@@ -1466,4 +1466,35 @@
 }
 
+NTSTATUS vboxVidPnEnumTargetsForSource(PDEVICE_EXTENSION pDevExt, D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
+        CONST D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId,
+        PFNVBOXVIDPNENUMTARGETSFORSOURCE pfnCallback, PVOID pContext)
+{
+    SIZE_T cTgtPaths;
+    NTSTATUS Status = pVidPnTopologyInterface->pfnGetNumPathsFromSource(hVidPnTopology, VidPnSourceId, &cTgtPaths);
+    Assert(Status == STATUS_SUCCESS);
+    if (Status == STATUS_SUCCESS)
+    {
+        for (SIZE_T i = 0; i < cTgtPaths; ++i)
+        {
+            D3DDDI_VIDEO_PRESENT_TARGET_ID VidPnTargetId;
+            Status = pVidPnTopologyInterface->pfnEnumPathTargetsFromSource(hVidPnTopology, VidPnSourceId, i, &VidPnTargetId);
+            Assert(Status == STATUS_SUCCESS);
+            if (Status == STATUS_SUCCESS)
+            {
+                if (!pfnCallback(pDevExt, hVidPnTopology, pVidPnTopologyInterface, VidPnSourceId, VidPnTargetId, cTgtPaths, pContext))
+                    break;
+            }
+            else
+            {
+                drprintf((__FUNCTION__": pfnEnumPathTargetsFromSource failed Status(0x%x)\n", Status));
+                break;
+            }
+        }
+    }
+    else
+        drprintf((__FUNCTION__": pfnGetNumPathsFromSource failed Status(0x%x)\n", Status));
+
+    return Status;
+}
 
 NTSTATUS vboxVidPnEnumPaths(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
@@ -1527,6 +1558,6 @@
 NTSTATUS vboxVidPnCommitSourceMode(struct _DEVICE_EXTENSION* pDevExt, D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId, CONST D3DKMDT_VIDPN_SOURCE_MODE* pVidPnSourceModeInfo, PVBOXWDDM_ALLOCATION pAllocation)
 {
-    Assert(srcId < pDevExt->cSources);
-    if (srcId < pDevExt->cSources)
+    Assert(srcId < (UINT)pDevExt->u.primary.cDisplays);
+    if (srcId < (UINT)pDevExt->u.primary.cDisplays)
     {
         PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[srcId];
@@ -1534,6 +1565,49 @@
     }
 
-    drprintf((__FUNCTION__": invalid srcId (%d), cSources(%d)\n", srcId, pDevExt->cSources));
+    drprintf((__FUNCTION__": invalid srcId (%d), cSources(%d)\n", srcId, pDevExt->u.primary.cDisplays));
     return STATUS_INVALID_PARAMETER;
+}
+
+typedef struct VBOXVIDPNCOMMITTARGETMODE
+{
+    NTSTATUS Status;
+    D3DKMDT_HVIDPN hVidPn;
+    const DXGK_VIDPN_INTERFACE* pVidPnInterface;
+} VBOXVIDPNCOMMITTARGETMODE;
+
+DECLCALLBACK(BOOLEAN) vboxVidPnCommitTargetModeEnum(PDEVICE_EXTENSION pDevExt, D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
+        CONST D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId, D3DDDI_VIDEO_PRESENT_TARGET_ID VidPnTargetId, SIZE_T cTgtPaths, PVOID pContext)
+{
+    VBOXVIDPNCOMMITTARGETMODE *pInfo = (VBOXVIDPNCOMMITTARGETMODE*)pContext;
+    Assert(cTgtPaths <= (SIZE_T)pDevExt->u.primary.cDisplays);
+    D3DKMDT_HVIDPNTARGETMODESET hVidPnTargetModeSet;
+    CONST DXGK_VIDPNTARGETMODESET_INTERFACE* pVidPnTargetModeSetInterface;
+    NTSTATUS Status = pInfo->pVidPnInterface->pfnAcquireTargetModeSet(pInfo->hVidPn, VidPnTargetId, &hVidPnTargetModeSet, &pVidPnTargetModeSetInterface);
+    Assert(Status == STATUS_SUCCESS);
+    if (Status == STATUS_SUCCESS)
+    {
+        CONST D3DKMDT_VIDPN_TARGET_MODE* pPinnedVidPnTargetModeInfo;
+        Status = pVidPnTargetModeSetInterface->pfnAcquirePinnedModeInfo(hVidPnTargetModeSet, &pPinnedVidPnTargetModeInfo);
+        Assert(Status == STATUS_SUCCESS);
+        if (Status == STATUS_SUCCESS)
+        {
+            VBOXWDDM_TARGET *pTarget = &pDevExt->aTargets[VidPnTargetId];
+            if (pTarget->HeightVisible != pPinnedVidPnTargetModeInfo->VideoSignalInfo.ActiveSize.cy
+                    || pTarget->HeightTotal != pPinnedVidPnTargetModeInfo->VideoSignalInfo.TotalSize.cy)
+            {
+                pTarget->HeightVisible = pPinnedVidPnTargetModeInfo->VideoSignalInfo.ActiveSize.cy;
+                pTarget->HeightTotal = pPinnedVidPnTargetModeInfo->VideoSignalInfo.TotalSize.cy;
+                pTarget->ScanLineState = 0;
+            }
+            pVidPnTargetModeSetInterface->pfnReleaseModeInfo(hVidPnTargetModeSet, pPinnedVidPnTargetModeInfo);
+        }
+
+        pInfo->pVidPnInterface->pfnReleaseTargetModeSet(pInfo->hVidPn, hVidPnTargetModeSet);
+    }
+    else
+        drprintf((__FUNCTION__": pfnAcquireTargetModeSet failed Status(0x%x)\n", Status));
+
+    pInfo->Status = Status;
+    return Status == STATUS_SUCCESS;
 }
 
@@ -1558,5 +1632,32 @@
             Status = vboxVidPnCommitSourceMode(pDevExt, srcId, pPinnedVidPnSourceModeInfo, pAllocation);
             Assert(Status == STATUS_SUCCESS);
-            if (Status != STATUS_SUCCESS)
+            if (Status == STATUS_SUCCESS)
+            {
+                D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology;
+                CONST DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface;
+                Status = pVidPnInterface->pfnGetTopology(hDesiredVidPn, &hVidPnTopology, &pVidPnTopologyInterface);
+                Assert(Status == STATUS_SUCCESS);
+                if (Status == STATUS_SUCCESS)
+                {
+                    VBOXVIDPNCOMMITTARGETMODE TgtModeInfo = {0};
+                    TgtModeInfo.Status = STATUS_SUCCESS; /* <- to ensure we're succeeded if no targets are set */
+                    TgtModeInfo.hVidPn = hDesiredVidPn;
+                    TgtModeInfo.pVidPnInterface = pVidPnInterface;
+                    Status = vboxVidPnEnumTargetsForSource(pDevExt, hVidPnTopology, pVidPnTopologyInterface,
+                            srcId,
+                            vboxVidPnCommitTargetModeEnum, &TgtModeInfo);
+                    Assert(Status == STATUS_SUCCESS);
+                    if (Status == STATUS_SUCCESS)
+                    {
+                        Status = TgtModeInfo.Status;
+                        Assert(Status == STATUS_SUCCESS);
+                    }
+                    else
+                        drprintf((__FUNCTION__": vboxVidPnEnumTargetsForSource failed Status(0x%x)\n", Status));
+                }
+                else
+                    drprintf((__FUNCTION__": pfnGetTopology failed Status(0x%x)\n", Status));
+            }
+            else
                 drprintf((__FUNCTION__": vboxVidPnCommitSourceMode failed Status(0x%x)\n", Status));
             /* release */
Index: trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVidPn.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVidPn.h	(revision 30167)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVidPn.h	(revision 30169)
@@ -79,4 +79,7 @@
 typedef FNVBOXVIDPNENUMMONITORSOURCEMODES *PFNVBOXVIDPNENUMMONITORSOURCEMODES;
 
+typedef DECLCALLBACK(BOOLEAN) FNVBOXVIDPNENUMTARGETSFORSOURCE(PDEVICE_EXTENSION pDevExt, D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
+        CONST D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId, D3DDDI_VIDEO_PRESENT_TARGET_ID VidPnTargetId, SIZE_T cTgtPaths, PVOID pContext);
+typedef FNVBOXVIDPNENUMTARGETSFORSOURCE *PFNVBOXVIDPNENUMTARGETSFORSOURCE;
 
 DECLCALLBACK(BOOLEAN) vboxVidPnCofuncModalityPathEnum(struct _DEVICE_EXTENSION* pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
@@ -113,4 +116,8 @@
         PFNVBOXVIDPNENUMMONITORSOURCEMODES pfnCallback, PVOID pContext);
 
+NTSTATUS vboxVidPnEnumTargetsForSource(PDEVICE_EXTENSION pDevExt, D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
+        CONST D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId,
+        PFNVBOXVIDPNENUMTARGETSFORSOURCE pfnCallback, PVOID pContext);
+
 NTSTATUS vboxVidPnPopulateMonitorSourceModeInfoFromLegacy(struct _DEVICE_EXTENSION* pDevExt,
         D3DKMDT_MONITOR_SOURCE_MODE *pMonitorSourceMode,
Index: trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp	(revision 30167)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp	(revision 30169)
@@ -139,5 +139,5 @@
         pView->u32ViewIndex     = pAllocation->SurfDesc.VidPnSourceId;
         pView->u32ViewOffset    = (uint32_t)offVram; /* we pretend the view is located at the start of each framebuffer */
-        pView->u32ViewSize      = vboxWddmVramCpuVisibleSegmentSize(pDevExt)/pDevExt->cSources;
+        pView->u32ViewSize      = vboxWddmVramCpuVisibleSegmentSize(pDevExt)/pDevExt->u.primary.cDisplays;
 
         pView->u32MaxScreenSize = pView->u32ViewSize;
@@ -645,6 +645,6 @@
                 {
                     drprintf(("VBoxVideoWddm: using HGSMI\n"));
-                    *NumberOfVideoPresentSources = pContext->cSources;
-                    *NumberOfChildren = pContext->cSources;
+                    *NumberOfVideoPresentSources = pContext->u.primary.cDisplays;
+                    *NumberOfChildren = pContext->u.primary.cDisplays;
                     dprintf(("VBoxVideoWddm: sources(%d), children(%d)\n", *NumberOfVideoPresentSources, *NumberOfChildren));
 #ifdef VBOX_WITH_VIDEOHWACCEL
@@ -1041,6 +1041,6 @@
 
     dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", MiniportDeviceContext));
-    Assert(ChildRelationsSize == (pDevExt->cSources + 1)*sizeof(DXGK_CHILD_DESCRIPTOR));
-    for (UINT i = 0; i < pDevExt->cSources; ++i)
+    Assert(ChildRelationsSize == (pDevExt->u.primary.cDisplays + 1)*sizeof(DXGK_CHILD_DESCRIPTOR));
+    for (UINT i = 0; i < pDevExt->u.primary.cDisplays; ++i)
     {
         ChildRelations[i].ChildDeviceType = TypeVideoOutput;
@@ -1232,5 +1232,5 @@
             pCaps->MaxOverlays = 0;
 #ifdef VBOX_WITH_VIDEOHWACCEL
-            for (uint32_t i = 0; i < pContext->cSources; ++i)
+            for (uint32_t i = 0; i < pContext->u.primary.cDisplays; ++i)
             {
                 if ( pContext->aSources[i].Vhwa.Settings.fFlags & VBOXVHWA_F_ENABLED)
@@ -1321,7 +1321,7 @@
                 memset (pQi, 0, sizeof (VBOXWDDM_QI));
                 pQi->u32Version = VBOXVIDEOIF_VERSION;
-                pQi->cInfos = pContext->cSources;
+                pQi->cInfos = pContext->u.primary.cDisplays;
 #ifdef VBOX_WITH_VIDEOHWACCEL
-                for (uint32_t i = 0; i < pContext->cSources; ++i)
+                for (uint32_t i = 0; i < pContext->u.primary.cDisplays; ++i)
                 {
                     pQi->aInfos[i] = pContext->aSources[i].Vhwa.Settings;
@@ -1597,5 +1597,5 @@
         {
             PVBOXWDDM_RCINFO pRcInfo = (PVBOXWDDM_RCINFO)pCreateAllocation->pPrivateDriverData;
-//            Assert(pRcInfo->RcDesc.VidPnSourceId < pDevExt->cSources);
+//            Assert(pRcInfo->RcDesc.VidPnSourceId < pDevExt->u.primary.cDisplays);
             Assert(pRcInfo->cAllocInfos == pCreateAllocation->NumAllocations);
             pResource = (PVBOXWDDM_RESOURCE)vboxWddmMemAllocZero(RT_OFFSETOF(VBOXWDDM_RESOURCE, aAllocations[pRcInfo->cAllocInfos]));
@@ -2644,5 +2644,5 @@
             if (Status == STATUS_SUCCESS && bSupported)
             {
-                for (UINT id = 0; id < pContext->cSources; ++id)
+                for (UINT id = 0; id < pContext->u.primary.cDisplays; ++id)
                 {
                     D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet;
@@ -2675,5 +2675,5 @@
                 if (Status == STATUS_SUCCESS && bSupported)
                 {
-                    for (UINT id = 0; id < pContext->cSources; ++id)
+                    for (UINT id = 0; id < pContext->u.primary.cDisplays; ++id)
                     {
                         D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet;
@@ -2785,5 +2785,5 @@
     if (Status == STATUS_SUCCESS)
     {
-        for (uint32_t i = 0; i < pDevExt->cSources; ++i)
+        for (uint32_t i = 0; i < pDevExt->u.primary.cDisplays; ++i)
         {
             Status = vboxVidPnCheckAddMonitorModes(pDevExt, i, D3DKMDT_MCO_DRIVER, &Resolution, 1, 0);
@@ -2902,6 +2902,6 @@
     NTSTATUS Status = STATUS_SUCCESS;
     PDEVICE_EXTENSION pDevExt = (PDEVICE_EXTENSION)hAdapter;
-    Assert(pDevExt->cSources > pSetVidPnSourceAddress->VidPnSourceId);
-    if (pDevExt->cSources > pSetVidPnSourceAddress->VidPnSourceId)
+    Assert(pDevExt->u.primary.cDisplays > pSetVidPnSourceAddress->VidPnSourceId);
+    if (pDevExt->u.primary.cDisplays > pSetVidPnSourceAddress->VidPnSourceId)
     {
         PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[pSetVidPnSourceAddress->VidPnSourceId];
@@ -2945,5 +2945,5 @@
     else
     {
-        drprintf((__FUNCTION__": invalid VidPnSourceId (%d), should be smaller than (%d)\n", pSetVidPnSourceAddress->VidPnSourceId, pDevExt->cSources));
+        drprintf((__FUNCTION__": invalid VidPnSourceId (%d), should be smaller than (%d)\n", pSetVidPnSourceAddress->VidPnSourceId, pDevExt->u.primary.cDisplays));
         Status = STATUS_INVALID_PARAMETER;
     }
@@ -2970,6 +2970,6 @@
     NTSTATUS Status = STATUS_SUCCESS;
     PDEVICE_EXTENSION pDevExt = (PDEVICE_EXTENSION)hAdapter;
-    Assert(pDevExt->cSources > pSetVidPnSourceVisibility->VidPnSourceId);
-    if (pDevExt->cSources > pSetVidPnSourceVisibility->VidPnSourceId)
+    Assert(pDevExt->u.primary.cDisplays > pSetVidPnSourceVisibility->VidPnSourceId);
+    if (pDevExt->u.primary.cDisplays > pSetVidPnSourceVisibility->VidPnSourceId)
     {
         PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[pSetVidPnSourceVisibility->VidPnSourceId];
@@ -2997,5 +2997,5 @@
     else
     {
-        drprintf((__FUNCTION__": invalid VidPnSourceId (%d), should be smaller than (%d)\n", pSetVidPnSourceVisibility->VidPnSourceId, pDevExt->cSources));
+        drprintf((__FUNCTION__": invalid VidPnSourceId (%d), should be smaller than (%d)\n", pSetVidPnSourceVisibility->VidPnSourceId, pDevExt->u.primary.cDisplays));
         Status = STATUS_INVALID_PARAMETER;
     }
@@ -3036,5 +3036,5 @@
         {
             /* clear all current primaries */
-            for (UINT i = 0; i < pDevExt->cSources; ++i)
+            for (UINT i = 0; i < pDevExt->u.primary.cDisplays; ++i)
             {
                 vboxWddmAssignPrimary(pDevExt, &pDevExt->aSources[i], NULL, i);
@@ -3066,4 +3066,9 @@
                 drprintf((__FUNCTION__ ": pfnGetTopology failed Status(0x%x)\n", Status));
         }
+
+        if (Status == STATUS_SUCCESS)
+        {
+            pDevExt->u.primary.hCommittedVidPn = pCommitVidPnArg->hFunctionalVidPn;
+        }
     }
     else
@@ -3176,8 +3181,30 @@
     dfprintf(("==> "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
 
-    AssertBreakpoint();
-
-    pGetScanLine->InVerticalBlank = FALSE;
-    pGetScanLine->ScanLine = 0;
+    PDEVICE_EXTENSION pDevExt = (PDEVICE_EXTENSION)hAdapter;
+
+    Assert(pDevExt->u.primary.cDisplays > pGetScanLine->VidPnTargetId);
+    VBOXWDDM_TARGET *pTarget = &pDevExt->aTargets[pGetScanLine->VidPnTargetId];
+    Assert(pTarget->HeightTotal);
+    Assert(pTarget->HeightVisible);
+    Assert(pTarget->HeightTotal > pTarget->HeightVisible);
+    Assert(pTarget->ScanLineState < pTarget->HeightTotal);
+    if (pTarget->HeightTotal)
+    {
+        uint32_t curScanLine = pTarget->ScanLineState;
+        BOOLEAN bVBlanck;
+        ++pTarget->ScanLineState;
+        if (pTarget->ScanLineState >= pTarget->HeightTotal)
+            pTarget->ScanLineState = 0;
+
+
+        BOOL bVBlank = (!curScanLine || curScanLine > pTarget->HeightVisible);
+        pGetScanLine->ScanLine = curScanLine;
+        pGetScanLine->InVerticalBlank = bVBlank;
+    }
+    else
+    {
+        pGetScanLine->InVerticalBlank = TRUE;
+        pGetScanLine->ScanLine = 0;
+    }
 
     dfprintf(("<== "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
@@ -3431,5 +3458,5 @@
 
     D3DDDI_VIDEO_PRESENT_SOURCE_ID id = pAllocation->SurfDesc.VidPnSourceId;
-    if (id >=  pDevExt->cSources)
+    if (id >=  pDevExt->u.primary.cDisplays)
         return false;
 
