Index: /trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp	(revision 30864)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp	(revision 30865)
@@ -1885,4 +1885,10 @@
     HRESULT hr = S_OK;
 
+#ifdef DEBUG_misha
+    uint32_t iBackBuf = (pDevice->iRenderTargetFrontBuf + 1) % pDevice->pRenderTargetRc->cAllocations;
+    vboxVDbgDumpSurfData((pDevice, ">>>DrawPrimitive:\n", pDevice->pRenderTargetRc, iBackBuf,
+            NULL, (IDirect3DSurface9*)pDevice->pRenderTargetRc->aAllocations[iBackBuf].pD3DIf, "\n"));
+#endif
+
     if (!pDevice->cStreamSources)
     {
@@ -1900,4 +1906,6 @@
                                       pDevice->aStreamSourceUm[0].cbStride);
             Assert(hr == S_OK);
+
+            vboxVDbgMpPrint((pDevice, __FUNCTION__": DrawPrimitiveUP\n"));
         }
         else
@@ -1909,8 +1917,30 @@
     else
     {
+
+#ifdef DEBUG
+            for (UINT i = 0; i < RT_ELEMENTS(pDevice->aStreamSourceUm); ++i)
+            {
+                Assert(!pDevice->aStreamSourceUm[i].pvBuffer);
+            }
+
+            uint32_t cStreams = 0;
+            for (UINT i = 0; i < RT_ELEMENTS(pDevice->aStreamSource); ++i)
+            {
+                if (pDevice->aStreamSource[i])
+                {
+                    ++cStreams;
+                    Assert(!pDevice->aStreamSource[i]->LockInfo.cLocks);
+                }
+            }
+
+            Assert(cStreams);
+            Assert(cStreams == pDevice->cStreamSources);
+#endif
         hr = pDevice->pDevice9If->DrawPrimitive(pData->PrimitiveType,
                                                 pData->VStart,
                                                 pData->PrimitiveCount);
         Assert(hr == S_OK);
+
+        vboxVDbgMpPrint((pDevice, __FUNCTION__": DrawPrimitive\n"));
 #if 0
         IDirect3DVertexDeclaration9* pDecl;
@@ -2121,4 +2151,11 @@
 #endif
     }
+
+#ifdef DEBUG_misha
+    iBackBuf = (pDevice->iRenderTargetFrontBuf + 1) % pDevice->pRenderTargetRc->cAllocations;
+    vboxVDbgDumpSurfData((pDevice, "<<<DrawPrimitive:\n", pDevice->pRenderTargetRc, iBackBuf,
+            NULL, (IDirect3DSurface9*)pDevice->pRenderTargetRc->aAllocations[iBackBuf].pD3DIf, "\n"));
+#endif
+
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
     return hr;
@@ -2131,4 +2168,33 @@
     Assert(pDevice);
     Assert(pDevice->pDevice9If);
+#ifdef DEBUG_misha
+    uint32_t iBackBuf = (pDevice->iRenderTargetFrontBuf + 1) % pDevice->pRenderTargetRc->cAllocations;
+    vboxVDbgDumpSurfData((pDevice, ">>>DrawIndexedPrimitive:\n", pDevice->pRenderTargetRc, iBackBuf,
+            NULL, (IDirect3DSurface9*)pDevice->pRenderTargetRc->aAllocations[iBackBuf].pD3DIf, "\n"));
+#endif
+
+#ifdef DEBUG
+            for (UINT i = 0; i < RT_ELEMENTS(pDevice->aStreamSourceUm); ++i)
+            {
+                Assert(!pDevice->aStreamSourceUm[i].pvBuffer);
+            }
+
+            Assert(pDevice->pIndicesAlloc);
+            Assert(!pDevice->pIndicesAlloc->LockInfo.cLocks);
+
+            uint32_t cStreams = 0;
+            for (UINT i = 0; i < RT_ELEMENTS(pDevice->aStreamSource); ++i)
+            {
+                if (pDevice->aStreamSource[i])
+                {
+                    ++cStreams;
+                    Assert(!pDevice->aStreamSource[i]->LockInfo.cLocks);
+                }
+            }
+
+            Assert(cStreams);
+            Assert(cStreams == pDevice->cStreamSources);
+#endif
+
     HRESULT hr = pDevice->pDevice9If->DrawIndexedPrimitive(
             pData->PrimitiveType,
@@ -2139,4 +2205,11 @@
             pData->PrimitiveCount);
     Assert(hr == S_OK);
