VirtualBox

Ignore:
Timestamp:
Sep 16, 2010 10:00:43 AM (14 years ago)
Author:
vboxsync
Message:

wddm/3d: wine multi-swapchain fixes, umd driver fixes

Location:
trunk/src/VBox/Additions/WINNT/Graphics
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp

    r32501 r32545  
    19171917    IDirect3DDevice9 *pDevice9If = NULL;
    19181918    HWND hOldWnd = pSwapchain->hWnd;
     1919//#define VBOXDISP_NEWWND_ON_SWAPCHAINUPDATE
    19191920#ifndef VBOXDISP_NEWWND_ON_SWAPCHAINUPDATE
    19201921    if (!hOldWnd)
     
    47594760                            Assert(hr == S_OK);
    47604761                            if (hr == S_OK)
     4762                            {
     4763                                if(pResource->Flags.Primary)
     4764                                {
     4765                                    for (UINT i = 0; i < pResource->SurfCount; ++i)
     4766                                    {
     4767                                        vboxWddmSwapchainFindCreate(pDevice, &pRc->aAllocations[i]);
     4768                                    }
     4769                                    Assert(bIssueCreateResource);
     4770                                }
    47614771                                continue;
     4772                            }
    47624773
    47634774                            /* fail branch */
     
    56325643        {
    56335644#ifndef VBOXWDDM_WITH_VISIBLE_FB
    5634             if (pSrcSwapchain && vboxWddmSwapchainGetFb(pSrcSwapchain)->pAlloc != pSrcAlloc
     5645            if (pSrcSwapchain
     5646                    && pSrcSwapchain->pRenderTargetFbCopy
     5647                    && vboxWddmSwapchainGetFb(pSrcSwapchain)->pAlloc != pSrcAlloc
    56355648                    && vboxWddmSwapchainNumRTs(pSrcSwapchain) > 1) /* work-around wine backbuffer */
    56365649            {
     
    56715684                    pSrcSurfIf = pSrcSwapchain->pRenderTargetFbCopy;
    56725685                    Assert(pSrcSurfIf);
    5673                     hr = pDevice9If->GetFrontBufferData(0, pSrcSurfIf);
     5686                    hr = pSrcSwapchain->pSwapChainIf->GetFrontBufferData(pSrcSurfIf);
    56745687                    Assert(hr == S_OK);
    56755688                    if (hr == S_OK)
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/wined3d.h

    r32461 r32545  
    73087308    virtual HRESULT STDMETHODCALLTYPE AddSwapChain(
    73097309        IWineD3DSwapChain *swapchain) = 0;
     7310
     7311    virtual HRESULT STDMETHODCALLTYPE RemoveSwapChain(
     7312        IWineD3DSwapChain *swapchain) = 0;
    73107313#endif
    73117314};
     
    80748077
    80758078    HRESULT (STDMETHODCALLTYPE *AddSwapChain)(
     8079        IWineD3DDevice* This,
     8080        IWineD3DSwapChain *swapchain);
     8081
     8082    HRESULT (STDMETHODCALLTYPE *RemoveSwapChain)(
    80768083        IWineD3DDevice* This,
    80778084        IWineD3DSwapChain *swapchain);
     
    82368243#define IWineD3DDevice_Flush(This) (This)->lpVtbl->Flush(This)
    82378244#define IWineD3DDevice_AddSwapChain(This,swapchain) (This)->lpVtbl->AddSwapChain(This,swapchain)
     8245#define IWineD3DDevice_RemoveSwapChain(This,swapchain) (This)->lpVtbl->RemoveSwapChain(This,swapchain)
    82388246#endif
    82398247#endif
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/arb_program_shader.c

    r32461 r32545  
    69696969    if (wined3d_settings.strict_draw_ordering || (dst_swapchain
    69706970            && ((IWineD3DSurface *)dst_surface == dst_swapchain->frontBuffer
    6971             || dst_swapchain->num_contexts > 1)))
     6971#ifdef VBOXWDDM
     6972            || dst_swapchain->device->numContexts > 1
     6973#else
     6974            || dst_swapchain->num_contexts > 1
     6975#endif
     6976            )))
    69726977        wglFlush(); /* Flush to ensure ordering across contexts. */
    69736978
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/context.c

    r32508 r32545  
    757757{
    758758#ifdef VBOXWDDM
     759# ifdef DEBUG_misha
     760    Assert(0);
     761# endif
    759762    TRACE("Updating context %p window from %p to %p.\n",
    760763            context, context->win_handle, swapchain->win_handle);
     
    776779#ifdef VBOXWDDM
    777780    context->win_handle = swapchain->win_handle;
    778     context->hdc = GetDC(context->win_handle);
    779781    context->currentSwapchain = swapchain;
    780782#else
    781783    context->win_handle = context->swapchain->win_handle;
    782 
     784#endif
    783785    if (!(context->hdc = GetDC(context->win_handle)))
    784786    {
     
    786788        goto err;
    787789    }
    788 #endif
    789790
    790791    if (!context_set_pixel_format(context->gl_info, context->hdc, context->pixel_format))
     
    15951596        const struct wined3d_format_desc *ds_format_desc)
    15961597{
    1597     int i, j;
    1598     int swapchains = IWineD3DDevice_GetNumberOfSwapChains(device);
     1598    int i;
    15991599    DWORD tid = GetCurrentThreadId();
    16001600    struct wined3d_context *context = NULL;
    16011601
    1602 //    Assert(0);
    1603 
    1604     for(i = 0 ; i < swapchains ; i ++)
    1605     {
    1606         IWineD3DSwapChainImpl *curSwapChain;
    1607         IWineD3DDevice_GetSwapChain(device, i, &curSwapChain);
    1608         if (curSwapChain->ds_format == ds_format_desc)
    1609         {
    1610             for(j = 0; j < curSwapChain->num_contexts; j++) {
    1611                 if(curSwapChain->context[j]->tid == tid) {
    1612                     context = curSwapChain->context[j];
    1613                     break;
    1614                 }
    1615             }
    1616         }
    1617         else
    1618         {
    1619             Assert(0);
    1620         }
    1621 
    1622         IWineD3DSwapChain_Release(curSwapChain);
    1623 
    1624         if (context)
     1602    Assert(0);
     1603
     1604    for(i = 0 ; i < device->numContexts ; i ++)
     1605    {
     1606        if(device->contexts[i]->tid == tid) {
     1607            context = device->contexts[i];
    16251608            break;
     1609        }
    16261610    }
    16271611
    16281612    if (!context)
    16291613    {
    1630         Assert(!swapchains);
     1614        Assert(!device->NumberOfSwapChains);
    16311615        context = context_create(swapchain, target, ds_format_desc);
    16321616    }
     
    19151899{
    19161900    unsigned int i;
    1917 
     1901#ifdef VBOXWDDM
     1902    IWineD3DDeviceImpl *device = ((IWineD3DSwapChainImpl*)swapchain)->device;
     1903    for (i = 0; i < device->numContexts; ++i)
     1904    {
     1905        if (device->contexts[i]->tid == tid)
     1906            return device->contexts[i];
     1907    }
     1908#else
    19181909    for(i = 0; i < ((IWineD3DSwapChainImpl *) swapchain)->num_contexts; i++) {
    19191910        if(((IWineD3DSwapChainImpl *) swapchain)->context[i]->tid == tid) {
     
    19211912        }
    19221913    }
    1923 
    1924 #ifdef VBOXWDDM
    1925     Assert(0);
    19261914#endif
    19271915
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/device.c

    r32461 r32545  
    62966296}
    62976297
    6298 static void delete_opengl_contexts(IWineD3DDevice *iface, IWineD3DSwapChainImpl *swapchain)
     6298static void delete_opengl_contexts(IWineD3DDevice *iface
     6299#ifndef VBOXWDDM
     6300        , IWineD3DSwapChainImpl *swapchain
     6301#endif
     6302        )
    62996303{
    63006304    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
     
    63356339        context_destroy(This, This->contexts[0]);
    63366340    }
     6341#ifndef VBOXWDDM
    63376342    HeapFree(GetProcessHeap(), 0, swapchain->context);
    63386343    swapchain->context = NULL;
    63396344    swapchain->num_contexts = 0;
     6345#endif
    63406346}
    63416347
     
    63476353    IWineD3DSurfaceImpl *target;
    63486354
     6355#ifndef VBOXWDDM
    63496356    /* Recreate the primary swapchain's context */
    63506357    swapchain->context = HeapAlloc(GetProcessHeap(), 0, sizeof(*swapchain->context));
     
    63546361        return E_OUTOFMEMORY;
    63556362    }
     6363#endif
    63566364
    63576365    target = (IWineD3DSurfaceImpl *)(swapchain->backBuffer ? swapchain->backBuffer[0] : swapchain->frontBuffer);
     
    63596367    {
    63606368        WARN("Failed to create context.\n");
     6369#ifndef VBOXWDDM
    63616370        HeapFree(GetProcessHeap(), 0, swapchain->context);
     6371#endif
    63626372        return E_FAIL;
    63636373    }
    63646374
     6375#ifndef VBOXWDDM
    63656376    swapchain->context[0] = context;
    63666377    swapchain->num_contexts = 1;
     6378#endif
    63676379    create_dummy_textures(This);
    63686380    context_release(context);
     
    63996411    context_release(context);
    64006412    context_destroy(This, context);
     6413#ifndef VBOXWDDM
    64016414    HeapFree(GetProcessHeap(), 0, swapchain->context);
    64026415    swapchain->num_contexts = 0;
     6416#endif
    64036417    return hr;
    64046418}
     
    64116425    WINED3DDISPLAYMODE mode;
    64126426    TRACE("(%p)\n", This);
     6427
     6428#ifdef VBOXWDDM
     6429    /* todo: implement multi-swapchain handlling!!! */
     6430    Assert(0);
     6431#endif
    64136432
    64146433    hr = IWineD3DDevice_GetSwapChain(iface, 0, (IWineD3DSwapChain **) &swapchain);
     
    64996518    IWineD3DStateBlock_Release((IWineD3DStateBlock *)This->stateBlock);
    65006519
    6501     delete_opengl_contexts(iface, swapchain);
     6520    delete_opengl_contexts(iface
     6521#ifndef VBOXWDDM
     6522            , swapchain
     6523#endif
     6524            );
    65026525
    65036526    if(pPresentationParameters->Windowed) {
     
    68656888        return E_OUTOFMEMORY;
    68666889    }
    6867     IUnknown_AddRef(swapchain);
    68686890    This->swapchains = (IWineD3DSwapChain *)pvNewBuf;
    68696891    This->swapchains[This->NumberOfSwapChains] = swapchain;
    68706892    ++This->NumberOfSwapChains;
     6893    return WINED3D_OK;
     6894}
     6895
     6896static HRESULT WINAPI IWineD3DDeviceImpl_RemoveSwapChain(IWineD3DDevice *iface, IWineD3DSwapChain *swapchain)
     6897{
     6898    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
     6899    int i;
     6900    for (i = 0; i < This->NumberOfSwapChains; ++i)
     6901    {
     6902        if (This->swapchains[i] == swapchain)
     6903        {
     6904            break;
     6905        }
     6906    }
     6907
     6908    if (i == This->NumberOfSwapChains)
     6909    {
     6910        WARN("swapchain 0x%p is not part of device 0x%p\n", swapchain, iface);
     6911        return E_INVALIDARG;
     6912    }
     6913
     6914    --This->NumberOfSwapChains;
     6915    if (This->NumberOfSwapChains)
     6916    {
     6917        IWineD3DSwapChain **pvNewBuf = (IWineD3DSwapChain **)HeapAlloc(GetProcessHeap(), 0, (This->NumberOfSwapChains) * sizeof(IWineD3DSwapChain *));
     6918        if(!pvNewBuf) {
     6919            ERR("Out of memory!\n");
     6920            return E_OUTOFMEMORY;
     6921        }
     6922        if (i) {
     6923            memcpy (pvNewBuf, This->swapchains, i*sizeof(IWineD3DSwapChain *));
     6924        }
     6925        if (i < This->NumberOfSwapChains) {
     6926            memcpy (pvNewBuf + i, This->swapchains +i+1, (This->NumberOfSwapChains - i)*sizeof(IWineD3DSwapChain *));
     6927        }
     6928
     6929        This->swapchains = (IWineD3DSwapChain *)pvNewBuf;
     6930    }
     6931    else
     6932    {
     6933        while (This->numContexts)
     6934        {
     6935            context_destroy(This, This->contexts[0]);
     6936        }
     6937    }
    68716938    return WINED3D_OK;
    68726939}
     
    70297096    IWineD3DDeviceImpl_Flush,
    70307097    IWineD3DDeviceImpl_AddSwapChain,
     7098    IWineD3DDeviceImpl_RemoveSwapChain,
    70317099#endif
    70327100};
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/surface.c

    r32508 r32545  
    488488        Assert(shared_handle);
    489489        VBOXSHRC_SET_INITIALIZED(surface);
    490         IWineD3DSurface_LoadLocation(surface, SFLAG_INTEXTURE, NULL);
     490        IWineD3DSurface_LoadLocation((IWineD3DSurface*)surface, SFLAG_INTEXTURE, NULL);
    491491        if (!VBOXSHRC_IS_SHARED_OPENED(surface))
    492492        {
     
    37923792        if (wined3d_settings.strict_draw_ordering || (dstSwapchain
    37933793                && ((IWineD3DSurface *)This == dstSwapchain->frontBuffer
    3794                 || dstSwapchain->num_contexts > 1)))
     3794#ifdef VBOXWDDM
     3795                || dstSwapchain->device->numContexts > 1
     3796#else
     3797                || dstSwapchain->num_contexts > 1
     3798#endif
     3799                )))
    37953800            wglFlush(); /* Flush to ensure ordering across contexts. */
    37963801
     
    44024407    if (wined3d_settings.strict_draw_ordering || (swapchain
    44034408            && ((IWineD3DSurface *)This == swapchain->frontBuffer
    4404             || swapchain->num_contexts > 1)))
     4409#ifdef VBOXWDDM
     4410            || swapchain->device->numContexts > 1
     4411#else
     4412            || swapchain->num_contexts > 1
     4413#endif
     4414            )))
    44054415        wglFlush(); /* Flush to ensure ordering across contexts. */
    44064416
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/surface_gdi.c

    r28475 r32545  
    440440            IWineD3DSurfaceImpl *dds_primary;
    441441            IWineD3DSwapChainImpl *swapchain;
    442             swapchain = (IWineD3DSwapChainImpl *)This->resource.device->swapchains[0];
     442            swapchain = (IWineD3DSwapChainImpl *)This->resource.device->swapchains[This->resource.device->NumberOfSwapChains-1];
    443443            dds_primary = (IWineD3DSurfaceImpl *)swapchain->frontBuffer;
    444444            if (dds_primary && dds_primary->palette)
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/swapchain.c

    r32461 r32545  
    8383        This->backBuffer = NULL;
    8484    }
    85 
     85#ifndef VBOXWDDM
    8686    for (i = 0; i < This->num_contexts; ++i)
    8787    {
    8888        context_destroy(This->device, This->context[i]);
    8989    }
    90     /* Restore the screen resolution if we rendered in fullscreen
    91      * This will restore the screen resolution to what it was before creating the swapchain. In case of d3d8 and d3d9
    92      * this will be the original desktop resolution. In case of d3d7 this will be a NOP because ddraw sets the resolution
    93      * before starting up Direct3D, thus orig_width and orig_height will be equal to the modes in the presentation params
    94      */
    95     if(This->presentParms.Windowed == FALSE && This->presentParms.AutoRestoreDisplayMode) {
    96         mode.Width = This->orig_width;
    97         mode.Height = This->orig_height;
    98         mode.RefreshRate = 0;
    99         mode.Format = This->orig_fmt;
    100         IWineD3DDevice_SetDisplayMode((IWineD3DDevice *)This->device, 0, &mode);
    101     }
    102 
     90#else
     91    IWineD3DDevice_RemoveSwapChain(This->device, This);
     92    if (!This->device->NumberOfSwapChains)
     93#endif
     94    {
     95        /* Restore the screen resolution if we rendered in fullscreen
     96         * This will restore the screen resolution to what it was before creating the swapchain. In case of d3d8 and d3d9
     97         * this will be the original desktop resolution. In case of d3d7 this will be a NOP because ddraw sets the resolution
     98         * before starting up Direct3D, thus orig_width and orig_height will be equal to the modes in the presentation params
     99         */
     100        if(This->presentParms.Windowed == FALSE && This->presentParms.AutoRestoreDisplayMode) {
     101            mode.Width = This->orig_width;
     102            mode.Height = This->orig_height;
     103            mode.RefreshRate = 0;
     104            mode.Format = This->orig_fmt;
     105            IWineD3DDevice_SetDisplayMode((IWineD3DDevice *)This->device, 0, &mode);
     106        }
     107    }
     108#ifdef VBOXWDDM
     109    if(This->device_window) {
     110        ReleaseDC(This->device_window, This->hDC);
     111    }
     112#else
    103113    HeapFree(GetProcessHeap(), 0, This->context);
     114#endif
    104115    HeapFree(GetProcessHeap(), 0, This);
    105116}
     
    353364    }
    354365
     366#ifdef VBOXWDDM
     367    if (This->device->numContexts > 1) wglFinish();
     368#else
    355369    if (This->num_contexts > 1) wglFinish();
     370#endif
    356371    SwapBuffers(context->hdc); /* TODO: cycle through the swapchain buffers */
    357372
     
    720735    swapchain->win_handle = window;
    721736    swapchain->device_window = window;
     737#ifdef VBOXWDDM
     738    Assert(window);
     739    swapchain->hDC = GetDC(window);
     740    if (!swapchain->hDC)
     741    {
     742        DWORD winEr = GetLastError();
     743        WARN("Failed to get a window DC, winEr %d.\n", winEr);
     744        Assert(0);
     745        goto err;
     746    }
     747#endif
    722748
    723749    if (!present_parameters->Windowed && window)
     
    812838    }
    813839
     840#ifndef VBOXWDDM
    814841    swapchain->context = HeapAlloc(GetProcessHeap(), 0, sizeof(swapchain->context));
    815842    if (!swapchain->context)
     
    820847    }
    821848    swapchain->num_contexts = 1;
     849#endif
    822850
    823851    if (surface_type == SURFACE_OPENGL)
    824852    {
     853        struct wined3d_context * swapchainContext;
    825854        const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
    826855
     
    844873
    845874#ifdef VBOXWDDM
    846         swapchain->context[0] = context_find_create(device, swapchain, (IWineD3DSurfaceImpl *)swapchain->frontBuffer,
     875        swapchainContext = context_find_create(device, swapchain, (IWineD3DSurfaceImpl *)swapchain->frontBuffer,
    847876                swapchain->ds_format);
     877        if (!swapchainContext)
    848878#else
    849879        swapchain->context[0] = context_create(swapchain, (IWineD3DSurfaceImpl *)swapchain->frontBuffer,
    850880                swapchain->ds_format);
    851 #endif
    852881        if (!swapchain->context[0])
     882#endif
    853883        {
    854884            WARN("Failed to create context.\n");
     
    856886            goto err;
    857887        }
     888#ifdef VBOXWDDM
     889        context_release(swapchainContext);
     890#else
    858891        context_release(swapchain->context[0]);
     892#endif
    859893    }
    860894    else
    861895    {
     896#ifndef VBOXWDDM
    862897        swapchain->context[0] = NULL;
     898#endif
    863899    }
    864900
     
    943979    }
    944980
     981#ifdef VBOXWDDM
     982    if (!device->NumberOfSwapChains)
     983    {
     984        while (device->numContexts)
     985        {
     986            context_destroy(device, device->contexts[0]);
     987        }
     988    }
     989#else
    945990    if (swapchain->context)
    946991    {
     
    953998        HeapFree(GetProcessHeap(), 0, swapchain->context);
    954999    }
     1000#endif
    9551001
    9561002    if (swapchain->frontBuffer) IWineD3DSurface_Release(swapchain->frontBuffer);
     
    9731019    }
    9741020    context_release(ctx);
    975 
     1021#ifdef VBOXWDDM
     1022    /* no need to do anything since context gets added to the device context list within the context_create call */
     1023#else
    9761024    newArray = HeapAlloc(GetProcessHeap(), 0, sizeof(*newArray) * This->num_contexts + 1);
    9771025    if(!newArray) {
     
    9851033    This->context = newArray;
    9861034    This->num_contexts++;
    987 
     1035#endif
    9881036    TRACE("Returning context %p\n", ctx);
    9891037    return ctx;
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/swapchain_gdi.c

    r31868 r32545  
    8080    }
    8181
     82#ifndef VBOXWDDM
    8283    HeapFree(GetProcessHeap(), 0, This->context);
     84#endif
    8385    HeapFree(GetProcessHeap(), 0, This);
    8486}
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/wined3d_private.h

    r32461 r32545  
    26432643    unsigned int vSyncCounter;
    26442644
     2645#ifndef VBOXWDDM
    26452646    struct wined3d_context **context;
    26462647    unsigned int            num_contexts;
     2648#endif
    26472649
    26482650    HWND                    win_handle;
    26492651    HWND device_window;
     2652#ifdef VBOXWDDM
     2653    HDC hDC;
     2654#endif
    26502655};
    26512656
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