Index: trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp	(revision 30885)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp	(revision 30916)
@@ -1889,9 +1889,9 @@
     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
+//#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)
@@ -1911,5 +1911,5 @@
             Assert(hr == S_OK);
 
-            vboxVDbgMpPrint((pDevice, __FUNCTION__": DrawPrimitiveUP\n"));
+//            vboxVDbgMpPrint((pDevice, __FUNCTION__": DrawPrimitiveUP\n"));
         }
         else
@@ -1946,5 +1946,5 @@
         Assert(hr == S_OK);
 
-        vboxVDbgMpPrint((pDevice, __FUNCTION__": DrawPrimitive\n"));
+//        vboxVDbgMpPrint((pDevice, __FUNCTION__": DrawPrimitive\n"));
 #if 0
         IDirect3DVertexDeclaration9* pDecl;
@@ -2156,9 +2156,9 @@
     }
 
-#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
+//#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));
@@ -2172,9 +2172,9 @@
     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_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
@@ -2210,9 +2210,9 @@
     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
+//#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
 
 
@@ -2274,9 +2274,9 @@
     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_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
@@ -2298,5 +2298,5 @@
             if (pDevice->aStreamSource[stream]->LockInfo.cLocks)
             {
-                vboxVDbgMpPrint((pDevice, __FUNCTION__": DrawPrimitiveUP\n"));
+//                vboxVDbgMpPrint((pDevice, __FUNCTION__": DrawPrimitiveUP\n"));
 
                 Assert(pLock->fFlags.MightDrawFromLocked && (pLock->fFlags.Discard || pLock->fFlags.NoOverwrite));
@@ -2310,5 +2310,5 @@
             else
             {
-                vboxVDbgMpPrint((pDevice, __FUNCTION__": DrawPrimitive\n"));
+//                vboxVDbgMpPrint((pDevice, __FUNCTION__": DrawPrimitive\n"));
 
                 hr = pDevice->pDevice9If->DrawPrimitive(pData->PrimitiveType, pData->FirstVertexOffset/pDevice->StreamSourceInfo[stream].uiStride, pData->PrimitiveCount);
@@ -2324,9 +2324,9 @@
 #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
+//#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
 
     Assert(hr == S_OK);
@@ -2679,7 +2679,8 @@
                     Assert(pLockAlloc->pvMem);
                     Assert(pRc->RcDesc.enmPool == D3DDDIPOOL_SYSTEMMEM);
-
+#if 0
                     if (bNeedResynch)
                         vboxWddmLockUnlockMemSynch(pLockAlloc, &pLockAlloc->LockInfo.LockedRect, pRect, false /*bool bToLockInfo*/);
+#endif
                 }
             }
@@ -2983,4 +2984,5 @@
                 Assert(pD3DIfTex);
                 /* this is a sysmem texture, update  */
+#if 0
                 if (pLockAlloc->pvMem && !pLockAlloc->LockInfo.fFlags.ReadOnly)
                 {
@@ -2989,4 +2991,5 @@
                             true /*bool bToLockInfo*/);
                 }
+#endif
                 hr = pD3DIfTex->UnlockRect(pData->SubResourceIndex);
                 Assert(hr == S_OK);
@@ -3407,4 +3410,5 @@
                 CONST D3DDDI_SURFACEINFO* pSurf = &pResource->pSurfList[0];
                 IDirect3DTexture9 *pD3DIfTex;
+#if 0
                 hr = pDevice->pDevice9If->CreateTexture(pSurf->Width,
                                             pSurf->Height,
@@ -3416,4 +3420,16 @@
                                             NULL /* HANDLE* pSharedHandle */
                                             );
+#else
+                hr = pDevice->pAdapter->D3D.pfnVBoxWineExD3DDev9CreateTexture((IDirect3DDevice9Ex *)pDevice->pDevice9If,
+                                            pSurf->Width,
+                                            pSurf->Height,
+                                            pResource->SurfCount,
+                                            vboxDDI2D3DUsage(pResource->Flags),
+                                            vboxDDI2D3DFormat(pResource->Format),
+                                            vboxDDI2D3DPool(pResource->Pool),
+                                            &pD3DIfTex,
+                                            NULL /* HANDLE* pSharedHandle */,
+                                            pResource->Pool == D3DDDIPOOL_SYSTEMMEM ? pRc->aAllocations[0].pvMem : NULL);
+#endif
                 Assert(hr == S_OK);
                 if (hr == S_OK)
@@ -3422,4 +3438,5 @@
                     pAllocation->enmD3DIfType = VBOXDISP_D3DIFTYPE_TEXTURE;
                     pAllocation->pD3DIf = pD3DIfTex;
+#if 0
                     if (pResource->Pool == D3DDDIPOOL_SYSTEMMEM)
                     {
@@ -3444,4 +3461,5 @@
                         }
                     }
+#endif
                 }
 #ifdef DEBUG
@@ -4209,7 +4227,4 @@
     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;