+
+#ifdef DEBUG_misha
+    iBackBuf = (pDevice->iRenderTargetFrontBuf + 1) % pDevice->pRenderTargetRc->cAllocations;
+    vboxVDbgDumpSurfData((pDevice, "<<<DrawIndexedPrimitive:\n", pDevice->pRenderTargetRc, iBackBuf,
+            NULL, (IDirect3DSurface9*)pDevice->pRenderTargetRc->aAllocations[iBackBuf].pD3DIf, "\n"));
+#endif
+
 
     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
@@ -2197,4 +2270,14 @@
     hr = pDevice->pDevice9If->DrawPrimitive(pData->PrimitiveType, pData->FirstVertexOffset, pData->PrimitiveCount);
 #else
+#ifdef DEBUG_misha
+    uint32_t iBackBuf = (pDevice->iRenderTargetFrontBuf + 1) % pDevice->pRenderTargetRc->cAllocations;
+    vboxVDbgDumpSurfData((pDevice, ">>>DrawPrimitive2:\n", pDevice->pRenderTargetRc, iBackBuf,
+            NULL, (IDirect3DSurface9*)pDevice->pRenderTargetRc->aAllocations[iBackBuf].pD3DIf, "\n"));
+#endif
+
+#ifdef DEBUG
+    uint32_t cStreams = 0;
+#endif
+
     int stream;
     for (stream=0; stream<VBOXWDDMDISP_MAX_VERTEX_STREAMS; ++stream)
@@ -2202,4 +2285,7 @@
         if (pDevice->aStreamSource[stream])
         {
+#ifdef DEBUG
+            ++cStreams;
+#endif
             Assert(stream==0); /*only stream 0 should be accessed here*/
             Assert(pDevice->StreamSourceInfo[stream].uiStride!=0);
@@ -2208,4 +2294,6 @@
             if (pDevice->aStreamSource[stream]->LockInfo.cLocks)
             {
+                vboxVDbgMpPrint((pDevice, __FUNCTION__": DrawPrimitiveUP\n"));
+
                 Assert(pLock->fFlags.MightDrawFromLocked && (pLock->fFlags.Discard || pLock->fFlags.NoOverwrite));
                 hr = pDevice->pDevice9If->DrawPrimitiveUP(pData->PrimitiveType, pData->PrimitiveCount,
@@ -2214,11 +2302,26 @@
                 Assert(hr == S_OK);
                 hr = pDevice->pDevice9If->SetStreamSource(stream, (IDirect3DVertexBuffer9*)pDevice->aStreamSource[stream]->pD3DIf, pDevice->StreamSourceInfo[stream].uiOffset, pDevice->StreamSourceInfo[stream].uiStride);
+                Assert(hr == S_OK);
             }
             else
             {
+                vboxVDbgMpPrint((pDevice, __FUNCTION__": DrawPrimitive\n"));
+
                 hr = pDevice->pDevice9If->DrawPrimitive(pData->PrimitiveType, pData->FirstVertexOffset/pDevice->StreamSourceInfo[stream].uiStride, pData->PrimitiveCount);
-            }
-        }
-    }
+                Assert(hr == S_OK);
+            }
+        }
+    }
+
+#ifdef DEBUG
+    Assert(cStreams);
+    Assert(cStreams == pDevice->cStreamSources);
+#endif
+#endif
+
+#ifdef DEBUG_misha
+    iBackBuf = (pDevice->iRenderTargetFrontBuf + 1) % pDevice->pRenderTargetRc->cAllocations;
+    vboxVDbgDumpSurfData((pDevice, "<<<DrawPrimitive2:\n", pDevice->pRenderTargetRc, iBackBuf,
+            NULL, (IDirect3DSurface9*)pDevice->pRenderTargetRc->aAllocations[iBackBuf].pD3DIf, "\n"));
 #endif
 
