Index: /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/Helper.cpp
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/Helper.cpp	(revision 27200)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/Helper.cpp	(revision 27201)
@@ -52,4 +52,9 @@
 #include "Helper.h"
 
+#ifdef DEBUG_misha
+bool g_bVBoxVDbgBreakF = true;
+bool g_bVBoxVDbgBreakFv = false;
+#endif
+
 /**
  * Globals
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/Helper.h
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/Helper.h	(revision 27200)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/Helper.h	(revision 27201)
@@ -81,4 +81,16 @@
 #endif
 
+#ifdef DEBUG_misha
+/* specifies whether the vboxVDbgBreakF should break in the debugger
+ * windbg seems to have some issues when there is a lot ( >~50) of sw breakpoints defined
+ * to simplify things we just insert breaks for the case of intensive debugging WDDM driver*/
+extern bool g_bVBoxVDbgBreakF;
+extern bool g_bVBoxVDbgBreakFv;
+#define vboxVDbgBreakF() do { if (g_bVBoxVDbgBreakF) AssertBreakpoint(); } while (0)
+#define vboxVDbgBreakFv() do { if (g_bVBoxVDbgBreakF) AssertBreakpoint(); } while (0)
+#else
+#define vboxVDbgBreakF() do { } while (0)
+#define vboxVDbgBreakFv() do { } while (0)
+#endif
 
 #endif // __HELPER_h__
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp	(revision 27200)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp	(revision 27201)
@@ -346,5 +346,5 @@
     ULONG vramSize = DeviceExtension->pPrimary->u.primary.ulMaxFrameBufferSize;
 #else
-    ULONG vramSize = vboxWddmVramReportedSize(DeviceExtension);
+    ULONG vramSize = vboxWddmVramReportedSegmentSize(DeviceExtension);
 
     gPreferredVideoMode = 0;
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h	(revision 27200)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h	(revision 27201)
@@ -581,4 +581,12 @@
 }
 
+DECLINLINE(ULONG) vboxWddmVramReportedSegmentSize(PDEVICE_EXTENSION pDevExt)
+{
+    ULONG size = vboxWddmVramReportedSize(pDevExt);
+    size /= 2;
+    size &= ~0xfffUL;
+    return size;
+}
+
 DECLINLINE(VOID) vboxWddmAssignPrimary(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_SOURCE pSource, PVBOXWDDM_ALLOCATION pAllocation, D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId)
 {
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVidPn.cpp
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVidPn.cpp	(revision 27200)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVidPn.cpp	(revision 27201)
@@ -496,4 +496,47 @@
 }
 
