Index: /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp	(revision 34017)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp	(revision 34018)
@@ -599,4 +599,6 @@
 }
 
+#ifdef VBOX_WITH_WDDM
+
 static bool vboxVideoModesMatch(VIDEO_MODE_INFORMATION *pMode1, VIDEO_MODE_INFORMATION *pMode2)
 {
@@ -606,5 +608,5 @@
 }
 
-static DECLINLINE(void) vboxVideoChackModeAdd(VIDEO_MODE_INFORMATION *pModes, int *pcNumModes)
+static DECLINLINE(void) vboxVideoCheckModeAdd(VIDEO_MODE_INFORMATION *pModes, int *pcNumModes)
 {
     const int cNumModes = *pcNumModes;
@@ -617,6 +619,5 @@
 }
 
-#ifdef VBOX_WITH_WDDM
-# define VBOXVIDEOMODE_ADDED(_aModes, _pcModes) vboxVideoChackModeAdd(_aModes, _pcModes)
+# define VBOXVIDEOMODE_ADDED(_aModes, _pcModes) vboxVideoCheckModeAdd(_aModes, _pcModes)
 #else
 # define VBOXVIDEOMODE_ADDED(_aModes, _pcModes) do { (*(_pcModes))++; } while (0)
@@ -2318,13 +2319,13 @@
 }
 
