Index: trunk/src/VBox/Additions/WINNT/Graphics/Display/Makefile.kmk
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Display/Makefile.kmk	(revision 30795)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Display/Makefile.kmk	(revision 30855)
@@ -106,4 +106,14 @@
 endif
 
+ifdef VBOXVIDEOWINDBG
+DLLS += vbvdbg
+vbvdbg_TEMPLATE = VBOXR3STATIC
+vbvdbg_DEFS     = UNICODE _UNICODE
+vbvdbg_SOURCES  = \
+	wddm/dbg/VBoxVideoWinDbg.cpp \
+	wddm/dbg/VBoxVideoWinDbg.def
+vbvdbg_SDKS     = WINDDKWLH
+endif
+
 include	$(KBUILD_PATH)/subfooter.kmk
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispCm.cpp
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispCm.cpp	(revision 30795)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispCm.cpp	(revision 30855)
@@ -234,5 +234,5 @@
             }
             default:
-                AssertBreakpoint();
+                Assert(0);
                 return E_FAIL;
         }
@@ -240,5 +240,5 @@
 
     /* should never be here */
-    AssertBreakpoint();
+    Assert(0);
     return E_FAIL;
 }
Index: trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp	(revision 30795)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp	(revision 30855)
@@ -1084,26 +1084,20 @@
     PVBOXWDDMDISP_ALLOCATION pAlloc;
     UINT iBBuf = 0;