@@ -2260,4 +2363,7 @@
     PVBOXWDDMDISP_RESOURCE pDstRc = (PVBOXWDDMDISP_RESOURCE)pData->hDstResource;
     PVBOXWDDMDISP_RESOURCE pSrcRc = (PVBOXWDDMDISP_RESOURCE)pData->hSrcResource;
+    /* requirements for D3DDevice9::UpdateTexture */
+    Assert(pSrcRc->RcDesc.enmPool == D3DDDIPOOL_SYSTEMMEM);
+    Assert(pDstRc->RcDesc.enmPool != D3DDDIPOOL_SYSTEMMEM);
     IDirect3DTexture9 *pD3DIfSrcTex = (IDirect3DTexture9*)pSrcRc->aAllocations[0].pD3DIf;
     IDirect3DTexture9 *pD3DIfDstTex = (IDirect3DTexture9*)pDstRc->aAllocations[0].pD3DIf;
@@ -4089,23 +4195,4 @@
 }
 
-#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)
 {
@@ -4118,4 +4205,7 @@
     Assert(pDstRc->cAllocations > pData->DstSubResourceIndex);
     Assert(pSrcRc->cAllocations > pData->SrcSubResourceIndex);
+//    Assert(pSrcRc->RcDesc.enmPool != D3DDDIPOOL_SYSTEMMEM);
+    /* @todo: use UpdateRect in case of Src is a D3DDDIPOOL_SYSTEMMEM */
+    Assert(pDstRc->RcDesc.enmPool != D3DDDIPOOL_SYSTEMMEM);
     Assert(pDstRc != pDevice->pRenderTargetRc || pDevice->iRenderTargetFrontBuf != pData->DstSubResourceIndex);
     HRESULT hr = S_OK;
@@ -4191,46 +4281,8 @@
                 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
+//#ifdef DEBUG_misha
+//                vboxVDbgDumpSurfData((pDevice, "Blt-pre Src:\n", pSrcRc, pData->SrcSubResourceIndex, &pData->SrcRect, pSrcSurfIf, "\n"));
+//                vboxVDbgDumpSurfData((pDevice, "Blt-pre Dst:\n", pDstRc, pData->DstSubResourceIndex, &pData->DstRect, pDstSurfIf, "\n"));
+//#endif
                 /* we support only Point & Linear, we ignore [Begin|Continue|End]PresentToDwm */
                 Assert((pData->Flags.Value & (~(0x00000100 | 0x00000200 | 0x00000400 | 0x00000001  | 0x00000002))) == 0);
@@ -4242,46 +4294,8 @@
                 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
+//#ifdef DEBUG_misha
+//                vboxVDbgDumpSurfData((pDevice, "Blt-post Src:\n", pSrcRc, pData->SrcSubResourceIndex, &pData->SrcRect, pSrcSurfIf, "\n"));
+//                vboxVDbgDumpSurfData((pDevice, "Blt-post Dst:\n", pDstRc, pData->DstSubResourceIndex, &pData->DstRect, pDstSurfIf, "\n"));
+//#endif
                 pSrcSurfIf->Release();
             }
@@ -4456,4 +4470,11 @@
     Assert(pRc);
     Assert(pData->SubResourceIndex < pRc->cAllocations);
+    Assert(pRc == pDevice->pRenderTargetRc);
+    if (pRc == pDevice->pRenderTargetRc)
+    {
+        /* backbuffer */
+        Assert(pData->SubResourceIndex == ((pDevice->iRenderTargetFrontBuf + 1) % pDevice->pRenderTargetRc->cAllocations));
+    }
+
     HRESULT hr = S_OK;
     IDirect3DSurface9 *pD3D9Surf;
@@ -5345,4 +5366,107 @@
 
 #ifdef VBOXWDDMDISP_DEBUG
+VOID vboxVDbgDoDumpSurfData(const PVBOXWDDMDISP_DEVICE pDevice, const char * pPrefix, const PVBOXWDDMDISP_RESOURCE pRc, uint32_t iAlloc, const RECT *pRect, IDirect3DSurface9 *pSurf, const char* pSuffix)
+{
+    if (pPrefix)
+    {
+        vboxVDbgMpPrint((pDevice, "%s", pPrefix));
+    }
+
+    Assert(pRc->cAllocations > iAlloc);
+    PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[iAlloc];
+
+    vboxVDbgMpPrintAlloc((pDevice, "allocation info:\n", pRc, iAlloc, "\n"));
+
+    D3DLOCKED_RECT Lr;
+    if (pRect)
+    {
+        Assert(pRect->right > pRect->left);
+        Assert(pRect->bottom > pRect->top);
+        vboxVDbgMpPrintRect((pDevice, "rect: ", pRect, "\n"));
+    }
+    HRESULT srcHr = pSurf->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);
+        vboxVDbgMpPrint((pDevice, "<?dml?><exec cmd=\"!vbvdbg.ms 0x%p 0n%d 0n%d 0n%d 0n%d\">surface info</exec>\n",
+                Lr.pBits, pAlloc->SurfDesc.width, pAlloc->SurfDesc.height, bpp, Lr.Pitch));
+        if (pRect)
+        {
+            vboxVDbgMpPrint((pDevice, "<?dml?><exec cmd=\"!vbvdbg.ms 0x%p 0n%d 0n%d 0n%d 0n%d\">rect info</exec>\n",
+                    ((uint8_t*)Lr.pBits) + (pRect->top * Lr.Pitch) + ((pRect->left * bpp) >> 3),
+                    pRect->right - pRect->left, pRect->bottom - pRect->top, bpp, Lr.Pitch));
+        }
+        Assert(0);
+
+        srcHr = pSurf->UnlockRect();
+        Assert(srcHr == S_OK);
+    }
+    if (pSuffix)
+    {
+        vboxVDbgMpPrint((pDevice, "%s\n", pSuffix));
+    }
+}
+
+void vboxVDbgDoMpPrintAlloc(const PVBOXWDDMDISP_DEVICE pDevice, const char * pPrefix, const PVBOXWDDMDISP_RESOURCE pRc, uint32_t iAlloc, const char * pSuffix)
+{
+    Assert(pRc->cAllocations > iAlloc);
+    PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[iAlloc];
+    vboxVDbgDoMpPrintF(pDevice, "%s width(%d), height(%d), format(%d), usage(%s), %s", pPrefix,
+            pAlloc->SurfDesc.width, pAlloc->SurfDesc.height, pAlloc->SurfDesc.format,
+            pRc == pDevice->pRenderTargetRc ?
+                    (iAlloc == pDevice->iRenderTargetFrontBuf ? "Front Buffer" : "Back Buffer")
+                    : "?Everage? Alloc",
+            pSuffix);
+}
+
+void vboxVDbgDoMpPrintRect(const PVBOXWDDMDISP_DEVICE pDevice, const char * pPrefix, const RECT *pRect, const char * pSuffix)
+{
+    vboxVDbgDoMpPrintF(pDevice, "%s left(%d), top(%d), right(%d), bottom(%d) %s", pPrefix, pRect->left, pRect->top, pRect->right, pRect->bottom, pSuffix);
+}
+
+VOID vboxVDbgDoMpPrint(const PVBOXWDDMDISP_DEVICE pDevice, LPCSTR szString)
+{
+    uint32_t cbString = strlen(szString) + 1;
+    uint32_t cbCmd = RT_OFFSETOF(VBOXDISPIFESCAPE_DBGPRINT, aStringBuf[cbString]);
+    PVBOXDISPIFESCAPE_DBGPRINT pCmd = (PVBOXDISPIFESCAPE_DBGPRINT)RTMemAllocZ(cbCmd);
+    Assert(pCmd);
+    if (pCmd)
+    {
+        pCmd->EscapeHdr.escapeCode = VBOXESC_DBGPRINT;
+        memcpy(pCmd->aStringBuf, szString, cbString);
+
+        D3DDDICB_ESCAPE DdiEscape = {0};
+        DdiEscape.hContext = NULL;
+        DdiEscape.hDevice = NULL;
+        DdiEscape.Flags.Value = 0;
+        DdiEscape.pPrivateDriverData = pCmd;
+        DdiEscape.PrivateDriverDataSize = cbCmd;
+
+        HRESULT hr = pDevice->RtCallbacks.pfnEscapeCb(pDevice->pAdapter->hAdapter, &DdiEscape);
+        Assert(hr == S_OK);
+
+        RTMemFree(pCmd);
+    }
+}
+VOID vboxVDbgDoMpPrintF(const PVBOXWDDMDISP_DEVICE pDevice, LPCSTR szString, ...)
+{
+    char szBuffer[4096] = {0};
+    va_list pArgList;
+    va_start(pArgList, szString);
+    _vsnprintf(szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]), szString, pArgList);
+    va_end(pArgList);
+
+    if (pDevice)
+    {
+        vboxVDbgDoMpPrint(pDevice, szBuffer);
+    }
+    else
+    {
+        OutputDebugStringA(szBuffer);
+    }
+}
 VOID vboxVDbgDoPrint(LPCSTR szString, ...)
 {
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3DCmn.h
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3DCmn.h	(revision 30864)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3DCmn.h	(revision 30865)
@@ -56,5 +56,9 @@
 
 #ifdef VBOXWDDMDISP_DEBUG
+VOID vboxVDbgDoDumpSurfData(const PVBOXWDDMDISP_DEVICE pDevice, const char * pPrefix, const PVBOXWDDMDISP_RESOURCE pRc, uint32_t iAlloc, const RECT *pRect, IDirect3DSurface9 *pSurf, const char* pSuffix);
+void vboxVDbgDoMpPrintRect(const PVBOXWDDMDISP_DEVICE pDevice, const char * pPrefix, const RECT *pRect, const char * pSuffix);
+void vboxVDbgDoMpPrintAlloc(const PVBOXWDDMDISP_DEVICE pDevice, const char * pPrefix, const PVBOXWDDMDISP_RESOURCE pRc, uint32_t iAlloc, const char * pSuffix);
 VOID vboxVDbgDoPrint(LPCSTR szString, ...);
+VOID vboxVDbgDoMpPrintF(const PVBOXWDDMDISP_DEVICE pDevice, LPCSTR szString, ...);
 void vboxVDbgVEHandlerRegister();
 void vboxVDbgVEHandlerUnregister();
@@ -66,4 +70,20 @@
     } while (0)
 #define vboxVDbgPrintR vboxVDbgPrint
