VirtualBox

Ignore:
Timestamp:
Aug 8, 2011 7:01:30 PM (13 years ago)
Author:
vboxsync
Message:

wddm/3d: make wine handle gl window create/destroy

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  
    17671767        pSwapchain->pSwapChainIf->Release();
    17681768        Assert(pSwapchain->hWnd);
    1769         HRESULT hr = VBoxDispWndDestroy(pDevice->pAdapter, pSwapchain->hWnd);
    1770         Assert(hr == S_OK);
    17711769        pSwapchain->pSwapChainIf = NULL;
    17721770        pSwapchain->hWnd = NULL;
    1773         return hr;
     1771        return S_OK;
    17741772    }
    17751773
     
    22972295    {
    22982296//#define VBOXDISP_NEWWND_ON_SWAPCHAINUPDATE
    2299 #ifndef VBOXDISP_NEWWND_ON_SWAPCHAINUPDATE
    2300         if (!hOldWnd)
    2301 #endif
    2302         {
    2303             hr = VBoxDispWndCreate(pAdapter, Params.BackBufferWidth, Params.BackBufferHeight, &pSwapchain->hWnd);
    2304             Assert(hr == S_OK);
    2305         }
    23062297        if (hr == S_OK)
    23072298        {
    23082299            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;
    23132304                        /* @todo: it seems there should be a way to detect this correctly since
    23142305                         * our vboxWddmDDevSetDisplayMode will be called in case we are using full-screen */
     
    23212312            if (!pDevice->pDevice9If)
    23222313            {
    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);
    23242315                Assert(hr == S_OK);
    23252316                if (hr == S_OK)
    23262317                {
     2318                    Assert(Params.hDeviceWindow);
     2319                    pSwapchain->hWnd = Params.hDeviceWindow;
    23272320                    pDevice->pDevice9If = pDevice9If;
    23282321                    hr = pDevice9If->GetSwapChain(0, &pNewIf);
     
    24102403                if (hr == S_OK)
    24112404                {
     2405                    Assert(Params.hDeviceWindow);
     2406                    pSwapchain->hWnd = Params.hDeviceWindow;
    24122407                    Assert(pNewIf);
    24132408                }
     
    24962491                        Assert(hOldWnd);
    24972492                        pOldIf->Release();
    2498                         if (hOldWnd != pSwapchain->hWnd)
    2499                         {
    2500                             VBoxDispWndDestroy(pAdapter, hOldWnd);
    2501                         }
    25022493                    }
    25032494                    else
     
    25132504
    25142505        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;
    25212507    }
    25222508
     
    53265312    if (VBOXDISPMODE_IS_3D(pAdapter))
    53275313    {
    5328 //        if (pRc->RcDesc.fFlags.RenderTarget)
    5329 //        {
    5330 //            Assert(pDevice->hWnd);
    5331 //            Assert(pDevice->pDevice9If);
    5332 //        }
    5333 
    53345314        for (UINT i = 0; i < pRc->cAllocations; ++i)
    53355315        {
     
    54985478        }
    54995479#endif
    5500 #if 1
    55015480        PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)pData->hSrcResource;
    55025481        Assert(pRc);
     
    55055484        hr = vboxWddmSwapchainPresent(pDevice, pAlloc);
    55065485        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    {
    55805489        D3DDDICB_PRESENT DdiPresent = {0};
    55815490        if (pData->hSrcResource)
     
    55965505        }
    55975506        DdiPresent.hContext = pDevice->DefaultContext.ContextInfo.hContext;
    5598 //        DdiPresent.BroadcastContextCount;
    5599 //        DdiPresent.BroadcastContext[D3DDDI_MAX_BROADCAST_CONTEXT];
    56005507
    56015508        hr = pDevice->RtCallbacks.pfnPresentCb(pDevice->hDevice, &DdiPresent);
     
    72157122    {
    72167123        VBOXDISPCRHGSMI_SCOPE_SET_GLOBAL();
    7217         HRESULT hr = VBoxDispWorkerDestroy(&pAdapter->WndWorker);
    7218         Assert(hr == S_OK);
    72197124        pAdapter->pD3D9If->Release();
    72207125        VBoxDispD3DClose(&pAdapter->D3D);
     
    73297234                                Assert(pAdapter->cMaxSimRTs);
    73307235                                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;
    73387238                            }
    73397239                            pAdapter->pD3D9If->Release();
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispD3D.h

    r38112 r38363  
    5656    UINT uRtVersion;
    5757    VBOXDISPD3D D3D;
    58     VBOXDISPWORKER WndWorker;
    5958    IDirect3D9Ex * pD3D9If;
    6059    D3DDDI_ADAPTERCALLBACKS RtCallbacks;
     
    148147#endif
    149148    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 */
    150153    HWND hWnd;
    151154    VBOXDISP_KMHANDLE hSwapchainKm;
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispD3DIf.cpp

    r38112 r38363  
    8181    return E_FAIL;
    8282}
    83 
    84 #define WM_VBOXDISP_CALLPROC (WM_APP+1)
    85 
    86 typedef struct VBOXDISP_CALLPROC
    87 {
    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     do
    105     {
    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->hEvent
    139      * 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         else
    152             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             else
    197             {
    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         else
    231             rc = VERR_GENERAL_FAILURE;
    232     }
    233     else
    234         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 lParam
    243 )
    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         else
    306         {
    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_INFO
    330 {
    331     int hr;
    332     HWND hWnd;
    333     DWORD width;
    334     DWORD height;
    335 } VBOXDISPWND_CREATE_INFO;
    336 
    337 typedef struct VBOXDISPWND_DESTROY_INFO
    338 {
    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  
    5353void VBoxDispD3DClose(VBOXDISPD3D *pD3D);
    5454
    55 
    56 typedef struct VBOXDISPWORKER
    57 {
    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 
    7955#endif /* ifndef ___VBoxDispD3DIf_h___ */
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d9/device.c

    r35650 r38363  
    281281
    282282      IWineD3DDevice_Uninit3D(This->WineD3DDevice, D3D9CB_DestroySwapChain);
     283#ifndef VBOX_WITH_WDDM
    283284      IWineD3DDevice_ReleaseFocusWindow(This->WineD3DDevice);
     285#endif
    284286      IWineD3DDevice_Release(This->WineD3DDevice);
    285287      wined3d_mutex_unlock();
     
    30443046    }
    30453047
     3048#ifndef VBOX_WITH_WDDM
    30463049    if (!parameters->Windowed)
    30473050    {
     
    30553058        }
    30563059    }
     3060#endif
    30573061
    30583062    if (flags & D3DCREATE_ADAPTERGROUP_DEVICE)
     
    30993103    {
    31003104        WARN("Failed to initialize 3D, hr %#x.\n", hr);
     3105#ifndef VBOX_WITH_WDDM
    31013106        IWineD3DDevice_ReleaseFocusWindow(device->WineD3DDevice);
     3107#endif
    31023108        HeapFree(GetProcessHeap(), 0, wined3d_parameters);
    31033109        IWineD3DDevice_Release(device->WineD3DDevice);
     
    31363142        wined3d_mutex_lock();
    31373143        IWineD3DDevice_Uninit3D(device->WineD3DDevice, D3D9CB_DestroySwapChain);
     3144#ifndef VBOX_WITH_WDDM
    31383145        IWineD3DDevice_ReleaseFocusWindow(device->WineD3DDevice);
     3146#endif
    31393147        IWineD3DDevice_Release(device->WineD3DDevice);
    31403148        wined3d_mutex_unlock();
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/device.c

    r37873 r38363  
    15481548static HRESULT WINAPI IWineD3DDeviceImpl_AcquireFocusWindow(IWineD3DDevice *iface, HWND window)
    15491549{
     1550#ifndef VBOX_WITH_WDDM
    15501551    IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)iface;
    15511552
     
    15581559    device->focus_window = window;
    15591560    SetForegroundWindow(window);
    1560 
     1561#else
     1562    ERR("should not be here");
     1563#endif
    15611564    return WINED3D_OK;
    15621565}
     
    15641567static void WINAPI IWineD3DDeviceImpl_ReleaseFocusWindow(IWineD3DDevice *iface)
    15651568{
     1569#ifndef VBOX_WITH_WDDM
    15661570    IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)iface;
    15671571
    15681572    if (device->focus_window) wined3d_unregister_window(device->focus_window);
    15691573    device->focus_window = NULL;
     1574#else
     1575    ERR("should not be here");
     1576#endif
    15701577}
    15711578
     
    72627269}
    72637270
     7271#ifndef VBOX_WITH_WDDM
    72647272LRESULT device_process_message(IWineD3DDeviceImpl *device, HWND window,
    72657273        UINT message, WPARAM wparam, LPARAM lparam, WNDPROC proc)
     
    72837291    return CallWindowProcW(proc, window, message, wparam, lparam);
    72847292}
     7293#endif
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/swapchain.c

    r38331 r38363  
    8989    }
    9090#else
    91     IWineD3DDevice_RemoveSwapChain(This->device, This);
     91    IWineD3DDevice_RemoveSwapChain((IWineD3DDevice*)This->device, (IWineD3DSwapChain*)This);
    9292    if (!This->device->NumberOfSwapChains)
    9393#endif
     
    109109    if(This->device_window) {
    110110        /* 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");
    112116    }
    113117#else
     
    692696    WINED3DDISPLAYMODE mode;
    693697    RECT client_rect;
    694     HWND window;
     698    HWND window = NULL;
     699#ifdef VBOX_WITH_WDDM
     700    HDC hDC = NULL;
     701#endif
    695702    HRESULT hr;
    696703    UINT i;
     
    724731    }
    725732
     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
    726749    window = present_parameters->hDeviceWindow ? present_parameters->hDeviceWindow : device->createParms.hFocusWindow;
     750#endif
    727751
    728752    swapchain->device = device;
     
    733757#ifdef VBOX_WITH_WDDM
    734758    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;
    744760#endif
    745761
     
    848864    if (surface_type == SURFACE_OPENGL)
    849865    {
     866#ifdef VBOX_WITH_WDDM
    850867        struct wined3d_context * swapchainContext;
     868#endif
    851869        const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
    852870
     
    9991017    if (swapchain->frontBuffer) IWineD3DSurface_Release(swapchain->frontBuffer);
    10001018
     1019#ifdef VBOX_WITH_WDDM
     1020    if (swapchain->device_window)
     1021    {
     1022        VBoxExtWndDestroy(swapchain->device_window, swapchain->hDC);
     1023    }
     1024#endif
     1025
    10011026    return hr;
    10021027}
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/vboxext.c

    r38331 r38363  
    2626
    2727/*******************************/
     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
    2833
    2934typedef struct VBOXEXT_WORKER
     
    3540    HANDLE hThread;
    3641    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;
    3746} VBOXEXT_WORKER, *PVBOXEXT_WORKER;
    3847
     
    4554
    4655/*******************************/
    47 
    4856typedef struct VBOXEXT_GLOBAL
    4957{
     
    107115HRESULT VBoxExtWorkerCreate(PVBOXEXT_WORKER pWorker)
    108116{
     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
    109124    InitializeCriticalSection(&pWorker->CritSect);
    110125    pWorker->hEvent = CreateEvent(NULL, /* LPSECURITY_ATTRIBUTES lpEventAttributes */
     
    143158    }
    144159
     160    FreeLibrary(pWorker->hSelf);
     161
    145162    return E_FAIL;
    146163}
     
    166183    CloseHandle(pWorker->hEvent);
    167184    DeleteCriticalSection(&pWorker->CritSect);
     185
     186    FreeLibrary(pWorker->hSelf);
    168187
    169188    return S_OK;
     
    284303    pData->ret = ReleaseDC(pData->hWnd, pData->hDC);
    285304}
    286 
     305#if 0
    287306HDC VBoxExtGetDC(HWND hWnd)
    288307{
     
    327346#endif
    328347}
     348#endif
    329349
    330350/* window creation API */
     
    353373#define VBOXEXTWND_NAME "VboxDispD3DWineWnd"
    354374
    355 HRESULT vboxExtWndDoCreate(DWORD w, DWORD h, HWND *phWnd)
     375HRESULT vboxExtWndDoCreate(DWORD w, DWORD h, HWND *phWnd, HDC *phDC)
    356376{
    357377    HRESULT hr = S_OK;
     
    394414        {
    395415            *phWnd = hWnd;
     416            *phDC = GetDC(hWnd);
    396417        }
    397418        else
     
    406427}
    407428
    408 static HRESULT vboxExtWndDoDestroy(HWND hWnd)
    409 {
    410     BOOL bResult = DestroyWindow(hWnd);
     429static HRESULT vboxExtWndDoDestroy(HWND hWnd, HDC hDC)
     430{
     431    BOOL bResult;
    411432    DWORD winErr;
     433    ReleaseDC(hWnd, hDC);
     434    bResult = DestroyWindow(hWnd);
    412435    Assert(bResult);
    413436    if (bResult)
     
    424447    int hr;
    425448    HWND hWnd;
     449    HDC hDC;
    426450    DWORD width;
    427451    DWORD height;
     
    432456    int hr;
    433457    HWND hWnd;
     458    HDC hDC;
    434459} VBOXEXTWND_DESTROY_INFO;
    435460
     
    437462{
    438463    VBOXEXTWND_DESTROY_INFO *pInfo = (VBOXEXTWND_DESTROY_INFO*)pvUser;
    439     pInfo->hr = vboxExtWndDoDestroy(pInfo->hWnd);
     464    pInfo->hr = vboxExtWndDoDestroy(pInfo->hWnd, pInfo->hDC);
    440465    Assert(pInfo->hr == S_OK);
    441466}
     
    444469{
    445470    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);
    447472    Assert(pInfo->hr == S_OK);
    448473}
    449474
    450 HRESULT VBoxExtWndDestroy(HWND hWnd)
     475HRESULT VBoxExtWndDestroy(HWND hWnd, HDC hDC)
    451476{
    452477    HRESULT hr;
     
    454479    Info.hr = E_FAIL;
    455480    Info.hWnd = hWnd;
     481    Info.hDC = hDC;
    456482    hr = VBoxExtDwSubmitProc(vboxExtWndDestroyWorker, &Info);
    457483    Assert(hr == S_OK);
     
    464490}
    465491
    466 HRESULT VBoxExtWndCreate(DWORD width, DWORD height, HWND *phWnd)
     492HRESULT VBoxExtWndCreate(DWORD width, DWORD height, HWND *phWnd, HDC *phDC)
    467493{
    468494    HRESULT hr;
     
    477503        Assert(Info.hr == S_OK);
    478504        if (Info.hr == S_OK)
     505        {
    479506            *phWnd = Info.hWnd;
     507            *phDC = Info.hDC;
     508        }
    480509        return Info.hr;
    481510    }
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/vboxext.h

    r38331 r38363  
    2323HRESULT VBoxExtCheckInit();
    2424HRESULT VBoxExtCheckTerm();
     25#if 0
    2526/* Windows destroys HDC created by a given thread when the thread is terminated
    2627 * this leads to a mess-up in Wine & Chromium code in some situations, e.g.
     
    2930HDC VBoxExtGetDC(HWND hWnd);
    3031int VBoxExtReleaseDC(HWND hWnd, HDC hDC);
     32#endif
    3133
    3234/* API for creating & destroying windows */
    33 HRESULT VBoxExtWndDestroy(HWND hWnd);
    34 HRESULT VBoxExtWndCreate(DWORD width, DWORD height, HWND *phWnd);
     35HRESULT VBoxExtWndDestroy(HWND hWnd, HDC hDC);
     36HRESULT VBoxExtWndCreate(DWORD width, DWORD height, HWND *phWnd, HDC *phDC);
    3537
    3638#endif /* #ifndef ___VBOXEXT_H__*/
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/wined3d_main.c

    r38112 r38363  
    403403}
    404404
     405#ifndef VBOX_WITH_WDDM
    405406static struct wined3d_wndproc *wined3d_find_wndproc(HWND window)
    406407{
     
    500501    ERR("Window %p is not registered with wined3d.\n", window);
    501502}
    502 
     503#endif
    503504/* At process attach */
    504505BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/wined3d_private.h

    r38331 r38363  
    16391639
    16401640HRESULT wined3d_init(IWineD3DImpl *wined3d, UINT version, IUnknown *parent) DECLSPEC_HIDDEN;
     1641#ifndef VBOX_WITH_WDDM
    16411642BOOL wined3d_register_window(HWND window, struct IWineD3DDeviceImpl *device) DECLSPEC_HIDDEN;
    16421643void wined3d_unregister_window(HWND window) DECLSPEC_HIDDEN;
     1644#endif
    16431645
    16441646/*****************************************************************************
     
    17151717    WINED3DDEVICE_CREATION_PARAMETERS createParms;
    17161718    WINED3DDEVTYPE                  devType;
     1719#ifndef VBOX_WITH_WDDM
    17171720    HWND focus_window;
     1721#endif
    17181722
    17191723    IWineD3DSwapChain     **swapchains;
     
    17901794        IUnknown *parent, IWineD3DDeviceParent *device_parent) DECLSPEC_HIDDEN;
    17911795void device_preload_textures(IWineD3DDeviceImpl *device) DECLSPEC_HIDDEN;
     1796#ifndef VBOX_WITH_WDDM
    17921797LRESULT device_process_message(IWineD3DDeviceImpl *device, HWND window,
    17931798        UINT message, WPARAM wparam, LPARAM lparam, WNDPROC proc) DECLSPEC_HIDDEN;
     1799#endif
    17941800void device_resource_add(IWineD3DDeviceImpl *This, IWineD3DResource *resource) DECLSPEC_HIDDEN;
    17951801void device_resource_released(IWineD3DDeviceImpl *This, IWineD3DResource *resource) DECLSPEC_HIDDEN;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette