VirtualBox

Changeset 38172 in vbox for trunk/src


Ignore:
Timestamp:
Jul 26, 2011 6:56:40 AM (13 years ago)
Author:
vboxsync
Message:

wddm/wine: context handling fixes

Location:
trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d
Files:
2 edited

Legend:

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

    r38146 r38172  
    734734}
    735735
    736 void context_update_window(struct wined3d_context *context
     736#ifdef VBOX_WITH_WDDM
     737static BOOL swapchain_validate(IWineD3DSwapChainImpl *swapchain)
     738{
     739    HWND hWnd = WindowFromDC(swapchain->hDC);
     740    if (hWnd != swapchain->win_handle)
     741    {
     742        ERR("Unexpected swapchain for dc %p window expected %p, but was %p.\n", swapchain->hDC, swapchain->win_handle, hWnd);
     743        return FALSE;
     744    }
     745    return TRUE;
     746}
     747
     748static IWineD3DSwapChainImpl * swapchain_find_valid(IWineD3DDeviceImpl *device)
     749{
     750    int i;
     751    for (i = device->NumberOfSwapChains - 1; i >= 0 ; --i)
     752    {
     753        if (swapchain_validate((IWineD3DSwapChainImpl*)device->swapchains[i]))
     754        {
     755            return (IWineD3DSwapChainImpl*)device->swapchains[i];
     756        }
     757    }
     758
     759    return NULL;
     760}
     761#endif
     762
     763static void context_update_window(struct wined3d_context *context
    737764#ifdef VBOX_WITH_WDDM
    738765        , IWineD3DSwapChainImpl *swapchain
     
    761788
    762789#ifdef VBOX_WITH_WDDM
    763 # ifdef DEBUG
    764     {
    765         HWND wnd = WindowFromDC(swapchain->hDC);
    766         if (wnd != swapchain->win_handle)
    767         {
    768             ERR("Lost swapchain dc %p for window %p.\n", swapchain->hDC, swapchain->win_handle);
    769         }
    770     }
    771 # endif
    772 
     790    if (!swapchain_validate(swapchain))
     791    {
     792        ERR("invalid swapchain %p\n", swapchain);
     793        goto err;
     794    }
    773795    context->win_handle = swapchain->win_handle;
    774796    context->currentSwapchain = swapchain;
     
    814836    {
    815837        DWORD winEr = GetLastError();
    816         ERR("DC %p belongs to window %p instead of %p., winEr(%d)\n",
     838        WARN("DC %p belongs to window %p instead of %p., winEr(%d)\n",
    817839                context->hdc, wnd, context->win_handle, winEr);
     840#ifdef VBOX_WITH_WDDM
     841        if (!swapchain || context->win_handle == swapchain->win_handle)
     842        {
     843            ERR("!!!unexpected equal HWND!!!: DC %p belongs to window %p instead of %p., winEr(%d)\n",
     844                            context->hdc, wnd, context->win_handle, winEr);
     845        }
     846#endif
    818847        context->valid = 0;
    819848    }
     
    834863    }
    835864}
     865
     866#ifdef VBOX_WITH_WDDM
     867static void context_validate_adjust_wnd(struct wined3d_context *context)
     868{
     869    IWineD3DSwapChainImpl *swapchain = NULL;
     870
     871    context_validate(context, NULL);
     872    if (context->valid)
     873        return;
     874
     875    swapchain = swapchain_find_valid(context->device);
     876    if (swapchain)
     877    {
     878        context_validate(context, swapchain);
     879        if (!context->valid)
     880        {
     881            ERR("unexpected\n");
     882        }
     883    }
     884    else
     885    {
     886        ERR("novalid swapchain found\n");
     887    }
     888}
     889#endif
    836890
    837891static void context_destroy_gl_resources(struct wined3d_context *context)
     
    848902    restore_dc = pwglGetCurrentDC();
    849903
    850     context_validate(context
    851 #ifdef VBOX_WITH_WDDM/* tmp work-around */
    852             , NULL //(IWineD3DSwapChainImpl*)context->device->swapchains[context->device->NumberOfSwapChains-1]
    853 #endif
    854             );
     904#ifdef VBOX_WITH_WDDM
     905    context_validate_adjust_wnd(context);
     906#else
     907    context_validate(context);
     908#endif
    855909    if (context->valid && restore_ctx != context->glCtx) pwglMakeCurrent(context->hdc, context->glCtx);
    856910    else restore_ctx = NULL;
     
    13231377    /* When findCompatible is set and no suitable format was found, let ChoosePixelFormat choose a pixel format in order not to crash. */
    13241378    if(!iPixelFormat && !findCompatible) {
     1379#ifdef DEBUG_misha
     1380        WARN("Can't find a suitable iPixelFormat\n");
     1381#else
    13251382        ERR("Can't find a suitable iPixelFormat\n");
     1383#endif
    13261384        return FALSE;
    13271385    } else if(!iPixelFormat) {
     
    17181776        }
    17191777        else {
    1720                                                                                                     /* tmp work-around */
    1721             context_validate(context,
    1722                     NULL //(IWineD3DSwapChainImpl*)context->device->swapchains[context->device->NumberOfSwapChains-1]
    1723                                                                                 );
     1778            context_validate_adjust_wnd(context);
    17241779        }
    17251780    }
     
    22452300    struct wined3d_context *context = This->numContexts ? This->contexts[0] : NULL;
    22462301
     2302
    22472303    if (context && context->destroyed)
    22482304    {
     
    22612317        else
    22622318        {
    2263 #ifdef VBOX_WITH_WDDM
    2264             /* tmp work-around */
    2265             IWineD3DSwapChainImpl *swapchain = (IWineD3DSwapChainImpl *)This->swapchains[This->NumberOfSwapChains-1];
    2266 #else
    2267             IWineD3DSwapChainImpl *swapchain = (IWineD3DSwapChainImpl *)This->swapchains[0];
    2268 #endif
     2319            IWineD3DSwapChainImpl *swapchain = swapchain_find_valid(This);
     2320            if (!swapchain)
     2321                swapchain = (IWineD3DSwapChainImpl *)This->swapchains[This->NumberOfSwapChains-1]; /* just fallback to anything to avoid NPE */
    22692322            if (swapchain->backBuffer) target = swapchain->backBuffer[0];
    22702323            else target = swapchain->frontBuffer;
     
    22742327    if (context && context->current_rt == target)
    22752328    {
    2276 #ifdef VBOX_WITH_WDDM
    22772329        IWineD3DSwapChain *swapchain = NULL;
    22782330        if (SUCCEEDED(IWineD3DSurface_GetContainer(target, &IID_IWineD3DSwapChain, (void **)&swapchain))) {
     
    22812333        }
    22822334        else {
    2283                                                                                                     /* tmp work-around */
    2284             context_validate(context,
    2285                     NULL //(IWineD3DSwapChainImpl*)current_context->device->swapchains[current_context->device->NumberOfSwapChains-1]
    2286                                                                                 );
    2287         }
    2288 #else
    2289         context_validate(context);
    2290 #endif
     2335            context_validate_adjust_wnd(context);
     2336        }
    22912337        return context;
    22922338    }
     
    22962342
    22972343        context = findThreadContextForSwapChain(swapchain);
    2298 #ifdef VBOX_WITH_WDDM
    22992344        context_validate(context, (IWineD3DSwapChainImpl*)swapchain);
    2300 #endif
    23012345        IWineD3DSwapChain_Release(swapchain);
    23022346    }
    23032347    else
    23042348    {
     2349        if (context)
     2350        {
     2351            context_validate_adjust_wnd(context);
     2352        }
     2353        else
     2354        {
     2355            IWineD3DSwapChainImpl *swapchain = swapchain_find_valid(This);
     2356            if (!swapchain)
     2357                swapchain = (IWineD3DSwapChainImpl *)This->swapchains[This->NumberOfSwapChains-1]; /* just fallback to anything to avoid NPE */
     2358            context = findThreadContextForSwapChain(swapchain);
     2359            context_validate(context, swapchain);
     2360        }
     2361
    23052362        TRACE("Rendering offscreen\n");
    2306 
    2307         if (!context)
    2308         {
    2309             /* This may happen if the app jumps straight into offscreen rendering
    2310              * Start using the context of the primary swapchain. tid == 0 is no problem
    2311              * for findThreadContextForSwapChain.
    2312              *
    2313              * Can also happen on thread switches - in that case findThreadContextForSwapChain
    2314              * is perfect to call. */
    2315 #ifdef VBOX_WITH_WDDM /* tmp work-around */
    2316             context = findThreadContextForSwapChain(This->swapchains[This->NumberOfSwapChains-1]);
    2317 #else
    2318             context = findThreadContextForSwapChain(This->swapchains[0], tid);
    2319 #endif
    2320         }
    2321 #ifdef VBOX_WITH_WDDM
    2322         context_validate(context,
    2323                 NULL //(IWineD3DSwapChainImpl*)This->swapchains[This->NumberOfSwapChains-1] /* tmp work-around */
    2324                                  );
    2325 #endif
    2326     }
    2327 
    2328 #ifndef VBOX_WITH_WDDM
    2329     context_validate(context);
    2330 #endif
     2363    }
    23312364
    23322365    return context;
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/state.c

    r36029 r38172  
    5353static void state_undefined(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
    5454{
     55#ifdef DEBUG_misha
     56    WARN("Undefined state.\n");
     57#else
    5558    ERR("Undefined state.\n");
     59#endif
    5660}
    5761
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