@@ -4284,9 +4299,41 @@
             {
                 Assert(pSrcSurfIf);
-
-//#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
+#ifdef DEBUG_misha
+                bool bDo = false;
+
+                if (g_VDbgTstDumpEnable)
+                {
+                    if (g_VDbgTstDumpOnSys2VidSameSizeEnable)
+                    {
+                        if (pDstRc->RcDesc.enmPool != D3DDDIPOOL_SYSTEMMEM
+                                && pSrcRc->RcDesc.enmPool == D3DDDIPOOL_SYSTEMMEM)
+                        {
+                            D3DSURFACE_DESC SrcDesc;
+                            HRESULT hr = pSrcSurfIf->GetDesc(&SrcDesc);
+                            Assert(hr == S_OK);
+                            if (hr == S_OK)
+                            {
+                                D3DSURFACE_DESC DstDesc;
+                                hr = pDstSurfIf->GetDesc(&DstDesc);
+                                Assert(hr == S_OK);
+                                if (hr == S_OK)
+                                {
+                                    if (SrcDesc.Width == DstDesc.Width
+                                            && SrcDesc.Height == DstDesc.Height)
+                                    {
+                                        bDo = true;
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+
+                if (bDo)
+                {
+                    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);
@@ -4298,8 +4345,11 @@
                 Assert(hr == S_OK);
 
-//#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
+#ifdef DEBUG_misha
+                if (bDo)
+                {
+                    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();
             }
@@ -5369,4 +5419,8 @@
 
 #ifdef VBOXWDDMDISP_DEBUG
+
+bool g_VDbgTstDumpEnable = false;
+bool g_VDbgTstDumpOnSys2VidSameSizeEnable = false;
+
 VOID vboxVDbgDoDumpSurfData(const PVBOXWDDMDISP_DEVICE pDevice, const char * pPrefix, const PVBOXWDDMDISP_RESOURCE pRc, uint32_t iAlloc, const RECT *pRect, IDirect3DSurface9 *pSurf, const char* pSuffix)
 {
@@ -5411,4 +5465,28 @@
     {
         vboxVDbgMpPrint((pDevice, "%s\n", pSuffix));
+    }
+}
+
+VOID vboxVDbgDoDumpSurfDataBySurf(const PVBOXWDDMDISP_DEVICE pDevice, IDirect3DSurface9 *pSurf)
+{
+    D3DSURFACE_DESC Desc;
+    HRESULT hr = pSurf->GetDesc(&Desc);
+    Assert(hr == S_OK);
+    if (hr == S_OK)
+    {
+        D3DLOCKED_RECT Lr;
+        hr = pSurf->LockRect(&Lr, NULL, D3DLOCK_READONLY);
+        Assert(hr == S_OK);
+        if (hr == S_OK)
+        {
+            UINT bpp = vboxWddmCalcBitsPerPixel((D3DDDIFORMAT)Desc.Format);
+            vboxVDbgMpPrint((pDevice, "<?dml?><exec cmd=\"!vbvdbg.ms 0x%p 0n%d 0n%d 0n%d 0n%d\">surface info</exec>\n",
+                    Lr.pBits, Desc.Width, Desc.Height, bpp, Lr.Pitch));
+
+            Assert(0);
+
+            hr = pSurf->UnlockRect();
+            Assert(hr == S_OK);
+        }
     }
 }
Index: trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3DCmn.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3DCmn.h	(revision 30885)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3DCmn.h	(revision 30916)
@@ -38,5 +38,5 @@
 # define VBOXWDDMDISP_DEBUG
 # define VBOXWDDMDISP_DEBUG_FLOW
-//# define VBOXWDDMDISP_DEBUG_DUMPSURFDATA
+# define VBOXWDDMDISP_DEBUG_DUMPSURFDATA
 #endif
 
@@ -57,4 +57,7 @@
 
 #ifdef VBOXWDDMDISP_DEBUG
+extern bool g_VDbgTstDumpEnable;
+extern bool g_VDbgTstDumpOnSys2VidSameSizeEnable;
+
 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);
Index: trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3DIf.cpp
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3DIf.cpp	(revision 30885)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3DIf.cpp	(revision 30916)
@@ -34,5 +34,12 @@
         Assert(pD3D->pfnDirect3DCreate9Ex);
         if (pD3D->pfnDirect3DCreate9Ex)
-            return S_OK;
+        {
+            pD3D->pfnVBoxWineExD3DDev9CreateTexture = (PFNVBOXWINEEXD3DDEV9_CREATETEXTURE)GetProcAddress(pD3D->hD3DLib, "VBoxWineExD3DDev9CreateTexture");
+            Assert(pD3D->pfnVBoxWineExD3DDev9CreateTexture);
+            if (pD3D->pfnVBoxWineExD3DDev9CreateTexture)
+            {
+                return S_OK;
+            }
+        }
         else
         {
Index: trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3DIf.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3DIf.h	(revision 30885)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3DIf.h	(revision 30916)
@@ -22,4 +22,6 @@
 #include <D3D9.h>
 
+#include "../../Wine/vbox/VBoxWineEx.h"
+
 /* D3D functionality the VBOXDISPD3D provides */
 typedef HRESULT WINAPI FNVBOXDISPD3DCREATE9EX(UINT SDKVersion, IDirect3D9Ex **ppD3D);
@@ -30,4 +32,6 @@
     /* D3D functionality the VBOXDISPD3D provides */
     PFNVBOXDISPD3DCREATE9EX pfnDirect3DCreate9Ex;
+
+    PFNVBOXWINEEXD3DDEV9_CREATETEXTURE pfnVBoxWineExD3DDev9CreateTexture;
 
     /* module handle */