+#define vboxVDbgMpPrint(_m) \
+    do { \
+        vboxVDbgDoMpPrintF _m ; \
+    } while (0)
+#define vboxVDbgMpPrintRect(_m) \
+    do { \
+        vboxVDbgDoMpPrintRect _m ; \
+    } while (0)
+#define vboxVDbgMpPrintAlloc(_m) \
+    do { \
+        vboxVDbgDoMpPrintAlloc _m ; \
+    } while (0)
+#define vboxVDbgDumpSurfData(_m) \
+    do { \
+        vboxVDbgDoDumpSurfData _m ; \
+    } while (0)
 #ifdef VBOXWDDMDISP_DEBUG_FLOW
 # define vboxVDbgPrintF  vboxVDbgPrint
@@ -72,4 +92,8 @@
 #endif
 #else
+#define vboxVDbgMpPrint(_m) do {} while (0)
+#define vboxVDbgMpPrintRect(_m) do {} while (0)
+#define vboxVDbgMpPrintAlloc(_m) do {} while (0)
+#define vboxVDbgDumpSurfData(_m) do {} while (0)
 #define vboxVDbgBreak() do {} while (0)
 #define vboxVDbgPrint(_m)  do {} while (0)
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoIf.h
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoIf.h	(revision 30864)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoIf.h	(revision 30865)
@@ -231,4 +231,12 @@
 AssertCompile((sizeof (VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD) & 7) == 0);
 AssertCompile(RT_OFFSETOF(VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD, EscapeHdr) == 0);
+
+typedef struct VBOXDISPIFESCAPE_DBGPRINT
+{
+    VBOXDISPIFESCAPE EscapeHdr;
+    /* null-terminated string to DbgPrint including \0 */
+    char aStringBuf[1];
+} VBOXDISPIFESCAPE_DBGPRINT, *PVBOXDISPIFESCAPE_DBGPRINT;
+AssertCompile(RT_OFFSETOF(VBOXDISPIFESCAPE_DBGPRINT, EscapeHdr) == 0);
 
 /* query info func */
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVdma.cpp
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVdma.cpp	(revision 30864)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVdma.cpp	(revision 30865)
@@ -146,5 +146,5 @@
         {
             vboxVideoLeDetach(&pPipe->CmdListHead, pDetachHead);
-            bListEmpty = IsListEmpty(pDetachHead);
+            bListEmpty = !!(IsListEmpty(pDetachHead));
             pPipe->bNeedNotify = bListEmpty;
         }
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp	(revision 30864)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp	(revision 30865)
@@ -2784,5 +2784,24 @@
                 Status = STATUS_SUCCESS;
                 break;
+            case VBOXESC_DBGPRINT:
+            {
+                /* use RT_OFFSETOF instead of sizeof since sizeof will give an aligned size that might
+                 * be bigger than the VBOXDISPIFESCAPE_DBGPRINT with a data containing just a few chars */
+                Assert(pEscape->PrivateDriverDataSize >= RT_OFFSETOF(VBOXDISPIFESCAPE_DBGPRINT, aStringBuf[1]));
+                /* only do DbgPrint when pEscape->PrivateDriverDataSize > RT_OFFSETOF(VBOXDISPIFESCAPE_DBGPRINT, aStringBuf[1])
+                 * since == RT_OFFSETOF(VBOXDISPIFESCAPE_DBGPRINT, aStringBuf[1]) means the buffer contains just \0,
+                 * i.e. no need to print it */
+                if (pEscape->PrivateDriverDataSize > RT_OFFSETOF(VBOXDISPIFESCAPE_DBGPRINT, aStringBuf[1]))
+                {
+                    PVBOXDISPIFESCAPE_DBGPRINT pDbgPrint = (PVBOXDISPIFESCAPE_DBGPRINT)pEscapeHdr;
+                    /* ensure the last char is \0*/
+                    *((uint8_t*)pDbgPrint + pEscape->PrivateDriverDataSize - 1) = '\0';
+                    DbgPrint(pDbgPrint->aStringBuf);
+                }
+                Status = STATUS_SUCCESS;
+                break;
+            }
             default:
+                Assert(0);
                 drprintf((__FUNCTION__": unsupported escape code (0x%x)\n", pEscapeHdr->escapeCode));
                 break;
Index: /trunk/src/VBox/Additions/WINNT/include/VBoxDisplay.h
===================================================================
--- /trunk/src/VBox/Additions/WINNT/include/VBoxDisplay.h	(revision 30864)
+++ /trunk/src/VBox/Additions/WINNT/include/VBoxDisplay.h	(revision 30865)
@@ -21,4 +21,5 @@
 # define VBOXESC_REINITVIDEOMODES           0xABCD9003
 # define VBOXESC_GETVBOXVIDEOCMCMD          0xABCD9004
+# define VBOXESC_DBGPRINT                   0xABCD9005
 
 #include <iprt/assert.h>