+NTSTATUS vboxVidPnPopulateVideoSignalInfo(PDEVICE_EXTENSION pDevExt,
+        D3DKMDT_VIDEO_SIGNAL_INFO *pVsi,
+        D3DKMDT_2DREGION *pResolution,
+        ULONG VSync)
+{
+    NTSTATUS Status = STATUS_SUCCESS;
+
+    pVsi->VideoStandard  = D3DKMDT_VSS_VESA_DMT;
+    pVsi->ActiveSize = *pResolution;
+    pVsi->VSyncFreq.Numerator = VSync * 1000;
+    pVsi->VSyncFreq.Denominator = 1000;
+    pVsi->TotalSize.cx = pVsi->ActiveSize.cx + VBOXVDPN_C_DISPLAY_HBLANK_SIZE;
+    pVsi->TotalSize.cy = pVsi->ActiveSize.cy + VBOXVDPN_C_DISPLAY_VBLANK_SIZE;
+    pVsi->PixelRate = pVsi->TotalSize.cx * pVsi->TotalSize.cy * VSync;
+    pVsi->HSyncFreq.Numerator = (UINT)((pVsi->PixelRate / pVsi->TotalSize.cy) * 1000);
+    pVsi->HSyncFreq.Denominator = 1000;
+    pVsi->ScanLineOrdering = D3DDDI_VSSLO_PROGRESSIVE;
+
+    return Status;
+}
+
+NTSTATUS vboxVidPnPopulateMonitorSourceModeInfoFromLegacy(PDEVICE_EXTENSION pDevExt,
+        D3DKMDT_MONITOR_SOURCE_MODE *pMonitorSourceMode,
+        D3DKMDT_2DREGION *pResolution,
+        D3DKMDT_MONITOR_CAPABILITIES_ORIGIN enmOrigin,
+        BOOLEAN bPreferred)
+{
+    NTSTATUS Status = vboxVidPnPopulateVideoSignalInfo(pDevExt, &pMonitorSourceMode->VideoSignalInfo, pResolution, 60 /* ULONG VSync */);
+    Assert(Status == STATUS_SUCCESS);
+    if (Status == STATUS_SUCCESS)
+    {
+        pMonitorSourceMode->ColorBasis = D3DKMDT_CB_SRGB;
+        pMonitorSourceMode->ColorCoeffDynamicRanges.FirstChannel = 8;
+        pMonitorSourceMode->ColorCoeffDynamicRanges.SecondChannel = 8;
+        pMonitorSourceMode->ColorCoeffDynamicRanges.ThirdChannel = 8;
+        pMonitorSourceMode->ColorCoeffDynamicRanges.FourthChannel = 0;
+        pMonitorSourceMode->Origin = enmOrigin;
+        pMonitorSourceMode->Preference = bPreferred ? D3DKMDT_MP_PREFERRED : D3DKMDT_MP_NOTPREFERRED;
+    }
+
+    return Status;
+}
+
 NTSTATUS vboxVidPnPopulateTargetModeInfoFromLegacy(PDEVICE_EXTENSION pDevExt,
         D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo,
@@ -501,18 +544,7 @@
         BOOLEAN bPreferred)
 {
-    NTSTATUS Status = STATUS_SUCCESS;
-
-    pNewVidPnTargetModeInfo->VideoSignalInfo.VideoStandard  = D3DKMDT_VSS_VESA_DMT;
-    pNewVidPnTargetModeInfo->VideoSignalInfo.TotalSize = *pResolution;
-    pNewVidPnTargetModeInfo->VideoSignalInfo.ActiveSize = pNewVidPnTargetModeInfo->VideoSignalInfo.TotalSize;
-    pNewVidPnTargetModeInfo->VideoSignalInfo.VSyncFreq.Numerator = 60000;
-    pNewVidPnTargetModeInfo->VideoSignalInfo.VSyncFreq.Denominator = 1000;
-    pNewVidPnTargetModeInfo->VideoSignalInfo.HSyncFreq.Numerator = pNewVidPnTargetModeInfo->VideoSignalInfo.ActiveSize.cy * 63; /* 63 is (60 * 1.05)*/
-    pNewVidPnTargetModeInfo->VideoSignalInfo.HSyncFreq.Denominator = 1;
-    pNewVidPnTargetModeInfo->VideoSignalInfo.PixelRate = 165000; /* @todo: ? */
-    pNewVidPnTargetModeInfo->VideoSignalInfo.ScanLineOrdering = D3DDDI_VSSLO_PROGRESSIVE;
     pNewVidPnTargetModeInfo->Preference = bPreferred ? D3DKMDT_MP_PREFERRED : D3DKMDT_MP_NOTPREFERRED;
 
-    return Status;
+    return vboxVidPnPopulateVideoSignalInfo(pDevExt, &pNewVidPnTargetModeInfo->VideoSignalInfo, pResolution, 60 /* ULONG VSync */);
 }
 
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVidPn.h
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVidPn.h	(revision 27200)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVidPn.h	(revision 27201)
@@ -16,4 +16,7 @@
 #ifndef ___VBoxVideoVidPn_h___
 #define ___VBoxVideoVidPn_h___
+
+#define VBOXVDPN_C_DISPLAY_HBLANK_SIZE 200
+#define VBOXVDPN_C_DISPLAY_VBLANK_SIZE 180
 
 NTSTATUS vboxVidPnCheckTopology(const D3DKMDT_HVIDPN hDesiredVidPn,
@@ -104,3 +107,9 @@
         PFNVBOXVIDPNENUMTARGETMODES pfnCallback, PVOID pContext);
 
+NTSTATUS vboxVidPnPopulateMonitorSourceModeInfoFromLegacy(struct _DEVICE_EXTENSION* pDevExt,
+        D3DKMDT_MONITOR_SOURCE_MODE *pMonitorSourceMode,
+        D3DKMDT_2DREGION *pResolution,
+        D3DKMDT_MONITOR_CAPABILITIES_ORIGIN enmOrigin,
+        BOOLEAN bPreferred);
+
 #endif /* #ifndef ___VBoxVideoVidPn_h___ */
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp	(revision 27200)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp	(revision 27201)
@@ -141,5 +141,5 @@
         pView->u32ViewIndex     = pPrimaryInfo->VidPnSourceId;
         pView->u32ViewOffset    = offVram;
-        pView->u32ViewSize      = vboxWddmVramReportedSize(pDevExt)/pDevExt->cSources;
+        pView->u32ViewSize      = vboxWddmVramReportedSegmentSize(pDevExt)/pDevExt->cSources;
 
         pView->u32MaxScreenSize = pView->u32ViewSize;