-    for (UINT i = iNewRTFB + 1; i < pRc->cAllocations; ++i, ++iBBuf)
-    {
-        pAlloc = &pRc->aAllocations[i];
-        Assert(i != iNewRTFB);
+    Assert(iNewRTFB < pRc->cAllocations);
+
+    for (UINT i = 1; i < pRc->cAllocations; ++i, ++iBBuf)
+    {
+        UINT iAlloc = (iNewRTFB + i) % pRc->cAllocations;
+        Assert(iAlloc != iNewRTFB);
+        pAlloc = &pRc->aAllocations[iAlloc];
         HRESULT tmpHr = vboxWddmRenderTargetUpdateSurface(pDevice, pAlloc, iBBuf);
         Assert(tmpHr == S_OK);
     }
 
-    for (UINT i = 0; iBBuf < pRc->cAllocations-1; ++i, ++iBBuf)
-    {
-        Assert(i != iNewRTFB);
-        pAlloc = &pRc->aAllocations[i];
-        HRESULT tmpHr = vboxWddmRenderTargetUpdateSurface(pDevice, pAlloc, iBBuf);
-        Assert(tmpHr == S_OK);
-    }
-
+    pAlloc = &pRc->aAllocations[iNewRTFB];
 #ifdef VBOXWDDM_WITH_VISIBLE_FB
-    pAlloc = &pRc->aAllocations[iNewRTFB];
     HRESULT tmpHr = vboxWddmRenderTargetUpdateSurface(pDevice, pAlloc, ~0UL /* <- for the frontbuffer */);
     Assert(tmpHr == S_OK);
 #else
-    pAlloc = &pRc->aAllocations[iNewRTFB];
     if (pAlloc->pD3DIf)
     {
@@ -1117,4 +1111,9 @@
     {
         pAlloc = &pRc->aAllocations[i];
+        if (iNewRTFB == i)
+        {
+            Assert(!pAlloc->pD3DIf);
+        }
+
         for (UINT j = i+1; j < pRc->cAllocations; ++j)
         {
@@ -1126,4 +1125,62 @@
     return S_OK;
 }
+
+#ifdef DEBUG
+static void vboxWddmDbgRenderTargetUpdateCheckSurface(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_ALLOCATION pAlloc, uint32_t iBBuf)
+{
+    IDirect3DSurface9 *pD3D9Surf;
+    Assert(pAlloc->enmD3DIfType == VBOXDISP_D3DIFTYPE_SURFACE);
+    HRESULT hr = pDevice->pDevice9If->GetBackBuffer(0 /*UINT iSwapChain*/,
+            iBBuf, D3DBACKBUFFER_TYPE_MONO, &pD3D9Surf);
+    Assert(hr == S_OK);
+    if (hr == S_OK)
+    {
+        Assert(pD3D9Surf);
+        Assert(pD3D9Surf == pAlloc->pD3DIf);
+        pD3D9Surf->Release();
+    }
+}
+
+static void vboxWddmDbgRenderTargetCheck(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_RESOURCE pRc, uint32_t iNewRTFB)
+{
+    PVBOXWDDMDISP_ALLOCATION pAlloc;
+    UINT iBBuf = 0;
+    Assert(iNewRTFB < pRc->cAllocations);
+
+    for (UINT i = 1; i < pRc->cAllocations; ++i, ++iBBuf)
+    {
+        UINT iAlloc = (iNewRTFB + i) % pRc->cAllocations;
+        Assert(iAlloc != iNewRTFB);
+        pAlloc = &pRc->aAllocations[iAlloc];
+        vboxWddmDbgRenderTargetUpdateCheckSurface(pDevice, pAlloc, iBBuf);
+    }
+
+    pAlloc = &pRc->aAllocations[iNewRTFB];
+#ifdef VBOXWDDM_WITH_VISIBLE_FB
+    vboxWddmDbgRenderTargetUpdateCheckSurface(pDevice, pAlloc, ~0UL /* <- for the frontbuffer */);
+#else
+    Assert(pAlloc->pD3DIf == NULL);
+#endif
+
+    for (UINT i = 0; i < pRc->cAllocations; ++i)
+    {
+        pAlloc = &pRc->aAllocations[i];
+        if (iNewRTFB == i)
+        {
+            Assert(!pAlloc->pD3DIf);
+        }
+
+        for (UINT j = i+1; j < pRc->cAllocations; ++j)
+        {
+            PVBOXWDDMDISP_ALLOCATION pAllocJ = &pRc->aAllocations[j];
+            Assert(pAlloc->pD3DIf != pAllocJ->pD3DIf);
+        }
+    }
+}
+
+# define VBOXVDBG_RTGT_STATECHECK(_pDev) (vboxWddmDbgRenderTargetCheck((_pDev), (_pDev)->pRenderTargetRc, (_pDev)->iRenderTargetFrontBuf))
+#else
+# define VBOXVDBG_RTGT_STATECHECK(_pDev) do{}while(0)
+#endif
 
 static D3DFORMAT vboxDDI2D3DFormat(D3DDDIFORMAT format)
@@ -1152,5 +1209,5 @@
         return D3DPOOL_DEFAULT;
     default:
-        AssertBreakpoint();
+        Assert(0);
     }
     return D3DPOOL_DEFAULT;
@@ -1289,4 +1346,7 @@
         case DLL_PROCESS_ATTACH:
         {
+#ifdef VBOXWDDMDISP_DEBUG
+            vboxVDbgVEHandlerRegister();
+#endif
             RTR3Init();
 
@@ -1311,4 +1371,7 @@
         case DLL_PROCESS_DETACH:
         {
+#ifdef VBOXWDDMDISP_DEBUG
+            vboxVDbgVEHandlerUnregister();
+#endif
             HRESULT hr;
 #ifdef VBOXDISPMP_TEST
@@ -1432,5 +1495,5 @@
             memcpy(pData->pData, gVBoxQueryTypes, VBOX_QUERYTYPE_COUNT() * sizeof (D3DDDIQUERYTYPE));
 #else
-            AssertBreakpoint();
+            Assert(0);
             memset(pData->pData, 0, pData->DataSize);
 #endif
@@ -1525,5 +1588,5 @@
         {
             Assert(pData->DataSize >= sizeof (D3DCAPS9));
-//            AssertBreakpoint();
+//            Assert(0);
             if (pData->DataSize >= sizeof (D3DCAPS9))
             {
@@ -1579,5 +1642,5 @@
                         else
                         {
-                            AssertBreakpoint();
+                            Assert(0);
                         }
 #endif
@@ -1627,5 +1690,5 @@
         case D3DDDICAPS_GETEXTENSIONCAPS:
             vboxVDbgPrint((__FUNCTION__": unimplemented caps type(%d)\n", pData->Type));
-            AssertBreakpoint();
+            Assert(0);
             if (pData->pData && pData->DataSize)
                 memset(pData->pData, 0, pData->DataSize);
@@ -1633,5 +1696,5 @@
         default:
             vboxVDbgPrint((__FUNCTION__": unknown caps type(%d)\n", pData->Type));
-            AssertBreakpoint();
+            Assert(0);
     }
 
@@ -1663,5 +1726,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -1758,5 +1821,5 @@
 //        if (pStreamData)
 //        {
-//            AssertBreakpoint();
+//            Assert(0);
 //            /* @todo: impl! */
 //        }
@@ -1841,5 +1904,5 @@
         {
             /* todo: impl */
-            AssertBreakpoint();
+            Assert(0);
         }
     }
@@ -1943,5 +2006,5 @@
                                     break;
                                 default:
-                                    AssertBreakpoint();
+                                    Assert(0);
                                     cbType = 1;
                             }
@@ -1970,5 +2033,5 @@
                                     break;
                                 default:
-                                    AssertBreakpoint();
+                                    Assert(0);
                                     cVertexes = pData->PrimitiveCount;
                             }
@@ -2084,5 +2147,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -2092,5 +2155,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -2168,5 +2231,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -2176,5 +2239,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -2184,5 +2247,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -2218,5 +2281,5 @@
         else
         {
-            AssertBreakpoint();
+            Assert(0);
             /* @todo: impl */
         }
@@ -2224,5 +2287,5 @@
     else
     {
-        AssertBreakpoint();
+        Assert(0);
         /* @todo: impl */
     }
@@ -2235,5 +2298,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -2242,5 +2305,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -2274,5 +2337,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -2282,5 +2345,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -2304,5 +2367,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -2311,5 +2374,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -2346,5 +2409,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -2353,5 +2416,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -2360,5 +2423,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -2367,5 +2430,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -2386,5 +2449,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_NOTIMPL;
@@ -2708,5 +2771,5 @@
         else
         {
-            AssertBreakpoint();
+            Assert(0);
         }
     }
@@ -2744,5 +2807,5 @@
             {
                 vboxVDbgPrintF((__FUNCTION__": Implement Box area"));
-                AssertBreakpoint();
+                Assert(0);
             }
             else
@@ -2906,5 +2969,5 @@
         else
         {
-            AssertBreakpoint();
+            Assert(0);
         }
     }
@@ -2939,5 +3002,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -2946,5 +3009,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -2953,5 +3016,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -3074,5 +3137,5 @@
             if (pResource->Flags.SharedResource)
             {
-                AssertBreakpoint(); /* <-- need to test that */
+                Assert(0); /* <-- need to test that */
                 bIssueCreateResource = true;
             }
@@ -3645,4 +3708,6 @@
         Assert(pDevice->pDevice9If);
 #if 1
+        VBOXVDBG_RTGT_STATECHECK(pDevice);
+
         hr = pDevice->pDevice9If->Present(NULL, /* CONST RECT * pSourceRect */
                 NULL, /* CONST RECT * pDestRect */
@@ -3665,7 +3730,5 @@
             Assert(pRc->aAllocations[0].enmD3DIfType == VBOXDISP_D3DIFTYPE_SURFACE);
             Assert(pRc->RcDesc.fFlags.RenderTarget);
-            uint32_t iNewRTFB = pDevice->iRenderTargetFrontBuf + 1;
-            if (iNewRTFB >= pRc->cAllocations)
-                iNewRTFB = 0;
+            uint32_t iNewRTFB = (pDevice->iRenderTargetFrontBuf + 1) % pRc->cAllocations;
 
             Assert(pDevice->iRenderTargetFrontBuf != iNewRTFB);
@@ -3676,4 +3739,6 @@
             /* assign a new frontbuffer index */
             pDevice->iRenderTargetFrontBuf = iNewRTFB;
+
+            VBOXVDBG_RTGT_STATECHECK(pDevice);
         }
         D3DDDICB_PRESENT DdiPresent = {0};
@@ -3907,5 +3972,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -3914,5 +3979,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -3921,5 +3986,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -3952,5 +4017,5 @@
         }
         default:
-            AssertBreakpoint();
+            Assert(0);
             break;
     }
@@ -3980,5 +4045,5 @@
         }
         default:
-            AssertBreakpoint();
+            Assert(0);
             hr = E_FAIL;
             break;
@@ -4017,5 +4082,5 @@
         }
         default:
-            AssertBreakpoint();
+            Assert(0);
             hr = E_FAIL;
             break;
@@ -4023,4 +4088,23 @@
     return hr;
 }
+
+#ifdef DEBUG_misha
+static void vboxWddmDbgSurfData(PVBOXWDDMDISP_ALLOCATION pAlloc, IDirect3DSurface9 *pSurf)
+{
+    D3DLOCKED_RECT Lr;
+    HRESULT tmpHr = pSurf->LockRect(&Lr, NULL, D3DLOCK_READONLY);
+    Assert(tmpHr == S_OK);
+    if (tmpHr == S_OK)
+    {
+        UINT bpp = vboxWddmCalcBitsPerPixel(pAlloc->SurfDesc.format);
+        Assert(bpp == pAlloc->SurfDesc.bpp);
+        Assert(pAlloc->SurfDesc.pitch == Lr.Pitch);
+        vboxVDbgPrintF(("!vbvdbg.ms 0x%p 0x%x 0x%x 0x%x 0x%x\n",
+                Lr.pBits, pAlloc->SurfDesc.width, pAlloc->SurfDesc.height, bpp, Lr.Pitch));
+        Assert(0);
+        tmpHr = pSurf->UnlockRect();
+    }
+}
+#endif
 
 static HRESULT APIENTRY vboxWddmDDevBlt(HANDLE hDevice, CONST D3DDDIARG_BLT* pData)
@@ -4106,4 +4190,47 @@
             {
                 Assert(pSrcSurfIf);
+
+#ifdef DEBUG_misha
+                {
+                    D3DLOCKED_RECT Lr;
+                    PVBOXWDDMDISP_ALLOCATION pAlloc = &pSrcRc->aAllocations[pData->SrcSubResourceIndex];
+                    HRESULT srcHr = pSrcSurfIf->LockRect(&Lr, NULL, D3DLOCK_READONLY);
+                    Assert(srcHr == S_OK);
+                    if (srcHr == S_OK)
+                    {
+                        UINT bpp = vboxWddmCalcBitsPerPixel(pAlloc->SurfDesc.format);
+                        Assert(bpp == pAlloc->SurfDesc.bpp);
+                        Assert(pAlloc->SurfDesc.pitch == Lr.Pitch);
+                        vboxVDbgPrintF(("src: !vbvdbg.ms 0x%p 0x%x 0x%x 0x%x 0x%x\n",
+                                Lr.pBits, pAlloc->SurfDesc.width, pAlloc->SurfDesc.height, bpp, Lr.Pitch));
+                    }
+
+                    pAlloc = &pDstRc->aAllocations[pData->DstSubResourceIndex];
+                    HRESULT dstHr = pDstSurfIf->LockRect(&Lr, NULL, D3DLOCK_READONLY);
+                    Assert(dstHr == S_OK);
+                    if (dstHr == S_OK)
+                    {
+                        UINT bpp = vboxWddmCalcBitsPerPixel(pAlloc->SurfDesc.format);
+                        Assert(bpp == pAlloc->SurfDesc.bpp);
+                        Assert(pAlloc->SurfDesc.pitch == Lr.Pitch);
+                        vboxVDbgPrintF(("dst: !vbvdbg.ms 0x%p 0x%x 0x%x 0x%x 0x%x\n",
+                                Lr.pBits, pAlloc->SurfDesc.width, pAlloc->SurfDesc.height, bpp, Lr.Pitch));
+                    }
+
+                    Assert(0);
+
+                    if (srcHr == S_OK)
+                    {
+                        srcHr = pSrcSurfIf->UnlockRect();
+                        Assert(srcHr == S_OK);
+                    }
+
+                    if (dstHr == S_OK)
+                    {
+                        dstHr = pDstSurfIf->UnlockRect();
+                        Assert(dstHr == S_OK);
+                    }
+                }
+#endif
                 /* we support only Point & Linear, we ignore [Begin|Continue|End]PresentToDwm */
                 Assert((pData->Flags.Value & (~(0x00000100 | 0x00000200 | 0x00000400 | 0x00000001  | 0x00000002))) == 0);
@@ -4114,4 +4241,47 @@
                                     vboxDDI2D3DBltFlags(pData->Flags));
                 Assert(hr == S_OK);
+
+#ifdef DEBUG_misha
+                {
+                    D3DLOCKED_RECT Lr;
+                    PVBOXWDDMDISP_ALLOCATION pAlloc = &pSrcRc->aAllocations[pData->SrcSubResourceIndex];
+                    HRESULT srcHr = pSrcSurfIf->LockRect(&Lr, NULL, D3DLOCK_READONLY);
+                    Assert(srcHr == S_OK);
+                    if (srcHr == S_OK)
+                    {
+                        UINT bpp = vboxWddmCalcBitsPerPixel(pAlloc->SurfDesc.format);
+                        Assert(bpp == pAlloc->SurfDesc.bpp);
+                        Assert(pAlloc->SurfDesc.pitch == Lr.Pitch);
+                        vboxVDbgPrintF(("src: !vbvdbg.ms 0x%p 0x%x 0x%x 0x%x 0x%x\n",
+                                Lr.pBits, pAlloc->SurfDesc.width, pAlloc->SurfDesc.height, bpp, Lr.Pitch));
+                    }
+
+                    pAlloc = &pDstRc->aAllocations[pData->DstSubResourceIndex];
+                    HRESULT dstHr = pDstSurfIf->LockRect(&Lr, NULL, D3DLOCK_READONLY);
+                    Assert(dstHr == S_OK);
+                    if (dstHr == S_OK)
+                    {
+                        UINT bpp = vboxWddmCalcBitsPerPixel(pAlloc->SurfDesc.format);
+                        Assert(bpp == pAlloc->SurfDesc.bpp);
+                        Assert(pAlloc->SurfDesc.pitch == Lr.Pitch);
+                        vboxVDbgPrintF(("dst: !vbvdbg.ms 0x%p 0x%x 0x%x 0x%x 0x%x\n",
+                                Lr.pBits, pAlloc->SurfDesc.width, pAlloc->SurfDesc.height, bpp, Lr.Pitch));
+                    }
+
+                    Assert(0);
+
+                    if (srcHr == S_OK)
+                    {
+                        srcHr = pSrcSurfIf->UnlockRect();
+                        Assert(srcHr == S_OK);
+                    }
+
+                    if (dstHr == S_OK)
+                    {
+                        dstHr = pDstSurfIf->UnlockRect();
+                        Assert(dstHr == S_OK);
+                    }
+                }
+#endif
                 pSrcSurfIf->Release();
             }
@@ -4124,5 +4294,5 @@
     {
         /* todo: fallback to memcpy or whatever ? */
-        AssertBreakpoint();
+        Assert(0);
     }
 
@@ -4182,5 +4352,5 @@
             {
 
-                AssertBreakpoint();
+                Assert(0);
                 /* @todo: impl */
             }
@@ -4188,5 +4358,5 @@
         else
         {
-            AssertBreakpoint();
+            Assert(0);
             /* @todo: impl */
         }
@@ -4226,5 +4396,5 @@
         else
         {
-            AssertBreakpoint();
+            Assert(0);
             /* @todo: impl */
         }
@@ -4238,5 +4408,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -4245,5 +4415,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -4252,5 +4422,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -4259,5 +4429,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -4266,5 +4436,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -4273,5 +4443,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -4333,5 +4503,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -4392,5 +4562,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -4399,5 +4569,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -4406,5 +4576,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -4413,5 +4583,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -4420,5 +4590,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -4427,5 +4597,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -4434,5 +4604,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -4441,5 +4611,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -4448,5 +4618,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -4455,5 +4625,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -4462,5 +4632,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -4469,5 +4639,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -4476,5 +4646,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -4483,5 +4653,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -4490,5 +4660,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -4497,5 +4667,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -4680,5 +4850,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -4687,5 +4857,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -4716,5 +4886,5 @@
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
-    AssertBreakpoint();
+    Assert(0);
     HRESULT hr = S_OK;
 #if 0
@@ -4805,5 +4975,5 @@
                         break;
                     default:
-                        AssertBreakpoint();
+                        Assert(0);
                         hr = E_INVALIDARG;
                 }
@@ -4814,5 +4984,5 @@
         else
         {
-            AssertBreakpoint(); /* <-- need to test that */
+            Assert(0); /* <-- need to test that */
 
             /* this is a "generic" resource whose creation is initiaded by the UMD */
@@ -4859,5 +5029,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -4867,5 +5037,5 @@
 {
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    AssertBreakpoint();
+    Assert(0);
     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     return E_FAIL;
@@ -4877,5 +5047,5 @@
     vboxVDbgPrint(("==> "__FUNCTION__", hAdapter(0x%p), Interface(%d), Version(%d)\n", hAdapter, pCreateData->Interface, pCreateData->Version));
 
-//    AssertBreakpoint();
+//    Assert(0);
 
     PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)RTMemAllocZ(sizeof (VBOXWDDMDISP_DEVICE));
@@ -5044,5 +5214,5 @@
     vboxVDbgPrint(("==> "__FUNCTION__", hAdapter(0x%p)\n", hAdapter));
 
-//    AssertBreakpoint();
+//    Assert(0);
 
     PVBOXWDDMDISP_ADAPTER pAdapter = (PVBOXWDDMDISP_ADAPTER)hAdapter;
@@ -5185,3 +5355,35 @@
     OutputDebugStringA(szBuffer);
 }
+
+static PVOID g_VBoxWDbgVEHandler = NULL;
+LONG WINAPI vboxVDbgVectoredHandler(struct _EXCEPTION_POINTERS *pExceptionInfo)
+{
+    PEXCEPTION_RECORD pExceptionRecord = pExceptionInfo->ExceptionRecord;
+    PCONTEXT pContextRecord = pExceptionInfo->ContextRecord;
+    switch (pExceptionRecord->ExceptionCode)
+    {
+        case 0x40010006: /* <- OutputDebugString exception, ignore */
+            break;
+        default:
+            Assert(0);
+            break;
+    }
+    return EXCEPTION_CONTINUE_SEARCH;
+}
+
+void vboxVDbgVEHandlerRegister()
+{
+    Assert(!g_VBoxWDbgVEHandler);
+    g_VBoxWDbgVEHandler = AddVectoredExceptionHandler(1,vboxVDbgVectoredHandler);
+    Assert(g_VBoxWDbgVEHandler);
+}
+
+void vboxVDbgVEHandlerUnregister()
+{
+    Assert(g_VBoxWDbgVEHandler);
+    ULONG uResult = RemoveVectoredExceptionHandler(g_VBoxWDbgVEHandler);
+    Assert(uResult);
+    g_VBoxWDbgVEHandler = NULL;
+}
+
 #endif
Index: trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3DCmn.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3DCmn.h	(revision 30795)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3DCmn.h	(revision 30855)
@@ -37,4 +37,5 @@
 #ifdef DEBUG
 # define VBOXWDDMDISP_DEBUG
+# define VBOXWDDMDISP_DEBUG_FLOW
 #endif
 
@@ -56,4 +57,6 @@
 #ifdef VBOXWDDMDISP_DEBUG
 VOID vboxVDbgDoPrint(LPCSTR szString, ...);
+void vboxVDbgVEHandlerRegister();
+void vboxVDbgVEHandlerUnregister();
 
 #define vboxVDbgBreak() AssertBreakpoint()
@@ -63,5 +66,9 @@
     } while (0)
 #define vboxVDbgPrintR vboxVDbgPrint
-#define vboxVDbgPrintF(_m)  do {} while (0)
+#ifdef VBOXWDDMDISP_DEBUG_FLOW
+# define vboxVDbgPrintF  vboxVDbgPrint
+#else
+# define vboxVDbgPrintF(_m)  do {} while (0)
+#endif
 #else
 #define vboxVDbgBreak() do {} while (0)
