VirtualBox

Ignore:
Timestamp:
Dec 14, 2011 11:12:17 AM (13 years ago)
Author:
vboxsync
Message:

wine/XPDM: 1. Additional swapchain creation fixes 2. De-libwine'ize wined3d 3. Single context per swapchain 4. wine & crOgl current context sync fixes 5. Proper Get/ReleaseDC handling

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/vboxext.c

    r39257 r39602  
    1515 */
    1616#include "config.h"
     17#include "wine/port.h"
    1718#include "wined3d_private.h"
    1819#include "vboxext.h"
     
    2324typedef FNVBOXEXTWORKERCB *PFNVBOXEXTWORKERCB;
    2425
    25 HRESULT VBoxExtDwSubmitProc(PFNVBOXEXTWORKERCB pfnCb, void *pvCb);
     26HRESULT VBoxExtDwSubmitProcSync(PFNVBOXEXTWORKERCB pfnCb, void *pvCb);
     27HRESULT VBoxExtDwSubmitProcAsync(PFNVBOXEXTWORKERCB pfnCb, void *pvCb);
    2628
    2729/*******************************/
    28 #if defined(VBOX_WDDM_WOW64)
     30#ifdef VBOX_WITH_WDDM
     31# if defined(VBOX_WDDM_WOW64)
    2932# define VBOXEXT_WINE_MODULE_NAME "wined3dwddm-x86.dll"
     33# else
     34# define VBOXEXT_WINE_MODULE_NAME "wined3dwddm.dll"
     35# endif
    3036#else
    31 # define VBOXEXT_WINE_MODULE_NAME "wined3dwddm.dll"
     37/* both 32bit and 64bit versions of xpdm wine libs are named identically */
     38# define VBOXEXT_WINE_MODULE_NAME "wined3d.dll"
    3239#endif
    3340
     
    6168static VBOXEXT_GLOBAL g_VBoxExtGlobal;
    6269
    63 #define WM_VBOXEXT_CALLPROC (WM_APP+1)
     70#define WM_VBOXEXT_CALLPROC  (WM_APP+1)
     71#define WM_VBOXEXT_INIT_QUIT (WM_APP+2)
    6472
    6573typedef struct VBOXEXT_CALLPROC
     
    103111                pData->pfnCb(pData->pvCb);
    104112                SetEvent(pWorker->hEvent);
     113                break;
     114            }
     115            case WM_VBOXEXT_INIT_QUIT:
     116            case WM_CLOSE:
     117            {
     118                PostQuitMessage(0);
    105119                break;
    106120            }
     
    165179HRESULT VBoxExtWorkerDestroy(PVBOXEXT_WORKER pWorker)
    166180{
    167     BOOL bResult = PostThreadMessage(pWorker->idThread, WM_QUIT, 0, 0);
     181    BOOL bResult = PostThreadMessage(pWorker->idThread, WM_VBOXEXT_INIT_QUIT, 0, 0);
    168182    DWORD dwErr;
    169183    if (!bResult)
     
    191205}
    192206
    193 static HRESULT vboxExtWorkerSubmit(VBOXEXT_WORKER *pWorker, UINT Msg, LPARAM lParam)
     207static HRESULT vboxExtWorkerSubmit(VBOXEXT_WORKER *pWorker, UINT Msg, LPARAM lParam, BOOL fSync)
    194208{
    195209    HRESULT hr = E_FAIL;
     
    201215    if (bResult)
    202216    {
    203         DWORD dwErr = WaitForSingleObject(pWorker->hEvent, INFINITE);
    204         if (dwErr == WAIT_OBJECT_0)
    205         {
     217        if (fSync)
     218        {
     219            DWORD dwErr = WaitForSingleObject(pWorker->hEvent, INFINITE);
     220            if (dwErr == WAIT_OBJECT_0)
     221            {
     222                hr = S_OK;
     223            }
     224            else
     225            {
     226                ERR("WaitForSingleObject returned (%d)", dwErr);
     227            }
     228        }
     229        else
    206230            hr = S_OK;
    207         }
    208         else
    209         {
    210             ERR("WaitForSingleObject returned (%d)", dwErr);
    211         }
    212231    }
    213232    else
     
    221240}
    222241
    223 HRESULT VBoxExtWorkerSubmitProc(PVBOXEXT_WORKER pWorker, PFNVBOXEXTWORKERCB pfnCb, void *pvCb)
     242HRESULT VBoxExtWorkerSubmitProcSync(PVBOXEXT_WORKER pWorker, PFNVBOXEXTWORKERCB pfnCb, void *pvCb)
    224243{
    225244    VBOXEXT_CALLPROC Ctx;
    226245    Ctx.pfnCb = pfnCb;
    227246    Ctx.pvCb = pvCb;
    228     return vboxExtWorkerSubmit(pWorker, WM_VBOXEXT_CALLPROC, (LPARAM)&Ctx);
    229 }
     247    return vboxExtWorkerSubmit(pWorker, WM_VBOXEXT_CALLPROC, (LPARAM)&Ctx, TRUE);
     248}
     249
     250static DECLCALLBACK(void) vboxExtWorkerSubmitProcAsyncWorker(void *pvUser)
     251{
     252    PVBOXEXT_CALLPROC pCallInfo = (PVBOXEXT_CALLPROC)pvUser;
     253    pCallInfo[1].pfnCb(pCallInfo[1].pvCb);
     254    HeapFree(GetProcessHeap(), 0, pCallInfo);
     255}
     256
     257HRESULT VBoxExtWorkerSubmitProcAsync(PVBOXEXT_WORKER pWorker, PFNVBOXEXTWORKERCB pfnCb, void *pvCb)
     258{
     259    HRESULT hr;
     260    PVBOXEXT_CALLPROC pCallInfo = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof (VBOXEXT_CALLPROC) * 2);
     261    if (!pCallInfo)
     262    {
     263        ERR("HeapAlloc failed\n");
     264        return E_OUTOFMEMORY;
     265    }
     266    pCallInfo[0].pfnCb = vboxExtWorkerSubmitProcAsyncWorker;
     267    pCallInfo[0].pvCb = pCallInfo;
     268    pCallInfo[1].pfnCb = pfnCb;
     269    pCallInfo[1].pvCb = pvCb;
     270    hr = vboxExtWorkerSubmit(pWorker, WM_VBOXEXT_CALLPROC, (LPARAM)pCallInfo, FALSE);
     271    if (FAILED(hr))
     272    {
     273        ERR("vboxExtWorkerSubmit failed, hr 0x%x\n", hr);
     274        HeapFree(GetProcessHeap(), 0, pCallInfo);
     275        return hr;
     276    }
     277    return S_OK;
     278}
     279
    230280
    231281static HRESULT vboxExtInit()
     
    295345}
    296346
    297 HRESULT VBoxExtDwSubmitProc(PFNVBOXEXTWORKERCB pfnCb, void *pvCb)
    298 {
    299     return VBoxExtWorkerSubmitProc(&g_VBoxExtGlobal.Worker, pfnCb, pvCb);
    300 }
    301 
     347HRESULT VBoxExtDwSubmitProcSync(PFNVBOXEXTWORKERCB pfnCb, void *pvCb)
     348{
     349    return VBoxExtWorkerSubmitProcSync(&g_VBoxExtGlobal.Worker, pfnCb, pvCb);
     350}
     351
     352HRESULT VBoxExtDwSubmitProcAsync(PFNVBOXEXTWORKERCB pfnCb, void *pvCb)
     353{
     354    return VBoxExtWorkerSubmitProcAsync(&g_VBoxExtGlobal.Worker, pfnCb, pvCb);
     355}
     356
     357#if defined(VBOX_WINE_WITH_SINGLE_CONTEXT) || defined(VBOX_WINE_WITH_SINGLE_SWAPCHAIN_CONTEXT)
     358# ifndef VBOX_WITH_WDDM
    302359typedef struct VBOXEXT_GETDC_CB
    303360{
     
    324381    pData->ret = ReleaseDC(pData->hWnd, pData->hDC);
    325382}
    326 #if 0
     383
    327384HDC VBoxExtGetDC(HWND hWnd)
    328385{
    329 #ifdef VBOX_WINE_WITH_SINGLE_CONTEXT
    330386    HRESULT hr;
    331387    VBOXEXT_GETDC_CB Data = {0};
     
    333389    Data.hDC = NULL;
    334390
    335     hr = VBoxExtDwSubmitProc(vboxExtGetDCWorker, &Data);
     391    hr = VBoxExtDwSubmitProcSync(vboxExtGetDCWorker, &Data);
    336392    if (FAILED(hr))
    337393    {
    338         ERR("VBoxExtDwSubmitProc feiled, hr (0x%x)\n", hr);
     394        ERR("VBoxExtDwSubmitProcSync feiled, hr (0x%x)\n", hr);
    339395        return NULL;
    340396    }
    341397
    342398    return Data.hDC;
    343 #else
    344     return GetDC(hWnd);
    345 #endif
    346399}
    347400
    348401int VBoxExtReleaseDC(HWND hWnd, HDC hDC)
    349402{
    350 #ifdef VBOX_WINE_WITH_SINGLE_CONTEXT
    351403    HRESULT hr;
    352404    VBOXEXT_RELEASEDC_CB Data = {0};
     
    355407    Data.ret = 0;
    356408
    357     hr = VBoxExtDwSubmitProc(vboxExtReleaseDCWorker, &Data);
     409    hr = VBoxExtDwSubmitProcSync(vboxExtReleaseDCWorker, &Data);
    358410    if (FAILED(hr))
    359411    {
    360         ERR("VBoxExtDwSubmitProc feiled, hr (0x%x)\n", hr);
     412        ERR("VBoxExtDwSubmitProcSync feiled, hr (0x%x)\n", hr);
    361413        return -1;
    362414    }
    363415
    364416    return Data.ret;
    365 #else
    366     return ReleaseDC(hWnd, hDC);
    367 #endif
    368 }
    369 #endif
     417}
     418# endif /* #ifndef VBOX_WITH_WDDM */
     419
     420static DECLCALLBACK(void) vboxExtReleaseContextWorker(void *pvUser)
     421{
     422    struct wined3d_context *context = (struct wined3d_context *)pvUser;
     423    wined3d_mutex_lock();
     424    VBoxTlsRefRelease(context);
     425    wined3d_mutex_unlock();
     426}
     427
     428void VBoxExtReleaseContextAsync(struct wined3d_context *context)
     429{
     430    HRESULT hr;
     431
     432    hr = VBoxExtDwSubmitProcAsync(vboxExtReleaseContextWorker, context);
     433    if (FAILED(hr))
     434    {
     435        ERR("VBoxExtDwSubmitProcAsync feiled, hr (0x%x)\n", hr);
     436        return;
     437    }
     438}
     439
     440#endif /* #if defined(VBOX_WINE_WITH_SINGLE_CONTEXT) || defined(VBOX_WINE_WITH_SINGLE_SWAPCHAIN_CONTEXT) */
    370441
    371442/* window creation API */
     
    507578    Info.hWnd = hWnd;
    508579    Info.hDC = hDC;
    509     hr = VBoxExtDwSubmitProc(vboxExtWndDestroyWorker, &Info);
     580    hr = VBoxExtDwSubmitProcSync(vboxExtWndDestroyWorker, &Info);
    510581    Assert(hr == S_OK);
    511582    if (hr == S_OK)
     
    524595    Info.width = width;
    525596    Info.height = height;
    526     hr = VBoxExtDwSubmitProc(vboxExtWndCreateWorker, &Info);
     597    hr = VBoxExtDwSubmitProcSync(vboxExtWndCreateWorker, &Info);
    527598    Assert(hr == S_OK);
    528599    if (hr == S_OK)
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