@@ -917,4 +917,6 @@
     PAGED_CODE();
 
+    vboxVDbgBreakFv();
+
     PDEVICE_EXTENSION pDevExt = (PDEVICE_EXTENSION)MiniportDeviceContext;
 
@@ -943,4 +945,6 @@
     /* The DxgkDdiQueryChildStatus should be made pageable. */
     PAGED_CODE();
+
+    vboxVDbgBreakFv();
 
     dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", MiniportDeviceContext));
@@ -959,4 +963,5 @@
         default:
             drprintf(("VBoxVideoWddm: ERROR: status type: %d\n", ChildStatus->Type));
+            AssertBreakpoint();
             Status = STATUS_INVALID_PARAMETER;
             break;
@@ -976,4 +981,6 @@
     /* The DxgkDdiQueryDeviceDescriptor should be made pageable. */
     PAGED_CODE();
+
+    vboxVDbgBreakFv();
 
     dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", MiniportDeviceContext));
@@ -998,4 +1005,5 @@
 
     /* @todo: */
+    vboxVDbgBreakF();
 
     dfprintf(("<== "__FUNCTION__ ", context(0x%x)\n", MiniportDeviceContext));
@@ -1014,5 +1022,5 @@
     dfprintf(("==> "__FUNCTION__ ", MiniportDeviceContext(0x%x)\n", MiniportDeviceContext));
 
-    AssertBreakpoint();
+    vboxVDbgBreakF();
 
     dfprintf(("<== "__FUNCTION__ ", MiniportDeviceContext(0x%x)\n", MiniportDeviceContext));
@@ -1026,4 +1034,6 @@
 {
     /* DxgkDdiResetDevice can be called at any IRQL, so it must be in nonpageable memory.  */
+    vboxVDbgBreakF();
+
     dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", MiniportDeviceContext));
     dfprintf(("<== "__FUNCTION__ ", context(0x%x)\n", MiniportDeviceContext));
@@ -1050,5 +1060,5 @@
     dfprintf(("==> "__FUNCTION__ ", MiniportDeviceContext(0x%x)\n", MiniportDeviceContext));
 
-    AssertBreakpoint();
+    vboxVDbgBreakF();
 
     dfprintf(("<== "__FUNCTION__ ", MiniportDeviceContext(0x%x)\n", MiniportDeviceContext));
@@ -1065,5 +1075,5 @@
     dfprintf(("==> "__FUNCTION__ "\n"));
 
-    AssertBreakpoint();
+    vboxVDbgBreakF();
 
     dfprintf(("<== "__FUNCTION__ "\n"));
@@ -1084,5 +1094,5 @@
     PDEVICE_EXTENSION pContext = (PDEVICE_EXTENSION)hAdapter;
 
-    AssertBreakpoint();
+    vboxVDbgBreakF();
 
     switch (pQueryAdapterInfo->Type)
@@ -1142,19 +1152,33 @@
             else
             {
+                DXGK_SEGMENTDESCRIPTOR* pDr = pQsOut->pSegmentDescriptor;
                 /* we are requested to provide segment information */
-                pQsOut->pSegmentDescriptor->BaseAddress.QuadPart = 0; /* VBE_DISPI_LFB_PHYSICAL_ADDRESS; */
-                pQsOut->pSegmentDescriptor->CpuTranslatedAddress.QuadPart = VBE_DISPI_LFB_PHYSICAL_ADDRESS;
+                pDr->BaseAddress.QuadPart = 0; /* VBE_DISPI_LFB_PHYSICAL_ADDRESS; */
+                pDr->CpuTranslatedAddress.QuadPart = VBE_DISPI_LFB_PHYSICAL_ADDRESS;
                 /* make sure the size is page aligned */
                 /* @todo: need to setup VBVA buffers and adjust the mem size here */
-                pQsOut->pSegmentDescriptor->Size = vboxWddmVramReportedSize(pContext);
-                pQsOut->pSegmentDescriptor->NbOfBanks = 0;
-                pQsOut->pSegmentDescriptor->pBankRangeTable = 0;
-                pQsOut->pSegmentDescriptor->CommitLimit = pQsOut->pSegmentDescriptor->Size;
-                pQsOut->pSegmentDescriptor->Flags.Value = 0;
-                pQsOut->pSegmentDescriptor->Flags.CpuVisible = 1;
-            }
-            pQsOut->PagingBufferSegmentId = 0;
-            pQsOut->PagingBufferSize = 1024;
-            pQsOut->PagingBufferPrivateDataSize = 0; /* @todo: do we need a private buffer ? */
+                pDr->Size = vboxWddmVramReportedSegmentSize(pContext);
+                pDr->NbOfBanks = 0;
+                pDr->pBankRangeTable = 0;
+                pDr->CommitLimit = pDr->Size;
+                pDr->Flags.Value = 0;
+                pDr->Flags.CpuVisible = 1;
+
+                ++pDr;
+                /* create cpu-invisible segment of the same size */
+                pDr->BaseAddress.QuadPart = 0;
+                pDr->CpuTranslatedAddress.QuadPart = 0;
+                /* make sure the size is page aligned */
+                /* @todo: need to setup VBVA buffers and adjust the mem size here */
+                pDr->Size = vboxWddmVramReportedSegmentSize(pContext);
+                pDr->NbOfBanks = 0;
+                pDr->pBankRangeTable = 0;
+                pDr->CommitLimit = pDr->Size;
+                pDr->Flags.Value = 0;
+
+                pQsOut->PagingBufferSegmentId = 0;
+                pQsOut->PagingBufferSize = 1024;
+                pQsOut->PagingBufferPrivateDataSize = 0; /* @todo: do we need a private buffer ? */
+            }
             break;
         }
@@ -1188,5 +1212,5 @@
     PDEVICE_EXTENSION pContext = (PDEVICE_EXTENSION)hAdapter;
 
-    AssertBreakpoint();
+    vboxVDbgBreakFv();
 
     PVBOXWDDM_DEVICE pDevice = (PVBOXWDDM_DEVICE)vboxWddmMemAllocZero(sizeof (VBOXWDDM_DEVICE));
@@ -2383,9 +2407,54 @@
     dfprintf(("==> "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
 
-    AssertBreakpoint();
+    vboxVDbgBreakF();
+
+    PDEVICE_EXTENSION pDevExt = (PDEVICE_EXTENSION)hAdapter;
+    NTSTATUS Status;
+    uint32_t cModes;
+    uint32_t iPreferredMode;
+    VIDEO_MODE_INFORMATION *pModes;
+    uint32_t cResolutions;
+    D3DKMDT_2DREGION *pResolutions;
+    VBoxWddmGetModesTable(pDevExt, /* PDEVICE_EXTENSION DeviceExtension */
+            true, /* bool bRebuildTable*/
+            &pModes, /* VIDEO_MODE_INFORMATION ** ppModes*/
+            &cModes, /* uint32_t * pcModes */
+            &iPreferredMode, /* uint32_t * pPreferrableMode*/
+            &pResolutions, /* D3DKMDT_2DREGION **ppResolutions */
+            &cResolutions /* uint32_t * pcResolutions */);
+
+    for (uint32_t i = 0; i < cResolutions; i++)
+    {
+        D3DKMDT_MONITOR_SOURCE_MODE * pNewMonitorSourceModeInfo;
+        Status = pRecommendMonitorModesArg->pMonitorSourceModeSetInterface->pfnCreateNewModeInfo(
+                    pRecommendMonitorModesArg->hMonitorSourceModeSet, &pNewMonitorSourceModeInfo);
+        Assert(Status == STATUS_SUCCESS);
+        if (Status == STATUS_SUCCESS)
+        {
+            Status = vboxVidPnPopulateMonitorSourceModeInfoFromLegacy(pDevExt,
+                    pNewMonitorSourceModeInfo,
+                    &pResolutions[i],
+                    D3DKMDT_MCO_DRIVER,
+                    true);
+            Assert(Status == STATUS_SUCCESS);
+            if (Status == STATUS_SUCCESS)
+            {
+                Status = pRecommendMonitorModesArg->pMonitorSourceModeSetInterface->pfnAddMode(
+                        pRecommendMonitorModesArg->hMonitorSourceModeSet, pNewMonitorSourceModeInfo);
+                Assert(Status == STATUS_SUCCESS);
+                if (Status == STATUS_SUCCESS)
+                    continue;
+            }
+
+            /* error has occured, release & break */
+            pRecommendMonitorModesArg->pMonitorSourceModeSetInterface->pfnReleaseModeInfo(
+                    pRecommendMonitorModesArg->hMonitorSourceModeSet, pNewMonitorSourceModeInfo);
+            break;
+        }
+    }
 
     dfprintf(("<== "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
 
-    return STATUS_SUCCESS;
+    return Status;
 }
 
@@ -2399,5 +2468,5 @@
     dfprintf(("==> "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
 
-    AssertBreakpoint();
+    vboxVDbgBreakF();
 
     dfprintf(("<== "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
