Changeset 38363 in vbox for trunk/src/VBox/Additions/WINNT/Graphics
- Timestamp:
- Aug 8, 2011 7:01:30 PM (13 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/Graphics
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispD3D.cpp
r38112 r38363 1767 1767 pSwapchain->pSwapChainIf->Release(); 1768 1768 Assert(pSwapchain->hWnd); 1769 HRESULT hr = VBoxDispWndDestroy(pDevice->pAdapter, pSwapchain->hWnd);1770 Assert(hr == S_OK);1771 1769 pSwapchain->pSwapChainIf = NULL; 1772 1770 pSwapchain->hWnd = NULL; 1773 return hr;1771 return S_OK; 1774 1772 } 1775 1773 … … 2297 2295 { 2298 2296 //#define VBOXDISP_NEWWND_ON_SWAPCHAINUPDATE 2299 #ifndef VBOXDISP_NEWWND_ON_SWAPCHAINUPDATE2300 if (!hOldWnd)2301 #endif2302 {2303 hr = VBoxDispWndCreate(pAdapter, Params.BackBufferWidth, Params.BackBufferHeight, &pSwapchain->hWnd);2304 Assert(hr == S_OK);2305 }2306 2297 if (hr == S_OK) 2307 2298 { 2308 2299 DWORD fFlags = D3DCREATE_HARDWARE_VERTEXPROCESSING; 2309 if (pDevice->fFlags.AllowMultithreading)2310 fFlags |= D3DCREATE_MULTITHREADED;2311 2312 Params.hDeviceWindow = pSwapchain->hWnd;2300 // if (pDevice->fFlags.AllowMultithreading) 2301 // fFlags |= D3DCREATE_MULTITHREADED; 2302 2303 Params.hDeviceWindow = NULL; 2313 2304 /* @todo: it seems there should be a way to detect this correctly since 2314 2305 * our vboxWddmDDevSetDisplayMode will be called in case we are using full-screen */ … … 2321 2312 if (!pDevice->pDevice9If) 2322 2313 { 2323 hr = pAdapter->pD3D9If->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, pSwapchain->hWnd, fFlags, &Params, &pDevice9If);2314 hr = pAdapter->pD3D9If->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, NULL, fFlags, &Params, &pDevice9If); 2324 2315 Assert(hr == S_OK); 2325 2316 if (hr == S_OK) 2326 2317 { 2318 Assert(Params.hDeviceWindow); 2319 pSwapchain->hWnd = Params.hDeviceWindow; 2327 2320 pDevice->pDevice9If = pDevice9If; 2328 2321 hr = pDevice9If->GetSwapChain(0, &pNewIf); … … 2410 2403 if (hr == S_OK) 2411 2404 { 2405 Assert(Params.hDeviceWindow); 2406 pSwapchain->hWnd = Params.hDeviceWindow; 2412 2407 Assert(pNewIf); 2413 2408 } … … 2496 2491 Assert(hOldWnd); 2497 2492 pOldIf->Release(); 2498 if (hOldWnd != pSwapchain->hWnd)2499 {2500 VBoxDispWndDestroy(pAdapter, hOldWnd);2501 }2502 2493 } 2503 2494 else … … 2513 2504 2514 2505 Assert(hr != S_OK); 2515 if (hOldWnd != pSwapchain->hWnd) 2516 { 2517 HRESULT tmpHr = VBoxDispWndDestroy(pAdapter, pSwapchain->hWnd); 2518 Assert(tmpHr == S_OK); 2519 pSwapchain->hWnd = hOldWnd; 2520 } 2506 pSwapchain->hWnd = hOldWnd; 2521 2507 } 2522 2508 … … 5326 5312 if (VBOXDISPMODE_IS_3D(pAdapter)) 5327 5313 { 5328 // if (pRc->RcDesc.fFlags.RenderTarget)5329 // {5330 // Assert(pDevice->hWnd);5331 // Assert(pDevice->pDevice9If);5332 // }5333 5334 5314 for (UINT i = 0; i < pRc->cAllocations; ++i) 5335 5315 { … … 5498 5478 } 5499 5479 #endif 5500 #if 15501 5480 PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)pData->hSrcResource; 5502 5481 Assert(pRc); … … 5505 5484 hr = vboxWddmSwapchainPresent(pDevice, pAlloc); 5506 5485 Assert(hr == S_OK); 5507 #else 5508 PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)pData->hSrcResource; 5509 Assert(pRc); 5510 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pRc->RcDesc.VidPnSourceId]; 5511 Assert(pScreen->hWnd); 5512 Assert(pScreen->pDevice9If); 5513 Assert(pRc == pScreen->pRenderTargetRc); 5514 #if 1 5515 VBOXVDBG_RTGT_STATECHECK(pDevice); 5516 5517 if (pRc->RcDesc.VidPnSourceId != pDevice->iPrimaryScreen) 5518 { 5519 PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[pData->SrcSubResourceIndex]; 5520 PVBOXWDDMDISP_SCREEN pPrimaryScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 5521 Assert(pPrimaryScreen->pDevice9If); 5522 IDirect3DSurface9 *pSecondaryRt; 5523 Assert(pAlloc->enmD3DIfType == VBOXDISP_D3DIFTYPE_SURFACE); 5524 IDirect3DSurface9 *pDataRt = (IDirect3DSurface9*)pAlloc->pSecondaryOpenedD3DIf; 5525 Assert(pDataRt); 5526 hr = pDevice->pAdapter->D3D.pfnVBoxWineExD3DDev9Flush((IDirect3DDevice9Ex*)pPrimaryScreen->pDevice9If); 5527 Assert(hr == S_OK); 5528 if (hr == S_OK) 5529 { 5530 hr = pScreen->pDevice9If->GetRenderTarget(0, &pSecondaryRt); 5531 Assert(hr == S_OK); 5532 if (hr == S_OK) 5533 { 5534 hr = pScreen->pDevice9If->StretchRect(pDataRt, 5535 NULL, 5536 pSecondaryRt, 5537 NULL, 5538 D3DTEXF_NONE); 5539 pSecondaryRt->Release(); 5540 } 5541 } 5542 } 5543 5544 hr = pScreen->pDevice9If->Present(NULL, /* CONST RECT * pSourceRect */ 5545 NULL, /* CONST RECT * pDestRect */ 5546 NULL, /* HWND hDestWindowOverride */ 5547 NULL /*CONST RGNDATA * pDirtyRegion */ 5548 ); 5549 Assert(hr == S_OK); 5550 #endif 5551 #endif 5552 } 5553 #if 0 5554 else 5555 #endif 5556 { 5557 // if (pData->Flags.Flip) 5558 // { 5559 // Assert(pData->hSrcResource); 5560 // PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)pData->hSrcResource; 5561 // PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pRc->RcDesc.VidPnSourceId]; 5562 // Assert(pScreen->hWnd); 5563 // Assert(pScreen->pDevice9If); 5564 // Assert(pScreen->pRenderTargetRc == pRc); 5565 // Assert(pRc->cAllocations >= 2); 5566 // Assert(pRc->aAllocations[0].enmD3DIfType == VBOXDISP_D3DIFTYPE_SURFACE); 5567 // Assert(pRc->RcDesc.fFlags.RenderTarget); 5568 // uint32_t iNewRTFB = (pScreen->iRenderTargetFrontBuf + 1) % pRc->cAllocations; 5569 // 5570 // Assert(pScreen->iRenderTargetFrontBuf != iNewRTFB); 5571 // Assert(pData->SrcSubResourceIndex == iNewRTFB); 5572 // 5573 // vboxWddmRenderTargetUpdate(pDevice, pRc, iNewRTFB); 5574 // 5575 // /* assign a new frontbuffer index */ 5576 // pScreen->iRenderTargetFrontBuf = iNewRTFB; 5577 // 5578 // VBOXVDBG_RTGT_STATECHECK(pDevice); 5579 // } 5486 } 5487 5488 { 5580 5489 D3DDDICB_PRESENT DdiPresent = {0}; 5581 5490 if (pData->hSrcResource) … … 5596 5505 } 5597 5506 DdiPresent.hContext = pDevice->DefaultContext.ContextInfo.hContext; 5598 // DdiPresent.BroadcastContextCount;5599 // DdiPresent.BroadcastContext[D3DDDI_MAX_BROADCAST_CONTEXT];5600 5507 5601 5508 hr = pDevice->RtCallbacks.pfnPresentCb(pDevice->hDevice, &DdiPresent); … … 7215 7122 { 7216 7123 VBOXDISPCRHGSMI_SCOPE_SET_GLOBAL(); 7217 HRESULT hr = VBoxDispWorkerDestroy(&pAdapter->WndWorker);7218 Assert(hr == S_OK);7219 7124 pAdapter->pD3D9If->Release(); 7220 7125 VBoxDispD3DClose(&pAdapter->D3D); … … 7329 7234 Assert(pAdapter->cMaxSimRTs); 7330 7235 Assert(pAdapter->cMaxSimRTs < UINT32_MAX/2); 7331 hr = VBoxDispWorkerCreate(&pAdapter->WndWorker); 7332 Assert(hr == S_OK); 7333 if (hr == S_OK) 7334 { 7335 vboxVDbgPrint((__FUNCTION__": SUCCESS 3D Enabled, pAdapter (0x%p)\n", pAdapter)); 7336 break; 7337 } 7236 vboxVDbgPrint((__FUNCTION__": SUCCESS 3D Enabled, pAdapter (0x%p)\n", pAdapter)); 7237 break; 7338 7238 } 7339 7239 pAdapter->pD3D9If->Release(); -
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispD3D.h
r38112 r38363 56 56 UINT uRtVersion; 57 57 VBOXDISPD3D D3D; 58 VBOXDISPWORKER WndWorker;59 58 IDirect3D9Ex * pD3D9If; 60 59 D3DDDI_ADAPTERCALLBACKS RtCallbacks; … … 148 147 #endif 149 148 IDirect3DSwapChain9 *pSwapChainIf; 149 /* a read-only hWnd we receive from wine 150 * we use it for visible region notifications only, 151 * it MUST NOT be destroyed on swapchain destruction, 152 * wine will handle that for us */ 150 153 HWND hWnd; 151 154 VBOXDISP_KMHANDLE hSwapchainKm; -
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispD3DIf.cpp
r38112 r38363 81 81 return E_FAIL; 82 82 } 83 84 #define WM_VBOXDISP_CALLPROC (WM_APP+1)85 86 typedef struct VBOXDISP_CALLPROC87 {88 PFNVBOXDISPWORKERCB pfnCb;89 void *pvCb;90 } VBOXDISP_CALLPROC;91 92 static DWORD WINAPI vboxDispWorkerThread(void *pvUser)93 {94 VBOXDISPWORKER *pWorker = (VBOXDISPWORKER*)pvUser;95 MSG Msg;96 97 PeekMessage(&Msg,98 NULL /* HWND hWnd */,99 WM_USER /* UINT wMsgFilterMin */,100 WM_USER /* UINT wMsgFilterMax */,101 PM_NOREMOVE);102 RTSemEventSignal(pWorker->hEvent);103 104 do105 {106 BOOL bResult = GetMessage(&Msg,107 0 /*HWND hWnd*/,108 0 /*UINT wMsgFilterMin*/,109 0 /*UINT wMsgFilterMax*/110 );111 112 if(!bResult) /* WM_QUIT was posted */113 break;114 115 Assert(bResult != -1);116 if(bResult == -1) /* error occurred */117 break;118 119 switch (Msg.message)120 {121 case WM_VBOXDISP_CALLPROC:122 {123 VBOXDISP_CALLPROC* pData = (VBOXDISP_CALLPROC*)Msg.lParam;124 pData->pfnCb(pData->pvCb);125 RTSemEventSignal(pWorker->hEvent);126 break;127 }128 default:129 TranslateMessage(&Msg);130 DispatchMessage(&Msg);131 }132 } while (1);133 return 0;134 }135 136 static int vboxDispWorkerSubmit(VBOXDISPWORKER *pWorker, UINT Msg, LPARAM lParam)137 {138 /* need to serialize since vboxDispWorkerThread is using one pWorker->hEvent139 * to signal job completion */140 int rc = RTCritSectEnter(&pWorker->CritSect);141 AssertRC(rc);142 if (RT_SUCCESS(rc))143 {144 BOOL bResult = PostThreadMessage(pWorker->idThread, Msg, 0, lParam);145 Assert(bResult);146 if (bResult)147 {148 rc = RTSemEventWait(pWorker->hEvent, RT_INDEFINITE_WAIT);149 AssertRC(rc);150 }151 else152 rc = VERR_GENERAL_FAILURE;153 154 int tmpRc = RTCritSectLeave(&pWorker->CritSect);155 AssertRC(tmpRc);156 }157 return rc;158 }159 160 HRESULT VBoxDispWorkerSubmitProc(VBOXDISPWORKER *pWorker, PFNVBOXDISPWORKERCB pfnCb, void *pvCb)161 {162 VBOXDISP_CALLPROC Ctx;163 Ctx.pfnCb = pfnCb;164 Ctx.pvCb = pvCb;165 int rc = vboxDispWorkerSubmit(pWorker, WM_VBOXDISP_CALLPROC, (LPARAM)&Ctx);166 AssertRC(rc);167 return RT_SUCCESS(rc) ? S_OK : E_FAIL;168 }169 170 HRESULT VBoxDispWorkerCreate(VBOXDISPWORKER *pWorker)171 {172 int rc = RTCritSectInit(&pWorker->CritSect);173 AssertRC(rc);174 if (RT_SUCCESS(rc))175 {176 rc = RTSemEventCreate(&pWorker->hEvent);177 AssertRC(rc);178 if (RT_SUCCESS(rc))179 {180 pWorker->hThread = CreateThread(181 NULL /* LPSECURITY_ATTRIBUTES lpThreadAttributes */,182 0 /* SIZE_T dwStackSize */,183 vboxDispWorkerThread,184 pWorker,185 0 /* DWORD dwCreationFlags */,186 &pWorker->idThread);187 Assert(pWorker->hThread);188 if (pWorker->hThread)189 {190 rc = RTSemEventWait(pWorker->hEvent, RT_INDEFINITE_WAIT);191 AssertRC(rc);192 if (RT_SUCCESS(rc))193 return S_OK;194 /* destroy thread ? */195 }196 else197 {198 DWORD winErr = GetLastError();199 vboxVDbgPrintR((__FUNCTION__": CreateThread failed, winErr = (%d)", winErr));200 rc = VERR_GENERAL_FAILURE;201 }202 int tmpRc = RTSemEventDestroy(pWorker->hEvent);203 AssertRC(tmpRc);204 }205 int tmpRc = RTCritSectDelete(&pWorker->CritSect);206 AssertRC(tmpRc);207 }208 return E_FAIL;209 }210 211 HRESULT VBoxDispWorkerDestroy(VBOXDISPWORKER *pWorker)212 {213 int rc = VINF_SUCCESS;214 BOOL bResult = PostThreadMessage(pWorker->idThread, WM_QUIT, 0, 0);215 Assert(bResult);216 if (bResult)217 {218 DWORD dwErr = WaitForSingleObject(pWorker->hThread, INFINITE);219 Assert(dwErr == WAIT_OBJECT_0);220 if (dwErr == WAIT_OBJECT_0)221 {222 rc = RTSemEventDestroy(pWorker->hEvent);223 AssertRC(rc);224 if (RT_SUCCESS(rc))225 {226 rc = RTCritSectDelete(&pWorker->CritSect);227 AssertRC(rc);228 }229 }230 else231 rc = VERR_GENERAL_FAILURE;232 }233 else234 rc = VERR_GENERAL_FAILURE;235 236 return RT_SUCCESS(rc) ? S_OK : E_FAIL;237 }238 239 static LRESULT CALLBACK WindowProc(HWND hwnd,240 UINT uMsg,241 WPARAM wParam,242 LPARAM lParam243 )244 {245 switch(uMsg)246 {247 case WM_CLOSE:248 vboxVDbgPrint((__FUNCTION__": got WM_CLOSE for hwnd(0x%x)", hwnd));249 return 0;250 case WM_DESTROY:251 vboxVDbgPrint((__FUNCTION__": got WM_DESTROY for hwnd(0x%x)", hwnd));252 return 0;253 case WM_NCHITTEST:254 vboxVDbgPrint((__FUNCTION__": got WM_NCHITTEST for hwnd(0x%x)\n", hwnd));255 return HTNOWHERE;256 }257 258 return DefWindowProc(hwnd, uMsg, wParam, lParam);259 }260 261 #define VBOXDISPWND_NAME L"VboxDispD3DWindow"262 263 HRESULT vboxDispWndDoCreate(DWORD w, DWORD h, HWND *phWnd)264 {265 HRESULT hr = S_OK;266 HINSTANCE hInstance = (HINSTANCE)GetModuleHandle(NULL);267 /* Register the Window Class. */268 WNDCLASS wc;269 if (!GetClassInfo(hInstance, VBOXDISPWND_NAME, &wc))270 {271 wc.style = 0;//CS_OWNDC;272 wc.lpfnWndProc = WindowProc;273 wc.cbClsExtra = 0;274 wc.cbWndExtra = 0;275 wc.hInstance = hInstance;276 wc.hIcon = NULL;277 wc.hCursor = NULL;278 wc.hbrBackground = NULL;279 wc.lpszMenuName = NULL;280 wc.lpszClassName = VBOXDISPWND_NAME;281 if (!RegisterClass(&wc))282 {283 DWORD winErr = GetLastError();284 vboxVDbgPrint((__FUNCTION__": RegisterClass failed, winErr(%d)\n", winErr));285 hr = E_FAIL;286 }287 }288 289 if (hr == S_OK)290 {291 HWND hWnd = CreateWindowEx (WS_EX_TOOLWINDOW,292 VBOXDISPWND_NAME, VBOXDISPWND_NAME,293 WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_DISABLED,294 0, 0,295 w, h,296 NULL, //GetDesktopWindow() /* hWndParent */,297 NULL /* hMenu */,298 hInstance,299 NULL /* lpParam */);300 Assert(hWnd);301 if (hWnd)302 {303 *phWnd = hWnd;304 }305 else306 {307 DWORD winErr = GetLastError();308 vboxVDbgPrint((__FUNCTION__": CreateWindowEx failed, winErr(%d)\n", winErr));309 hr = E_FAIL;310 }311 }312 313 return hr;314 }315 316 static HRESULT vboxDispWndDoDestroy(HWND hWnd)317 {318 BOOL bResult = DestroyWindow(hWnd);319 Assert(bResult);320 if (bResult)321 return S_OK;322 323 DWORD winErr = GetLastError();324 vboxVDbgPrint((__FUNCTION__": DestroyWindow failed, winErr(%d) for hWnd(0x%x)\n", winErr, hWnd));325 326 return E_FAIL;327 }328 329 typedef struct VBOXDISPWND_CREATE_INFO330 {331 int hr;332 HWND hWnd;333 DWORD width;334 DWORD height;335 } VBOXDISPWND_CREATE_INFO;336 337 typedef struct VBOXDISPWND_DESTROY_INFO338 {339 int hr;340 HWND hWnd;341 } VBOXDISPWND_DESTROY_INFO;342 343 DECLCALLBACK(void) vboxDispWndDestroyWorker(void *pvUser)344 {345 VBOXDISPWND_DESTROY_INFO *pInfo = (VBOXDISPWND_DESTROY_INFO*)pvUser;346 pInfo->hr = vboxDispWndDoDestroy(pInfo->hWnd);347 Assert(pInfo->hr == S_OK);348 }349 350 DECLCALLBACK(void) vboxDispWndCreateWorker(void *pvUser)351 {352 VBOXDISPWND_CREATE_INFO *pInfo = (VBOXDISPWND_CREATE_INFO*)pvUser;353 pInfo->hr = vboxDispWndDoCreate(pInfo->width, pInfo->height, &pInfo->hWnd);354 Assert(pInfo->hr == S_OK);355 }356 357 358 HRESULT VBoxDispWndDestroy(PVBOXWDDMDISP_ADAPTER pAdapter, HWND hWnd)359 {360 VBOXDISPWND_DESTROY_INFO Info;361 Info.hr = E_FAIL;362 Info.hWnd = hWnd;363 HRESULT hr = VBoxDispWorkerSubmitProc(&pAdapter->WndWorker, vboxDispWndDestroyWorker, &Info);364 Assert(hr == S_OK);365 if (hr == S_OK)366 {367 Assert(Info.hr == S_OK);368 return Info.hr;369 }370 return hr;371 }372 373 HRESULT VBoxDispWndCreate(PVBOXWDDMDISP_ADAPTER pAdapter, DWORD width, DWORD height, HWND *phWnd)374 {375 VBOXDISPWND_CREATE_INFO Info;376 Info.hr = E_FAIL;377 Info.width = width;378 Info.height = height;379 HRESULT hr = VBoxDispWorkerSubmitProc(&pAdapter->WndWorker, vboxDispWndCreateWorker, &Info);380 Assert(hr == S_OK);381 if (hr == S_OK)382 {383 Assert(Info.hr == S_OK);384 if (Info.hr == S_OK)385 *phWnd = Info.hWnd;386 return Info.hr;387 }388 return hr;389 } -
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispD3DIf.h
r36867 r38363 53 53 void VBoxDispD3DClose(VBOXDISPD3D *pD3D); 54 54 55 56 typedef struct VBOXDISPWORKER57 {58 RTCRITSECT CritSect;59 60 RTSEMEVENT hEvent;61 62 HANDLE hThread;63 DWORD idThread;64 } VBOXDISPWORKER;65 66 HRESULT VBoxDispWorkerCreate(VBOXDISPWORKER *pWorker);67 HRESULT VBoxDispWorkerDestroy(VBOXDISPWORKER *pWorker);68 69 typedef DECLCALLBACK(void) FNVBOXDISPWORKERCB(void *pvUser);70 typedef FNVBOXDISPWORKERCB *PFNVBOXDISPWORKERCB;71 72 HRESULT VBoxDispWorkerSubmitProc(VBOXDISPWORKER *pWorker, PFNVBOXDISPWORKERCB pfnCb, void *pvCb);73 74 typedef struct VBOXWDDMDISP_ADAPTER *PVBOXWDDMDISP_ADAPTER;75 76 HRESULT VBoxDispWndDestroy(PVBOXWDDMDISP_ADAPTER pAdapter, HWND hWnd);77 HRESULT VBoxDispWndCreate(PVBOXWDDMDISP_ADAPTER pAdapter, DWORD width, DWORD height, HWND *phWnd);78 79 55 #endif /* ifndef ___VBoxDispD3DIf_h___ */ -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d9/device.c
r35650 r38363 281 281 282 282 IWineD3DDevice_Uninit3D(This->WineD3DDevice, D3D9CB_DestroySwapChain); 283 #ifndef VBOX_WITH_WDDM 283 284 IWineD3DDevice_ReleaseFocusWindow(This->WineD3DDevice); 285 #endif 284 286 IWineD3DDevice_Release(This->WineD3DDevice); 285 287 wined3d_mutex_unlock(); … … 3044 3046 } 3045 3047 3048 #ifndef VBOX_WITH_WDDM 3046 3049 if (!parameters->Windowed) 3047 3050 { … … 3055 3058 } 3056 3059 } 3060 #endif 3057 3061 3058 3062 if (flags & D3DCREATE_ADAPTERGROUP_DEVICE) … … 3099 3103 { 3100 3104 WARN("Failed to initialize 3D, hr %#x.\n", hr); 3105 #ifndef VBOX_WITH_WDDM 3101 3106 IWineD3DDevice_ReleaseFocusWindow(device->WineD3DDevice); 3107 #endif 3102 3108 HeapFree(GetProcessHeap(), 0, wined3d_parameters); 3103 3109 IWineD3DDevice_Release(device->WineD3DDevice); … … 3136 3142 wined3d_mutex_lock(); 3137 3143 IWineD3DDevice_Uninit3D(device->WineD3DDevice, D3D9CB_DestroySwapChain); 3144 #ifndef VBOX_WITH_WDDM 3138 3145 IWineD3DDevice_ReleaseFocusWindow(device->WineD3DDevice); 3146 #endif 3139 3147 IWineD3DDevice_Release(device->WineD3DDevice); 3140 3148 wined3d_mutex_unlock(); -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/device.c
r37873 r38363 1548 1548 static HRESULT WINAPI IWineD3DDeviceImpl_AcquireFocusWindow(IWineD3DDevice *iface, HWND window) 1549 1549 { 1550 #ifndef VBOX_WITH_WDDM 1550 1551 IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)iface; 1551 1552 … … 1558 1559 device->focus_window = window; 1559 1560 SetForegroundWindow(window); 1560 1561 #else 1562 ERR("should not be here"); 1563 #endif 1561 1564 return WINED3D_OK; 1562 1565 } … … 1564 1567 static void WINAPI IWineD3DDeviceImpl_ReleaseFocusWindow(IWineD3DDevice *iface) 1565 1568 { 1569 #ifndef VBOX_WITH_WDDM 1566 1570 IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)iface; 1567 1571 1568 1572 if (device->focus_window) wined3d_unregister_window(device->focus_window); 1569 1573 device->focus_window = NULL; 1574 #else 1575 ERR("should not be here"); 1576 #endif 1570 1577 } 1571 1578 … … 7262 7269 } 7263 7270 7271 #ifndef VBOX_WITH_WDDM 7264 7272 LRESULT device_process_message(IWineD3DDeviceImpl *device, HWND window, 7265 7273 UINT message, WPARAM wparam, LPARAM lparam, WNDPROC proc) … … 7283 7291 return CallWindowProcW(proc, window, message, wparam, lparam); 7284 7292 } 7293 #endif -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/swapchain.c
r38331 r38363 89 89 } 90 90 #else 91 IWineD3DDevice_RemoveSwapChain( This->device,This);91 IWineD3DDevice_RemoveSwapChain((IWineD3DDevice*)This->device, (IWineD3DSwapChain*)This); 92 92 if (!This->device->NumberOfSwapChains) 93 93 #endif … … 109 109 if(This->device_window) { 110 110 /* see VBoxExtGet/ReleaseDC for comments */ 111 VBoxExtReleaseDC(This->device_window, This->hDC); 111 VBoxExtWndDestroy(This->device_window, This->hDC); 112 } 113 else 114 { 115 ERR("null device window"); 112 116 } 113 117 #else … … 692 696 WINED3DDISPLAYMODE mode; 693 697 RECT client_rect; 694 HWND window; 698 HWND window = NULL; 699 #ifdef VBOX_WITH_WDDM 700 HDC hDC = NULL; 701 #endif 695 702 HRESULT hr; 696 703 UINT i; … … 724 731 } 725 732 733 #ifdef VBOX_WITH_WDDM 734 if (present_parameters->hDeviceWindow) 735 { 736 ERR("non-null device window"); 737 return E_FAIL; 738 } 739 hr = VBoxExtWndCreate(present_parameters->BackBufferWidth, present_parameters->BackBufferHeight, &window, &hDC); 740 if (FAILED(hr)) 741 { 742 ERR("VBoxExtWndCreate failed, hr 0x%x", hr); 743 return hr; 744 } 745 Assert(window); 746 Assert(hDC); 747 present_parameters->hDeviceWindow = window; 748 #else 726 749 window = present_parameters->hDeviceWindow ? present_parameters->hDeviceWindow : device->createParms.hFocusWindow; 750 #endif 727 751 728 752 swapchain->device = device; … … 733 757 #ifdef VBOX_WITH_WDDM 734 758 Assert(window); 735 /* see VBoxExtGet/ReleaseDC for comments */ 736 swapchain->hDC = VBoxExtGetDC(window); 737 if (!swapchain->hDC) 738 { 739 DWORD winEr = GetLastError(); 740 WARN("Failed to get a window DC, winEr %d.\n", winEr); 741 Assert(0); 742 goto err; 743 } 759 swapchain->hDC = hDC; 744 760 #endif 745 761 … … 848 864 if (surface_type == SURFACE_OPENGL) 849 865 { 866 #ifdef VBOX_WITH_WDDM 850 867 struct wined3d_context * swapchainContext; 868 #endif 851 869 const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; 852 870 … … 999 1017 if (swapchain->frontBuffer) IWineD3DSurface_Release(swapchain->frontBuffer); 1000 1018 1019 #ifdef VBOX_WITH_WDDM 1020 if (swapchain->device_window) 1021 { 1022 VBoxExtWndDestroy(swapchain->device_window, swapchain->hDC); 1023 } 1024 #endif 1025 1001 1026 return hr; 1002 1027 } -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/vboxext.c
r38331 r38363 26 26 27 27 /*******************************/ 28 #if defined(VBOX_WDDM_WOW64) 29 # define VBOXEXT_WINE_MODULE_NAME "wined3dwddm-x86.dll" 30 #else 31 # define VBOXEXT_WINE_MODULE_NAME "wined3dwddm.dll" 32 #endif 28 33 29 34 typedef struct VBOXEXT_WORKER … … 35 40 HANDLE hThread; 36 41 DWORD idThread; 42 /* wine does not seem to guarantie the dll is not unloaded in case FreeLibrary is used 43 * while d3d object is not terminated, keep an extra reference to ensure we're not unloaded 44 * while we are active */ 45 HMODULE hSelf; 37 46 } VBOXEXT_WORKER, *PVBOXEXT_WORKER; 38 47 … … 45 54 46 55 /*******************************/ 47 48 56 typedef struct VBOXEXT_GLOBAL 49 57 { … … 107 115 HRESULT VBoxExtWorkerCreate(PVBOXEXT_WORKER pWorker) 108 116 { 117 if(!GetModuleHandleEx(0, VBOXEXT_WINE_MODULE_NAME, &pWorker->hSelf)) 118 { 119 DWORD dwEr = GetLastError(); 120 ERR("GetModuleHandleEx failed, %d", dwEr); 121 return E_FAIL; 122 } 123 109 124 InitializeCriticalSection(&pWorker->CritSect); 110 125 pWorker->hEvent = CreateEvent(NULL, /* LPSECURITY_ATTRIBUTES lpEventAttributes */ … … 143 158 } 144 159 160 FreeLibrary(pWorker->hSelf); 161 145 162 return E_FAIL; 146 163 } … … 166 183 CloseHandle(pWorker->hEvent); 167 184 DeleteCriticalSection(&pWorker->CritSect); 185 186 FreeLibrary(pWorker->hSelf); 168 187 169 188 return S_OK; … … 284 303 pData->ret = ReleaseDC(pData->hWnd, pData->hDC); 285 304 } 286 305 #if 0 287 306 HDC VBoxExtGetDC(HWND hWnd) 288 307 { … … 327 346 #endif 328 347 } 348 #endif 329 349 330 350 /* window creation API */ … … 353 373 #define VBOXEXTWND_NAME "VboxDispD3DWineWnd" 354 374 355 HRESULT vboxExtWndDoCreate(DWORD w, DWORD h, HWND *phWnd )375 HRESULT vboxExtWndDoCreate(DWORD w, DWORD h, HWND *phWnd, HDC *phDC) 356 376 { 357 377 HRESULT hr = S_OK; … … 394 414 { 395 415 *phWnd = hWnd; 416 *phDC = GetDC(hWnd); 396 417 } 397 418 else … … 406 427 } 407 428 408 static HRESULT vboxExtWndDoDestroy(HWND hWnd )409 { 410 BOOL bResult = DestroyWindow(hWnd);429 static HRESULT vboxExtWndDoDestroy(HWND hWnd, HDC hDC) 430 { 431 BOOL bResult; 411 432 DWORD winErr; 433 ReleaseDC(hWnd, hDC); 434 bResult = DestroyWindow(hWnd); 412 435 Assert(bResult); 413 436 if (bResult) … … 424 447 int hr; 425 448 HWND hWnd; 449 HDC hDC; 426 450 DWORD width; 427 451 DWORD height; … … 432 456 int hr; 433 457 HWND hWnd; 458 HDC hDC; 434 459 } VBOXEXTWND_DESTROY_INFO; 435 460 … … 437 462 { 438 463 VBOXEXTWND_DESTROY_INFO *pInfo = (VBOXEXTWND_DESTROY_INFO*)pvUser; 439 pInfo->hr = vboxExtWndDoDestroy(pInfo->hWnd );464 pInfo->hr = vboxExtWndDoDestroy(pInfo->hWnd, pInfo->hDC); 440 465 Assert(pInfo->hr == S_OK); 441 466 } … … 444 469 { 445 470 VBOXEXTWND_CREATE_INFO *pInfo = (VBOXEXTWND_CREATE_INFO*)pvUser; 446 pInfo->hr = vboxExtWndDoCreate(pInfo->width, pInfo->height, &pInfo->hWnd );471 pInfo->hr = vboxExtWndDoCreate(pInfo->width, pInfo->height, &pInfo->hWnd, &pInfo->hDC); 447 472 Assert(pInfo->hr == S_OK); 448 473 } 449 474 450 HRESULT VBoxExtWndDestroy(HWND hWnd )475 HRESULT VBoxExtWndDestroy(HWND hWnd, HDC hDC) 451 476 { 452 477 HRESULT hr; … … 454 479 Info.hr = E_FAIL; 455 480 Info.hWnd = hWnd; 481 Info.hDC = hDC; 456 482 hr = VBoxExtDwSubmitProc(vboxExtWndDestroyWorker, &Info); 457 483 Assert(hr == S_OK); … … 464 490 } 465 491 466 HRESULT VBoxExtWndCreate(DWORD width, DWORD height, HWND *phWnd )492 HRESULT VBoxExtWndCreate(DWORD width, DWORD height, HWND *phWnd, HDC *phDC) 467 493 { 468 494 HRESULT hr; … … 477 503 Assert(Info.hr == S_OK); 478 504 if (Info.hr == S_OK) 505 { 479 506 *phWnd = Info.hWnd; 507 *phDC = Info.hDC; 508 } 480 509 return Info.hr; 481 510 } -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/vboxext.h
r38331 r38363 23 23 HRESULT VBoxExtCheckInit(); 24 24 HRESULT VBoxExtCheckTerm(); 25 #if 0 25 26 /* Windows destroys HDC created by a given thread when the thread is terminated 26 27 * this leads to a mess-up in Wine & Chromium code in some situations, e.g. … … 29 30 HDC VBoxExtGetDC(HWND hWnd); 30 31 int VBoxExtReleaseDC(HWND hWnd, HDC hDC); 32 #endif 31 33 32 34 /* API for creating & destroying windows */ 33 HRESULT VBoxExtWndDestroy(HWND hWnd );34 HRESULT VBoxExtWndCreate(DWORD width, DWORD height, HWND *phWnd );35 HRESULT VBoxExtWndDestroy(HWND hWnd, HDC hDC); 36 HRESULT VBoxExtWndCreate(DWORD width, DWORD height, HWND *phWnd, HDC *phDC); 35 37 36 38 #endif /* #ifndef ___VBOXEXT_H__*/ -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/wined3d_main.c
r38112 r38363 403 403 } 404 404 405 #ifndef VBOX_WITH_WDDM 405 406 static struct wined3d_wndproc *wined3d_find_wndproc(HWND window) 406 407 { … … 500 501 ERR("Window %p is not registered with wined3d.\n", window); 501 502 } 502 503 #endif 503 504 /* At process attach */ 504 505 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv) -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/wined3d_private.h
r38331 r38363 1639 1639 1640 1640 HRESULT wined3d_init(IWineD3DImpl *wined3d, UINT version, IUnknown *parent) DECLSPEC_HIDDEN; 1641 #ifndef VBOX_WITH_WDDM 1641 1642 BOOL wined3d_register_window(HWND window, struct IWineD3DDeviceImpl *device) DECLSPEC_HIDDEN; 1642 1643 void wined3d_unregister_window(HWND window) DECLSPEC_HIDDEN; 1644 #endif 1643 1645 1644 1646 /***************************************************************************** … … 1715 1717 WINED3DDEVICE_CREATION_PARAMETERS createParms; 1716 1718 WINED3DDEVTYPE devType; 1719 #ifndef VBOX_WITH_WDDM 1717 1720 HWND focus_window; 1721 #endif 1718 1722 1719 1723 IWineD3DSwapChain **swapchains; … … 1790 1794 IUnknown *parent, IWineD3DDeviceParent *device_parent) DECLSPEC_HIDDEN; 1791 1795 void device_preload_textures(IWineD3DDeviceImpl *device) DECLSPEC_HIDDEN; 1796 #ifndef VBOX_WITH_WDDM 1792 1797 LRESULT device_process_message(IWineD3DDeviceImpl *device, HWND window, 1793 1798 UINT message, WPARAM wparam, LPARAM lparam, WNDPROC proc) DECLSPEC_HIDDEN; 1799 #endif 1794 1800 void device_resource_add(IWineD3DDeviceImpl *This, IWineD3DResource *resource) DECLSPEC_HIDDEN; 1795 1801 void device_resource_released(IWineD3DDeviceImpl *This, IWineD3DResource *resource) DECLSPEC_HIDDEN;
Note:
See TracChangeset
for help on using the changeset viewer.