-NTSTATUS vboxWddmGetModesForResolution(PDEVICE_EXTENSION DeviceExtension, PVBOXWDDM_VIDEOMODES_INFO pModeInfos,
-        D3DKMDT_2DREGION *pResolution, VIDEO_MODE_INFORMATION * pModes, uint32_t cModes, uint32_t *pcModes, int32_t *piPreferrableMode)
+NTSTATUS vboxWddmGetModesForResolution(VIDEO_MODE_INFORMATION *pAllModes, uint32_t cAllModes, int iSearchPreferredMode,
+        const D3DKMDT_2DREGION *pResolution, VIDEO_MODE_INFORMATION * pModes, uint32_t cModes, uint32_t *pcModes, int32_t *piPreferrableMode)
 {
     NTSTATUS Status = STATUS_SUCCESS;
     uint32_t cFound = 0;
     int iFoundPreferrableMode = -1;
-    for (uint32_t i = 0; i < pModeInfos->cModes; ++i)
-    {
-        VIDEO_MODE_INFORMATION *pCur = &pModeInfos->aModes[i];
+    for (uint32_t i = 0; i < cAllModes; ++i)
+    {
+        VIDEO_MODE_INFORMATION *pCur = &pAllModes[i];
         if (pResolution->cx == pCur->VisScreenWidth
                         && pResolution->cy == pCur->VisScreenHeight)
@@ -2335,5 +2336,5 @@
                 Status = STATUS_BUFFER_TOO_SMALL;
 
-            if (i == pModeInfos->iPreferredMode)
+            if (i == iSearchPreferredMode)
                 iFoundPreferrableMode = cFound;
 
@@ -2351,4 +2352,182 @@
 }
 
+int vboxWddmVideoModeFind(const VIDEO_MODE_INFORMATION *pModes, int cModes, const VIDEO_MODE_INFORMATION *pM)
+{
+    for (int i = 0; i < cModes; ++i)
+    {
+        const VIDEO_MODE_INFORMATION *pMode = &pModes[i];
+        if (pMode->VisScreenHeight == pM->VisScreenHeight && pMode->VisScreenWidth == pM->VisScreenWidth && pMode->BitsPerPlane == pM->BitsPerPlane)
+            return i;
+    }
+    return -1;
+}
+
+int vboxWddmVideoResolutionFind(const D3DKMDT_2DREGION *pResolutions, int cResolutions, const D3DKMDT_2DREGION *pRes)
+{
+    for (int i = 0; i < cResolutions; ++i)
+    {
+        const D3DKMDT_2DREGION *pResolution = &pResolutions[i];
+        if (pResolution->cx == pRes->cx && pResolution->cy == pRes->cy)
+            return i;
+    }
+    return -1;
+}
+
+bool vboxWddmVideoResolutionsMatch(const D3DKMDT_2DREGION *pResolutions1, const D3DKMDT_2DREGION *pResolutions2, int cResolutions)
+{
+    for (int i = 0; i < cResolutions; ++i)
+    {
+        const D3DKMDT_2DREGION * pRes1 = &pResolutions1[i];
+        int j = 0;
+        for (;j < cResolutions; ++j)
+        {
+            const D3DKMDT_2DREGION * pRes2 = &pResolutions2[j];
+            if (pRes1->cx == pRes2->cx && pRes1->cy == pRes2->cy)
+                break;
+        }
+
+        if (j == cResolutions)
+        {
+            return false;
+        }
+    }
+    return true;
+}
+
+bool vboxWddmVideoModesMatch(const VIDEO_MODE_INFORMATION *pModes1, const VIDEO_MODE_INFORMATION *pModes2, int cModes)
+{
+    for (int i = 0; i < cModes; ++i)
+    {
+        const VIDEO_MODE_INFORMATION *pM1 = &pModes1[i];
+        int j = 0;
+        for (;j < cModes; ++j)
+        {
+            const VIDEO_MODE_INFORMATION *pM2 = &pModes2[j];
+
+            if (pM1->VisScreenHeight == pM2->VisScreenHeight
+                    && pM1->VisScreenWidth == pM2->VisScreenWidth
+                    && pM1->BitsPerPlane == pM2->BitsPerPlane)
+                break;
+        }
+
+        if (j == cModes)
+        {
+            return false;
+        }
+    }
+    return true;
+}
+
+D3DDDIFORMAT vboxWddmCalcPixelFormat(const VIDEO_MODE_INFORMATION *pInfo)
+{
+    switch (pInfo->BitsPerPlane)
+    {
+        case 32:
+            if(!(pInfo->AttributeFlags & VIDEO_MODE_PALETTE_DRIVEN) && !(pInfo->AttributeFlags & VIDEO_MODE_MANAGED_PALETTE))
+            {
+                if (pInfo->RedMask == 0xFF0000 && pInfo->GreenMask == 0xFF00 && pInfo->BlueMask == 0xFF)
+                    return D3DDDIFMT_A8R8G8B8;
+                drprintf((__FUNCTION__": unsupported format: bpp(%d), rmask(%d), gmask(%d), bmask(%d)\n", pInfo->BitsPerPlane, pInfo->RedMask, pInfo->GreenMask, pInfo->BlueMask));
+                AssertBreakpoint();
+            }
+            else
+            {
+                drprintf((__FUNCTION__": unsupported AttributeFlags(0x%x)\n", pInfo->AttributeFlags));
+                AssertBreakpoint();
+            }
+            break;
+        case 24:
+            if(!(pInfo->AttributeFlags & VIDEO_MODE_PALETTE_DRIVEN) && !(pInfo->AttributeFlags & VIDEO_MODE_MANAGED_PALETTE))
+            {
+                if (pInfo->RedMask == 0xFF0000 && pInfo->GreenMask == 0xFF00 && pInfo->BlueMask == 0xFF)
+                    return D3DDDIFMT_R8G8B8;
+                drprintf((__FUNCTION__": unsupported format: bpp(%d), rmask(%d), gmask(%d), bmask(%d)\n", pInfo->BitsPerPlane, pInfo->RedMask, pInfo->GreenMask, pInfo->BlueMask));
+                AssertBreakpoint();
+            }
+            else
+            {
+                drprintf((__FUNCTION__": unsupported AttributeFlags(0x%x)\n", pInfo->AttributeFlags));
+                AssertBreakpoint();
+            }
+            break;
+        case 16:
+            if(!(pInfo->AttributeFlags & VIDEO_MODE_PALETTE_DRIVEN) && !(pInfo->AttributeFlags & VIDEO_MODE_MANAGED_PALETTE))
+            {
+                if (pInfo->RedMask == 0xF800 && pInfo->GreenMask == 0x7E0 && pInfo->BlueMask == 0x1F)
+                    return D3DDDIFMT_R5G6B5;
+                drprintf((__FUNCTION__": unsupported format: bpp(%d), rmask(%d), gmask(%d), bmask(%d)\n", pInfo->BitsPerPlane, pInfo->RedMask, pInfo->GreenMask, pInfo->BlueMask));
+                AssertBreakpoint();
+            }
+            else
+            {
+                drprintf((__FUNCTION__": unsupported AttributeFlags(0x%x)\n", pInfo->AttributeFlags));
+                AssertBreakpoint();
+            }
+            break;
+        case 8:
+            if((pInfo->AttributeFlags & VIDEO_MODE_PALETTE_DRIVEN) && (pInfo->AttributeFlags & VIDEO_MODE_MANAGED_PALETTE))
+            {
+                return D3DDDIFMT_P8;
+            }
+            else
+            {
+                drprintf((__FUNCTION__": unsupported AttributeFlags(0x%x)\n", pInfo->AttributeFlags));
+                AssertBreakpoint();
+            }
+            break;
+        default:
+            drprintf((__FUNCTION__": unsupported bpp(%d)\n", pInfo->BitsPerPlane));
+            AssertBreakpoint();
+            break;
+    }
+
+    return D3DDDIFMT_UNKNOWN;
+}
+
+bool vboxWddmFillMode(VIDEO_MODE_INFORMATION *pInfo, D3DDDIFORMAT enmFormat, ULONG w, ULONG h)
+{
+    pInfo->VisScreenWidth = w;
+    pInfo->VisScreenHeight = h;
+    pInfo->VideoMemoryBitmapWidth = w;
+    pInfo->VideoMemoryBitmapHeight = h;
+
+    switch (enmFormat)
+    {
+        case D3DDDIFMT_A8R8G8B8:
+            pInfo->AttributeFlags = VIDEO_MODE_GRAPHICS | VIDEO_MODE_COLOR | VIDEO_MODE_NO_OFF_SCREEN;
+            pInfo->BitsPerPlane = 32;
+            pInfo->RedMask = 0xFF0000;
+            pInfo->GreenMask = 0xFF00;
+            pInfo->BlueMask = 0xFF;
+            return true;
+        case D3DDDIFMT_R8G8B8:
+            pInfo->AttributeFlags = VIDEO_MODE_GRAPHICS | VIDEO_MODE_COLOR | VIDEO_MODE_NO_OFF_SCREEN;
+            pInfo->BitsPerPlane = 24;
+            pInfo->RedMask = 0xFF0000;
+            pInfo->GreenMask = 0xFF00;
+            pInfo->BlueMask = 0xFF;
+            return true;
+        case D3DDDIFMT_R5G6B5:
+            pInfo->AttributeFlags = VIDEO_MODE_GRAPHICS | VIDEO_MODE_COLOR | VIDEO_MODE_NO_OFF_SCREEN;
+            pInfo->BitsPerPlane = 16;
+            pInfo->RedMask = 0xF800;
+            pInfo->GreenMask = 0x7E0;
+            pInfo->BlueMask = 0x1F;
+            return true;
+        case D3DDDIFMT_P8:
+            pInfo->AttributeFlags = VIDEO_MODE_GRAPHICS | VIDEO_MODE_COLOR | VIDEO_MODE_NO_OFF_SCREEN | VIDEO_MODE_PALETTE_DRIVEN | VIDEO_MODE_MANAGED_PALETTE;
+            pInfo->BitsPerPlane = 8;
+            pInfo->RedMask = 0;
+            pInfo->GreenMask = 0;
+            pInfo->BlueMask = 0;
+            return true;
+        default:
+            drprintf((__FUNCTION__": unsupported enmFormat(%d)\n", enmFormat));
+            AssertBreakpoint();
+            break;
+    }
+
+    return false;
+}
 
 static VBOXWDDM_VIDEOMODES_INFO g_aVBoxVideoModeInfos[VBOX_VIDEO_MAX_SCREENS] = {0};
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h	(revision 34017)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h	(revision 34018)
@@ -409,8 +409,14 @@
 
 /* @return STATUS_BUFFER_TOO_SMALL - if buffer is too small, STATUS_SUCCESS - on success */
-NTSTATUS vboxWddmGetModesForResolution(PDEVICE_EXTENSION DeviceExtension, PVBOXWDDM_VIDEOMODES_INFO pModeInfos,
-        D3DKMDT_2DREGION *pResolution, VIDEO_MODE_INFORMATION * pModes, uint32_t cModes, uint32_t *pcModes, int32_t *piPreferrableMode);
-
-D3DDDIFORMAT vboxWddmCalcPixelFormat(VIDEO_MODE_INFORMATION *pInfo);
+NTSTATUS vboxWddmGetModesForResolution(VIDEO_MODE_INFORMATION *pAllModes, uint32_t cAllModes, int iSearchPreferredMode,
+        const D3DKMDT_2DREGION *pResolution, VIDEO_MODE_INFORMATION * pModes, uint32_t cModes, uint32_t *pcModes, int32_t *piPreferrableMode);
+
+int vboxWddmVideoModeFind(const VIDEO_MODE_INFORMATION *pModes, int cModes, const VIDEO_MODE_INFORMATION *pM);
+int vboxWddmVideoResolutionFind(const D3DKMDT_2DREGION *pResolutions, int cResolutions, const D3DKMDT_2DREGION *pRes);
+bool vboxWddmVideoResolutionsMatch(const D3DKMDT_2DREGION *pResolutions1, const D3DKMDT_2DREGION *pResolutions2, int cResolutions);
+bool vboxWddmVideoModesMatch(const VIDEO_MODE_INFORMATION *pModes1, const VIDEO_MODE_INFORMATION *pModes2, int cModes);
+
+D3DDDIFORMAT vboxWddmCalcPixelFormat(const VIDEO_MODE_INFORMATION *pInfo);
+bool vboxWddmFillMode(VIDEO_MODE_INFORMATION *pInfo, D3DDDIFORMAT enmFormat, ULONG w, ULONG h);
 
 DECLINLINE(ULONG) vboxWddmVramCpuVisibleSize(PDEVICE_EXTENSION pDevExt)
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVidPn.cpp
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVidPn.cpp	(revision 34017)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVidPn.cpp	(revision 34018)
@@ -23,5 +23,5 @@
     if (Status == STATUS_SUCCESS)
     {
-        BOOLEAN bFoundPrimary = FALSE;
+        BOOLEAN bFoundPrimary = TRUE;
 
         while (1)
@@ -30,5 +30,5 @@
             {
                 dprintf(("unsupported source(%d)->target(%d) pare\n", pNewVidPnPresentPathInfo->VidPnSourceId, pNewVidPnPresentPathInfo->VidPnTargetId));
-                AssertBreakpoint();
+//                AssertBreakpoint();
                 bSupported = FALSE;
                 break;
@@ -213,5 +213,5 @@
         }
 
-        bSupported &= bFoundPrimary;
+//        bSupported &= bFoundPrimary;
 
         if (pNewVidPnPresentPathInfo)
@@ -1121,51 +1121,161 @@
 }
 
-DECLCALLBACK(BOOLEAN) vboxVidPnCofuncModalityPathEnum(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
-        D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
+typedef struct VBOXVIDPNPOPRESOLUTIONENUM
+{
+    NTSTATUS Status;
+    D3DKMDT_2DREGION *pResolutions;
+    int cResolutions;
+    int cResultResolutions;
+}VBOXVIDPNPOPRESOLUTIONENUM, *PVBOXVIDPNPOPRESOLUTIONENUM;
+
+static DECLCALLBACK(BOOLEAN) vboxVidPnPopulateResolutionsFromSourceModeSetEnum(D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet, const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface,
+        const D3DKMDT_VIDPN_SOURCE_MODE *pNewVidPnSourceModeInfo, PVOID pContext)
+{
+    NTSTATUS Status = STATUS_SUCCESS;
+    PVBOXVIDPNPOPRESOLUTIONENUM pInfo = (PVBOXVIDPNPOPRESOLUTIONENUM)pContext;
+    Assert(pInfo->cResolutions >= pInfo->cResultResolutions);
+    Assert(pInfo->Status == STATUS_SUCCESS);
+    if (vboxWddmVideoResolutionFind(pInfo->pResolutions, pInfo->cResultResolutions, &pNewVidPnSourceModeInfo->Format.Graphics.PrimSurfSize) < 0)
+    {
+        if (pInfo->cResultResolutions < pInfo->cResolutions)
+        {
+            pInfo->pResolutions[pInfo->cResultResolutions] = pNewVidPnSourceModeInfo->Format.Graphics.PrimSurfSize;
+            ++pInfo->cResultResolutions;
+        }
+        else
+        {
+            Status = STATUS_BUFFER_OVERFLOW;
+        }
+    }
+
+    pInfo->Status = Status;
+
+    return Status == STATUS_SUCCESS;
+}
+
+static DECLCALLBACK(BOOLEAN) vboxVidPnPopulateResolutionsFromTargetModeSetEnum(D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet, const DXGK_VIDPNTARGETMODESET_INTERFACE *pVidPnTargetModeSetInterface,
+        const D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo, PVOID pContext)
+{
+    NTSTATUS Status = STATUS_SUCCESS;
+    PVBOXVIDPNPOPRESOLUTIONENUM pInfo = (PVBOXVIDPNPOPRESOLUTIONENUM)pContext;
+    Assert(pInfo->cResolutions >= pInfo->cResultResolutions);
+    Assert(pInfo->Status == STATUS_SUCCESS);
+    if (vboxWddmVideoResolutionFind(pInfo->pResolutions, pInfo->cResultResolutions, &pNewVidPnTargetModeInfo->VideoSignalInfo.ActiveSize) < 0)
+    {
+        if (pInfo->cResultResolutions < pInfo->cResolutions)
+        {
+            pInfo->pResolutions[pInfo->cResultResolutions] = pNewVidPnTargetModeInfo->VideoSignalInfo.ActiveSize;
+            ++pInfo->cResultResolutions;
+        }
+        else
+        {
+            Status = STATUS_BUFFER_OVERFLOW;
+        }
+    }
+
+    pInfo->Status = Status;
+
+    return Status == STATUS_SUCCESS;
+}
+
+typedef struct VBOXVIDPNPOPMODEENUM
+{
+    NTSTATUS Status;
+    VIDEO_MODE_INFORMATION *pModes;
+    int cModes;
+    int cResultModes;
+}VBOXVIDPNPOPMODEENUM, *PVBOXVIDPNPOPMODEENUM;
+
+static DECLCALLBACK(BOOLEAN) vboxVidPnPopulateModesFromSourceModeSetEnum(D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet, const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface,
+        const D3DKMDT_VIDPN_SOURCE_MODE *pNewVidPnSourceModeInfo, PVOID pContext)
+{
+    NTSTATUS Status = STATUS_SUCCESS;
+    PVBOXVIDPNPOPMODEENUM pInfo = (PVBOXVIDPNPOPMODEENUM)pContext;
+    VIDEO_MODE_INFORMATION Mode;
+    Assert(pInfo->cModes >= pInfo->cResultModes);
+    Assert(pInfo->Status == STATUS_SUCCESS);
+    if (vboxWddmFillMode(&Mode, pNewVidPnSourceModeInfo->Format.Graphics.PixelFormat,
+            pNewVidPnSourceModeInfo->Format.Graphics.VisibleRegionSize.cx,
+            pNewVidPnSourceModeInfo->Format.Graphics.VisibleRegionSize.cy))
+    {
+        if (vboxWddmVideoModeFind(pInfo->pModes, pInfo->cModes, &Mode) < 0)
+        {
+            if (pInfo->cResultModes < pInfo->cModes)
+            {
+                pInfo->pModes[pInfo->cResultModes] = Mode;
+                ++pInfo->cResultModes;
+            }
+            else
+            {
+                Status = STATUS_BUFFER_OVERFLOW;
+            }
+        }
+    }
+    else
+    {
+        Assert(0);
+        Status = STATUS_INVALID_PARAMETER;
+    }
+
+    pInfo->Status = Status;
+
+    return Status == STATUS_SUCCESS;
+}
+
+typedef struct VBOXVIDPNPOPMODETARGETENUM
+{
+    VBOXVIDPNPOPMODEENUM Base;
+    VIDEO_MODE_INFORMATION *pSuperset;
+    int cSuperset;
+}VBOXVIDPNPOPMODETARGETENUM, *PVBOXVIDPNPOPMODETARGETENUM;
+
+static DECLCALLBACK(BOOLEAN) vboxVidPnPopulateModesFromTargetModeSetEnum(D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet, const DXGK_VIDPNTARGETMODESET_INTERFACE *pVidPnTargetModeSetInterface,
+        const D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo, PVOID pContext)
+{
+    NTSTATUS Status = STATUS_SUCCESS;
+    PVBOXVIDPNPOPMODETARGETENUM pInfo = (PVBOXVIDPNPOPMODETARGETENUM)pContext;
+    Assert(pInfo->Base.cModes >= pInfo->Base.cResultModes);
+    Assert(pInfo->Base.Status == STATUS_SUCCESS);
+    uint32_t cResult;
+    Status = vboxWddmGetModesForResolution(pInfo->pSuperset, pInfo->cSuperset, -1, &pNewVidPnTargetModeInfo->VideoSignalInfo.ActiveSize,
+            pInfo->Base.pModes + pInfo->Base.cResultModes, pInfo->Base.cModes - pInfo->Base.cResultModes, &cResult, NULL);
+    Assert(Status == STATUS_SUCCESS);
+    if (Status == STATUS_SUCCESS)
+    {
+        pInfo->Base.cResultModes += cResult;
+    }
+
+    pInfo->Base.Status = Status;
+
+    return Status == STATUS_SUCCESS;
+}
+
+DECLCALLBACK(BOOLEAN) vboxVidPnCofuncModalityPathEnum(D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
         const D3DKMDT_VIDPN_PRESENT_PATH *pNewVidPnPresentPathInfo, PVOID pContext)
 {
     PVBOXVIDPNCOFUNCMODALITY pCbContext = (PVBOXVIDPNCOFUNCMODALITY)pContext;
+    PDEVICE_EXTENSION pDevExt = pCbContext->pDevExt;
+    D3DKMDT_HVIDPN hDesiredVidPn = pCbContext->pEnumCofuncModalityArg->hConstrainingVidPn;
+    const DXGK_VIDPN_INTERFACE* pVidPnInterface = pCbContext->pVidPnInterface;
     NTSTATUS Status = STATUS_SUCCESS;
     pCbContext->Status = STATUS_SUCCESS;
     PVBOXWDDM_VIDEOMODES_INFO pInfo = &pCbContext->pInfos[pNewVidPnPresentPathInfo->VidPnTargetId];
-    VIDEO_MODE_INFORMATION *pModes = pInfo->aModes;
-    uint32_t cModes = pInfo->cModes;
-    /* we do not want the mode to be pinned */
-    int iPreferredMode = -1; /* pInfo->iPreferredMode; */
-    uint32_t cResolutions = pInfo->cResolutions;
-    D3DKMDT_2DREGION * pResolutions = pInfo->aResolutions;
-
-
-    /* adjust scaling */
-    if (pCbContext->pEnumCofuncModalityArg->EnumPivotType != D3DKMDT_EPT_SCALING)
-    {
-        if (pNewVidPnPresentPathInfo->ContentTransformation.Scaling != D3DKMDT_VPPS_IDENTITY
-                && pNewVidPnPresentPathInfo->ContentTransformation.Scaling != D3DKMDT_VPPS_CENTERED
-                && pNewVidPnPresentPathInfo->ContentTransformation.Scaling != D3DKMDT_VPPS_STRETCHED
-                && pNewVidPnPresentPathInfo->ContentTransformation.Scaling != D3DKMDT_VPPS_UNPINNED
-                && pNewVidPnPresentPathInfo->ContentTransformation.Scaling != D3DKMDT_VPPS_NOTSPECIFIED)
-        {
-            AssertBreakpoint();
-            /* todo: create a new path (if not done already) and assign a proper info */
-        }
-    }
-
-    /* adjust rotation */
-    if (pCbContext->pEnumCofuncModalityArg->EnumPivotType != D3DKMDT_EPT_ROTATION)
-    {
-        if (pNewVidPnPresentPathInfo->ContentTransformation.Rotation != D3DKMDT_VPPR_IDENTITY
-                && pNewVidPnPresentPathInfo->ContentTransformation.Rotation != D3DKMDT_VPPR_ROTATE90
-                && pNewVidPnPresentPathInfo->ContentTransformation.Rotation != D3DKMDT_VPPR_ROTATE180
-                && pNewVidPnPresentPathInfo->ContentTransformation.Rotation != D3DKMDT_VPPR_ROTATE270
-                && pNewVidPnPresentPathInfo->ContentTransformation.Rotation != D3DKMDT_VPPR_UNPINNED)
-        {
-            AssertBreakpoint();
-            /* todo: create a new path (if not done already) and assign a proper info */
-        }
-    }
+    bool bConversionSupported =
+               (
+                       pNewVidPnPresentPathInfo->ContentTransformation.Scaling == D3DKMDT_VPPS_UNINITIALIZED
+                    || pNewVidPnPresentPathInfo->ContentTransformation.Scaling == D3DKMDT_VPPS_IDENTITY
+                    || pNewVidPnPresentPathInfo->ContentTransformation.Scaling == D3DKMDT_VPPS_UNPINNED
+                    || pNewVidPnPresentPathInfo->ContentTransformation.Scaling == D3DKMDT_VPPS_NOTSPECIFIED
+               )
+            && (
+                       pNewVidPnPresentPathInfo->ContentTransformation.Rotation == D3DKMDT_VPPR_UNINITIALIZED
+                    || pNewVidPnPresentPathInfo->ContentTransformation.Rotation == D3DKMDT_VPPR_IDENTITY
+                    || pNewVidPnPresentPathInfo->ContentTransformation.Rotation == D3DKMDT_VPPR_UNPINNED
+                    || pNewVidPnPresentPathInfo->ContentTransformation.Rotation == D3DKMDT_VPPR_NOTSPECIFIED
+                );
+
 
     D3DKMDT_HVIDPNSOURCEMODESET hCurVidPnSourceModeSet;
     const DXGK_VIDPNSOURCEMODESET_INTERFACE *pCurVidPnSourceModeSetInterface;
-    VIDEO_MODE_INFORMATION *pPreferredMode = iPreferredMode >= 0 ? &pModes[iPreferredMode] : NULL;
 
     Status = pVidPnInterface->pfnAcquireSourceModeSet(hDesiredVidPn,
@@ -1207,111 +1317,365 @@
                 drprintf((__FUNCTION__": pfnAcquirePinnedModeInfo failed Status(0x%x)\n", Status));
 
-            switch (pCbContext->pEnumCofuncModalityArg->EnumPivotType)
-            {
-                case D3DKMDT_EPT_VIDPNSOURCE:
-                    if (!pPinnedVidPnTargetModeInfo)
+            bool bSrcPinned = pPinnedVidPnSourceModeInfo
+                    || (pCbContext->pEnumCofuncModalityArg->EnumPivotType == D3DKMDT_EPT_VIDPNSOURCE
+                        && (pCbContext->pEnumCofuncModalityArg->EnumPivot.VidPnSourceId == pNewVidPnPresentPathInfo->VidPnSourceId
+                            || pCbContext->pEnumCofuncModalityArg->EnumPivot.VidPnSourceId == D3DDDI_ID_ALL));
+            bool bTgtPinned = pPinnedVidPnTargetModeInfo
+                    || (pCbContext->pEnumCofuncModalityArg->EnumPivotType == D3DKMDT_EPT_VIDPNTARGET
+                            && (pCbContext->pEnumCofuncModalityArg->EnumPivot.VidPnTargetId == pNewVidPnPresentPathInfo->VidPnTargetId
+                                || pCbContext->pEnumCofuncModalityArg->EnumPivot.VidPnTargetId == D3DDDI_ID_ALL));
+            if (bSrcPinned)
+            {
+                if (!bTgtPinned)
+                {
+                    /* adjust target mode set relative to source mode set */
+                    /* 1. get list of resolutions for source and for target
+                     * 2. if they do not match create and populate a new set */
+                    SIZE_T cTgtModes;
+                    SIZE_T cSrcModes;
+                    Status = pCurVidPnTargetModeSetInterface->pfnGetNumModes(hCurVidPnTargetModeSet, &cTgtModes);
+                    Assert(Status == STATUS_SUCCESS);
+                    if (Status == STATUS_SUCCESS)
                     {
-                        if (pPinnedVidPnSourceModeInfo)
+                        Status = pCurVidPnSourceModeSetInterface->pfnGetNumModes(hCurVidPnSourceModeSet, &cSrcModes);
+                        Assert(Status == STATUS_SUCCESS);
+                        if (Status == STATUS_SUCCESS)
                         {
-                            SIZE_T cModes;
-                            Status = pCurVidPnTargetModeSetInterface->pfnGetNumModes(hCurVidPnTargetModeSet, &cModes);
-                            Assert(Status == STATUS_SUCCESS);
+                            D3DKMDT_2DREGION *pSrcResolutions = cSrcModes ? (D3DKMDT_2DREGION*)vboxWddmMemAlloc(cSrcModes * sizeof (pSrcResolutions[0])) : NULL;
+                            Assert(pSrcResolutions || !cSrcModes);
+                            if (pSrcResolutions || !cSrcModes)
+                            {
+                                VBOXVIDPNPOPRESOLUTIONENUM Info = {0};
+                                if (cSrcModes)
+                                {
+                                    Info.pResolutions = pSrcResolutions;
+                                    Info.cResolutions = cSrcModes;
+                                    Status = vboxVidPnEnumSourceModes(hCurVidPnSourceModeSet, pCurVidPnSourceModeSetInterface,
+                                            vboxVidPnPopulateResolutionsFromSourceModeSetEnum, &Info);
+                                    Assert(Status == STATUS_SUCCESS);
+                                }
+                                if (Status == STATUS_SUCCESS)
+                                {
+                                    Assert(Info.Status == STATUS_SUCCESS);
+                                    if (Info.Status == STATUS_SUCCESS)
+                                    {
+                                        D3DKMDT_2DREGION *pTgtResolutions = cTgtModes ? (D3DKMDT_2DREGION*)vboxWddmMemAlloc(cTgtModes * sizeof (pTgtResolutions[0])) : NULL;
+                                        Assert(pTgtResolutions || !cTgtModes);
+                                        if (pTgtResolutions || !cTgtModes)
+                                        {
+                                            int cSrcResolutions = Info.cResultResolutions;
+                                            memset(&Info, 0, sizeof (Info));
+                                            if (cTgtModes)
+                                            {
+                                                Info.pResolutions = pTgtResolutions;
+                                                Info.cResolutions = cTgtModes;
+                                                Status = vboxVidPnEnumTargetModes(hCurVidPnTargetModeSet, pCurVidPnTargetModeSetInterface,
+                                                        vboxVidPnPopulateResolutionsFromTargetModeSetEnum, &Info);
+                                                Assert(Status == STATUS_SUCCESS);
+                                            }
+                                            if (Status == STATUS_SUCCESS)
+                                            {
+                                                Assert(Info.Status == STATUS_SUCCESS);
+                                                if (Info.Status == STATUS_SUCCESS)
+                                                {
+                                                    bool bNeedSet;
+                                                    Assert(cTgtModes == Info.cResultResolutions);
+                                                    if (cSrcResolutions == Info.cResultResolutions)
+                                                    {
+                                                        /* need to check all modes */
+                                                        bNeedSet = !vboxWddmVideoResolutionsMatch(pSrcResolutions, pTgtResolutions, cSrcResolutions);
+                                                    }
+                                                    else
+                                                    {
+                                                        bNeedSet = true;
+                                                    }
+
+                                                    if (bNeedSet)
+                                                    {
+                                                        Status = vboxVidPnCreatePopulateTargetModeSetFromLegacy(pDevExt, hDesiredVidPn, pVidPnInterface,
+                                                                                pNewVidPnPresentPathInfo->VidPnTargetId,
+                                                                                pSrcResolutions,
+                                                                                cSrcResolutions,
+                                                                                NULL,
+                                                                                0,
+                                                                                NULL);
+                                                        Assert(Status == STATUS_SUCCESS);
+                                                    }
+                                                }
+                                                else
+                                                {
+                                                    Status = Info.Status;
+                                                }
+                                            }
+
+                                            if (pTgtResolutions)
+                                                vboxWddmMemFree(pTgtResolutions);
+                                        }
+                                        else
+                                        {
+                                            Status = STATUS_NO_MEMORY;
+                                        }
+                                    }
+                                    else
+                                    {
+                                        Status = Info.Status;
+                                    }
+                                }
+                                if (pSrcResolutions)
+                                    vboxWddmMemFree(pSrcResolutions);
+                            }
+                            else
+                            {
+                                Status = STATUS_NO_MEMORY;
+                            }
+                        }
+                    }
+                }
+            }
+            else if (bTgtPinned)
+            {
+                /* adjust source mode set relative to target mode set */
+                /* 1. get list of modes for target resolutions
+                 * 2. get list of modes for sources
+                 * 3. if modes do not match create and populate new set */
+                SIZE_T cTgtModes;
+                SIZE_T cSrcModes;
+                Status = pCurVidPnTargetModeSetInterface->pfnGetNumModes(hCurVidPnTargetModeSet, &cTgtModes);
+                Assert(Status == STATUS_SUCCESS);
+                if (Status == STATUS_SUCCESS)
+                {
+                    Status = pCurVidPnSourceModeSetInterface->pfnGetNumModes(hCurVidPnSourceModeSet, &cSrcModes);
+                    Assert(Status == STATUS_SUCCESS);
+                    if (Status == STATUS_SUCCESS)
+                    {
+                        VIDEO_MODE_INFORMATION *pSrcModes = cSrcModes ? (VIDEO_MODE_INFORMATION*)vboxWddmMemAlloc(cSrcModes * sizeof (pSrcModes[0])) : NULL;
+                        Assert(pSrcModes || !cSrcModes);
+                        if (pSrcModes || !cSrcModes)
+                        {
+                            VBOXVIDPNPOPMODETARGETENUM Info = {0};
+                            if (cSrcModes)
+                            {
+                                Info.Base.pModes = pSrcModes;
+                                Info.Base.cModes = cSrcModes;
+                                Status = vboxVidPnEnumSourceModes(hCurVidPnSourceModeSet, pCurVidPnSourceModeSetInterface,
+                                        vboxVidPnPopulateModesFromSourceModeSetEnum, &Info.Base);
+                                Assert(Status == STATUS_SUCCESS);
+                            }
                             if (Status == STATUS_SUCCESS)
                             {
-                                D3DKMDT_2DREGION Resolution;
-                                Resolution.cx = pPinnedVidPnSourceModeInfo->Format.Graphics.VisibleRegionSize.cx;
-                                Resolution.cy = pPinnedVidPnSourceModeInfo->Format.Graphics.VisibleRegionSize.cy;
-                                BOOLEAN bCreateTrg = FALSE;
-                                if (cModes == 1)
+                                Assert(Info.Base.Status == STATUS_SUCCESS);
+                                if (Info.Base.Status == STATUS_SUCCESS)
                                 {
-                                    const D3DKMDT_VIDPN_TARGET_MODE *pVidPnTargetModeInfo;
-                                    Status = pCurVidPnTargetModeSetInterface->pfnAcquireFirstModeInfo(hCurVidPnTargetModeSet, &pVidPnTargetModeInfo);
-                                    Assert(Status == STATUS_SUCCESS);
+                                    VIDEO_MODE_INFORMATION *pTgtModes = cTgtModes ? (VIDEO_MODE_INFORMATION*)vboxWddmMemAlloc(pInfo->cModes * sizeof (pTgtModes[0])) : NULL;
+                                    Assert(pTgtModes || !cTgtModes);
+                                    if (pTgtModes || !cTgtModes)
+                                    {
+                                        int cSrcResultModes = Info.Base.cModes;
+                                        Assert(cSrcResultModes == cSrcModes);
+                                        memset(&Info, 0, sizeof (Info));
+                                        if (cTgtModes)
+                                        {
+                                            Info.Base.pModes = pTgtModes;
+                                            Info.Base.cModes = pInfo->cModes;
+                                            Info.pSuperset = pInfo->aModes;
+                                            Info.cSuperset = pInfo->cModes;
+                                            Status = vboxVidPnEnumTargetModes(hCurVidPnTargetModeSet, pCurVidPnTargetModeSetInterface,
+                                                    vboxVidPnPopulateModesFromTargetModeSetEnum, &Info);
+                                            Assert(Status == STATUS_SUCCESS);
+                                        }
+                                        if (Status == STATUS_SUCCESS)
+                                        {
+                                            Assert(Info.Base.Status == STATUS_SUCCESS);
+                                            if (Info.Base.Status == STATUS_SUCCESS)
+                                            {
+                                                bool bNeedSet;
+                                                Assert((int)cTgtModes <= Info.Base.cResultModes);
+                                                if (cSrcResultModes == Info.Base.cResultModes)
+                                                {
+                                                    /* need to check all modes */
+                                                    bNeedSet = !vboxWddmVideoModesMatch(pSrcModes, pTgtModes, cSrcResultModes);
+                                                }
+                                                else
+                                                {
+                                                    bNeedSet = true;
+                                                }
+
+                                                if (bNeedSet)
+                                                {
+                                                    Status = Status = vboxVidPnCreatePopulateSourceModeSetFromLegacy(pDevExt, hDesiredVidPn, pVidPnInterface,
+                                                            pNewVidPnPresentPathInfo->VidPnSourceId,
+                                                            pTgtModes, Info.Base.cResultModes, -1, NULL);
+                                                    Assert(Status == STATUS_SUCCESS);
+                                                }
+                                            }
+                                            else
+                                            {
+                                                Status = Info.Base.Status;
+                                            }
+                                        }
+
+                                        if (pTgtModes)
+                                            vboxWddmMemFree(pTgtModes);
+                                    }
+                                    else
+                                    {
+                                        Status = STATUS_NO_MEMORY;
+                                    }
+                                }
+                                else
+                                {
+                                    Status = Info.Base.Status;
+                                }
+                            }
+                            if (pSrcModes)
+                                vboxWddmMemFree(pSrcModes);
+                        }
+                        else
+                        {
+                            Status = STATUS_NO_MEMORY;
+                        }
+                    }
+                }
+            }
+            else
+            {
+                /* neither Source nor Target are pinned */
+                /* 1. get list of target resolutions
+                 * 2. if resolutions do not match with the complete list we have build - create and populate new
+                 * 3. get list of modes for sources
+                 * 4. if modes do not match with the complete list we have - create and populate a new set */
+                SIZE_T cTgtModes;
+                SIZE_T cSrcModes;
+                Status = pCurVidPnSourceModeSetInterface->pfnGetNumModes(hCurVidPnSourceModeSet, &cSrcModes);
+                Assert(Status == STATUS_SUCCESS);
+                if (Status == STATUS_SUCCESS)
+                {
+                    bool bNeedSet = false;
+                    uint32_t cModes = bConversionSupported ? pInfo->cModes : 0;
+                    if (cSrcModes != cModes)
+                    {
+                        bNeedSet = true;
+                    }
+                    else
+                    {
+                        VIDEO_MODE_INFORMATION *pSrcModes = cSrcModes ? (VIDEO_MODE_INFORMATION*)vboxWddmMemAlloc(cSrcModes * sizeof (pSrcModes[0])) : NULL;
+                        Assert(pSrcModes || !cSrcModes);
+                        if (pSrcModes || !cSrcModes)
+                        {
+                            VBOXVIDPNPOPMODETARGETENUM Info = {0};
+                            if (cSrcModes)
+                            {
+                                Info.Base.pModes = pSrcModes;
+                                Info.Base.cModes = cSrcModes;
+                                Status = vboxVidPnEnumSourceModes(hCurVidPnSourceModeSet, pCurVidPnSourceModeSetInterface,
+                                        vboxVidPnPopulateModesFromSourceModeSetEnum, &Info.Base);
+                                Assert(Status == STATUS_SUCCESS);
+                            }
+                            if (Status == STATUS_SUCCESS)
+                            {
+                                Assert(Info.Base.Status == STATUS_SUCCESS);
+                                if (Info.Base.Status == STATUS_SUCCESS)
+                                {
+                                    Assert(cSrcModes == Info.Base.cResultModes);
+                                    if (cSrcModes == Info.Base.cResultModes)
+                                    {
+                                        /* need to check all modes */
+                                        bNeedSet = !vboxWddmVideoModesMatch(pSrcModes, pInfo->aModes, cModes);
+                                    }
+                                    else
+                                    {
+                                        bNeedSet = true;
+                                    }
+                                }
+                            }
+                            if (pSrcModes)
+                                vboxWddmMemFree(pSrcModes);
+                        }
+                        else
+                        {
+                            Status = STATUS_NO_MEMORY;
+                        }
+                    }
+
+                    if (Status == STATUS_SUCCESS && bNeedSet)
+                    {
+                        Status = Status = vboxVidPnCreatePopulateSourceModeSetFromLegacy(pDevExt, hDesiredVidPn, pVidPnInterface,
+                                pNewVidPnPresentPathInfo->VidPnSourceId,
+                                pInfo->aModes, cModes, -1, NULL);
+                        Assert(Status == STATUS_SUCCESS);
+                    }
+
+                    if (Status == STATUS_SUCCESS)
+                    {
+                        Status = pCurVidPnTargetModeSetInterface->pfnGetNumModes(hCurVidPnTargetModeSet, &cTgtModes);
+                        Assert(Status == STATUS_SUCCESS);
+                        if (Status == STATUS_SUCCESS)
+                        {
+                            bool bNeedSet = false;
+                            uint32_t cResolutions = bConversionSupported ? pInfo->cResolutions : 0;
+                            if (cTgtModes == cResolutions)
+                            {
+                                D3DKMDT_2DREGION *pTgtResolutions = cTgtModes ? (D3DKMDT_2DREGION*)vboxWddmMemAlloc(cTgtModes * sizeof (pTgtResolutions[0])) : NULL;
+                                Assert(pTgtResolutions || !cTgtModes);
+                                if (pTgtResolutions || !cTgtModes)
+                                {
+                                    VBOXVIDPNPOPRESOLUTIONENUM Info = {0};
+                                    if (cTgtModes)
+                                    {
+                                        Info.pResolutions = pTgtResolutions;
+                                        Info.cResolutions = cTgtModes;
+                                        Status = vboxVidPnEnumTargetModes(hCurVidPnTargetModeSet, pCurVidPnTargetModeSetInterface,
+                                                vboxVidPnPopulateResolutionsFromTargetModeSetEnum, &Info);
+                                        Assert(Status == STATUS_SUCCESS);
+                                    }
                                     if (Status == STATUS_SUCCESS)
                                     {
-                                        D3DKMDT_VIDPN_TARGET_MODE dummyMode = {0};
-                                        Status = vboxVidPnPopulateTargetModeInfoFromLegacy(&dummyMode, &Resolution, FALSE);
-                                        Assert(Status == STATUS_SUCCESS);
-                                        if (Status == STATUS_SUCCESS)
+                                        Assert(Info.Status == STATUS_SUCCESS);
+                                        if (Info.Status == STATUS_SUCCESS)
                                         {
-                                            if (!vboxVidPnMatchVideoSignal(&dummyMode.VideoSignalInfo, &pVidPnTargetModeInfo->VideoSignalInfo))
-                                                bCreateTrg = TRUE;
+                                            Assert(cTgtModes == Info.cResultResolutions);
+                                            if (Info.cResultResolutions == cResolutions)
+                                            {
+                                                /* need to check all modes */
+                                                bNeedSet = !vboxWddmVideoResolutionsMatch(pInfo->aResolutions, pTgtResolutions, cResolutions);
+                                            }
                                             else
                                             {
-                                                /* do we need to check pVidPnTargetModeInfo->Preference; ? */
+                                                bNeedSet = true;
                                             }
                                         }
                                         else
                                         {
-                                            drprintf((__FUNCTION__": trg vboxVidPnPopulateTargetModeInfoFromLegacy failed Status(0x%x), pretending success\n", Status));
-                                            Status = STATUS_SUCCESS;
-                                            bCreateTrg = TRUE;
+                                            Status = Info.Status;
                                         }
                                     }
-                                    else
-                                        drprintf((__FUNCTION__": trg pfnAcquireFirstModeInfo failed Status(0x%x)\n", Status));
+
+                                    if (pTgtResolutions)
+                                        vboxWddmMemFree(pTgtResolutions);
                                 }
                                 else
-                                    bCreateTrg = TRUE;
-
-                                if (bCreateTrg)
                                 {
-                                    Status = vboxVidPnCreatePopulateTargetModeSetFromLegacy(pDevExt, hDesiredVidPn, pVidPnInterface,
-                                            pNewVidPnPresentPathInfo->VidPnTargetId,
-                                            &Resolution,
-                                            1,
-                                            pPreferredMode,
-                                            0,
-                                            NULL);
-                                    Assert(Status == STATUS_SUCCESS);
-                                    if (Status != STATUS_SUCCESS)
-                                        drprintf((__FUNCTION__": vboxVidPnCreatePopulateTargetModeSetFromLegacy for pinned source failed Status(0x%x)\n", Status));                                }
+                                    Status = STATUS_NO_MEMORY;
+                                }
                             }
                             else
-                                drprintf((__FUNCTION__": trg pfnGetNumModes failed Status(0x%x)\n", Status));
-                        }
-                        else
-                        {
-                            dprintf((__FUNCTION__": source pivot w/o pinned source mode\n"));
-//                            AssertBreakpoint();
+                            {
+                                bNeedSet = true;
+                            }
+
+                            if (Status == STATUS_SUCCESS && bNeedSet)
+                            {
+                                Status = vboxVidPnCreatePopulateTargetModeSetFromLegacy(pDevExt, hDesiredVidPn, pVidPnInterface,
+                                                        pNewVidPnPresentPathInfo->VidPnTargetId,
+                                                        pInfo->aResolutions,
+                                                        cResolutions,
+                                                        NULL,
+                                                        0,
+                                                        NULL);
+                                Assert(Status == STATUS_SUCCESS);
+                            }
                         }
                     }
-                    break;
-                case D3DKMDT_EPT_VIDPNTARGET:
-                    break;
-                case D3DKMDT_EPT_SCALING:
-                    break;
-                case D3DKMDT_EPT_ROTATION:
-                    break;
-                case D3DKMDT_EPT_NOPIVOT:
-                    Assert(!!pPinnedVidPnSourceModeInfo == !!pPinnedVidPnTargetModeInfo);
-                    if (!pPinnedVidPnSourceModeInfo && !pPinnedVidPnTargetModeInfo)
-                    {
-                        /* just create and populate the new source mode set for now */
-                        Status = vboxVidPnCreatePopulateSourceModeSetFromLegacy(pDevExt, hDesiredVidPn, pVidPnInterface,
-                                pNewVidPnPresentPathInfo->VidPnSourceId,
-                                pModes, cModes, iPreferredMode, NULL);
-                        Assert(Status == STATUS_SUCCESS);
-                        if (Status == STATUS_SUCCESS)
-                        {
-                            /* just create and populate a new target mode info for now */
-                            Status = vboxVidPnCreatePopulateTargetModeSetFromLegacy(pDevExt, hDesiredVidPn, pVidPnInterface,
-                                    pNewVidPnPresentPathInfo->VidPnTargetId,
-                                    pResolutions,
-                                    cResolutions,
-                                    pPreferredMode,
-                                    0,
-                                    NULL);
-                            Assert(Status == STATUS_SUCCESS);
-                            if (Status != STATUS_SUCCESS)
-                                drprintf((__FUNCTION__": vboxVidPnCreatePopulateTargetModeSetFromLegacy failed Status(0x%x)\n", Status));
-                        }
-                        else
-                            drprintf((__FUNCTION__": vboxVidPnCreatePopulateSourceModeSetFromLegacy failed Status(0x%x)\n", Status));
-                    }
-                    break;
-                default:
-                    drprintf((__FUNCTION__": unknown EnumPivotType (%dx)\n", pCbContext->pEnumCofuncModalityArg->EnumPivotType));
-                    break;
+                }
             }
 
@@ -1391,7 +1755,6 @@
 }
 
-NTSTATUS vboxVidPnEnumSourceModes(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
-        D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet, const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface,
-        PFNVBOXVIDPNENUMSOURCEMODES pfnCallback, PVOID pContext)
+NTSTATUS vboxVidPnEnumSourceModes(D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet, const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface,
+                                    PFNVBOXVIDPNENUMSOURCEMODES pfnCallback, PVOID pContext)
 {
     const D3DKMDT_VIDPN_SOURCE_MODE *pNewVidPnSourceModeInfo;
@@ -1404,6 +1767,5 @@
             const D3DKMDT_VIDPN_SOURCE_MODE *pNextVidPnSourceModeInfo;
             Status = pVidPnSourceModeSetInterface->pfnAcquireNextModeInfo(hNewVidPnSourceModeSet, pNewVidPnSourceModeInfo, &pNextVidPnSourceModeInfo);
-            if (!pfnCallback(pDevExt, hDesiredVidPn, pVidPnInterface,
-                    hNewVidPnSourceModeSet, pVidPnSourceModeSetInterface,
+            if (!pfnCallback(hNewVidPnSourceModeSet, pVidPnSourceModeSetInterface,
                     pNewVidPnSourceModeInfo, pContext))
             {
@@ -1448,6 +1810,5 @@
 }
 
-NTSTATUS vboxVidPnEnumTargetModes(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
-        D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet, const DXGK_VIDPNTARGETMODESET_INTERFACE *pVidPnTargetModeSetInterface,
+NTSTATUS vboxVidPnEnumTargetModes(D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet, const DXGK_VIDPNTARGETMODESET_INTERFACE *pVidPnTargetModeSetInterface,
         PFNVBOXVIDPNENUMTARGETMODES pfnCallback, PVOID pContext)
 {
@@ -1461,6 +1822,5 @@
             const D3DKMDT_VIDPN_TARGET_MODE *pNextVidPnTargetModeInfo;
             Status = pVidPnTargetModeSetInterface->pfnAcquireNextModeInfo(hNewVidPnTargetModeSet, pNewVidPnTargetModeInfo, &pNextVidPnTargetModeInfo);
-            if (!pfnCallback(pDevExt, hDesiredVidPn, pVidPnInterface,
-                    hNewVidPnTargetModeSet, pVidPnTargetModeSetInterface,
+            if (!pfnCallback(hNewVidPnTargetModeSet, pVidPnTargetModeSetInterface,
                     pNewVidPnTargetModeInfo, pContext))
             {
@@ -1537,6 +1897,5 @@
 }
 
-NTSTATUS vboxVidPnEnumPaths(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
-        D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
+NTSTATUS vboxVidPnEnumPaths(D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
         PFNVBOXVIDPNENUMPATHS pfnCallback, PVOID pContext)
 {
@@ -1550,5 +1909,5 @@
             Status = pVidPnTopologyInterface->pfnAcquireNextPathInfo(hVidPnTopology, pNewVidPnPresentPathInfo, &pNextVidPnPresentPathInfo);
 
-            if (!pfnCallback(pDevExt, hDesiredVidPn, pVidPnInterface, hVidPnTopology, pVidPnTopologyInterface, pNewVidPnPresentPathInfo, pContext))
+            if (!pfnCallback(hVidPnTopology, pVidPnTopologyInterface, pNewVidPnPresentPathInfo, pContext))
             {
                 Assert(Status == STATUS_SUCCESS);
@@ -1725,10 +2084,12 @@
 }
 
-DECLCALLBACK(BOOLEAN) vboxVidPnCommitPathEnum(struct _DEVICE_EXTENSION* pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
-        D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
+DECLCALLBACK(BOOLEAN) vboxVidPnCommitPathEnum(D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
         const D3DKMDT_VIDPN_PRESENT_PATH *pVidPnPresentPathInfo, PVOID pContext)
 {
     NTSTATUS Status = STATUS_SUCCESS;
     PVBOXVIDPNCOMMIT pCommitInfo = (PVBOXVIDPNCOMMIT)pContext;
+    PDEVICE_EXTENSION pDevExt = pCommitInfo->pDevExt;
+    const D3DKMDT_HVIDPN hDesiredVidPn = pCommitInfo->pCommitVidPnArg->hFunctionalVidPn;
+    const DXGK_VIDPN_INTERFACE* pVidPnInterface = pCommitInfo->pVidPnInterface;
 
     if (pCommitInfo->pCommitVidPnArg->AffectedVidPnSourceId == D3DDDI_ID_ALL
@@ -2139,6 +2500,5 @@
 
 
-static DECLCALLBACK(BOOLEAN) vboxVidPnDumpSourceModeSetEnum(struct _DEVICE_EXTENSION* pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
-        D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet, const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface,
+static DECLCALLBACK(BOOLEAN) vboxVidPnDumpSourceModeSetEnum(D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet, const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface,
         const D3DKMDT_VIDPN_SOURCE_MODE *pNewVidPnSourceModeInfo, PVOID pContext)
 {
@@ -2161,5 +2521,5 @@
     {
 
-        Status = vboxVidPnEnumSourceModes(pDevExt, hVidPn, pVidPnInterface, hCurVidPnSourceModeSet, pCurVidPnSourceModeSetInterface,
+        Status = vboxVidPnEnumSourceModes(hCurVidPnSourceModeSet, pCurVidPnSourceModeSetInterface,
                 vboxVidPnDumpSourceModeSetEnum, NULL);
         Assert(Status == STATUS_SUCCESS);
@@ -2178,6 +2538,5 @@
 }
 
-DECLCALLBACK(BOOLEAN) vboxVidPnDumpTargetModeSetEnum(struct _DEVICE_EXTENSION* pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
-        D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet, const DXGK_VIDPNTARGETMODESET_INTERFACE *pVidPnTargetModeSetInterface,
+DECLCALLBACK(BOOLEAN) vboxVidPnDumpTargetModeSetEnum(D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet, const DXGK_VIDPNTARGETMODESET_INTERFACE *pVidPnTargetModeSetInterface,
         const D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo, PVOID pContext)
 {
@@ -2200,5 +2559,5 @@
     {
 
-        Status = vboxVidPnEnumTargetModes(pDevExt, hVidPn, pVidPnInterface, hCurVidPnTargetModeSet, pCurVidPnTargetModeSetInterface,
+        Status = vboxVidPnEnumTargetModes(hCurVidPnTargetModeSet, pCurVidPnTargetModeSetInterface,
                 vboxVidPnDumpTargetModeSetEnum, NULL);
         Assert(Status == STATUS_SUCCESS);
@@ -2261,6 +2620,5 @@
 }
 
-void vboxVidPnDumpPath(struct _DEVICE_EXTENSION* pDevExt, const D3DKMDT_HVIDPN hVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
-        const D3DKMDT_VIDPN_PRESENT_PATH *pVidPnPresentPathInfo)
+void vboxVidPnDumpPath(const D3DKMDT_HVIDPN hVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface, const D3DKMDT_VIDPN_PRESENT_PATH *pVidPnPresentPathInfo)
 {
     drprintf((" >>**** Start Dump VidPn Path ****>>\n"));
@@ -2285,9 +2643,15 @@
 }
 
-static DECLCALLBACK(BOOLEAN) vboxVidPnDumpPathEnum(struct _DEVICE_EXTENSION* pDevExt, const D3DKMDT_HVIDPN hVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
-        D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
+typedef struct VBOXVIDPNDUMPPATHENUM
+{
+    D3DKMDT_HVIDPN hVidPn;
+    const DXGK_VIDPN_INTERFACE* pVidPnInterface;
+} VBOXVIDPNDUMPPATHENUM, *PVBOXVIDPNDUMPPATHENUM;
+
+static DECLCALLBACK(BOOLEAN) vboxVidPnDumpPathEnum(D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
         const D3DKMDT_VIDPN_PRESENT_PATH *pVidPnPresentPathInfo, PVOID pContext)
 {
-    vboxVidPnDumpPath(pDevExt, hVidPn, pVidPnInterface, pVidPnPresentPathInfo);
+    PVBOXVIDPNDUMPPATHENUM pData = (PVBOXVIDPNDUMPPATHENUM)pContext;
+    vboxVidPnDumpPath(pData->hVidPn, pData->pVidPnInterface, pVidPnPresentPathInfo);
 
     pVidPnTopologyInterface->pfnReleasePathInfo(hVidPnTopology, pVidPnPresentPathInfo);
@@ -2299,4 +2663,7 @@
     drprintf (("%s", pPrefix));
 
+    VBOXVIDPNDUMPPATHENUM CbData;
+    CbData.hVidPn = hVidPn;
+    CbData.pVidPnInterface = pVidPnInterface;
     D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology;
     const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface;
@@ -2305,7 +2672,6 @@
     if (Status == STATUS_SUCCESS)
     {
-        Status = vboxVidPnEnumPaths(pDevExt, hVidPn, pVidPnInterface,
-                                        hVidPnTopology, pVidPnTopologyInterface,
-                                        vboxVidPnDumpPathEnum, NULL);
+        Status = vboxVidPnEnumPaths(hVidPnTopology, pVidPnTopologyInterface,
+                                        vboxVidPnDumpPathEnum, &CbData);
         Assert(Status == STATUS_SUCCESS);
     }
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVidPn.h
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVidPn.h	(revision 34017)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVidPn.h	(revision 34018)
@@ -41,4 +41,6 @@
 {
     NTSTATUS Status;
+    struct _DEVICE_EXTENSION* pDevExt;
+    const DXGK_VIDPN_INTERFACE* pVidPnInterface;
     CONST DXGKARG_ENUMVIDPNCOFUNCMODALITY* pEnumCofuncModalityArg;
     PVBOXWDDM_VIDEOMODES_INFO pInfos;
@@ -48,22 +50,21 @@
 {
     NTSTATUS Status;
+    struct _DEVICE_EXTENSION* pDevExt;
+    const DXGK_VIDPN_INTERFACE* pVidPnInterface;
     CONST DXGKARG_COMMITVIDPN* pCommitVidPnArg;
 } VBOXVIDPNCOMMIT, *PVBOXVIDPNCOMMIT;
 
 /* !!!NOTE: The callback is responsible for releasing the path */
-typedef DECLCALLBACK(BOOLEAN) FNVBOXVIDPNENUMPATHS(struct _DEVICE_EXTENSION* pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
-        D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
+typedef DECLCALLBACK(BOOLEAN) FNVBOXVIDPNENUMPATHS(D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
         const D3DKMDT_VIDPN_PRESENT_PATH *pNewVidPnPresentPathInfo, PVOID pContext);
 typedef FNVBOXVIDPNENUMPATHS *PFNVBOXVIDPNENUMPATHS;
 
 /* !!!NOTE: The callback is responsible for releasing the source mode info */
-typedef DECLCALLBACK(BOOLEAN) FNVBOXVIDPNENUMSOURCEMODES(struct _DEVICE_EXTENSION* pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
-        D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet, const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface,
+typedef DECLCALLBACK(BOOLEAN) FNVBOXVIDPNENUMSOURCEMODES(D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet, const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface,
         const D3DKMDT_VIDPN_SOURCE_MODE *pNewVidPnSourceModeInfo, PVOID pContext);
 typedef FNVBOXVIDPNENUMSOURCEMODES *PFNVBOXVIDPNENUMSOURCEMODES;
 
 /* !!!NOTE: The callback is responsible for releasing the target mode info */
-typedef DECLCALLBACK(BOOLEAN) FNVBOXVIDPNENUMTARGETMODES(struct _DEVICE_EXTENSION* pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
-        D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet, const DXGK_VIDPNTARGETMODESET_INTERFACE *pVidPnTargetModeSetInterface,
+typedef DECLCALLBACK(BOOLEAN) FNVBOXVIDPNENUMTARGETMODES(D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet, const DXGK_VIDPNTARGETMODESET_INTERFACE *pVidPnTargetModeSetInterface,
         const D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo, PVOID pContext);
 typedef FNVBOXVIDPNENUMTARGETMODES *PFNVBOXVIDPNENUMTARGETMODES;
@@ -78,6 +79,5 @@
 typedef FNVBOXVIDPNENUMTARGETSFORSOURCE *PFNVBOXVIDPNENUMTARGETSFORSOURCE;
 
-DECLCALLBACK(BOOLEAN) vboxVidPnCofuncModalityPathEnum(struct _DEVICE_EXTENSION* pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
-        D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
+DECLCALLBACK(BOOLEAN) vboxVidPnCofuncModalityPathEnum(D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
         const D3DKMDT_VIDPN_PRESENT_PATH *pNewVidPnPresentPathInfo, PVOID pContext);
 
@@ -90,20 +90,16 @@
         const D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo, PVOID pContext);
 
-DECLCALLBACK(BOOLEAN) vboxVidPnCommitPathEnum(struct _DEVICE_EXTENSION* pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
-        D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
+DECLCALLBACK(BOOLEAN) vboxVidPnCommitPathEnum(D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
         const D3DKMDT_VIDPN_PRESENT_PATH *pNewVidPnPresentPathInfo, PVOID pContext);
 
 NTSTATUS vboxVidPnCommitSourceModeForSrcId(struct _DEVICE_EXTENSION* pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface, D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId, struct VBOXWDDM_ALLOCATION *pAllocation);
 
-NTSTATUS vboxVidPnEnumPaths(struct _DEVICE_EXTENSION* pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
-        D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
+NTSTATUS vboxVidPnEnumPaths(D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
         PFNVBOXVIDPNENUMPATHS pfnCallback, PVOID pContext);
 
-NTSTATUS vboxVidPnEnumSourceModes(struct _DEVICE_EXTENSION* pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
-        D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet, const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface,
+NTSTATUS vboxVidPnEnumSourceModes(D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet, const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface,
         PFNVBOXVIDPNENUMSOURCEMODES pfnCallback, PVOID pContext);
 
-NTSTATUS vboxVidPnEnumTargetModes(struct _DEVICE_EXTENSION* pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
-        D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet, const DXGK_VIDPNTARGETMODESET_INTERFACE *pVidPnTargetModeSetInterface,
+NTSTATUS vboxVidPnEnumTargetModes(D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet, const DXGK_VIDPNTARGETMODESET_INTERFACE *pVidPnTargetModeSetInterface,
         PFNVBOXVIDPNENUMTARGETMODES pfnCallback, PVOID pContext);
 
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp	(revision 34017)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp	(revision 34018)
@@ -304,71 +304,4 @@
         return VBOXWDDM_HGSMICMD_TYPE_CTL;
     return VBOXWDDM_HGSMICMD_TYPE_UNDEFINED;
-}
-
-
-D3DDDIFORMAT vboxWddmCalcPixelFormat(VIDEO_MODE_INFORMATION *pInfo)
-{
-    switch (pInfo->BitsPerPlane)
-    {
-        case 32:
-            if(!(pInfo->AttributeFlags & VIDEO_MODE_PALETTE_DRIVEN) && !(pInfo->AttributeFlags & VIDEO_MODE_MANAGED_PALETTE))
-            {
-                if (pInfo->RedMask == 0xFF0000 && pInfo->GreenMask == 0xFF00 && pInfo->BlueMask == 0xFF)
-                    return D3DDDIFMT_A8R8G8B8;
-                drprintf((__FUNCTION__": unsupported format: bpp(%d), rmask(%d), gmask(%d), bmask(%d)\n", pInfo->BitsPerPlane, pInfo->RedMask, pInfo->GreenMask, pInfo->BlueMask));
-                AssertBreakpoint();
-            }
-            else
-            {
-                drprintf((__FUNCTION__": unsupported AttributeFlags(0x%x)\n", pInfo->AttributeFlags));
-                AssertBreakpoint();
-            }
-            break;
-        case 24:
-            if(!(pInfo->AttributeFlags & VIDEO_MODE_PALETTE_DRIVEN) && !(pInfo->AttributeFlags & VIDEO_MODE_MANAGED_PALETTE))
-            {
-                if (pInfo->RedMask == 0xFF0000 && pInfo->GreenMask == 0xFF00 && pInfo->BlueMask == 0xFF)
-                    return D3DDDIFMT_R8G8B8;
-                drprintf((__FUNCTION__": unsupported format: bpp(%d), rmask(%d), gmask(%d), bmask(%d)\n", pInfo->BitsPerPlane, pInfo->RedMask, pInfo->GreenMask, pInfo->BlueMask));
-                AssertBreakpoint();
-            }
-            else
-            {
-                drprintf((__FUNCTION__": unsupported AttributeFlags(0x%x)\n", pInfo->AttributeFlags));
-                AssertBreakpoint();
-            }
-            break;
-        case 16:
-            if(!(pInfo->AttributeFlags & VIDEO_MODE_PALETTE_DRIVEN) && !(pInfo->AttributeFlags & VIDEO_MODE_MANAGED_PALETTE))
-            {
-                if (pInfo->RedMask == 0xF800 && pInfo->GreenMask == 0x7E0 && pInfo->BlueMask == 0x1F)
-                    return D3DDDIFMT_R5G6B5;
-                drprintf((__FUNCTION__": unsupported format: bpp(%d), rmask(%d), gmask(%d), bmask(%d)\n", pInfo->BitsPerPlane, pInfo->RedMask, pInfo->GreenMask, pInfo->BlueMask));
-                AssertBreakpoint();
-            }
-            else
-            {
-                drprintf((__FUNCTION__": unsupported AttributeFlags(0x%x)\n", pInfo->AttributeFlags));
-                AssertBreakpoint();
-            }
-            break;
-        case 8:
-            if((pInfo->AttributeFlags & VIDEO_MODE_PALETTE_DRIVEN) && (pInfo->AttributeFlags & VIDEO_MODE_MANAGED_PALETTE))
-            {
-                return D3DDDIFMT_P8;
-            }
-            else
-            {
-                drprintf((__FUNCTION__": unsupported AttributeFlags(0x%x)\n", pInfo->AttributeFlags));
-                AssertBreakpoint();
-            }
-            break;
-        default:
-            drprintf((__FUNCTION__": unsupported bpp(%d)\n", pInfo->BitsPerPlane));
-            AssertBreakpoint();
-            break;
-    }
-
-    return D3DDDIFMT_UNKNOWN;
 }
 
@@ -3621,5 +3554,5 @@
     if (Status == STATUS_SUCCESS)
     {
-#ifdef DEBUG_misha
+#ifdef VBOXWDDM_DEBUG_VIDPN
         vboxVidPnDumpVidPn("\n>>>>IS SUPPORTED VidPN : >>>>\n", pContext, pIsSupportedVidPnArg->hDesiredVidPn, pVidPnInterface, "<<<<<<<<<<<<<<<<<<<<\n\n");
 #endif
@@ -3706,5 +3639,5 @@
     pIsSupportedVidPnArg->IsVidPnSupported = bSupported;
 
-#ifdef DEBUG_misha
+#ifdef VBOXWDDM_DEBUG_VIDPN
     drprintf(("The Given VidPn is %ssupported", pIsSupportedVidPnArg->IsVidPnSupported ? "" : "!!NOT!! "));
 #endif
@@ -3740,5 +3673,5 @@
         VIDEO_MODE_INFORMATION *pResModes = NULL;
         uint32_t cResModes = 0;
-        for (int i = commonFromDeviceExt(pDevExt)->cDisplays -1; i >= 0 ; --i)
+        for (int i = 0; i < commonFromDeviceExt(pDevExt)->cDisplays; ++i)
         {
             /* @todo: check that we actually need the current source->target */
@@ -3759,5 +3692,5 @@
             uint32_t cActualResModes;
 
-            Status = vboxWddmGetModesForResolution(pDevExt, pInfo, &Resolution,
+            Status = vboxWddmGetModesForResolution(pInfo->aModes, pInfo->cModes, pInfo->iPreferredMode, &Resolution,
                     pResModes, cResModes, &cActualResModes, &iPreferableResMode);
             Assert(Status == STATUS_SUCCESS || Status == STATUS_BUFFER_TOO_SMALL);
@@ -3777,5 +3710,5 @@
                 }
                 cResModes = cActualResModes;
-                Status = vboxWddmGetModesForResolution(pDevExt, pInfo, &Resolution,
+                Status = vboxWddmGetModesForResolution(pInfo->aModes, pInfo->cModes, pInfo->iPreferredMode, &Resolution,
                                     pResModes, cResModes, &cActualResModes, &iPreferableResMode);
                 Assert(Status == STATUS_SUCCESS);
@@ -3786,5 +3719,5 @@
                 break;
 
-            Assert(iPreferableResMode > 0);
+            Assert(iPreferableResMode >= 0);
 
             Status = vboxVidPnCreatePopulateVidPnFromLegacy(pDevExt, pRecommendFunctionalVidPnArg->hRecommendedFunctionalVidPn, pVidPnInterface,
@@ -3800,5 +3733,8 @@
         }
 
-#ifdef DEBUG_misha
+        if(pResModes)
+            vboxWddmMemFree(pResModes);
+
+#ifdef VBOXWDDM_DEBUG_VIDPN
         vboxVidPnDumpVidPn("\n>>>>Recommended VidPN: >>>>\n", pDevExt, pRecommendFunctionalVidPnArg->hRecommendedFunctionalVidPn, pVidPnInterface, "<<<<<<<<<<<<<<<<<<<<\n\n");
 #endif
@@ -3829,5 +3765,5 @@
     if (Status == STATUS_SUCCESS)
     {
-#ifdef DEBUG_misha
+#ifdef VBOXWDDM_DEBUG_VIDPN
         vboxVidPnDumpCofuncModalityArg(">>>>MODALITY Args: ", pEnumCofuncModalityArg, "\n");
         vboxVidPnDumpVidPn(">>>>MODALITY VidPN (IN) : >>>>\n", pDevExt, pEnumCofuncModalityArg->hConstrainingVidPn, pVidPnInterface, "<<<<<<<<<<<<<<<<<<<<\n\n");
@@ -3841,8 +3777,9 @@
         {
             VBOXVIDPNCOFUNCMODALITY CbContext = {0};
+            CbContext.pDevExt = pDevExt;
+            CbContext.pVidPnInterface = pVidPnInterface;
             CbContext.pEnumCofuncModalityArg = pEnumCofuncModalityArg;
             CbContext.pInfos = vboxWddmGetAllVideoModesInfos(pDevExt);
-            Status = vboxVidPnEnumPaths(pDevExt, pEnumCofuncModalityArg->hConstrainingVidPn, pVidPnInterface,
-                    hVidPnTopology, pVidPnTopologyInterface,
+            Status = vboxVidPnEnumPaths(hVidPnTopology, pVidPnTopologyInterface,
                     vboxVidPnCofuncModalityPathEnum, &CbContext);
             Assert(Status == STATUS_SUCCESS);
@@ -3860,5 +3797,5 @@
             drprintf((__FUNCTION__ ": pfnGetTopology failed Status(0x%x)\n", Status));
 
-#ifdef DEBUG_misha
+#ifdef VBOXWDDM_DEBUG_VIDPN
         vboxVidPnDumpVidPn("\n>>>>MODALITY VidPN (OUT) : >>>>\n", pDevExt, pEnumCofuncModalityArg->hConstrainingVidPn, pVidPnInterface, "<<<<<<<<<<<<<<<<<<<<\n\n");
 #endif
@@ -4052,5 +3989,5 @@
     if (Status == STATUS_SUCCESS)
     {
-#ifdef DEBUG_misha
+#ifdef VBOXWDDM_DEBUG_VIDPN
         vboxVidPnDumpVidPn("\n>>>>COMMIT VidPN: >>>>\n", pDevExt, pCommitVidPnArg->hFunctionalVidPn, pVidPnInterface, "<<<<<<<<<<<<<<<<<<<<\n\n");
 #endif
@@ -4080,7 +4017,8 @@
             {
                 VBOXVIDPNCOMMIT CbContext = {0};
+                CbContext.pDevExt = pDevExt;
+                CbContext.pVidPnInterface = pVidPnInterface;
                 CbContext.pCommitVidPnArg = pCommitVidPnArg;
-                Status = vboxVidPnEnumPaths(pDevExt, pCommitVidPnArg->hFunctionalVidPn, pVidPnInterface,
-                            hVidPnTopology, pVidPnTopologyInterface,
+                Status = vboxVidPnEnumPaths(hVidPnTopology, pVidPnTopologyInterface,
                             vboxVidPnCommitPathEnum, &CbContext);
                 Assert(Status == STATUS_SUCCESS);
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.h
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.h	(revision 34017)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.h	(revision 34018)
@@ -14,4 +14,6 @@
 
 #include "../VBoxVideo.h"
+
+//#define VBOXWDDM_DEBUG_VIDPN
 
 /* one page size */
