VirtualBox

Ignore:
Timestamp:
Sep 13, 2010 5:59:01 PM (14 years ago)
Author:
vboxsync
Message:

wddm/3d: wine multi-swapchain fixes

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d9/device.c

    r32281 r32461  
    462462    return ret;
    463463}
    464 
     464#ifdef VBOXWDDM
     465static HRESULT IDirect3DDevice9Impl_DoCreateAdditionalSwapChain(IDirect3DDevice9Ex *iface,
     466        D3DPRESENT_PARAMETERS *present_parameters, IDirect3DSwapChain9 **swapchain)
     467#else
    465468static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_CreateAdditionalSwapChain(IDirect3DDevice9Ex *iface,
    466469        D3DPRESENT_PARAMETERS *present_parameters, IDirect3DSwapChain9 **swapchain)
     470#endif
    467471{
    468472    IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
     
    493497    return D3D_OK;
    494498}
     499
     500#ifdef VBOXWDDM
     501static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_CreateAdditionalSwapChain(IDirect3DDevice9Ex *iface,
     502        D3DPRESENT_PARAMETERS *present_parameters, IDirect3DSwapChain9 **swapchain)
     503{
     504    IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
     505    IDirect3DSwapChain9Impl *newSwapchain;
     506    HRESULT hr = IDirect3DDevice9Impl_DoCreateAdditionalSwapChain(iface, present_parameters, &newSwapchain);
     507    if (FAILED(hr))
     508    {
     509        ERR("Failed to create additional swapchain, hr %#x.\n", hr);
     510        return hr;
     511    }
     512
     513    /* add swapchain to the swapchain list */
     514    wined3d_mutex_lock();
     515    hr = IWineD3DDevice_AddSwapChain(This->WineD3DDevice, newSwapchain->wineD3DSwapChain);
     516    wined3d_mutex_unlock();
     517    if (FAILED(hr))
     518    {
     519        ERR("Failed to add additional swapchain, hr %#x.\n", hr);
     520        IUnknown_Release(newSwapchain);
     521        return hr;
     522    }
     523
     524    *swapchain = (IDirect3DSwapChain9 *)newSwapchain;
     525    return D3D_OK;
     526}
     527#endif
    495528
    496529static HRESULT WINAPI reset_enum_callback(IWineD3DResource *resource, void *data) {
     
    28982931    local_parameters.PresentationInterval = present_parameters->PresentationInterval;
    28992932
     2933#ifdef VBOXWDDM
     2934    hr = IDirect3DDevice9Impl_DoCreateAdditionalSwapChain((IDirect3DDevice9Ex *)This,
     2935            &local_parameters, (IDirect3DSwapChain9 **)&d3d_swapchain);
     2936#else
    29002937    hr = IDirect3DDevice9Impl_CreateAdditionalSwapChain((IDirect3DDevice9Ex *)This,
    29012938            &local_parameters, (IDirect3DSwapChain9 **)&d3d_swapchain);
     2939#endif
    29022940    if (FAILED(hr))
    29032941    {
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/wined3d.h

    r31868 r32461  
    73027302        ) = 0;
    73037303
     7304#ifdef VBOXWDDM
     7305    virtual HRESULT STDMETHODCALLTYPE Flush(
     7306        ) = 0;
     7307
     7308    virtual HRESULT STDMETHODCALLTYPE AddSwapChain(
     7309        IWineD3DSwapChain *swapchain) = 0;
     7310#endif
    73047311};
    73057312#else
     
    80658072    HRESULT (STDMETHODCALLTYPE *Flush)(
    80668073        IWineD3DDevice* This);
     8074
     8075    HRESULT (STDMETHODCALLTYPE *AddSwapChain)(
     8076        IWineD3DDevice* This,
     8077        IWineD3DSwapChain *swapchain);
    80678078#endif
    80688079
     
    82248235#ifdef VBOXWDDM
    82258236#define IWineD3DDevice_Flush(This) (This)->lpVtbl->Flush(This)
     8237#define IWineD3DDevice_AddSwapChain(This,swapchain) (This)->lpVtbl->AddSwapChain(This,swapchain)
    82268238#endif
    82278239#endif
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/arb_program_shader.c

    r28475 r32461  
    586586static void shader_arb_load_constants(const struct wined3d_context *context, char usePixelShader, char useVertexShader)
    587587{
     588#ifdef VBOXWDDM
     589    IWineD3DDeviceImpl *device = context->device;
     590#else
    588591    IWineD3DDeviceImpl *device = context->swapchain->device;
     592#endif
    589593    IWineD3DStateBlockImpl* stateBlock = device->stateBlock;
    590594    const struct wined3d_gl_info *gl_info = context->gl_info;
     
    616620    /* We don't want shader constant dirtification to be an O(contexts), so just dirtify the active
    617621     * context. On a context switch the old context will be fully dirtified */
     622#ifdef VBOXWDDM
     623    if (!context || context->device != This) return;
     624#else
    618625    if (!context || context->swapchain->device != This) return;
     626#endif
    619627
    620628    memset(context->vshader_const_dirty + start, 1, sizeof(*context->vshader_const_dirty) * count);
     
    629637    /* We don't want shader constant dirtification to be an O(contexts), so just dirtify the active
    630638     * context. On a context switch the old context will be fully dirtified */
     639#ifdef VBOXWDDM
     640    if (!context || context->device != This) return;
     641#else
    631642    if (!context || context->swapchain->device != This) return;
     643#endif
    632644
    633645    memset(context->pshader_const_dirty + start, 1, sizeof(*context->pshader_const_dirty) * count);
     
    43494361static void shader_arb_select(const struct wined3d_context *context, BOOL usePS, BOOL useVS)
    43504362{
     4363#ifdef VBOXWDDM
     4364    IWineD3DDeviceImpl *This = context->device;
     4365#else
    43514366    IWineD3DDeviceImpl *This = context->swapchain->device;
     4367#endif
    43524368    struct shader_arb_priv *priv = This->shader_priv;
    43534369    const struct wined3d_gl_info *gl_info = context->gl_info;
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/context.c

    r31828 r32461  
    331331{
    332332    const struct wined3d_gl_info *gl_info = context->gl_info;
     333#ifdef VBOXWDDM
     334    IWineD3DDeviceImpl *device = context->device;
     335#else
    333336    IWineD3DDeviceImpl *device = context->swapchain->device;
     337#endif
    334338    struct fbo_entry *entry;
    335339
     
    348352{
    349353    const struct wined3d_gl_info *gl_info = context->gl_info;
     354#ifdef VBOXWDDM
     355    IWineD3DDeviceImpl *device = context->device;
     356#else
    350357    IWineD3DDeviceImpl *device = context->swapchain->device;
     358#endif
    351359
    352360    context_bind_fbo(context, GL_FRAMEBUFFER, &entry->id);
     
    377385{
    378386    const struct wined3d_gl_info *gl_info = context->gl_info;
     387#ifdef VBOXWDDM
     388    IWineD3DDeviceImpl *device = context->device;
     389#else
    379390    IWineD3DDeviceImpl *device = context->swapchain->device;
     391#endif
    380392    struct fbo_entry *entry;
    381393
     
    413425{
    414426    const struct wined3d_gl_info *gl_info = context->gl_info;
     427#ifdef VBOXWDDM
     428    IWineD3DDeviceImpl *device = context->device;
     429#else
    415430    IWineD3DDeviceImpl *device = context->swapchain->device;
     431#endif
    416432    unsigned int i;
    417433
     
    734750}
    735751
    736 static void context_update_window(struct wined3d_context *context)
    737 {
     752static void context_update_window(struct wined3d_context *context
     753#ifdef VBOXWDDM
     754        , IWineD3DSwapChainImpl *swapchain
     755#endif
     756        )
     757{
     758#ifdef VBOXWDDM
     759    TRACE("Updating context %p window from %p to %p.\n",
     760            context, context->win_handle, swapchain->win_handle);
     761#else
    738762    TRACE("Updating context %p window from %p to %p.\n",
    739763            context, context->win_handle, context->swapchain->win_handle);
     764#endif
    740765
    741766    if (context->valid)
     
    749774    else context->valid = 1;
    750775
     776#ifdef VBOXWDDM
     777    context->win_handle = swapchain->win_handle;
     778    context->hdc = GetDC(context->win_handle);
     779    context->currentSwapchain = swapchain;
     780#else
    751781    context->win_handle = context->swapchain->win_handle;
    752782
     
    756786        goto err;
    757787    }
     788#endif
    758789
    759790    if (!context_set_pixel_format(context->gl_info, context->hdc, context->pixel_format))
     
    777808}
    778809
    779 static void context_validate(struct wined3d_context *context)
     810static void context_validate(struct wined3d_context *context
     811#ifdef VBOXWDDM
     812        , IWineD3DSwapChainImpl *swapchain
     813#endif
     814        )
    780815{
    781816    HWND wnd = WindowFromDC(context->hdc);
     
    788823    }
    789824
    790     if (context->win_handle != context->swapchain->win_handle)
    791         context_update_window(context);
     825    if (
     826#ifdef VBOXWDDM
     827            swapchain && context->win_handle != swapchain->win_handle
     828#else
     829            context->win_handle != context->swapchain->win_handle
     830#endif
     831            )
     832    {
     833        context_update_window(context
     834#ifdef VBOXWDDM
     835                , swapchain
     836#endif
     837                );
     838    }
    792839}
    793840
     
    805852    restore_dc = pwglGetCurrentDC();
    806853
    807     context_validate(context);
     854    context_validate(context
     855#ifdef VBOXWDDM
     856            , NULL//context->device->swapchains[0]
     857#endif
     858            );
    808859    if (context->valid && restore_ctx != context->glCtx) pwglMakeCurrent(context->hdc, context->glCtx);
    809860    else restore_ctx = NULL;
     
    12101261}
    12111262
     1263
     1264
     1265
    12121266/*****************************************************************************
    12131267 * context_create
     
    13611415    }
    13621416
     1417#ifdef VBOXWDDM
     1418    ret->device = device;
     1419    ret->currentSwapchain = swapchain;
     1420#else
    13631421    ret->swapchain = swapchain;
     1422#endif
    13641423    ret->current_rt = (IWineD3DSurface *)target;
    13651424    ret->tid = GetCurrentThreadId();
     
    15291588    return NULL;
    15301589}
     1590
     1591#ifdef VBOXWDDM
     1592static void context_setup_target(IWineD3DDeviceImpl *device, struct wined3d_context *context, IWineD3DSurface *target);
     1593
     1594struct wined3d_context *context_find_create(IWineD3DDeviceImpl *device, IWineD3DSwapChainImpl *swapchain, IWineD3DSurfaceImpl *target,
     1595        const struct wined3d_format_desc *ds_format_desc)
     1596{
     1597    IWineD3DSwapChainImpl *swapChain = NULL;
     1598    int i, j;
     1599    int swapchains = IWineD3DDevice_GetNumberOfSwapChains(device);
     1600    DWORD tid = GetCurrentThreadId();
     1601    struct wined3d_context *context = NULL;
     1602
     1603    Assert(0);
     1604
     1605    for(i = 0 ; i < swapchains ; i ++)
     1606    {
     1607        IWineD3DDevice_GetSwapChain(device, i, &swapChain);
     1608        if (swapChain->ds_format == ds_format_desc)
     1609        {
     1610            for(j = 0; j < swapChain->num_contexts; j++) {
     1611                if(swapChain->context[j]->tid == tid
     1612                        && swapChain->context[j]->tid == tid) {
     1613                    context = swapChain->context[j];
     1614                    break;
     1615                }
     1616            }
     1617        }
     1618        else
     1619        {
     1620            Assert(0);
     1621        }
     1622
     1623        if (context)
     1624            break;
     1625        IWineD3DSwapChain_Release(swapChain);
     1626    }
     1627
     1628    if (!context)
     1629    {
     1630        Assert(!swapchains);
     1631        context = context_create(swapchain, target, ds_format_desc);
     1632    }
     1633    else
     1634    {
     1635        Assert(swapChain);
     1636        context_validate(context, swapChain);
     1637        context_setup_target(device, context, target);
     1638        context_enter(context);
     1639        Assert(context->valid);
     1640        IWineD3DSwapChain_Release(swapChain);
     1641    }
     1642
     1643    return context;
     1644}
     1645#endif
    15311646
    15321647/*****************************************************************************
     
    18071922            return ((IWineD3DSwapChainImpl *) swapchain)->context[i];
    18081923        }
    1809 
    1810     }
     1924    }
     1925
     1926#ifdef VBOXWDDM
     1927    Assert(0);
     1928#endif
    18111929
    18121930    /* Create a new context for the thread */
     
    18391957        if (current_context
    18401958                && current_context->current_rt
    1841                 && current_context->swapchain->device == This)
     1959#ifdef VBOXWDDM
     1960                && current_context->device == This
     1961#else
     1962                && current_context->swapchain->device == This
     1963#endif
     1964                )
    18421965        {
    18431966            target = current_context->current_rt;
     
    18531976    if (current_context && current_context->current_rt == target)
    18541977    {
    1855         context_validate(current_context);
     1978        context_validate(current_context
     1979#ifdef VBOXWDDM
     1980                , NULL// current_context->device->swapchains[0]
     1981#endif
     1982                                                    );
    18561983        return current_context;
    18571984    }
     
    18621989        context = findThreadContextForSwapChain(swapchain, tid);
    18631990        IWineD3DSwapChain_Release(swapchain);
     1991#ifdef VBOXWDDM
     1992        context_validate(context, swapchain);
     1993#endif
    18641994    }
    18651995    else
     
    18681998
    18691999        /* Stay with the currently active context. */
    1870         if (current_context && current_context->swapchain->device == This)
     2000        if (current_context
     2001#ifdef VBOXWDDM
     2002                && current_context->device == This
     2003#else
     2004                && current_context->swapchain->device == This
     2005#endif
     2006                )
    18712007        {
    18722008            context = current_context;
     
    18822018            context = findThreadContextForSwapChain(This->swapchains[0], tid);
    18832019        }
    1884     }
    1885 
     2020#ifdef VBOXWDDM
     2021        context_validate(context,
     2022                NULL//This->swapchains[0]
     2023                                 );
     2024#endif
     2025    }
     2026
     2027#ifndef VBOXWDDM
    18862028    context_validate(context);
     2029#endif
    18872030
    18882031    return context;
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/device.c

    r31868 r32461  
    68576857}
    68586858
     6859static HRESULT WINAPI IWineD3DDeviceImpl_AddSwapChain(IWineD3DDevice *iface, IWineD3DSwapChain *swapchain)
     6860{
     6861    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
     6862    VOID *pvNewBuf = HeapReAlloc(GetProcessHeap(), 0, This->swapchains, (This->NumberOfSwapChains + 1) * sizeof(IWineD3DSwapChain *));
     6863    if(!pvNewBuf) {
     6864        ERR("Out of memory!\n");
     6865        return E_OUTOFMEMORY;
     6866    }
     6867    IUnknown_AddRef(swapchain);
     6868    This->swapchains = (IWineD3DSwapChain *)pvNewBuf;
     6869    This->swapchains[This->NumberOfSwapChains] = swapchain;
     6870    ++This->NumberOfSwapChains;
     6871    return WINED3D_OK;
     6872}
    68596873#endif
    68606874
     
    70147028    /* VBox WDDM extensions */
    70157029    IWineD3DDeviceImpl_Flush,
     7030    IWineD3DDeviceImpl_AddSwapChain,
    70167031#endif
    70177032};
     
    71217136void get_drawable_size_backbuffer(struct wined3d_context *context, UINT *width, UINT *height)
    71227137{
     7138#ifdef VBOXWDDM
     7139    IWineD3DSwapChainImpl *swapchain = context->currentSwapchain;
     7140#else
    71237141    IWineD3DSwapChainImpl *swapchain = context->swapchain;
     7142#endif
    71247143    /* The drawable size of a backbuffer / aux buffer offscreen target is the size of the
    71257144     * current context's drawable, which is the size of the back buffer of the swapchain
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/glsl_shader.c

    r30885 r32461  
    773773{
    774774    const struct wined3d_gl_info *gl_info = context->gl_info;
     775#ifdef VBOXWDDM
     776    IWineD3DDeviceImpl *device = context->device;
     777#else
    775778    IWineD3DDeviceImpl *device = context->swapchain->device;
     779#endif
    776780    IWineD3DStateBlockImpl* stateBlock = device->stateBlock;
    777781    struct shader_glsl_priv *priv = device->shader_priv;
     
    46164620{
    46174621    const struct wined3d_gl_info *gl_info = context->gl_info;
     4622#ifdef VBOXWDDM
     4623    IWineD3DDeviceImpl *device = context->device;
     4624#else
    46184625    IWineD3DDeviceImpl *device = context->swapchain->device;
     4626#endif
    46194627    struct shader_glsl_priv *priv = device->shader_priv;
    46204628    GLhandleARB program_id = 0;
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/swapchain.c

    r31868 r32461  
    842842        }
    843843        swapchain->ds_format = getFormatDescEntry(WINED3DFMT_D24_UNORM_S8_UINT, gl_info);
     844
     845#ifdef VBOXWDDM
     846        swapchain->context[0] = context_find_create(device, swapchain, (IWineD3DSurfaceImpl *)swapchain->frontBuffer,
     847                swapchain->ds_format);
     848#else
    844849        swapchain->context[0] = context_create(swapchain, (IWineD3DSurfaceImpl *)swapchain->frontBuffer,
    845850                swapchain->ds_format);
     851#endif
    846852        if (!swapchain->context[0])
    847853        {
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/wined3d_private.h

    r31828 r32461  
    10741074    DWORD isStateDirty[STATE_HIGHEST / (sizeof(DWORD) * CHAR_BIT) + 1]; /* Bitmap to find out quickly if a state is dirty */
    10751075
     1076#ifdef VBOXWDDM
     1077    IWineD3DDeviceImpl    *device;
     1078    IWineD3DSwapChainImpl *currentSwapchain;
     1079#else
    10761080    IWineD3DSwapChainImpl *swapchain;
     1081#endif
     1082
    10771083    IWineD3DSurface *current_rt;
    10781084    DWORD                   tid;    /* Thread ID which owns this context at the moment */
     
    12401246struct wined3d_context *context_create(IWineD3DSwapChainImpl *swapchain, IWineD3DSurfaceImpl *target,
    12411247        const struct wined3d_format_desc *ds_format_desc) DECLSPEC_HIDDEN;
     1248#ifdef VBOXWDDM
     1249struct wined3d_context *context_find_create(IWineD3DDeviceImpl *device, IWineD3DSwapChainImpl *swapchain, IWineD3DSurfaceImpl *target,
     1250        const struct wined3d_format_desc *ds_format_desc) DECLSPEC_HIDDEN;
     1251#endif
    12421252void context_destroy(IWineD3DDeviceImpl *This, struct wined3d_context *context) DECLSPEC_HIDDEN;
    12431253void context_free_event_query(struct wined3d_event_query *query) 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