Changeset 38112 in vbox for trunk/src/VBox/Additions
- Timestamp:
- Jul 22, 2011 1:26:19 PM (13 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/Graphics
- Files:
-
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Video/common/VBoxVideoLog.h
r37490 r38112 39 39 40 40 #ifdef DEBUG_misha 41 # define B REAK_WARN() AssertFailed()41 # define BP_WARN() AssertFailed() 42 42 #else 43 # define B REAK_WARN() do {} while(0)43 # define BP_WARN() do {} while(0) 44 44 #endif 45 45 … … 58 58 } while (0) 59 59 60 #define WARN (_a)\60 #define WARN_NOBP(_a) \ 61 61 do \ 62 62 { \ … … 64 64 Log(_a); \ 65 65 Log((VBOX_VIDEO_LOG_SUFFIX_FMT VBOX_VIDEO_LOG_SUFFIX_PARMS)); \ 66 BREAK_WARN(); \ 66 } while (0) 67 68 #define WARN(_a) \ 69 do \ 70 { \ 71 WARN_NOBP(_a); \ 72 BP_WARN(); \ 67 73 } while (0) 68 74 -
trunk/src/VBox/Additions/WINNT/Graphics/Video/common/wddm/VBoxMPIf.h
r37626 r38112 292 292 #define VBOXWDDM_RECTS_INFO_SIZE(_pRects) (VBOXVIDEOCM_CMD_RECTS_SIZE4CRECTS((_pRects)->cRects)) 293 293 294 typedef enum 295 { 296 /* command to be post to user mode */ 297 VBOXVIDEOCM_CMD_TYPE_UM = 0, 298 /* control command processed in kernel mode */ 299 VBOXVIDEOCM_CMD_TYPE_CTL_KM, 300 VBOXVIDEOCM_CMD_DUMMY_32BIT = 0x7fffffff 301 } VBOXVIDEOCM_CMD_TYPE; 302 294 303 typedef struct VBOXVIDEOCM_CMD_HDR 295 304 { 296 305 uint64_t u64UmData; 297 306 uint32_t cbCmd; 298 uint32_t u32CmdSpecific;307 VBOXVIDEOCM_CMD_TYPE enmType; 299 308 }VBOXVIDEOCM_CMD_HDR, *PVBOXVIDEOCM_CMD_HDR; 300 309 -
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispD3D.cpp
r37907 r38112 1023 1023 } 1024 1024 1025 #define VBOX_WDDM_SHRC_WO_NOTIFY 1025 1026 static BOOLEAN vboxWddmDalCheckAdd(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_ALLOCATION pAlloc, BOOLEAN fWrite) 1026 1027 { 1027 1028 if (!pAlloc->hSharedHandle /* only shared resources matter */ 1028 || !fWrite) /* only write op matter */ 1029 { 1029 #ifdef VBOX_WDDM_SHRC_WO_NOTIFY 1030 || !fWrite /* only write op matter */ 1031 #endif 1032 ) 1033 { 1034 #ifdef VBOX_WDDM_SHRC_WO_NOTIFY 1030 1035 Assert(!pAlloc->DirtyAllocListEntry.pNext || (!fWrite && pAlloc->hSharedHandle && pAlloc->fDirtyWrite)); 1036 #else 1037 Assert(!pAlloc->DirtyAllocListEntry.pNext); 1038 #endif 1031 1039 return FALSE; 1032 1040 } … … 1708 1716 1709 1717 Assert(cAllocsKm == Buf.SwapchainInfo.SwapchainInfo.cAllocs || !cAllocsKm); 1710 1718 HRESULT hr = S_OK; 1711 1719 if (cAllocsKm == Buf.SwapchainInfo.SwapchainInfo.cAllocs) 1712 1720 { … … 1717 1725 DdiEscape.pPrivateDriverData = &Buf.SwapchainInfo; 1718 1726 DdiEscape.PrivateDriverDataSize = RT_OFFSETOF(VBOXDISPIFESCAPE_SWAPCHAININFO, SwapchainInfo.ahAllocs[Buf.SwapchainInfo.SwapchainInfo.cAllocs]); 1719 HRESULThr = pDevice->RtCallbacks.pfnEscapeCb(pDevice->pAdapter->hAdapter, &DdiEscape);1727 hr = pDevice->RtCallbacks.pfnEscapeCb(pDevice->pAdapter->hAdapter, &DdiEscape); 1720 1728 #ifdef DEBUG_misha 1721 1729 Assert(hr == S_OK); … … 1725 1733 pSwapchain->hSwapchainKm = Buf.SwapchainInfo.SwapchainInfo.hSwapchainKm; 1726 1734 } 1727 1728 return hr; 1729 } 1735 } 1736 1730 1737 return S_OK; 1731 1738 } … … 1777 1784 pSwapchain->aRTs[i].pAlloc->pSwapchain = NULL; 1778 1785 } 1786 1787 /* first do a Km destroy to ensure all km->um region submissions are completed */ 1788 vboxWddmSwapchainKmDestroy(pDevice, pSwapchain); 1789 vboxDispMpInternalCancel(&pDevice->DefaultContext, pSwapchain); 1779 1790 vboxWddmSwapchainDestroyIf(pDevice, pSwapchain); 1780 vboxWddmSwapchainKmDestroy(pDevice, pSwapchain);1781 1791 vboxWddmSwapchainInit(pSwapchain); 1782 1792 } … … 2843 2853 if (hr == S_OK) 2844 2854 { 2845 vboxVDbgPrint(("VBoxDispD3D: DLL loaded OK\n")); 2846 return TRUE; 2855 hr = vboxDispMpInternalInit(); 2856 Assert(hr == S_OK); 2857 if (hr == S_OK) 2858 { 2859 vboxVDbgPrint(("VBoxDispD3D: DLL loaded OK\n")); 2860 return TRUE; 2861 } 2847 2862 } 2848 2863 VbglR3Term(); … … 2857 2872 vboxVDbgVEHandlerUnregister(); 2858 2873 #endif 2859 HRESULT hr = vboxDisp CmTerm();2874 HRESULT hr = vboxDispMpInternalTerm(); 2860 2875 Assert(hr == S_OK); 2861 2876 if (hr == S_OK) 2862 2877 { 2863 VbglR3Term(); 2864 /// @todo RTR3Term(); 2865 return TRUE; 2878 hr = vboxDispCmTerm(); 2879 Assert(hr == S_OK); 2880 if (hr == S_OK) 2881 { 2882 VbglR3Term(); 2883 /// @todo RTR3Term(); 2884 return TRUE; 2885 } 2866 2886 } 2867 2887 … … 3299 3319 pD3DIfTex = (IDirect3DTexture9*)pRc->aAllocations[0].pD3DIf; 3300 3320 3321 VBOXVDBG_BREAK_SHARED(pRc); 3301 3322 VBOXVDBG_DUMP_SETTEXTURE(pRc); 3302 3323 } … … 3305 3326 pD3DIfTex = (IDirect3DCubeTexture9*)pRc->aAllocations[0].pD3DIf; 3306 3327 3328 VBOXVDBG_BREAK_SHARED(pRc); 3307 3329 VBOXVDBG_DUMP_SETTEXTURE(pRc); 3308 3330 } … … 3433 3455 HRESULT hr = S_OK; 3434 3456 3435 VBOXVDBG_DUMP_DRAWPRIM_ENTER(pDevice 9If);3457 VBOXVDBG_DUMP_DRAWPRIM_ENTER(pDevice); 3436 3458 3437 3459 if (!pDevice->cStreamSources) … … 3491 3513 vboxWddmDalCheckAddRts(pDevice); 3492 3514 3493 VBOXVDBG_DUMP_DRAWPRIM_LEAVE(pDevice 9If);3515 VBOXVDBG_DUMP_DRAWPRIM_LEAVE(pDevice); 3494 3516 3495 3517 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr)); … … 3506 3528 3507 3529 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 3508 VBOXVDBG_DUMP_DRAWPRIM_ENTER(pDevice 9If);3530 VBOXVDBG_DUMP_DRAWPRIM_ENTER(pDevice); 3509 3531 3510 3532 #ifdef DEBUG … … 3542 3564 vboxWddmDalCheckAddRts(pDevice); 3543 3565 3544 VBOXVDBG_DUMP_DRAWPRIM_LEAVE(pDevice 9If);3566 VBOXVDBG_DUMP_DRAWPRIM_LEAVE(pDevice); 3545 3567 3546 3568 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr)); … … 3614 3636 hr = pDevice9If->DrawPrimitive(pData->PrimitiveType, pData->FirstVertexOffset, pData->PrimitiveCount); 3615 3637 #else 3616 VBOXVDBG_DUMP_DRAWPRIM_ENTER(pDevice 9If);3638 VBOXVDBG_DUMP_DRAWPRIM_ENTER(pDevice); 3617 3639 3618 3640 #ifdef DEBUG … … 3662 3684 vboxWddmDalCheckAddRts(pDevice); 3663 3685 3664 VBOXVDBG_DUMP_DRAWPRIM_LEAVE(pDevice 9If);3686 VBOXVDBG_DUMP_DRAWPRIM_LEAVE(pDevice); 3665 3687 3666 3688 Assert(hr == S_OK); … … 4191 4213 Assert(pRc->RcDesc.enmPool == D3DDDIPOOL_SYSTEMMEM); 4192 4214 } 4215 4216 VBOXVDBG_DUMP_LOCK_ST(pData); 4193 4217 } 4194 4218 } … … 4475 4499 Assert(pData->SubResourceIndex < pRc->cAllocations); 4476 4500 PVBOXWDDMDISP_ALLOCATION pLockAlloc = &pRc->aAllocations[pData->SubResourceIndex]; 4501 4502 VBOXVDBG_DUMP_UNLOCK_ST(pData); 4477 4503 4478 4504 --pLockAlloc->LockInfo.cLocks; … … 4993 5019 Assert(!!(pResource->Flags.SharedResource) == !!(hSharedHandle)); 4994 5020 pAllocation->hSharedHandle = hSharedHandle; 5021 #ifdef DEBUG_misha 5022 if (pResource->Flags.SharedResource) 5023 { 5024 vboxVDbgPrint(("\n\n********\nShared Texture pAlloc(0x%p) Handle(0x%x), (0n%d) CREATED, pid (0x%x), (0n%d)\n***********\n\n", 5025 pAllocation, hSharedHandle, hSharedHandle, GetCurrentProcessId(), GetCurrentProcessId())); 5026 } 5027 #endif 4995 5028 } 4996 5029 … … 5302 5335 { 5303 5336 PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[i]; 5337 #ifdef DEBUG_misha 5338 if (pAlloc->hSharedHandle) 5339 { 5340 vboxVDbgPrint(("\n\n********\nShared Texture pAlloc(0x%p) Handle(0x%x), (0n%d) DESTROYED, pid (0x%x), (0n%d)\n***********\n\n", 5341 pAlloc, pAlloc->hSharedHandle, pAlloc->hSharedHandle, GetCurrentProcessId(), GetCurrentProcessId())); 5342 } 5343 #endif 5304 5344 if (pAlloc->pD3DIf) 5305 5345 pAlloc->pD3DIf->Release(); … … 5585 5625 vboxWddmDalNotifyChange(pDevice); 5586 5626 5587 VBOXVDBG_DUMP_FLUSH(pDevice ->pDevice9If);5627 VBOXVDBG_DUMP_FLUSH(pDevice); 5588 5628 } 5589 5629 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr)); … … 5970 6010 Assert(pSrcSurfIf); 5971 6011 5972 VBOXVDBG_DUMP_BLT_ENTER(pSrcRc, pSrcSurfIf, &pData->SrcRect, pDstRc, pDstSurfIf, &pData->DstRect); 6012 VBOXVDBG_BREAK_SHARED(pSrcRc); 6013 VBOXVDBG_BREAK_SHARED(pDstRc); 6014 VBOXVDBG_DUMP_BLT_ENTER(pSrcAlloc, pSrcSurfIf, &pData->SrcRect, pDstAlloc, pDstSurfIf, &pData->DstRect); 5973 6015 5974 6016 /* we support only Point & Linear, we ignore [Begin|Continue|End]PresentToDwm */ … … 5981 6023 Assert(hr == S_OK); 5982 6024 5983 VBOXVDBG_DUMP_BLT_LEAVE(pSrc Rc, pSrcSurfIf, &pData->SrcRect, pDstRc, pDstSurfIf, &pData->DstRect);6025 VBOXVDBG_DUMP_BLT_LEAVE(pSrcAlloc, pSrcSurfIf, &pData->SrcRect, pDstAlloc, pDstSurfIf, &pData->DstRect); 5984 6026 5985 6027 pSrcSurfIf->Release(); … … 6453 6495 { 6454 6496 // Assert(!pDevice->cScreens); 6497 /* destroy the device first, since destroying PVBOXWDDMDISP_SWAPCHAIN would result in a device window termination */ 6498 if (pDevice->pDevice9If) 6499 { 6500 pDevice->pDevice9If->Release(); 6501 } 6455 6502 vboxWddmSwapchainDestroyAll(pDevice); 6456 if (pDevice->pDevice9If)6457 {6458 pDevice->pDevice9If->Release();6459 }6460 6503 } 6461 6504 … … 6814 6857 6815 6858 #ifdef DEBUG_misha 6816 vboxVDbgPrint(("\n\n********\nShared Resource (0x%x), (0n%d) openned\n\n\n", hSharedHandle, hSharedHandle)); 6859 vboxVDbgPrint(("\n\n********\nShared Texture pAlloc(0x%p) Handle(0x%x), (0n%d) OPENED, pid (0x%x), (0n%d)\n***********\n\n", 6860 pAllocation, hSharedHandle, hSharedHandle, GetCurrentProcessId(), GetCurrentProcessId())); 6861 6817 6862 #endif 6818 6863 -
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispD3D.h
r37840 r38112 207 207 D3DDDI_LOCKFLAGS fFlags; 208 208 D3DLOCKED_RECT LockedRect; 209 #ifdef VBOXWDDMDISP_DEBUG 210 PVOID pvData; 211 #endif 209 212 } VBOXWDDMDISP_LOCKINFO; 210 213 -
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispD3DCmn.h
r36867 r38112 38 38 #include "common/wddm/VBoxMPIf.h" 39 39 #include "VBoxDispCm.h" 40 #include "VBoxDispMpInternal.h" 40 41 #include "VBoxDispKmt.h" 41 42 #ifdef VBOX_WITH_CRHGSMI -
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispD3DIf.cpp
r36867 r38112 269 269 if (!GetClassInfo(hInstance, VBOXDISPWND_NAME, &wc)) 270 270 { 271 wc.style = CS_OWNDC;271 wc.style = 0;//CS_OWNDC; 272 272 wc.lpfnWndProc = WindowProc; 273 273 wc.cbClsExtra = 0; -
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispDbg.cpp
r37870 r38112 50 50 51 51 #ifdef VBOXWDDMDISP_DEBUG 52 DWORD g_VBoxVDbgFDumpSetTexture = 0; 53 DWORD g_VBoxVDbgFDumpDrawPrim = 0; 54 DWORD g_VBoxVDbgFDumpTexBlt = 0; 55 DWORD g_VBoxVDbgFDumpBlt = 0; 56 DWORD g_VBoxVDbgFDumpRtSynch = 0; 57 DWORD g_VBoxVDbgFDumpFlush = 0; 58 DWORD g_VBoxVDbgFDumpShared = 0; 52 #define VBOXWDDMDISP_DEBUG_DUMP_DEFAULT 1 53 DWORD g_VBoxVDbgFDumpSetTexture = VBOXWDDMDISP_DEBUG_DUMP_DEFAULT; 54 DWORD g_VBoxVDbgFDumpDrawPrim = VBOXWDDMDISP_DEBUG_DUMP_DEFAULT; 55 DWORD g_VBoxVDbgFDumpTexBlt = VBOXWDDMDISP_DEBUG_DUMP_DEFAULT; 56 DWORD g_VBoxVDbgFDumpBlt = VBOXWDDMDISP_DEBUG_DUMP_DEFAULT; 57 DWORD g_VBoxVDbgFDumpRtSynch = VBOXWDDMDISP_DEBUG_DUMP_DEFAULT; 58 DWORD g_VBoxVDbgFDumpFlush = VBOXWDDMDISP_DEBUG_DUMP_DEFAULT; 59 DWORD g_VBoxVDbgFDumpShared = VBOXWDDMDISP_DEBUG_DUMP_DEFAULT; 60 DWORD g_VBoxVDbgFDumpLock = VBOXWDDMDISP_DEBUG_DUMP_DEFAULT; 61 DWORD g_VBoxVDbgFDumpUnlock = VBOXWDDMDISP_DEBUG_DUMP_DEFAULT; 62 63 DWORD g_VBoxVDbgFBreakShared = VBOXWDDMDISP_DEBUG_DUMP_DEFAULT; 59 64 60 65 DWORD g_VBoxVDbgPid = 0; … … 175 180 { 176 181 vboxVDbgDoDumpSurfRectByRc(pPrefix, pAlloc->pRc, pAlloc->iAlloc, pRect, pSuffix); 182 } 183 184 VOID vboxVDbgDoPrintDumpCmd(const void *pvData, uint32_t width, uint32_t height, uint32_t bpp, uint32_t pitch) 185 { 186 vboxVDbgPrint(("<?dml?><exec cmd=\"!vbvdbg.ms 0x%p 0n%d 0n%d 0n%d 0n%d\">surface info</exec>, ( !vbvdbg.ms 0x%p 0n%d 0n%d 0n%d 0n%d )\n", 187 pvData, width, height, bpp, pitch, 188 pvData, width, height, bpp, pitch)); 177 189 } 178 190 … … 207 219 { 208 220 UINT bpp = vboxWddmCalcBitsPerPixel(pAlloc->SurfDesc.format); 209 vboxVDbgPrint(("<?dml?><exec cmd=\"!vbvdbg.ms 0x%p 0n%d 0n%d 0n%d 0n%d\">surface info</exec>, ( !vbvdbg.ms 0x%p 0n%d 0n%d 0n%d 0n%d )\n", 210 LockData.pData, pAlloc->D3DWidth, pAlloc->SurfDesc.height, bpp, pAlloc->SurfDesc.pitch, 211 LockData.pData, pAlloc->D3DWidth, pAlloc->SurfDesc.height, bpp, pAlloc->SurfDesc.pitch)); 221 vboxVDbgDoPrintDumpCmd(LockData.pData, pAlloc->D3DWidth, pAlloc->SurfDesc.height, bpp, pAlloc->SurfDesc.pitch); 212 222 if (pRect) 213 223 { … … 215 225 Assert(pRect->bottom > pRect->top); 216 226 vboxVDbgDoPrintRect("rect: ", pRect, "\n"); 217 vboxVDbgPrint(("<?dml?><exec cmd=\"!vbvdbg.ms 0x%p 0n%d 0n%d 0n%d 0n%d\">rect info</exec>, ( !vbvdbg.ms 0x%p 0n%d 0n%d 0n%d 0n%d )\n", 218 ((uint8_t*)LockData.pData) + (pRect->top * pAlloc->SurfDesc.pitch) + ((pRect->left * bpp) >> 3), 219 pRect->right - pRect->left, pRect->bottom - pRect->top, bpp, pAlloc->SurfDesc.pitch, 220 ((uint8_t*)LockData.pData) + (pRect->top * pAlloc->SurfDesc.pitch) + ((pRect->left * bpp) >> 3), 221 pRect->right - pRect->left, pRect->bottom - pRect->top, bpp, pAlloc->SurfDesc.pitch)); 227 vboxVDbgDoPrintDumpCmd(((uint8_t*)LockData.pData) + (pRect->top * pAlloc->SurfDesc.pitch) + ((pRect->left * bpp) >> 3), 228 pRect->right - pRect->left, pRect->bottom - pRect->top, bpp, pAlloc->SurfDesc.pitch); 222 229 } 223 230 Assert(0); … … 270 277 { 271 278 UINT bpp = vboxWddmCalcBitsPerPixel((D3DDDIFORMAT)Desc.Format); 272 vboxVDbgPrint(("<?dml?><exec cmd=\"!vbvdbg.ms 0x%p 0n%d 0n%d 0n%d 0n%d\">surface info</exec>, ( !vbvdbg.ms 0x%p 0n%d 0n%d 0n%d 0n%d )\n", 273 Lr.pBits, Desc.Width, Desc.Height, bpp, Lr.Pitch, 274 Lr.pBits, Desc.Width, Desc.Height, bpp, Lr.Pitch)); 279 vboxVDbgDoPrintDumpCmd(Lr.pBits, Desc.Width, Desc.Height, bpp, Lr.Pitch); 275 280 if (pRect) 276 281 { … … 278 283 Assert(pRect->bottom > pRect->top); 279 284 vboxVDbgDoPrintRect("rect: ", pRect, "\n"); 280 vboxVDbgPrint(("<?dml?><exec cmd=\"!vbvdbg.ms 0x%p 0n%d 0n%d 0n%d 0n%d\">rect info</exec>, ( !vbvdbg.ms 0x%p 0n%d 0n%d 0n%d 0n%d )\n", 281 ((uint8_t*)Lr.pBits) + (pRect->top * Lr.Pitch) + ((pRect->left * bpp) >> 3), 282 pRect->right - pRect->left, pRect->bottom - pRect->top, bpp, Lr.Pitch, 283 ((uint8_t*)Lr.pBits) + (pRect->top * Lr.Pitch) + ((pRect->left * bpp) >> 3), 284 pRect->right - pRect->left, pRect->bottom - pRect->top, bpp, Lr.Pitch)); 285 vboxVDbgDoPrintDumpCmd(((uint8_t*)Lr.pBits) + (pRect->top * Lr.Pitch) + ((pRect->left * bpp) >> 3), 286 pRect->right - pRect->left, pRect->bottom - pRect->top, bpp, Lr.Pitch); 285 287 } 286 288 … … 386 388 IDirect3DSurface9 *pSurf = (IDirect3DSurface9 *)pRc; 387 389 vboxVDbgDoDumpSurfRect("", pSurf, pRect, "\n", true); 390 break; 388 391 } 389 392 default: … … 398 401 } 399 402 403 VOID vboxVDbgDoDumpRcRectByAlloc(const char * pPrefix, const PVBOXWDDMDISP_ALLOCATION pAlloc, IDirect3DResource9 *pD3DIf, const RECT *pRect, const char* pSuffix) 404 { 405 if (pPrefix) 406 vboxVDbgPrint(("%s", pPrefix)); 407 408 if (!pD3DIf) 409 { 410 pD3DIf = (IDirect3DResource9*)pAlloc->pD3DIf; 411 } 412 413 vboxVDbgPrint(("Rc(0x%p), pAlloc(0x%x), pD3DIf(0x%p), SharedHandle(0x%p)\n", pAlloc->pRc, pAlloc, pD3DIf, pAlloc->pRc->aAllocations[0].hSharedHandle)); 414 415 vboxVDbgDoDumpRcRect("", pD3DIf, pRect, pSuffix); 416 } 417 400 418 VOID vboxVDbgDoDumpRcRectByRc(const char * pPrefix, const PVBOXWDDMDISP_RESOURCE pRc, const RECT *pRect, const char* pSuffix) 401 419 { 402 vboxVDbgDoDumpRcRect (pPrefix, (IDirect3DResource9*)pRc->aAllocations[0].pD3DIf, pRect, pSuffix);420 vboxVDbgDoDumpRcRectByAlloc(pPrefix, &pRc->aAllocations[0], NULL, pRect, pSuffix); 403 421 } 404 422 … … 408 426 } 409 427 410 VOID vboxVDbgDoDumpRt(const char * pPrefix, IDirect3DDevice9 *pDevice, const char * pSuffix) 411 { 412 IDirect3DSurface9 *pRt; 413 HRESULT hr = pDevice->GetRenderTarget(0, &pRt); 414 Assert(hr == S_OK); 415 if (hr == S_OK) 416 { 417 vboxVDbgDoDumpSurf(pPrefix, pRt, pSuffix); 428 VOID vboxVDbgDoDumpRt(const char * pPrefix, PVBOXWDDMDISP_DEVICE pDevice, const char * pSuffix) 429 { 430 for (UINT i = 0; i < pDevice->cRTs; ++i) 431 { 432 IDirect3DSurface9 *pRt; 433 PVBOXWDDMDISP_ALLOCATION pAlloc = pDevice->apRTs[i]; 434 IDirect3DDevice9 *pDeviceIf = pDevice->pDevice9If; 435 HRESULT hr = pDeviceIf->GetRenderTarget(i, &pRt); 436 Assert(hr == S_OK); 437 if (hr == S_OK) 438 { 439 // Assert(pAlloc->pD3DIf == pRt); 440 vboxVDbgDoDumpRcRectByAlloc(pPrefix, pAlloc, NULL, NULL, "\n"); 441 pRt->Release(); 442 } 443 else 444 { 445 vboxVDbgPrint((__FUNCTION__": ERROR getting rt: 0x%x", hr)); 446 } 447 } 448 } 449 450 VOID vboxVDbgDoDumpLockUnlockSurfTex(const char * pPrefix, const PVBOXWDDMDISP_ALLOCATION pAlloc, const char * pSuffix, bool fBreak) 451 { 452 if (pPrefix) 453 { 454 vboxVDbgPrint(("%s", pPrefix)); 455 } 456 457 Assert(!pAlloc->hSharedHandle); 458 459 UINT bpp = vboxWddmCalcBitsPerPixel(pAlloc->SurfDesc.format); 460 uint32_t width, height, pitch; 461 RECT Rect, *pRect; 462 void *pvData; 463 Assert(!pAlloc->LockInfo.fFlags.RangeValid); 464 Assert(!pAlloc->LockInfo.fFlags.BoxValid); 465 if (pAlloc->LockInfo.fFlags.AreaValid) 466 { 467 pRect = &pAlloc->LockInfo.Area; 468 width = pAlloc->LockInfo.Area.left - pAlloc->LockInfo.Area.right; 469 height = pAlloc->LockInfo.Area.bottom - pAlloc->LockInfo.Area.top; 418 470 } 419 471 else 420 472 { 421 vboxVDbgPrint((__FUNCTION__": ERROR getting rt: 0x%x", hr)); 422 } 473 width = pAlloc->SurfDesc.width; 474 height = pAlloc->SurfDesc.height; 475 Rect.top = 0; 476 Rect.bottom = height; 477 Rect.left = 0; 478 Rect.right = width; 479 pRect = &Rect; 480 } 481 482 if (pAlloc->LockInfo.fFlags.NotifyOnly) 483 { 484 pitch = pAlloc->SurfDesc.pitch; 485 pvData = ((uint8_t*)pAlloc->pvMem) + pitch*pRect->top + ((bpp*pRect->left) >> 3); 486 } 487 else 488 { 489 pvData = pAlloc->LockInfo.pvData; 490 } 491 492 vboxVDbgPrint(("pRc(0x%p) iAlloc(%d), type(%d), cLocks(%d)\n", pAlloc->pRc, pAlloc->iAlloc, pAlloc->enmD3DIfType, pAlloc->LockInfo.cLocks)); 493 494 vboxVDbgDoPrintDumpCmd(pvData, width, height, bpp, pitch); 495 496 if (fBreak) 497 { 498 Assert(0); 499 } 500 501 if (pSuffix) 502 { 503 vboxVDbgPrint(("%s", pSuffix)); 504 } 505 506 } 507 508 VOID vboxVDbgDoDumpLockSurfTex(const char * pPrefix, const D3DDDIARG_LOCK* pData, const char * pSuffix, bool fBreak) 509 { 510 const PVBOXWDDMDISP_RESOURCE pRc = (const PVBOXWDDMDISP_RESOURCE)pData->hResource; 511 const PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[pData->SubResourceIndex]; 512 pAlloc->LockInfo.pvData = pData->pSurfData; 513 vboxVDbgDoDumpLockUnlockSurfTex(pPrefix, pAlloc, pSuffix, fBreak); 514 } 515 516 VOID vboxVDbgDoDumpUnlockSurfTex(const char * pPrefix, const D3DDDIARG_UNLOCK* pData, const char * pSuffix, bool fBreak) 517 { 518 const PVBOXWDDMDISP_RESOURCE pRc = (const PVBOXWDDMDISP_RESOURCE)pData->hResource; 519 const PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[pData->SubResourceIndex]; 520 vboxVDbgDoDumpLockUnlockSurfTex(pPrefix, pAlloc, pSuffix, fBreak); 423 521 } 424 522 … … 426 524 { 427 525 Assert(pRc->cAllocations > iAlloc); 428 PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[iAlloc];526 const PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[iAlloc]; 429 527 BOOL bPrimary = pRc->RcDesc.fFlags.Primary; 430 528 BOOL bFrontBuf = FALSE; -
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispDbg.h
r37870 r38112 111 111 extern DWORD g_VBoxVDbgFDumpFlush; 112 112 extern DWORD g_VBoxVDbgFDumpShared; 113 extern DWORD g_VBoxVDbgFDumpLock; 114 extern DWORD g_VBoxVDbgFDumpUnlock; 115 116 extern DWORD g_VBoxVDbgFBreakShared; 113 117 114 118 void vboxDispLogDrvF(char * szString, ...); … … 126 130 VOID vboxVDbgDoDumpRcRect(const char * pPrefix, IDirect3DResource9 *pRc, const RECT *pRect, const char * pSuffix); 127 131 VOID vboxVDbgDoDumpRcRectByRc(const char * pPrefix, const PVBOXWDDMDISP_RESOURCE pRc, const RECT *pRect, const char* pSuffix); 132 VOID vboxVDbgDoDumpRcRectByAlloc(const char * pPrefix, const PVBOXWDDMDISP_ALLOCATION pAlloc, IDirect3DResource9 *pD3DIf, const RECT *pRect, const char* pSuffix); 128 133 VOID vboxVDbgDoDumpTex(const char * pPrefix, IDirect3DBaseTexture9 *pTexBase, const char * pSuffix); 129 VOID vboxVDbgDoDumpRt(const char * pPrefix, IDirect3DDevice9*pDevice, const char * pSuffix);134 VOID vboxVDbgDoDumpRt(const char * pPrefix, struct VBOXWDDMDISP_DEVICE *pDevice, const char * pSuffix); 130 135 131 136 void vboxVDbgDoPrintRect(const char * pPrefix, const RECT *pRect, const char * pSuffix); 132 137 void vboxVDbgDoPrintAlloc(const char * pPrefix, const PVBOXWDDMDISP_RESOURCE pRc, uint32_t iAlloc, const char * pSuffix); 133 VOID vboxVDbgDoDumpRtData(char * pPrefix, IDirect3DDevice9 *pDevice, char * pSuffix); 138 139 VOID vboxVDbgDoDumpLockSurfTex(const char * pPrefix, const D3DDDIARG_LOCK* pData, const char * pSuffix, bool fBreak); 140 VOID vboxVDbgDoDumpUnlockSurfTex(const char * pPrefix, const D3DDDIARG_UNLOCK* pData, const char * pSuffix, bool fBreak); 141 134 142 135 143 extern DWORD g_VBoxVDbgPid; … … 144 152 ) 145 153 154 #define VBOXVDBG_IS_BREAK_ALLOWED(_type) ( \ 155 g_VBoxVDbgFBreak##_type \ 156 && (g_VBoxVDbgFBreak##_type == 1 \ 157 || VBOXVDBG_IS_DUMP_ALLOWED_PID(g_VBoxVDbgFBreak##_type) \ 158 ) \ 159 ) 160 146 161 #define VBOXVDBG_IS_DUMP_SHARED_ALLOWED(_pRc) (\ 147 162 (_pRc)->RcDesc.fFlags.SharedResource \ … … 149 164 ) 150 165 166 #define VBOXVDBG_IS_BREAK_SHARED_ALLOWED(_pRc) (\ 167 (_pRc)->RcDesc.fFlags.SharedResource \ 168 && VBOXVDBG_IS_BREAK_ALLOWED(Shared) \ 169 ) 170 171 #define VBOXVDBG_BREAK_SHARED(_pRc) do { \ 172 if (VBOXVDBG_IS_BREAK_SHARED_ALLOWED(_pRc)) { \ 173 vboxVDbgPrint(("Break on shared access: Rc(0x%p), SharedHandle(0x%p)\n", (_pRc), (_pRc)->aAllocations[0].hSharedHandle)); \ 174 AssertFailed(); \ 175 } \ 176 } while (0) 177 151 178 #define VBOXVDBG_DUMP_DRAWPRIM_ENTER(_pDevice) do { \ 152 179 if (VBOXVDBG_IS_DUMP_ALLOWED(DrawPrim)) \ … … 168 195 ) \ 169 196 { \ 170 vboxVDbgPrint(("== "__FUNCTION__": Texture Dump, SharedHandle(0x%p)\n", (_pRc)->aAllocations[0].hSharedHandle)); \ 171 vboxVDbgDoDumpRcRectByRc("", _pRc, NULL, "\n"); \ 197 vboxVDbgDoDumpRcRectByRc("== "__FUNCTION__": ", _pRc, NULL, "\n"); \ 172 198 } \ 173 199 } while (0) … … 181 207 RECT _DstRect; \ 182 208 vboxWddmRectMoved(&_DstRect, (_pSrcRect), (_pDstPoint)->x, (_pDstPoint)->y); \ 183 vboxVDbgDoDumpRcRectByRc("==>"__FUNCTION__" Src: \n", (_pSrcRc), (_pSrcRect), "\n"); \184 vboxVDbgDoDumpRcRectByRc("==>"__FUNCTION__" Dst: \n", (_pDstRc), &_DstRect, "\n"); \209 vboxVDbgDoDumpRcRectByRc("==>"__FUNCTION__" Src: ", (_pSrcRc), (_pSrcRect), "\n"); \ 210 vboxVDbgDoDumpRcRectByRc("==>"__FUNCTION__" Dst: ", (_pDstRc), &_DstRect, "\n"); \ 185 211 } \ 186 212 } while (0) … … 194 220 RECT _DstRect; \ 195 221 vboxWddmRectMoved(&_DstRect, (_pSrcRect), (_pDstPoint)->x, (_pDstPoint)->y); \ 196 vboxVDbgDoDumpRcRectByRc("<=="__FUNCTION__" Src: \n", (_pSrcRc), (_pSrcRect), "\n"); \197 vboxVDbgDoDumpRcRectByRc("<=="__FUNCTION__" Dst: \n", (_pDstRc), &_DstRect, "\n"); \198 } \ 199 } while (0) 200 201 #define VBOXVDBG_DUMP_BLT_ENTER(_pSrc Rc, _pSrcSurf, _pSrcRect, _pDstRc, _pDstSurf, _pDstRect) do { \222 vboxVDbgDoDumpRcRectByRc("<=="__FUNCTION__" Src: ", (_pSrcRc), (_pSrcRect), "\n"); \ 223 vboxVDbgDoDumpRcRectByRc("<=="__FUNCTION__" Dst: ", (_pDstRc), &_DstRect, "\n"); \ 224 } \ 225 } while (0) 226 227 #define VBOXVDBG_DUMP_BLT_ENTER(_pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) do { \ 202 228 if (VBOXVDBG_IS_DUMP_ALLOWED(Blt) \ 203 || VBOXVDBG_IS_DUMP_SHARED_ALLOWED(_pSrcRc) \ 204 || VBOXVDBG_IS_DUMP_SHARED_ALLOWED(_pDstRc) \ 205 ) \ 206 { \ 207 vboxVDbgPrint(("==>"__FUNCTION__" Src: SharedHandle(0x%p)\n", (_pSrcRc)->aAllocations[0].hSharedHandle)); \ 208 vboxVDbgDoDumpSurfRect("", (_pSrcSurf), (_pSrcRect), "\n", true); \ 209 vboxVDbgPrint(("==>"__FUNCTION__" Dst: SharedHandle(0x%p)\n", (_pDstRc)->aAllocations[0].hSharedHandle)); \ 210 vboxVDbgDoDumpSurfRect("", (_pDstSurf), (_pDstRect), "\n", true); \ 211 } \ 212 } while (0) 213 214 #define VBOXVDBG_DUMP_BLT_LEAVE(_pSrcRc, _pSrcSurf, _pSrcRect, _pDstRc, _pDstSurf, _pDstRect) do { \ 229 || VBOXVDBG_IS_DUMP_SHARED_ALLOWED((_pSrcAlloc)->pRc) \ 230 || VBOXVDBG_IS_DUMP_SHARED_ALLOWED((_pDstAlloc)->pRc) \ 231 ) \ 232 { \ 233 vboxVDbgDoDumpRcRectByAlloc("==>"__FUNCTION__" Src: ", (_pSrcAlloc), (_pSrcSurf), (_pSrcRect), "\n"); \ 234 vboxVDbgDoDumpRcRectByAlloc("==>"__FUNCTION__" Dst: ", (_pDstAlloc), (_pDstSurf), (_pDstRect), "\n"); \ 235 } \ 236 } while (0) 237 238 #define VBOXVDBG_DUMP_BLT_LEAVE(_pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) do { \ 215 239 if (VBOXVDBG_IS_DUMP_ALLOWED(Blt) \ 216 || VBOXVDBG_IS_DUMP_SHARED_ALLOWED(_pSrcRc) \ 217 || VBOXVDBG_IS_DUMP_SHARED_ALLOWED(_pDstRc) \ 218 ) \ 219 { \ 220 vboxVDbgPrint(("<=="__FUNCTION__" Src: SharedHandle(0x%p)\n", (_pSrcRc)->aAllocations[0].hSharedHandle)); \ 221 vboxVDbgDoDumpSurfRect("", (_pSrcSurf), (_pSrcRect), "\n", true); \ 222 vboxVDbgPrint(("<=="__FUNCTION__" Dst: SharedHandle(0x%p)\n", (_pDstRc)->aAllocations[0].hSharedHandle)); \ 223 vboxVDbgDoDumpSurfRect("", (_pDstSurf), (_pDstRect), "\n", true); \ 240 || VBOXVDBG_IS_DUMP_SHARED_ALLOWED((_pSrcAlloc)->pRc) \ 241 || VBOXVDBG_IS_DUMP_SHARED_ALLOWED((_pDstAlloc)->pRc) \ 242 ) \ 243 { \ 244 vboxVDbgDoDumpRcRectByAlloc("<=="__FUNCTION__" Src: ", (_pSrcAlloc), (_pSrcSurf), (_pSrcRect), "\n"); \ 245 vboxVDbgDoDumpRcRectByAlloc("<=="__FUNCTION__" Dst: ", (_pDstAlloc), (_pDstSurf), (_pDstRect), "\n"); \ 224 246 } \ 225 247 } while (0) … … 238 260 }\ 239 261 } while (0) 262 263 #define VBOXVDBG_DUMP_LOCK_ST(_pData) do { \ 264 if (VBOXVDBG_IS_DUMP_ALLOWED(Lock) \ 265 || VBOXVDBG_IS_DUMP_ALLOWED(Unlock) \ 266 ) \ 267 { \ 268 vboxVDbgDoDumpLockSurfTex("== "__FUNCTION__": ", (_pData), "\n", VBOXVDBG_IS_DUMP_ALLOWED(Lock)); \ 269 } \ 270 } while (0) 271 272 #define VBOXVDBG_DUMP_UNLOCK_ST(_pData) do { \ 273 if (VBOXVDBG_IS_DUMP_ALLOWED(Unlock) \ 274 ) \ 275 { \ 276 vboxVDbgDoDumpUnlockSurfTex("== "__FUNCTION__": ", (_pData), "\n", true); \ 277 } \ 278 } while (0) 279 240 280 #else 241 281 #define VBOXVDBG_DUMP_DRAWPRIM_ENTER(_pDevice) do { } while (0) … … 248 288 #define VBOXVDBG_DUMP_SYNC_RT(_pBbSurf) do { } while (0) 249 289 #define VBOXVDBG_DUMP_FLUSH(_pDevice) do { } while (0) 290 #define VBOXVDBG_DUMP_LOCK_ST(_pData) do { } while (0) 291 #define VBOXVDBG_DUMP_UNLOCK_ST(_pData) do { } while (0) 250 292 #endif 251 293 -
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispMp.cpp
r36867 r38112 30 30 typedef struct VBOXDISPMP 31 31 { 32 CRITICAL_SECTION CritSect; 32 33 PVBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD pEscapeCmd; 33 34 uint32_t cbEscapeCmd; … … 54 55 } 55 56 57 DECLINLINE(VOID) vboxVideoCmIterCopyToBack(PVBOXVIDEOCM_ITERATOR pIter, PVBOXVIDEOCM_CMD_HDR pCur) 58 { 59 memcpy((((uint8_t*)pIter->pCur) + pIter->cbRemain), pCur, pCur->cbCmd); 60 pIter->cbRemain += pCur->cbCmd; 61 } 62 56 63 DECLINLINE(bool) vboxVideoCmIterHasNext(PVBOXVIDEOCM_ITERATOR pIter) 57 64 { … … 63 70 DECLCALLBACK(HRESULT) vboxDispMpEnableEvents() 64 71 { 72 EnterCriticalSection(&g_VBoxDispMp.CritSect); 65 73 g_VBoxDispMp.pEscapeCmd = NULL; 66 74 g_VBoxDispMp.cbEscapeCmd = 0; … … 69 77 vboxUhgsmiGlobalSetCurrent(); 70 78 #endif 79 LeaveCriticalSection(&g_VBoxDispMp.CritSect); 71 80 return S_OK; 72 81 } … … 75 84 DECLCALLBACK(HRESULT) vboxDispMpDisableEvents() 76 85 { 86 EnterCriticalSection(&g_VBoxDispMp.CritSect); 77 87 if (g_VBoxDispMp.pEscapeCmd) 88 { 78 89 RTMemFree(g_VBoxDispMp.pEscapeCmd); 90 g_VBoxDispMp.pEscapeCmd = NULL; 91 } 79 92 #ifdef VBOX_WITH_CRHGSMI 80 93 vboxUhgsmiGlobalClearCurrent(); 81 94 #endif 95 LeaveCriticalSection(&g_VBoxDispMp.CritSect); 82 96 return S_OK; 83 97 } … … 90 104 { 91 105 HRESULT hr = S_OK; 106 EnterCriticalSection(&g_VBoxDispMp.CritSect); 92 107 PVBOXVIDEOCM_CMD_HDR pHdr = vboxVideoCmIterNext(&g_VBoxDispMp.Iterator); 93 108 if (!pHdr) … … 100 115 g_VBoxDispMp.cbEscapeCmd = VBOXDISPMP_BUF_INITSIZE; 101 116 else 117 { 118 LeaveCriticalSection(&g_VBoxDispMp.CritSect); 102 119 return E_OUTOFMEMORY; 120 } 103 121 } 104 122 … … 150 168 PVBOXVIDEOCM_CMD_RECTS_INTERNAL pCmdInternal = (PVBOXVIDEOCM_CMD_RECTS_INTERNAL)(((uint8_t*)pHdr) + sizeof (VBOXVIDEOCM_CMD_HDR)); 151 169 PVBOXWDDMDISP_SWAPCHAIN pSwapchain = (PVBOXWDDMDISP_SWAPCHAIN)pCmdInternal->hSwapchainUm; 152 /* todo: synchronization */ 170 /* the miniport driver should ensure all swapchain-involved commands are completed before swapchain termination, 171 * so we should have it always valid here */ 153 172 Assert(pSwapchain); 173 Assert(pSwapchain->hWnd); 154 174 pRegions->hWnd = pSwapchain->hWnd; 155 175 pRegions->pRegions = &pCmdInternal->Cmd; 156 176 } 177 LeaveCriticalSection(&g_VBoxDispMp.CritSect); 157 178 return hr; 158 179 } … … 175 196 return S_OK; 176 197 } 198 199 HRESULT vboxDispMpInternalInit() 200 { 201 memset(&g_VBoxDispMp, 0, sizeof (g_VBoxDispMp)); 202 InitializeCriticalSection(&g_VBoxDispMp.CritSect); 203 return S_OK; 204 } 205 206 HRESULT vboxDispMpInternalTerm() 207 { 208 vboxDispMpDisableEvents(); 209 DeleteCriticalSection(&g_VBoxDispMp.CritSect); 210 return S_OK; 211 } 212 213 HRESULT vboxDispMpInternalCancel(VBOXWDDMDISP_CONTEXT *pContext, PVBOXWDDMDISP_SWAPCHAIN pSwapchain) 214 { 215 HRESULT hr = S_OK; 216 EnterCriticalSection(&g_VBoxDispMp.CritSect); 217 do 218 { 219 /* the pEscapeCmd is used as an indicator to whether the events capturing is active */ 220 if (!g_VBoxDispMp.pEscapeCmd) 221 break; 222 223 /* copy the iterator data to restore it back later */ 224 VBOXVIDEOCM_ITERATOR IterCopy = g_VBoxDispMp.Iterator; 225 226 /* first check if we have matching elements */ 227 PVBOXVIDEOCM_CMD_HDR pHdr; 228 bool fHasMatch = false; 229 while (pHdr = vboxVideoCmIterNext(&g_VBoxDispMp.Iterator)) 230 { 231 VBOXWDDMDISP_CONTEXT *pCurContext = (VBOXWDDMDISP_CONTEXT*)pHdr->u64UmData; 232 if (pCurContext != pContext) 233 continue; 234 235 if (!pSwapchain) 236 { 237 fHasMatch = true; 238 break; 239 } 240 241 PVBOXVIDEOCM_CMD_RECTS_INTERNAL pCmdInternal = (PVBOXVIDEOCM_CMD_RECTS_INTERNAL)(((uint8_t*)pHdr) + sizeof (VBOXVIDEOCM_CMD_HDR)); 242 PVBOXWDDMDISP_SWAPCHAIN pCurSwapchain = (PVBOXWDDMDISP_SWAPCHAIN)pCmdInternal->hSwapchainUm; 243 if (pCurSwapchain != pSwapchain) 244 continue; 245 246 fHasMatch = true; 247 break; 248 } 249 250 /* restore the iterator */ 251 g_VBoxDispMp.Iterator = IterCopy; 252 253 if (!fHasMatch) 254 break; 255 256 /* there are elements to remove */ 257 PVBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD pEscapeCmd = (PVBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD)RTMemAlloc(g_VBoxDispMp.cbEscapeCmd); 258 if (!pEscapeCmd) 259 { 260 WARN(("no memory")); 261 hr = E_OUTOFMEMORY; 262 break; 263 } 264 /* copy the header data */ 265 *pEscapeCmd = *g_VBoxDispMp.pEscapeCmd; 266 /* now copy the command data filtering out the canceled commands */ 267 pHdr = (PVBOXVIDEOCM_CMD_HDR)(((uint8_t*)pEscapeCmd) + sizeof (VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD)); 268 vboxVideoCmIterInit(&g_VBoxDispMp.Iterator, pHdr, 0); 269 while (pHdr = vboxVideoCmIterNext(&IterCopy)) 270 { 271 VBOXWDDMDISP_CONTEXT *pCurContext = (VBOXWDDMDISP_CONTEXT*)pHdr->u64UmData; 272 if (pCurContext != pContext) 273 { 274 vboxVideoCmIterCopyToBack(&g_VBoxDispMp.Iterator, pHdr); 275 continue; 276 } 277 278 if (!pSwapchain) 279 { 280 /* match, just continue */ 281 continue; 282 } 283 284 PVBOXVIDEOCM_CMD_RECTS_INTERNAL pCmdInternal = (PVBOXVIDEOCM_CMD_RECTS_INTERNAL)(((uint8_t*)pHdr) + sizeof (VBOXVIDEOCM_CMD_HDR)); 285 PVBOXWDDMDISP_SWAPCHAIN pCurSwapchain = (PVBOXWDDMDISP_SWAPCHAIN)pCmdInternal->hSwapchainUm; 286 if (pCurSwapchain != pSwapchain) 287 { 288 vboxVideoCmIterCopyToBack(&g_VBoxDispMp.Iterator, pHdr); 289 continue; 290 } 291 /* match, just continue */ 292 } 293 294 Assert(g_VBoxDispMp.pEscapeCmd); 295 RTMemFree(g_VBoxDispMp.pEscapeCmd); 296 Assert(pEscapeCmd); 297 g_VBoxDispMp.pEscapeCmd = pEscapeCmd; 298 } while (0); 299 300 LeaveCriticalSection(&g_VBoxDispMp.CritSect); 301 return hr; 302 } -
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxScreen.cpp
r36867 r38112 282 282 if (!GetClassInfo(hInstance, VBOXSCREENMONWND_NAME, &wc)) 283 283 { 284 wc.style = CS_OWNDC;284 wc.style = 0;//CS_OWNDC; 285 285 wc.lpfnWndProc = vboxScreenMonWndProc; 286 286 wc.cbClsExtra = 0; -
trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/common/VBoxMPUtils.h
r36867 r38112 103 103 #define VBE_DISPI_TOTAL_VIDEO_MEMORY_BYTES 4*_1M 104 104 105 #define VBOXMP_WARN_VPS_NOBP(_vps) \ 106 if ((_vps) != NO_ERROR) \ 107 { \ 108 WARN_NOBP(("vps(%#x)!=NO_ERROR", _vps)); \ 109 } 110 105 111 #define VBOXMP_WARN_VPS(_vps) \ 106 112 if ((_vps) != NO_ERROR) \ 107 113 { \ 108 WARN(("vps(%#x)!=NO_ERROR" )); \114 WARN(("vps(%#x)!=NO_ERROR", _vps)); \ 109 115 } 116 110 117 111 118 #define VBOXMP_CHECK_VPS_BREAK(_vps) \ -
trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/common/VBoxMPVidModes.cpp
r37490 r38112 156 156 /*First name without a suffix*/ 157 157 rc = VBoxMPCmnRegQueryDword(Registry, L"CustomXRes", &CustomXRes); 158 VBOXMP_WARN_VPS (rc);158 VBOXMP_WARN_VPS_NOBP(rc); 159 159 rc = VBoxMPCmnRegQueryDword(Registry, L"CustomYRes", &CustomYRes); 160 VBOXMP_WARN_VPS (rc);160 VBOXMP_WARN_VPS_NOBP(rc); 161 161 rc = VBoxMPCmnRegQueryDword(Registry, L"CustomBPP", &CustomBPP); 162 VBOXMP_WARN_VPS (rc);162 VBOXMP_WARN_VPS_NOBP(rc); 163 163 } 164 164 else … … 167 167 swprintf(keyname, L"CustomXRes%d", iMode); 168 168 rc = VBoxMPCmnRegQueryDword(Registry, keyname, &CustomXRes); 169 VBOXMP_WARN_VPS (rc);169 VBOXMP_WARN_VPS_NOBP(rc); 170 170 swprintf(keyname, L"CustomYRes%d", iMode); 171 171 rc = VBoxMPCmnRegQueryDword(Registry, keyname, &CustomYRes); 172 VBOXMP_WARN_VPS (rc);172 VBOXMP_WARN_VPS_NOBP(rc); 173 173 swprintf(keyname, L"CustomBPP%d", iMode); 174 174 rc = VBoxMPCmnRegQueryDword(Registry, keyname, &CustomBPP); 175 VBOXMP_WARN_VPS (rc);175 VBOXMP_WARN_VPS_NOBP(rc); 176 176 } 177 177 -
trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPCm.cpp
r37734 r38112 29 29 } VBOXVIDEOCM_CMD_DR, *PVBOXVIDEOCM_CMD_DR; 30 30 31 typedef enum 32 { 33 VBOXVIDEOCM_CMD_CTL_KM_TYPE_POST_INVOKE = 1, 34 VBOXVIDEOCM_CMD_CTL_KM_TYPE_PRE_INVOKE, 35 VBOXVIDEOCM_CMD_CTL_KM_TYPE_DUMMY_32BIT = 0x7fffffff 36 } VBOXVIDEOCM_CMD_CTL_KM_TYPE; 37 38 typedef DECLCALLBACK(VOID) FNVBOXVIDEOCM_CMD_CB(PVBOXVIDEOCM_CTX pContext, struct VBOXVIDEOCM_CMD_CTL_KM *pCmd, PVOID pvContext); 39 typedef FNVBOXVIDEOCM_CMD_CB *PFNVBOXVIDEOCM_CMD_CB; 40 41 typedef struct VBOXVIDEOCM_CMD_CTL_KM 42 { 43 VBOXVIDEOCM_CMD_CTL_KM_TYPE enmType; 44 uint32_t u32Reserved; 45 PFNVBOXVIDEOCM_CMD_CB pfnCb; 46 PVOID pvCb; 47 } VBOXVIDEOCM_CMD_CTL_KM, *PVBOXVIDEOCM_CMD_CTL_KM; 48 31 49 AssertCompile(VBOXWDDM_ROUNDBOUND(RT_OFFSETOF(VBOXVIDEOCM_CMD_DR, CmdHdr), 8) == RT_OFFSETOF(VBOXVIDEOCM_CMD_DR, CmdHdr)); 32 50 … … 49 67 /* commands list */ 50 68 LIST_ENTRY CommandsList; 69 /* post process commands list */ 70 LIST_ENTRY PpCommandsList; 51 71 /* event used to notify UMD about pending commands */ 52 72 PKEVENT pUmEvent; … … 95 115 } 96 116 117 static PVBOXVIDEOCM_CMD_CTL_KM vboxVideoCmCmdCreateKm(PVBOXVIDEOCM_CTX pContext, VBOXVIDEOCM_CMD_CTL_KM_TYPE enmType, 118 PFNVBOXVIDEOCM_CMD_CB pfnCb, PVOID pvCb, 119 uint32_t cbSize) 120 { 121 PVBOXVIDEOCM_CMD_CTL_KM pCmd = (PVBOXVIDEOCM_CMD_CTL_KM)vboxVideoCmCmdCreate(pContext, cbSize + sizeof (*pCmd)); 122 pCmd->enmType = enmType; 123 pCmd->pfnCb = pfnCb; 124 pCmd->pvCb = pvCb; 125 PVBOXVIDEOCM_CMD_DR pHdr = VBOXVIDEOCM_HEAD(pCmd); 126 pHdr->CmdHdr.enmType = VBOXVIDEOCM_CMD_TYPE_CTL_KM; 127 return pCmd; 128 } 129 130 static DECLCALLBACK(VOID) vboxVideoCmCmdCbSetEventAndDereference(PVBOXVIDEOCM_CTX pContext, PVBOXVIDEOCM_CMD_CTL_KM pCmd, PVOID pvContext) 131 { 132 PKEVENT pEvent = (PKEVENT)pvContext; 133 KeSetEvent(pEvent, 0, FALSE); 134 ObDereferenceObject(pEvent); 135 vboxVideoCmCmdRelease(pCmd); 136 } 137 138 NTSTATUS vboxVideoCmCmdSubmitCompleteEvent(PVBOXVIDEOCM_CTX pContext, PKEVENT pEvent) 139 { 140 Assert(pEvent); 141 PVBOXVIDEOCM_CMD_CTL_KM pCmd = vboxVideoCmCmdCreateKm(pContext, VBOXVIDEOCM_CMD_CTL_KM_TYPE_POST_INVOKE, 142 vboxVideoCmCmdCbSetEventAndDereference, pEvent, 0); 143 if (!pCmd) 144 { 145 WARN(("vboxVideoCmCmdCreateKm failed")); 146 return STATUS_NO_MEMORY; 147 } 148 149 vboxVideoCmCmdSubmit(pCmd, VBOXVIDEOCM_SUBMITSIZE_DEFAULT); 150 151 return STATUS_SUCCESS; 152 } 153 97 154 DECLINLINE(void) vboxVideoCmCmdRetainByHdr(PVBOXVIDEOCM_CMD_DR pHdr) 98 155 { … … 162 219 } 163 220 164 NTSTATUS vboxVideoCmCmdVisit(PVBOXVIDEOCM_CTX pContext, BOOL bEntireSession, PFNVBOXVIDEOCMCMDVISITOR pfnVisitor, PVOID pvVisitor)221 NTSTATUS vboxVideoCmCmdVisit(PVBOXVIDEOCM_CTX pContext, BOOLEAN bEntireSession, PFNVBOXVIDEOCMCMDVISITOR pfnVisitor, PVOID pvVisitor) 165 222 { 166 223 PVBOXVIDEOCM_SESSION pSession = pContext->pSession; … … 179 236 if (bEntireSession || pHdr->pContext == pContext) 180 237 { 181 void * pvBody = VBOXVIDEOCM_BODY(pHdr, void); 182 UINT fRet = pfnVisitor(pHdr->pContext, pvBody, pHdr->CmdHdr.cbCmd, pvVisitor); 183 if (fRet & VBOXVIDEOCMCMDVISITOR_RETURN_RMCMD) 238 if (pHdr->CmdHdr.enmType == VBOXVIDEOCM_CMD_TYPE_UM) 184 239 { 185 RemoveEntryList(&pHdr->QueueList); 240 void * pvBody = VBOXVIDEOCM_BODY(pHdr, void); 241 UINT fRet = pfnVisitor(pHdr->pContext, pvBody, pHdr->CmdHdr.cbCmd, pvVisitor); 242 if (fRet & VBOXVIDEOCMCMDVISITOR_RETURN_RMCMD) 243 { 244 RemoveEntryList(&pHdr->QueueList); 245 } 246 if ((fRet & VBOXVIDEOCMCMDVISITOR_RETURN_BREAK)) 247 break; 186 248 } 187 if (!(fRet & VBOXVIDEOCMCMDVISITOR_RETURN_CONTINUE)) 188 break; 249 else 250 { 251 WARN(("non-um cmd on visit, skipping")); 252 } 189 253 } 190 254 } … … 231 295 Assert(IsListEmpty(&pSession->ContextList)); 232 296 Assert(IsListEmpty(&pSession->CommandsList)); 297 Assert(IsListEmpty(&pSession->PpCommandsList)); 233 298 RemoveEntryList(&pSession->QueueEntry); 234 299 vboxWddmMemFree(pSession); 235 300 } 236 301 302 static void vboxVideoCmSessionCtxPpList(PVBOXVIDEOCM_CTX pContext, PLIST_ENTRY pHead) 303 { 304 LIST_ENTRY *pCur; 305 for (pCur = pHead->Flink; pCur != pHead; pCur = pHead->Flink) 306 { 307 RemoveEntryList(pCur); 308 PVBOXVIDEOCM_CMD_DR pHdr = VBOXCMENTRY_2_CMD(pCur); 309 PVBOXVIDEOCM_CMD_CTL_KM pCmd = VBOXVIDEOCM_BODY(pHdr, VBOXVIDEOCM_CMD_CTL_KM); 310 pCmd->pfnCb(pContext, pCmd, pCmd->pvCb); 311 } 312 } 313 314 static void vboxVideoCmSessionCtxDetachCmdsLocked(PLIST_ENTRY pEntriesHead, PVBOXVIDEOCM_CTX pContext, PLIST_ENTRY pDstHead) 315 { 316 LIST_ENTRY *pCur; 317 LIST_ENTRY *pPrev; 318 pCur = pEntriesHead->Flink; 319 pPrev = pEntriesHead; 320 while (pCur != pEntriesHead) 321 { 322 PVBOXVIDEOCM_CMD_DR pCmd = VBOXCMENTRY_2_CMD(pCur); 323 if (pCmd->pContext == pContext) 324 { 325 RemoveEntryList(pCur); 326 InsertTailList(pDstHead, pCur); 327 pCur = pPrev; 328 /* pPrev - remains unchanged */ 329 } 330 else 331 { 332 pPrev = pCur; 333 } 334 pCur = pCur->Flink; 335 } 336 } 237 337 /** 238 338 * @return true iff the given session is destroyed … … 242 342 bool bDestroy; 243 343 LIST_ENTRY RemainedList; 344 LIST_ENTRY RemainedPpList; 244 345 LIST_ENTRY *pCur; 245 LIST_ENTRY *pPrev;246 346 InitializeListHead(&RemainedList); 347 InitializeListHead(&RemainedPpList); 247 348 Assert(KeGetCurrentIrql() < DISPATCH_LEVEL); 248 349 ExAcquireFastMutex(&pSession->Mutex); … … 254 355 { 255 356 vboxVideoLeDetach(&pSession->CommandsList, &RemainedList); 357 vboxVideoLeDetach(&pSession->PpCommandsList, &RemainedPpList); 256 358 } 257 359 else 258 360 { 259 pCur = pSession->CommandsList.Flink; 260 pPrev = &pSession->CommandsList; 261 while (pCur != &pSession->CommandsList) 262 { 263 PVBOXVIDEOCM_CMD_DR pCmd = VBOXCMENTRY_2_CMD(pCur); 264 if (pCmd->pContext == pContext) 265 { 266 RemoveEntryList(pCur); 267 InsertHeadList(&RemainedList, pCur); 268 pCur = pPrev; 269 /* pPrev - remains unchanged */ 270 } 271 else 272 { 273 pPrev = pCur; 274 } 275 pCur = pCur->Flink; 276 } 361 vboxVideoCmSessionCtxDetachCmdsLocked(&pSession->CommandsList, pContext, &RemainedList); 362 vboxVideoCmSessionCtxDetachCmdsLocked(&pSession->PpCommandsList, pContext, &RemainedPpList); 277 363 } 278 364 ExReleaseFastMutex(&pSession->Mutex); … … 284 370 vboxVideoCmCmdCancel(pCmd); 285 371 } 372 373 vboxVideoCmSessionCtxPpList(pContext, &RemainedPpList); 286 374 287 375 if (bDestroy) … … 303 391 InitializeListHead(&pSession->ContextList); 304 392 InitializeListHead(&pSession->CommandsList); 393 InitializeListHead(&pSession->PpCommandsList); 305 394 pSession->pUmEvent = pUmEvent; 306 395 Assert(KeGetCurrentIrql() < DISPATCH_LEVEL); … … 411 500 } 412 501 502 VOID vboxVideoCmProcessKm(PVBOXVIDEOCM_CTX pContext, PVBOXVIDEOCM_CMD_CTL_KM pCmd) 503 { 504 PVBOXVIDEOCM_SESSION pSession = pContext->pSession; 505 506 switch (pCmd->enmType) 507 { 508 case VBOXVIDEOCM_CMD_CTL_KM_TYPE_PRE_INVOKE: 509 { 510 pCmd->pfnCb(pContext, pCmd, pCmd->pvCb); 511 break; 512 } 513 514 case VBOXVIDEOCM_CMD_CTL_KM_TYPE_POST_INVOKE: 515 { 516 PVBOXVIDEOCM_CMD_DR pHdr = VBOXVIDEOCM_HEAD(pCmd); 517 ExAcquireFastMutex(&pSession->Mutex); 518 InsertTailList(&pSession->PpCommandsList, &pHdr->QueueList); 519 ExReleaseFastMutex(&pSession->Mutex); 520 break; 521 } 522 523 default: 524 { 525 WARN(("unsupported cmd type %d", pCmd->enmType)); 526 break; 527 } 528 } 529 } 530 413 531 NTSTATUS vboxVideoCmEscape(PVBOXVIDEOCM_CTX pContext, PVBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD pCmd, uint32_t cbCmd) 414 532 { … … 420 538 PVBOXVIDEOCM_CMD_DR pHdr; 421 539 LIST_ENTRY DetachedList; 540 LIST_ENTRY DetachedPpList; 422 541 PLIST_ENTRY pCurEntry = NULL; 423 542 uint32_t cbCmdsReturned = 0; … … 428 547 bool bDetachMode = true; 429 548 InitializeListHead(&DetachedList); 549 InitializeListHead(&DetachedPpList); 430 550 // PVBOXWDDM_GETVBOXVIDEOCMCMD_HDR *pvCmd 431 551 432 552 Assert(KeGetCurrentIrql() < DISPATCH_LEVEL); 433 553 ExAcquireFastMutex(&pSession->Mutex); 554 555 vboxVideoCmSessionCtxDetachCmdsLocked(&pSession->PpCommandsList, pContext, &DetachedPpList); 434 556 435 557 do … … 442 564 pHdr = VBOXCMENTRY_2_CMD(pSession->CommandsList.Blink); 443 565 Assert(pHdr->CmdHdr.cbCmd); 444 if (cbData >= pHdr->CmdHdr.cbCmd) 566 uint32_t cbUserCmd = pHdr->CmdHdr.enmType == VBOXVIDEOCM_CMD_TYPE_UM ? pHdr->CmdHdr.cbCmd : 0; 567 if (cbData >= cbUserCmd) 445 568 { 446 569 RemoveEntryList(&pHdr->QueueList); 447 570 InsertHeadList(&DetachedList, &pHdr->QueueList); 448 cbData -= pHdr->CmdHdr.cbCmd;571 cbData -= cbUserCmd; 449 572 } 450 573 else 451 574 { 452 cbRemainingFirstCmd = pHdr->CmdHdr.cbCmd; 453 cbRemainingCmds = pHdr->CmdHdr.cbCmd; 575 Assert(cbUserCmd); 576 cbRemainingFirstCmd = cbUserCmd; 577 cbRemainingCmds = cbUserCmd; 454 578 pCurEntry = pHdr->QueueList.Blink; 455 579 bDetachMode = false; … … 468 592 { 469 593 pHdr = VBOXCMENTRY_2_CMD(pCurEntry); 594 uint32_t cbUserCmd = pHdr->CmdHdr.enmType == VBOXVIDEOCM_CMD_TYPE_UM ? pHdr->CmdHdr.cbCmd : 0; 470 595 Assert(cbRemainingFirstCmd); 471 cbRemainingCmds += pHdr->CmdHdr.cbCmd;596 cbRemainingCmds += cbUserCmd; 472 597 pCurEntry = pHdr->QueueList.Blink; 473 598 } … … 483 608 ExReleaseFastMutex(&pSession->Mutex); 484 609 610 vboxVideoCmSessionCtxPpList(pContext, &DetachedPpList); 611 485 612 pCmd->Hdr.cbCmdsReturned = 0; 486 613 for (pCurEntry = DetachedList.Blink; pCurEntry != &DetachedList; pCurEntry = DetachedList.Blink) 487 614 { 488 615 pHdr = VBOXCMENTRY_2_CMD(pCurEntry); 489 memcpy(pvData, &pHdr->CmdHdr, pHdr->CmdHdr.cbCmd);490 pvData += pHdr->CmdHdr.cbCmd;491 pCmd->Hdr.cbCmdsReturned += pHdr->CmdHdr.cbCmd;492 616 RemoveEntryList(pCurEntry); 493 vboxVideoCmCmdReleaseByHdr(pHdr); 617 switch (pHdr->CmdHdr.enmType) 618 { 619 case VBOXVIDEOCM_CMD_TYPE_UM: 620 { 621 memcpy(pvData, &pHdr->CmdHdr, pHdr->CmdHdr.cbCmd); 622 pvData += pHdr->CmdHdr.cbCmd; 623 pCmd->Hdr.cbCmdsReturned += pHdr->CmdHdr.cbCmd; 624 vboxVideoCmCmdReleaseByHdr(pHdr); 625 break; 626 } 627 628 case VBOXVIDEOCM_CMD_TYPE_CTL_KM: 629 { 630 vboxVideoCmProcessKm(pContext, VBOXVIDEOCM_BODY(pHdr, VBOXVIDEOCM_CMD_CTL_KM)); 631 break; 632 } 633 634 default: 635 { 636 WARN(("unsupported cmd type %d", pHdr->CmdHdr.enmType)); 637 break; 638 } 639 } 494 640 } 495 641 -
trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPCm.h
r37734 r38112 42 42 NTSTATUS vboxVideoCmTerm(PVBOXVIDEOCM_MGR pMgr); 43 43 44 NTSTATUS vboxVideoCmCmdSubmitCompleteEvent(PVBOXVIDEOCM_CTX pContext, PKEVENT pEvent); 44 45 void* vboxVideoCmCmdCreate(PVBOXVIDEOCM_CTX pContext, uint32_t cbSize); 45 46 void* vboxVideoCmCmdReinitForContext(void *pvCmd, PVBOXVIDEOCM_CTX pContext); … … 49 50 void vboxVideoCmCmdSubmit(void *pvCmd, uint32_t cbSize); 50 51 51 #define VBOXVIDEOCMCMDVISITOR_RETURN_ CONTINUE0x0000000152 #define VBOXVIDEOCMCMDVISITOR_RETURN_BREAK 0x00000001 52 53 #define VBOXVIDEOCMCMDVISITOR_RETURN_RMCMD 0x00000002 53 54 typedef DECLCALLBACK(UINT) FNVBOXVIDEOCMCMDVISITOR(PVBOXVIDEOCM_CTX pContext, PVOID pvCmd, uint32_t cbCmd, PVOID pvVisitor); 54 55 typedef FNVBOXVIDEOCMCMDVISITOR *PFNVBOXVIDEOCMCMDVISITOR; 55 NTSTATUS vboxVideoCmCmdVisit(PVBOXVIDEOCM_CTX pContext, BOOL bEntireSession, PFNVBOXVIDEOCMCMDVISITOR pfnVisitor, PVOID pvVisitor);56 NTSTATUS vboxVideoCmCmdVisit(PVBOXVIDEOCM_CTX pContext, BOOLEAN bEntireSession, PFNVBOXVIDEOCMCMDVISITOR pfnVisitor, PVOID pvVisitor); 56 57 57 58 NTSTATUS vboxVideoCmEscape(PVBOXVIDEOCM_CTX pContext, PVBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD pCmd, uint32_t cbCmd); -
trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPMisc.cpp
r37734 r38112 216 216 DECLINLINE(VOID) vboxWddmSwapchainRelease(PVBOXWDDM_SWAPCHAIN pSwapchain) 217 217 { 218 uint32_t cRefs = ASMAtomicDecU32(&pSwapchain->cRefs);218 const uint32_t cRefs = ASMAtomicDecU32(&pSwapchain->cRefs); 219 219 Assert(cRefs < UINT32_MAX/2); 220 220 if (!cRefs) 221 221 { 222 Assert(pSwapchain->pContext);223 if (pSwapchain->pContext)224 {225 NTSTATUS tmpStatus = vboxVdmaPostHideSwapchain(pSwapchain);226 Assert(tmpStatus == STATUS_SUCCESS);227 }228 222 vboxWddmMemFree(pSwapchain); 229 223 } … … 312 306 { 313 307 vboxWddmSwapchainAllocRemoveAllInternal(pDevExt, pSwapchain, TRUE); 308 309 Assert(pSwapchain->pContext); 310 if (pSwapchain->pContext) 311 { 312 NTSTATUS tmpStatus = vboxVdmaGgCmdCancel(pDevExt, pSwapchain->pContext, pSwapchain); 313 if (tmpStatus != STATUS_SUCCESS) 314 { 315 WARN(("vboxVdmaGgCmdCancel returned Status (0x%x)", tmpStatus)); 316 } 317 } 318 314 319 vboxWddmSwapchainRelease(pSwapchain); 315 320 } … … 397 402 return STATUS_INVALID_PARAMETER; 398 403 399 PVBOXWDDM_SWAPCHAIN pSwapchain ;404 PVBOXWDDM_SWAPCHAIN pSwapchain = NULL; 400 405 PVBOXWDDM_ALLOCATION *apAlloc = NULL; 401 if (pSwapchainInfo->SwapchainInfo.cAllocs) 402 { 403 apAlloc = (PVBOXWDDM_ALLOCATION *)vboxWddmMemAlloc(sizeof (PVBOXWDDM_ALLOCATION) * pSwapchainInfo->SwapchainInfo.cAllocs); 404 Assert(apAlloc); 405 if (!apAlloc) 406 return STATUS_NO_MEMORY; 407 for (UINT i = 0; i < pSwapchainInfo->SwapchainInfo.cAllocs; ++i) 408 { 409 DXGKARGCB_GETHANDLEDATA GhData; 410 GhData.hObject = pSwapchainInfo->SwapchainInfo.ahAllocs[i]; 411 GhData.Type = DXGK_HANDLE_ALLOCATION; 412 GhData.Flags.Value = 0; 413 PVBOXWDDM_ALLOCATION pAlloc = (PVBOXWDDM_ALLOCATION)pDevExt->u.primary.DxgkInterface.DxgkCbGetHandleData(&GhData); 414 Assert(pAlloc); 415 if (!pAlloc) 416 return STATUS_INVALID_PARAMETER; 417 apAlloc[i] = pAlloc; 418 } 419 } 420 421 if (pSwapchainInfo->SwapchainInfo.hSwapchainKm) 422 { 423 ExAcquireFastMutex(&pDevExt->ContextMutex); 424 pSwapchain = (PVBOXWDDM_SWAPCHAIN)vboxWddmHTableGet(&pContext->Swapchains, (VBOXWDDM_HANDLE)pSwapchainInfo->SwapchainInfo.hSwapchainKm); 425 Assert(pSwapchain); 426 if (!pSwapchain) 427 { 428 ExReleaseFastMutex(&pDevExt->ContextMutex); 429 return STATUS_INVALID_PARAMETER; 430 } 431 Assert(pSwapchain->hSwapchainKm == pSwapchainInfo->SwapchainInfo.hSwapchainKm); 432 Assert(pSwapchain->pContext == pContext); 433 if (pSwapchain->pContext != pContext) 434 { 435 ExReleaseFastMutex(&pDevExt->ContextMutex); 436 return STATUS_INVALID_PARAMETER; 437 } 438 } 439 else if (pSwapchainInfo->SwapchainInfo.cAllocs) 440 { 441 pSwapchain = vboxWddmSwapchainCreate(); 442 if (!pSwapchain) 443 return STATUS_NO_MEMORY; 444 445 ExAcquireFastMutex(&pDevExt->ContextMutex); 446 BOOLEAN bRc = vboxWddmSwapchainCtxAddLocked(pDevExt, pContext, pSwapchain); 447 Assert(bRc); 448 } 449 else 450 return STATUS_INVALID_PARAMETER; 451 452 memset(&pSwapchain->ViewRect, 0, sizeof (pSwapchain->ViewRect)); 453 if (pSwapchain->pLastReportedRects) 454 { 455 vboxVideoCmCmdRelease(pSwapchain->pLastReportedRects); 456 pSwapchain->pLastReportedRects = NULL; 457 } 458 459 vboxWddmSwapchainAllocRemoveAll(pDevExt, pSwapchain); 460 461 if (pSwapchainInfo->SwapchainInfo.cAllocs) 462 { 463 for (UINT i = 0; i < pSwapchainInfo->SwapchainInfo.cAllocs; ++i) 464 { 465 vboxWddmSwapchainAllocAdd(pDevExt, pSwapchain, apAlloc[i]); 466 } 467 pSwapchain->hSwapchainUm = pSwapchainInfo->SwapchainInfo.hSwapchainUm; 468 } 469 else 470 { 471 vboxWddmSwapchainCtxRemoveLocked(pDevExt, pContext, pSwapchain); 472 } 473 474 ExReleaseFastMutex(&pDevExt->ContextMutex); 475 476 if (pSwapchainInfo->SwapchainInfo.cAllocs) 477 { 478 Assert(pSwapchain->pContext); 479 Assert(pSwapchain->hSwapchainKm); 480 pSwapchainInfo->SwapchainInfo.hSwapchainKm = pSwapchain->hSwapchainKm; 481 } 482 else 483 { 484 vboxWddmSwapchainDestroy(pDevExt, pSwapchain); 485 pSwapchainInfo->SwapchainInfo.hSwapchainKm = 0; 486 } 487 488 return STATUS_SUCCESS; 406 Assert(KeGetCurrentIrql() == PASSIVE_LEVEL); 407 NTSTATUS Status = STATUS_SUCCESS; 408 409 do { 410 if (pSwapchainInfo->SwapchainInfo.cAllocs) 411 { 412 apAlloc = (PVBOXWDDM_ALLOCATION *)vboxWddmMemAlloc(sizeof (PVBOXWDDM_ALLOCATION) * pSwapchainInfo->SwapchainInfo.cAllocs); 413 Assert(apAlloc); 414 if (!apAlloc) 415 { 416 Status = STATUS_NO_MEMORY; 417 break; 418 } 419 for (UINT i = 0; i < pSwapchainInfo->SwapchainInfo.cAllocs; ++i) 420 { 421 DXGKARGCB_GETHANDLEDATA GhData; 422 GhData.hObject = pSwapchainInfo->SwapchainInfo.ahAllocs[i]; 423 GhData.Type = DXGK_HANDLE_ALLOCATION; 424 GhData.Flags.Value = 0; 425 PVBOXWDDM_ALLOCATION pAlloc = (PVBOXWDDM_ALLOCATION)pDevExt->u.primary.DxgkInterface.DxgkCbGetHandleData(&GhData); 426 Assert(pAlloc); 427 if (!pAlloc) 428 { 429 Status = STATUS_INVALID_PARAMETER; 430 break; 431 } 432 apAlloc[i] = pAlloc; 433 } 434 435 if (!NT_SUCCESS(Status)) 436 break; 437 } 438 439 if (pSwapchainInfo->SwapchainInfo.hSwapchainKm) 440 { 441 ExAcquireFastMutex(&pDevExt->ContextMutex); 442 pSwapchain = (PVBOXWDDM_SWAPCHAIN)vboxWddmHTableGet(&pContext->Swapchains, (VBOXWDDM_HANDLE)pSwapchainInfo->SwapchainInfo.hSwapchainKm); 443 Assert(pSwapchain); 444 if (!pSwapchain) 445 { 446 ExReleaseFastMutex(&pDevExt->ContextMutex); 447 Status = STATUS_INVALID_PARAMETER; 448 break; 449 } 450 Assert(pSwapchain->hSwapchainKm == pSwapchainInfo->SwapchainInfo.hSwapchainKm); 451 Assert(pSwapchain->pContext == pContext); 452 if (pSwapchain->pContext != pContext) 453 { 454 ExReleaseFastMutex(&pDevExt->ContextMutex); 455 Status = STATUS_INVALID_PARAMETER; 456 break; 457 } 458 } 459 else if (pSwapchainInfo->SwapchainInfo.cAllocs) 460 { 461 pSwapchain = vboxWddmSwapchainCreate(); 462 if (!pSwapchain) 463 { 464 Status = STATUS_NO_MEMORY; 465 break; 466 } 467 468 ExAcquireFastMutex(&pDevExt->ContextMutex); 469 BOOLEAN bRc = vboxWddmSwapchainCtxAddLocked(pDevExt, pContext, pSwapchain); 470 Assert(bRc); 471 } 472 else 473 { 474 Status = STATUS_INVALID_PARAMETER; 475 break; 476 } 477 478 memset(&pSwapchain->ViewRect, 0, sizeof (pSwapchain->ViewRect)); 479 if (pSwapchain->pLastReportedRects) 480 { 481 vboxVideoCmCmdRelease(pSwapchain->pLastReportedRects); 482 pSwapchain->pLastReportedRects = NULL; 483 } 484 485 vboxWddmSwapchainAllocRemoveAll(pDevExt, pSwapchain); 486 487 if (pSwapchainInfo->SwapchainInfo.cAllocs) 488 { 489 for (UINT i = 0; i < pSwapchainInfo->SwapchainInfo.cAllocs; ++i) 490 { 491 vboxWddmSwapchainAllocAdd(pDevExt, pSwapchain, apAlloc[i]); 492 } 493 pSwapchain->hSwapchainUm = pSwapchainInfo->SwapchainInfo.hSwapchainUm; 494 } 495 else 496 { 497 vboxWddmSwapchainCtxRemoveLocked(pDevExt, pContext, pSwapchain); 498 } 499 500 ExReleaseFastMutex(&pDevExt->ContextMutex); 501 502 if (pSwapchainInfo->SwapchainInfo.cAllocs) 503 { 504 Assert(pSwapchain->pContext); 505 Assert(pSwapchain->hSwapchainKm); 506 pSwapchainInfo->SwapchainInfo.hSwapchainKm = pSwapchain->hSwapchainKm; 507 } 508 else 509 { 510 vboxWddmSwapchainDestroy(pDevExt, pSwapchain); 511 pSwapchainInfo->SwapchainInfo.hSwapchainKm = 0; 512 } 513 514 Assert(Status == STATUS_SUCCESS); 515 } while (0); 516 517 /* cleanup */ 518 if (apAlloc) 519 vboxWddmMemFree(apAlloc); 520 521 return Status; 489 522 } 490 523 -
trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPVdma.cpp
r37736 r38112 927 927 break; 928 928 } 929 929 930 default: 930 931 Assert(0); … … 1064 1065 1065 1066 return Status; 1067 } 1068 1069 static DECLCALLBACK(UINT) vboxVdmaGgCmdCancelVisitor(PVBOXVIDEOCM_CTX pContext, PVOID pvCmd, uint32_t cbCmd, PVOID pvVisitor) 1070 { 1071 PVBOXWDDM_SWAPCHAIN pSwapchain = (PVBOXWDDM_SWAPCHAIN)pvVisitor; 1072 if (!pSwapchain) 1073 return VBOXVIDEOCMCMDVISITOR_RETURN_RMCMD; 1074 PVBOXVIDEOCM_CMD_RECTS_INTERNAL pCmdInternal = (PVBOXVIDEOCM_CMD_RECTS_INTERNAL)pvCmd; 1075 if (pCmdInternal->hSwapchainUm == pSwapchain->hSwapchainUm) 1076 return VBOXVIDEOCMCMDVISITOR_RETURN_RMCMD; 1077 return 0; 1066 1078 } 1067 1079 … … 1103 1115 break; 1104 1116 } 1117 case VBOXVDMAPIPE_CMD_TYPE_FINISH: 1118 { 1119 PVBOXVDMAPIPE_CMD_FINISH pCmd = (PVBOXVDMAPIPE_CMD_FINISH)pDr; 1120 PVBOXWDDM_CONTEXT pContext = pCmd->pContext; 1121 Assert(pCmd->pEvent); 1122 Status = vboxVideoCmCmdSubmitCompleteEvent(&pContext->CmContext, pCmd->pEvent); 1123 if (Status != STATUS_SUCCESS) 1124 { 1125 WARN(("vboxVideoCmCmdWaitCompleted failedm Status (0x%x)", Status)); 1126 } 1127 vboxVdmaGgCmdDestroy(pDevExt, &pCmd->Hdr); 1128 break; 1129 } 1130 case VBOXVDMAPIPE_CMD_TYPE_CANCEL: 1131 { 1132 PVBOXVDMAPIPE_CMD_CANCEL pCmd = (PVBOXVDMAPIPE_CMD_CANCEL)pDr; 1133 PVBOXWDDM_CONTEXT pContext = pCmd->pContext; 1134 Status = vboxVideoCmCmdVisit(&pContext->CmContext, FALSE, vboxVdmaGgCmdCancelVisitor, pCmd->pSwapchain); 1135 if (Status != STATUS_SUCCESS) 1136 { 1137 WARN(("vboxVideoCmCmdWaitCompleted failedm Status (0x%x)", Status)); 1138 } 1139 Assert(pCmd->pEvent); 1140 KeSetEvent(pCmd->pEvent, 0, FALSE); 1141 vboxVdmaGgCmdDestroy(pDevExt, &pCmd->Hdr); 1142 break; 1143 } 1105 1144 default: 1106 1145 AssertBreakpoint(); … … 1217 1256 #endif 1218 1257 vboxVdmaDdiCmdInit(pDdiCmd, u32NodeOrdinal, u32FenceId, pfnComplete, pvComplete); 1258 } 1259 1260 NTSTATUS vboxVdmaGgCmdFinish(PVBOXMP_DEVEXT pDevExt, VBOXWDDM_CONTEXT *pContext, PKEVENT pEvent) 1261 { 1262 NTSTATUS Status = STATUS_SUCCESS; 1263 1264 PVBOXVDMAPIPE_CMD_FINISH pCmd = (PVBOXVDMAPIPE_CMD_FINISH)vboxVdmaGgCmdCreate(pDevExt, VBOXVDMAPIPE_CMD_TYPE_FINISH, sizeof (*pCmd)); 1265 if (pCmd) 1266 { 1267 pCmd->pContext = pContext; 1268 pCmd->pEvent = pEvent; 1269 Status = vboxVdmaGgCmdSubmit(pDevExt, &pCmd->Hdr); 1270 if (!NT_SUCCESS(Status)) 1271 { 1272 WARN(("vboxVdmaGgCmdSubmit returned 0x%x", Status)); 1273 } 1274 } 1275 else 1276 { 1277 WARN(("vboxVdmaGgCmdCreate failed")); 1278 Status = STATUS_NO_MEMORY; 1279 } 1280 return Status; 1281 } 1282 1283 NTSTATUS vboxVdmaGgCmdCancel(PVBOXMP_DEVEXT pDevExt, VBOXWDDM_CONTEXT *pContext, PVBOXWDDM_SWAPCHAIN pSwapchain) 1284 { 1285 NTSTATUS Status = STATUS_SUCCESS; 1286 1287 PVBOXVDMAPIPE_CMD_CANCEL pCmd = (PVBOXVDMAPIPE_CMD_CANCEL)vboxVdmaGgCmdCreate(pDevExt, VBOXVDMAPIPE_CMD_TYPE_CANCEL, sizeof (*pCmd)); 1288 if (pCmd) 1289 { 1290 KEVENT Event; 1291 KeInitializeEvent(&Event, NotificationEvent, FALSE); 1292 pCmd->pContext = pContext; 1293 pCmd->pSwapchain = pSwapchain; 1294 pCmd->pEvent = &Event; 1295 Status = vboxVdmaGgCmdSubmit(pDevExt, &pCmd->Hdr); 1296 if (NT_SUCCESS(Status)) 1297 { 1298 Status = KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL); 1299 Assert(Status == STATUS_SUCCESS); 1300 } 1301 else 1302 { 1303 WARN(("vboxVdmaGgCmdSubmit returned 0x%x", Status)); 1304 } 1305 } 1306 else 1307 { 1308 WARN(("vboxVdmaGgCmdCreate failed")); 1309 Status = STATUS_NO_MEMORY; 1310 } 1311 return Status; 1219 1312 } 1220 1313 -
trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPVdma.h
r37626 r38112 161 161 VBOXVDMAPIPE_CMD_TYPE_UNDEFINED = 0, 162 162 VBOXVDMAPIPE_CMD_TYPE_RECTSINFO, 163 VBOXVDMAPIPE_CMD_TYPE_DMACMD 163 VBOXVDMAPIPE_CMD_TYPE_DMACMD, 164 VBOXVDMAPIPE_CMD_TYPE_FINISH, /* ensures all previously submitted commands are completed */ 165 VBOXVDMAPIPE_CMD_TYPE_CANCEL 164 166 } VBOXVDMAPIPE_CMD_TYPE; 165 167 … … 193 195 VBOXVDMAPIPE_RECTS ContextsRects; 194 196 } VBOXVDMAPIPE_CMD_RECTSINFO, *PVBOXVDMAPIPE_CMD_RECTSINFO; 197 198 typedef struct VBOXVDMAPIPE_CMD_FINISH 199 { 200 VBOXVDMAPIPE_CMD_DR Hdr; 201 PVBOXWDDM_CONTEXT pContext; 202 PKEVENT pEvent; 203 } VBOXVDMAPIPE_CMD_FINISH, *PVBOXVDMAPIPE_CMD_FINISH; 204 205 typedef struct VBOXVDMAPIPE_CMD_CANCEL 206 { 207 VBOXVDMAPIPE_CMD_DR Hdr; 208 PVBOXWDDM_CONTEXT pContext; 209 PVBOXWDDM_SWAPCHAIN pSwapchain; 210 PKEVENT pEvent; 211 } VBOXVDMAPIPE_CMD_CANCEL, *PVBOXVDMAPIPE_CMD_CANCEL; 195 212 196 213 typedef struct VBOXVDMAPIPE_FLAGS_DMACMD … … 313 330 PVBOXVDMAPIPE_CMD_DR vboxVdmaGgCmdCreate(PVBOXMP_DEVEXT pDevExt, VBOXVDMAPIPE_CMD_TYPE enmType, uint32_t cbCmd); 314 331 void vboxVdmaGgCmdDestroy(PVBOXMP_DEVEXT pDevExt, PVBOXVDMAPIPE_CMD_DR pDr); 332 NTSTATUS vboxVdmaGgCmdFinish(PVBOXMP_DEVEXT pDevExt, struct VBOXWDDM_CONTEXT *pContext, PKEVENT pEvent); 333 NTSTATUS vboxVdmaGgCmdCancel(PVBOXMP_DEVEXT pDevExt, VBOXWDDM_CONTEXT *pContext, PVBOXWDDM_SWAPCHAIN pSwapchain); 315 334 316 335 NTSTATUS vboxVdmaPostHideSwapchain(PVBOXWDDM_SWAPCHAIN pSwapchain); -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/Makefile.kmk
r38082 r38112 188 188 wined3dwddm_DEFS = $(subst __i386__,,$(wined3d_DEFS)) VBOX_WITH_WDDM VBOX_WINE_WITHOUT_LIBWINE 189 189 wined3dwddm_DEFS.x86 = $(NO_SUCH_VARIABLE) 190 wined3dwddm_SOURCES = $(subst wined3d.def,wined3dwddm.def,$(wined3d_SOURCES)) vbox/libWineStub/debug.c 190 wined3dwddm_SOURCES = $(subst wined3d.def,wined3dwddm.def,$(wined3d_SOURCES)) vbox/libWineStub/debug.c wined3d/vboxext.c 191 191 wined3dwddm_SOURCES.x86 = $(NO_SUCH_VARIABLE) 192 192 wined3dwddm_SOURCES.amd64 = $(NO_SUCH_VARIABLE) … … 199 199 $(VBOX_LIB_VBGL_R3) 200 200 wined3dwddm_DEFS += VBOX_WINE_WITH_IPRT 201 endif 202 ifdef VBOX_WINE_WITH_SINGLE_CONTEXT 203 wined3dwddm_DEFS += VBOX_WINE_WITH_SINGLE_CONTEXT 201 204 endif 202 205 … … 316 319 VBoxD3D9wddm_SDKS = WINDDKWLH 317 320 VBoxD3D9wddm_SDKS.amd64 = $(NO_SUCH_VARIABLE) 321 ifdef VBOX_WINE_WITH_IPRT 322 VBoxD3D9wddm_LIBS += \ 323 $(VBOX_LIB_IPRT_GUEST_R3) \ 324 $(VBOX_LIB_VBGL_R3) 325 VBoxD3D9wddm_DEFS += VBOX_WINE_WITH_IPRT 326 endif 318 327 319 328 DLLS.amd64 += VBoxD3D9wddm-x86 … … 322 331 VBoxD3D9wddm-x86_LIBS = $(PATH_STAGE_LIB)/wined3dwddm-x86$(VBOX_SUFF_LIB) 323 332 VBoxD3D9wddm-x86_DEFS = $(VBoxD3D9wddm_DEFS) VBOX_WDDM_WOW64 333 ifdef VBOX_WINE_WITH_IPRT 334 VBoxD3D9wddm-x86_LIBS += \ 335 $(VBOX_LIB_IPRT_GUEST_R3_X86) \ 336 $(VBOX_LIB_VBGL_R3_X86) 337 endif 324 338 endif 325 339 -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/debug.h
r33656 r38112 37 37 #endif 38 38 39 #ifdef VBOX_WITH_WDDM 40 # ifdef VBOX_WINE_WITH_IPRT 41 # include <iprt/assert.h> 42 # else 43 # define AssertBreakpoint() do { } while (0) 44 # define Assert(_expr) do { } while (0) 45 # define RT_BREAKPOINT() 46 # endif 47 #endif 48 39 49 #ifdef __WINE_WINE_TEST_H 40 50 #error This file should not be used in Wine tests … … 75 85 #ifndef WINE_NO_DEBUG_MSGS 76 86 # define __WINE_GET_DEBUGGING_WARN(dbch) ((dbch)->flags & (1 << __WINE_DBCL_WARN)) 77 # define __WINE_GET_DEBUGGING_FIXME(dbch) ((dbch)->flags & (1 << __WINE_DBCL_FIXME)) 87 # if defined(VBOX_WITH_WDDM) && defined(DEBUG_misha) 88 # define __WINE_GET_DEBUGGING_FIXME(dbch) (RT_BREAKPOINT(), ((dbch)->flags & (1 << __WINE_DBCL_FIXME))) 89 # else 90 # define __WINE_GET_DEBUGGING_FIXME(dbch) ((dbch)->flags & (1 << __WINE_DBCL_FIXME)) 91 # endif 78 92 #else 79 93 # define __WINE_GET_DEBUGGING_WARN(dbch) 0 80 # define __WINE_GET_DEBUGGING_FIXME(dbch) 0 94 # if defined(VBOX_WITH_WDDM) && defined(DEBUG_misha) 95 # define __WINE_GET_DEBUGGING_FIXME(dbch) (RT_BREAKPOINT(), 0) 96 # else 97 # define __WINE_GET_DEBUGGING_FIXME(dbch) 0 98 # endif 81 99 #endif 82 100 83 101 /* define error macro regardless of what is configured */ 102 #if defined(VBOX_WITH_WDDM) && defined(DEBUG_misha) 103 #define __WINE_GET_DEBUGGING_ERR(dbch) (RT_BREAKPOINT(), ((dbch)->flags & (1 << __WINE_DBCL_ERR))) 104 #else 84 105 #define __WINE_GET_DEBUGGING_ERR(dbch) ((dbch)->flags & (1 << __WINE_DBCL_ERR)) 106 #endif 85 107 86 108 #define __WINE_GET_DEBUGGING(dbcl,dbch) __WINE_GET_DEBUGGING##dbcl(dbch) -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/vbox/libWineStub/include/wine/debug.h
r35052 r38112 41 41 #endif 42 42 43 #ifdef VBOX_WITH_WDDM 44 # ifdef VBOX_WINE_WITH_IPRT 45 # include <iprt/assert.h> 46 # else 47 # define AssertBreakpoint() do { } while (0) 48 # define Assert(_expr) do { } while (0) 49 # define RT_BREAKPOINT() 50 # endif 51 #endif 52 43 53 #ifdef __cplusplus 44 54 extern "C" { … … 80 90 #ifndef WINE_NO_DEBUG_MSGS 81 91 # define __WINE_GET_DEBUGGING_WARN(dbch) ((dbch)->flags & (1 << __WINE_DBCL_WARN)) 82 # define __WINE_GET_DEBUGGING_FIXME(dbch) ((dbch)->flags & (1 << __WINE_DBCL_FIXME)) 92 # if defined(VBOX_WITH_WDDM) && defined(DEBUG_misha) 93 # define __WINE_GET_DEBUGGING_FIXME(dbch) (RT_BREAKPOINT(), ((dbch)->flags & (1 << __WINE_DBCL_FIXME))) 94 # else 95 # define __WINE_GET_DEBUGGING_FIXME(dbch) ((dbch)->flags & (1 << __WINE_DBCL_FIXME)) 96 # endif 83 97 #else 84 98 # define __WINE_GET_DEBUGGING_WARN(dbch) 0 85 # define __WINE_GET_DEBUGGING_FIXME(dbch) 0 99 # if defined(VBOX_WITH_WDDM) && defined(DEBUG_misha) 100 # define __WINE_GET_DEBUGGING_FIXME(dbch) (RT_BREAKPOINT(), 0) 101 # else 102 # define __WINE_GET_DEBUGGING_FIXME(dbch) 0 103 # endif 86 104 #endif 87 105 88 106 /* define error macro regardless of what is configured */ 107 #if defined(VBOX_WITH_WDDM) && defined(DEBUG_misha) 108 #define __WINE_GET_DEBUGGING_ERR(dbch) (RT_BREAKPOINT(), ((dbch)->flags & (1 << __WINE_DBCL_ERR))) 109 #else 89 110 #define __WINE_GET_DEBUGGING_ERR(dbch) ((dbch)->flags & (1 << __WINE_DBCL_ERR)) 111 #endif 90 112 91 113 #define __WINE_GET_DEBUGGING(dbcl,dbch) __WINE_GET_DEBUGGING##dbcl(dbch) -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/context.c
r37216 r38112 767 767 { 768 768 ERR("Lost swapchain dc %p for window %p.\n", swapchain->hDC, swapchain->win_handle); 769 swapchain->hDC = GetDC(swapchain->win_handle);770 Assert(swapchain->hDC && (WindowFromDC(swapchain->hDC)==swapchain->win_handle));771 769 } 772 770 } … … 815 813 if (wnd != context->win_handle) 816 814 { 817 WARN("DC %p belongs to window %p instead of %p.\n", 818 context->hdc, wnd, context->win_handle); 815 DWORD winEr = GetLastError(); 816 ERR("DC %p belongs to window %p instead of %p., winEr(%d)\n", 817 context->hdc, wnd, context->win_handle, winEr); 819 818 context->valid = 0; 820 819 } … … 952 951 ERR("Failed to disable GL context.\n"); 953 952 } 954 953 #ifndef VBOX_WINE_WITH_SINGLE_CONTEXT 954 # ifndef VBOX_WITH_WDDM 955 955 ReleaseDC(context->win_handle, context->hdc); 956 956 # else 957 VBoxExtReleaseDC(context->win_handle, context->hdc); 958 # endif 959 #endif 957 960 if (!pwglDeleteContext(context->glCtx)) 958 961 { … … 972 975 } 973 976 977 #ifdef VBOX_WINE_WITH_SINGLE_CONTEXT 978 static struct wined3d_context *context_get_current_ex(DWORD adjustTid) 979 { 980 struct wined3d_context *ctx = TlsGetValue(wined3d_context_tls_idx); 981 if (!adjustTid) 982 return ctx; 983 if (!ctx || ctx->tid == adjustTid) 984 return ctx; 985 if (context_set_current(ctx)) 986 { 987 Assert(ctx->tid == adjustTid); 988 return ctx; 989 } 990 ERR("context_set_current failed\n"); 991 return NULL; 992 } 993 #endif 994 974 995 struct wined3d_context *context_get_current(void) 975 996 { 997 #ifndef VBOX_WINE_WITH_SINGLE_CONTEXT 976 998 return TlsGetValue(wined3d_context_tls_idx); 977 } 999 #else 1000 DWORD tid = GetCurrentThreadId(); 1001 return context_get_current_ex(tid); 1002 #endif 1003 } 1004 978 1005 979 1006 BOOL context_set_current(struct wined3d_context *ctx) 980 1007 { 1008 #ifdef VBOX_WINE_WITH_SINGLE_CONTEXT 1009 struct wined3d_context *old = context_get_current_ex(0); 1010 DWORD tid = GetCurrentThreadId(); 1011 #else 981 1012 struct wined3d_context *old = context_get_current(); 982 1013 #endif 983 1014 if (old == ctx) 984 1015 { 985 TRACE("Already using D3D context %p.\n", ctx); 986 return TRUE; 1016 #ifdef VBOX_WINE_WITH_SINGLE_CONTEXT 1017 if (ctx && ctx->tid != tid) 1018 { 1019 old = NULL; 1020 } 1021 else 1022 #endif 1023 { 1024 TRACE("Already using D3D context %p.\n", ctx); 1025 return TRUE; 1026 } 987 1027 } 988 1028 989 1029 if (old) 990 1030 { 1031 #ifdef VBOX_WINE_WITH_SINGLE_CONTEXT 1032 old->tid = 0; 1033 #endif 991 1034 if (old->destroyed) 992 1035 { … … 1026 1069 } 1027 1070 1071 #ifndef VBOX_WINE_WITH_SINGLE_CONTEXT 1028 1072 return TlsSetValue(wined3d_context_tls_idx, ctx); 1073 #else 1074 if (TlsSetValue(wined3d_context_tls_idx, ctx)) 1075 { 1076 if (ctx) 1077 { 1078 ctx->tid = tid; 1079 } 1080 return TRUE; 1081 } 1082 else 1083 { 1084 DWORD err = GetLastError(); 1085 ERR("Failed to set tls value, last error %#x.\n", err); 1086 } 1087 return FALSE; 1088 #endif 1029 1089 } 1030 1090 … … 1044 1104 { 1045 1105 TRACE("Restoring GL context %p on device context %p.\n", context->restore_ctx, context->restore_dc); 1106 #ifdef VBOX_WINE_WITH_SINGLE_CONTEXT 1107 /* should not be here*/ 1108 ERR("should not be here\n"); 1109 #endif 1046 1110 if (!pwglMakeCurrent(context->restore_dc, context->restore_ctx)) 1047 1111 { … … 1050 1114 context->restore_ctx, context->restore_dc, err); 1051 1115 } 1116 #ifdef VBOX_WITH_WDDM 1117 else 1118 { 1119 /* success branch */ 1120 /* sync back our tls with gl settings */ 1121 const struct wined3d_context *current_context = context_get_current(); 1122 if (current_context && current_context->glCtx != context->restore_ctx) 1123 { 1124 IWineD3DDeviceImpl *device = context->device; 1125 int i = 0; 1126 for (; i < device->numContexts; ++i) 1127 { 1128 const struct wined3d_context *ctx = device->contexts[i]; 1129 if (ctx->glCtx == context->restore_ctx) 1130 { 1131 context_set_current(ctx); 1132 break; 1133 } 1134 } 1135 1136 if (i == device->numContexts) 1137 { 1138 context_set_current(NULL); 1139 } 1140 } 1141 } 1142 #endif 1143 1052 1144 context->restore_ctx = NULL; 1053 1145 context->restore_dc = NULL; … … 1066 1158 if (current_gl && (!current_context || current_context->glCtx != current_gl)) 1067 1159 { 1160 #ifdef VBOX_WINE_WITH_SINGLE_CONTEXT 1161 /* should not be here*/ 1162 ERR("should not be here\n"); 1163 #endif 1068 1164 TRACE("Another GL context (%p on device context %p) is already current.\n", 1069 1165 current_gl, pwglGetCurrentDC()); … … 1305 1401 } 1306 1402 1307 if (!(hdc = GetDC(swapchain->win_handle))) 1403 if (!(hdc = 1404 #ifdef VBOX_WINE_WITH_SINGLE_CONTEXT 1405 swapchain->hDC 1406 #else 1407 GetDC(swapchain->win_handle) 1408 #endif 1409 ) 1410 ) 1308 1411 { 1309 1412 ERR("Failed to retrieve a device context.\n"); … … 1426 1529 #endif 1427 1530 ret->current_rt = (IWineD3DSurface *)target; 1531 #ifndef VBOX_WINE_WITH_SINGLE_CONTEXT 1428 1532 ret->tid = GetCurrentThreadId(); 1533 #endif 1429 1534 1430 1535 ret->render_offscreen = surface_is_offscreen((IWineD3DSurface *) target); … … 1434 1539 ret->glCtx = ctx; 1435 1540 ret->win_handle = swapchain->win_handle; 1541 #ifdef VBOX_WITH_WDDM 1542 Assert(WindowFromDC(hdc) == ret->win_handle); 1543 #endif 1436 1544 ret->hdc = hdc; 1437 1545 ret->pixel_format = pixel_format; … … 1656 1764 const struct wined3d_format_desc *ds_format_desc) 1657 1765 { 1766 #ifndef VBOX_WINE_WITH_SINGLE_CONTEXT 1658 1767 UINT i; 1659 1768 DWORD tid = GetCurrentThreadId(); 1769 #endif 1660 1770 struct wined3d_context *context = NULL; 1661 1771 1772 #ifndef VBOX_WINE_WITH_SINGLE_CONTEXT 1662 1773 for(i = 0 ; i < device->numContexts ; i ++) 1663 1774 { … … 1667 1778 } 1668 1779 } 1780 #else 1781 context = device->numContexts ? device->contexts[0] : NULL; 1782 #endif 1669 1783 1670 1784 if (!context) … … 1961 2075 * 1962 2076 *****************************************************************************/ 1963 static struct wined3d_context *findThreadContextForSwapChain(IWineD3DSwapChain *swapchain, DWORD tid) 1964 { 2077 static struct wined3d_context *findThreadContextForSwapChain(IWineD3DSwapChain *swapchain 2078 #ifndef VBOX_WINE_WITH_SINGLE_CONTEXT 2079 , DWORD tid 2080 #endif 2081 ) 2082 { 2083 #ifdef VBOX_WINE_WITH_SINGLE_CONTEXT 2084 IWineD3DDeviceImpl *device = ((IWineD3DSwapChainImpl*)swapchain)->device; 2085 if (device->numContexts) 2086 return device->contexts[0]; 2087 #else 1965 2088 unsigned int i; 1966 # ifdef VBOX_WITH_WDDM2089 # ifdef VBOX_WITH_WDDM 1967 2090 IWineD3DDeviceImpl *device = ((IWineD3DSwapChainImpl*)swapchain)->device; 1968 2091 for (i = 0; i < device->numContexts; ++i) … … 1971 2094 return device->contexts[i]; 1972 2095 } 1973 # else2096 # else 1974 2097 for(i = 0; i < ((IWineD3DSwapChainImpl *) swapchain)->num_contexts; i++) { 1975 2098 if(((IWineD3DSwapChainImpl *) swapchain)->context[i]->tid == tid) { … … 1977 2100 } 1978 2101 } 2102 # endif 1979 2103 #endif 1980 2104 … … 1983 2107 } 1984 2108 2109 #ifndef VBOX_WINE_WITH_SINGLE_CONTEXT 1985 2110 /***************************************************************************** 1986 2111 * FindContext … … 1999 2124 IWineD3DSwapChain *swapchain = NULL; 2000 2125 struct wined3d_context *current_context = context_get_current(); 2126 #ifndef VBOX_WINE_WITH_SINGLE_CONTEXT 2001 2127 DWORD tid = GetCurrentThreadId(); 2128 #endif 2002 2129 struct wined3d_context *context; 2003 2130 … … 2049 2176 TRACE("Rendering onscreen\n"); 2050 2177 2051 context = findThreadContextForSwapChain(swapchain, tid); 2178 context = findThreadContextForSwapChain(swapchain 2179 #ifndef VBOX_WINE_WITH_SINGLE_CONTEXT 2180 , tid 2181 #endif 2182 ); 2052 2183 #ifdef VBOX_WITH_WDDM 2053 2184 context_validate(context, (IWineD3DSwapChainImpl*)swapchain); … … 2073 2204 * is perfect to call. */ 2074 2205 #ifdef VBOX_WITH_WDDM /* tmp work-around */ 2075 context = findThreadContextForSwapChain(This->swapchains[This->NumberOfSwapChains-1], tid); 2206 context = findThreadContextForSwapChain(This->swapchains[This->NumberOfSwapChains-1] 2207 # ifndef VBOX_WINE_WITH_SINGLE_CONTEXT 2208 , tid 2209 # endif 2210 ); 2076 2211 #else 2077 2212 context = findThreadContextForSwapChain(This->swapchains[0], tid); … … 2091 2226 return context; 2092 2227 } 2228 #else 2229 /***************************************************************************** 2230 * FindContext 2231 * 2232 * Finds a context for the current render target and thread 2233 * 2234 * Parameters: 2235 * target: Render target to find the context for 2236 * tid: Thread to activate the context for 2237 * 2238 * Returns: The needed context 2239 * 2240 *****************************************************************************/ 2241 static struct wined3d_context *FindContext(IWineD3DDeviceImpl *This, IWineD3DSurface *target) 2242 { 2243 IWineD3DSwapChain *swapchain = NULL; 2244 struct wined3d_context *context = This->numContexts ? This->contexts[0] : NULL; 2245 2246 if (context && context->destroyed) 2247 { 2248 ERR("context is destroyed"); 2249 } 2250 2251 if (!target) 2252 { 2253 if (context 2254 && context->current_rt 2255 && context_get_device(context) == This 2256 ) 2257 { 2258 target = context->current_rt; 2259 } 2260 else 2261 { 2262 #ifdef VBOX_WITH_WDDM 2263 /* tmp work-around */ 2264 IWineD3DSwapChainImpl *swapchain = (IWineD3DSwapChainImpl *)This->swapchains[This->NumberOfSwapChains-1]; 2265 #else 2266 IWineD3DSwapChainImpl *swapchain = (IWineD3DSwapChainImpl *)This->swapchains[0]; 2267 #endif 2268 if (swapchain->backBuffer) target = swapchain->backBuffer[0]; 2269 else target = swapchain->frontBuffer; 2270 } 2271 } 2272 2273 if (context && context->current_rt == target) 2274 { 2275 #ifdef VBOX_WITH_WDDM 2276 IWineD3DSwapChain *swapchain = NULL; 2277 if (SUCCEEDED(IWineD3DSurface_GetContainer(target, &IID_IWineD3DSwapChain, (void **)&swapchain))) { 2278 context_validate(context, (IWineD3DSwapChainImpl*)swapchain); 2279 IWineD3DSwapChain_Release(swapchain); 2280 } 2281 else { 2282 /* tmp work-around */ 2283 context_validate(context, 2284 NULL //(IWineD3DSwapChainImpl*)current_context->device->swapchains[current_context->device->NumberOfSwapChains-1] 2285 ); 2286 } 2287 #else 2288 context_validate(context); 2289 #endif 2290 return context; 2291 } 2292 2293 if (SUCCEEDED(IWineD3DSurface_GetContainer(target, &IID_IWineD3DSwapChain, (void **)&swapchain))) { 2294 TRACE("Rendering onscreen\n"); 2295 2296 context = findThreadContextForSwapChain(swapchain); 2297 #ifdef VBOX_WITH_WDDM 2298 context_validate(context, (IWineD3DSwapChainImpl*)swapchain); 2299 #endif 2300 IWineD3DSwapChain_Release(swapchain); 2301 } 2302 else 2303 { 2304 TRACE("Rendering offscreen\n"); 2305 2306 if (!context) 2307 { 2308 /* This may happen if the app jumps straight into offscreen rendering 2309 * Start using the context of the primary swapchain. tid == 0 is no problem 2310 * for findThreadContextForSwapChain. 2311 * 2312 * Can also happen on thread switches - in that case findThreadContextForSwapChain 2313 * is perfect to call. */ 2314 #ifdef VBOX_WITH_WDDM /* tmp work-around */ 2315 context = findThreadContextForSwapChain(This->swapchains[This->NumberOfSwapChains-1]); 2316 #else 2317 context = findThreadContextForSwapChain(This->swapchains[0], tid); 2318 #endif 2319 } 2320 #ifdef VBOX_WITH_WDDM 2321 context_validate(context, 2322 NULL //(IWineD3DSwapChainImpl*)This->swapchains[This->NumberOfSwapChains-1] /* tmp work-around */ 2323 ); 2324 #endif 2325 } 2326 2327 #ifndef VBOX_WITH_WDDM 2328 context_validate(context); 2329 #endif 2330 2331 return context; 2332 } 2333 #endif 2093 2334 2094 2335 /* Context activation is done by the caller. */ -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/directx.c
r35718 r38112 392 392 } 393 393 HeapFree(GetProcessHeap(), 0, This); 394 395 #ifdef VBOX_WITH_WDDM 396 VBoxExtCheckTerm(); 397 #endif 394 398 } 395 399 -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/query.c
r33656 r38112 64 64 if (!query->context->gl_info->supported[ARB_SYNC] && query->context->tid != GetCurrentThreadId()) 65 65 { 66 #ifdef VBOX_WINE_WITH_SINGLE_CONTEXT 67 ERR("Event query tested from wrong thread\n"); 68 #else 66 69 WARN("Event query tested from wrong thread\n"); 70 #endif 67 71 return WINED3D_EVENT_QUERY_WRONG_THREAD; 68 72 } … … 141 145 * to find its own way to cope with the thread switch 142 146 */ 147 #ifdef VBOX_WINE_WITH_SINGLE_CONTEXT 148 ERR("Event query finished from wrong thread\n"); 149 #else 143 150 WARN("Event query finished from wrong thread\n"); 151 #endif 144 152 return WINED3D_EVENT_QUERY_WRONG_THREAD; 145 153 } … … 198 206 if (!query->context->gl_info->supported[ARB_SYNC] && query->context->tid != GetCurrentThreadId()) 199 207 { 208 #ifdef VBOX_WINE_WITH_SINGLE_CONTEXT 209 ERR("unexpected\n"); 210 #endif 200 211 context_free_event_query(query); 201 212 context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD); -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/surface.c
r37873 r38112 553 553 { 554 554 IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface; 555 556 #if defined(DEBUG_misha) && defined (VBOX_WITH_WDDM)557 if (VBOXSHRC_IS_SHARED_UNLOCKED(This))558 {559 Assert(0);560 }561 #endif562 555 563 556 This->Flags &= ~(SFLAG_ALLOCATED | SFLAG_SRGBALLOCATED); -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/swapchain.c
r37300 r38112 108 108 #ifdef VBOX_WITH_WDDM 109 109 if(This->device_window) { 110 ReleaseDC(This->device_window, This->hDC); 110 /* see VBoxExtGet/ReleaseDC for comments */ 111 VBoxExtReleaseDC(This->device_window, This->hDC); 111 112 } 112 113 #else … … 376 377 Assert(wnd==context->win_handle); 377 378 Assert(IsWindow(context->win_handle)); 378 379 if (wnd != context->win_handle) 380 { 381 extern void context_update_window(struct wined3d_context *context, IWineD3DSwapChainImpl *swapchain); 382 383 context->valid = 0; 384 Assert(context->currentSwapchain == This); 385 context_update_window(context, context->currentSwapchain); 386 } 379 Assert(wnd == context->win_handle); 387 380 } 388 381 #endif … … 739 732 #ifdef VBOX_WITH_WDDM 740 733 Assert(window); 741 swapchain->hDC = GetDC(window); 734 /* see VBoxExtGet/ReleaseDC for comments */ 735 swapchain->hDC = VBoxExtGetDC(window); 742 736 if (!swapchain->hDC) 743 737 { -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/vboxsharedrc.h
r37870 r38112 2 2 /** @file 3 3 * 4 * VBox extension to Wine D3D 4 * VBox extension to Wine D3D - shared resource 5 5 * 6 6 * Copyright (C) 2010 Oracle Corporation -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/wined3d_main.c
r34943 r38112 95 95 HRESULT hr; 96 96 97 #ifdef VBOX_WITH_WDDM 98 hr = VBoxExtCheckInit(); 99 if (FAILED(hr)) 100 { 101 ERR("VBoxExtCheckInit failed, hr (0x%x)\n", hr); 102 return NULL; 103 } 104 #endif 105 97 106 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); 98 107 if (!object) 99 108 { 100 109 ERR("Failed to allocate wined3d object memory.\n"); 110 #ifdef VBOX_WITH_WDDM 111 VBoxExtCheckTerm(); 112 #endif 101 113 return NULL; 102 114 } … … 107 119 WARN("Failed to initialize wined3d object, hr %#x.\n", hr); 108 120 HeapFree(GetProcessHeap(), 0, object); 121 #ifdef VBOX_WITH_WDDM 122 VBoxExtCheckTerm(); 123 #endif 109 124 return NULL; 110 125 } -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/wined3d_private.h
r37870 r38112 51 51 #include "wine/debug.h" 52 52 #include "wine/unicode.h" 53 #ifdef VBOX_WITH_WDDM 54 # include "vboxext.h" 55 #endif 56 53 57 54 58 #ifndef VBOX_WINE_WITHOUT_LIBWINE
Note:
See TracChangeset
for help on using the changeset viewer.