VirtualBox

Changeset 40388 in vbox


Ignore:
Timestamp:
Mar 7, 2012 12:44:46 PM (13 years ago)
Author:
vboxsync
Message:

wddm/3d: shared resource destroy handling fixes

Location:
trunk/src/VBox
Files:
23 edited

Legend:

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

    r40125 r40388  
    31303130            if (RT_SUCCESS(rc))
    31313131            {
    3132                 rc = VbglR3Init();
    3133                 AssertRC(rc);
    3134                 if (RT_SUCCESS(rc))
     3132//                rc = VbglR3Init();
     3133//                AssertRC(rc);
     3134//                if (RT_SUCCESS(rc))
    31353135                {
    31363136                    HRESULT hr = vboxDispCmInit();
     
    31463146                        }
    31473147                    }
    3148                     VbglR3Term();
     3148//                    VbglR3Term();
    31493149                }
    31503150            }
     
    31693169                if (hr == S_OK)
    31703170                {
    3171                     VbglR3Term();
     3171//                    VbglR3Term();
    31723172                    /// @todo RTR3Term();
    31733173                    return TRUE;
     
    56725672        for (UINT i = 0; i < pRc->cAllocations; ++i)
    56735673        {
    5674             BOOL fSetDontDelete = FALSE;
     5674            BOOL fSetDelete = FALSE;
    56755675            PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[i];
    56765676            if (pAlloc->hSharedHandle)
    56775677            {
     5678                /* using one and the same shared resource by different clients could lead to the situation where one client can still refer to the resource
     5679                 * while another one has deleted it
     5680                 * this could lead to gl state corruption on both host and guest side.
     5681                 * This is why we take extra care to avoid it.
     5682                 * Until we do a vboxWddmShRcRefAlloc call below the resource is guarantied to be present, however it can be removed any time after the call
     5683                 * if cShRcRefs is non-zero, i.e. the current cliet is not the one deleting it.
     5684                 * We first explicitely say to wine that resource must NOT be accessed any more and that all references to it should be cleaned */
     5685                pAdapter->D3D.pfnVBoxWineExD3DRc9SetShRcState((IDirect3DResource9*)pAlloc->pD3DIf, VBOXWINEEX_SHRC_STATE_GL_DISABLE);
     5686
    56785687                DWORD cShRcRefs;
    56795688                HRESULT tmpHr = vboxWddmShRcRefAlloc(pDevice, pAlloc, FALSE, &cShRcRefs);
    5680                 if (cShRcRefs)
    5681                 {
    5682                     fSetDontDelete = TRUE;
     5689                if (!cShRcRefs)
     5690                {
     5691                    /* the current client IS the one deleting this resource */
     5692                    fSetDelete = TRUE;
    56835693                }
    56845694#ifdef DEBUG_misha
     
    56925702            }
    56935703
    5694             if (fSetDontDelete)
     5704            if (fSetDelete)
    56955705            {
    56965706                Assert(pAlloc->pD3DIf);
    5697                 pAdapter->D3D.pfnVBoxWineExD3DRc9SetDontDeleteGl((IDirect3DResource9*)pAlloc->pD3DIf);
     5707                pAdapter->D3D.pfnVBoxWineExD3DRc9SetShRcState((IDirect3DResource9*)pAlloc->pD3DIf, VBOXWINEEX_SHRC_STATE_GL_DELETE);
    56985708            }
    56995709
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispD3DIf.cpp

    r38982 r40388  
    8181        }
    8282
    83         pD3D->pfnVBoxWineExD3DRc9SetDontDeleteGl = (PFNVBOXWINEEXD3DRC9_SETDONTDELETEGL)GetProcAddress(pD3D->hD3DLib, "VBoxWineExD3DRc9SetDontDeleteGl");
    84         if (!pD3D->pfnVBoxWineExD3DRc9SetDontDeleteGl)
     83        pD3D->pfnVBoxWineExD3DRc9SetShRcState = (PFNVBOXWINEEXD3DRC9_SETSHRCSTATE)GetProcAddress(pD3D->hD3DLib, "VBoxWineExD3DRc9SetShRcState");
     84        if (!pD3D->pfnVBoxWineExD3DRc9SetShRcState)
    8585        {
    86             WARN(("no VBoxWineExD3DRc9SetDontDeleteGl"));
     86            WARN(("no VBoxWineExD3DRc9SetShRcState"));
    8787            break;
    8888        }
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispD3DIf.h

    r38982 r40388  
    4545    PFNVBOXWINEEXD3DDEV9_UPDATE pfnVBoxWineExD3DDev9Update;
    4646
    47     PFNVBOXWINEEXD3DRC9_SETDONTDELETEGL pfnVBoxWineExD3DRc9SetDontDeleteGl;
     47    PFNVBOXWINEEXD3DRC9_SETSHRCSTATE pfnVBoxWineExD3DRc9SetShRcState;
    4848
    4949    PFNVBOXWINEEXD3DSWAPCHAIN9_PRESENT pfnVBoxWineExD3DSwapchain9Present;
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/Makefile.kmk

    r39648 r40388  
    189189wined3dwddm_INCS           = vbox/libWineStub/include
    190190wined3dwddm_DEFS           = $(subst VBOX_WINE_WITH_SINGLE_SWAPCHAIN_CONTEXT,,$(wined3d_DEFS))
    191 wined3dwddm_DEFS          += VBOX_WITH_WDDM VBOX_WINE_WITH_SINGLE_CONTEXT
     191wined3dwddm_DEFS          += VBOX_WITH_WDDM VBOX_WINE_WITH_SINGLE_CONTEXT IN_VBOXLIBWINE
    192192wined3dwddm_SOURCES        = $(subst wined3d.def,wined3dwddm.def,$(wined3d_SOURCES)) vbox/VBoxDbgGl.c
    193193
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d9/d3d9_private.h

    r35650 r40388  
    4848#include "wine/wined3d.h"
    4949
    50 #ifdef VBOX_WITH_WDDM
    51 #include "../vbox/VBoxWineEx.h"
    52 #endif
    5350
    5451/* ===========================================================================
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d9/d3d9wddm.def

    r38982 r40388  
    1717  VBoxWineExD3DDev9Update
    1818  VBoxWineExD3DSwapchain9Present
    19   VBoxWineExD3DRc9SetDontDeleteGl
     19  VBoxWineExD3DRc9SetShRcState
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d9/device.c

    r39889 r40388  
    32823282
    32833283#ifdef VBOX_WITH_WDDM
    3284 VBOXWINEEX_DECL(HRESULT) VBoxWineExD3DRc9SetDontDeleteGl(IDirect3DResource9 *iface)
     3284VBOXWINEEX_DECL(HRESULT) VBoxWineExD3DRc9SetShRcState(IDirect3DResource9 *iface, VBOXWINEEX_SHRC_STATE enmState)
    32853285{
    32863286    D3DRESOURCETYPE enmType = IDirect3DResource9_GetType(iface);
     
    32923292            IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl*)iface ;
    32933293            wined3d_mutex_lock();
    3294             hr = IWineD3DResource_SetDontDeleteGl((IWineD3DResource*)This->wineD3DSurface);
     3294            hr = IWineD3DResource_SetShRcState((IWineD3DResource*)This->wineD3DSurface, enmState);
    32953295            wined3d_mutex_unlock();
    32963296            break;
     
    33003300            IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl*)iface ;
    33013301            wined3d_mutex_lock();
    3302             hr = IWineD3DResource_SetDontDeleteGl((IWineD3DResource*)This->wineD3DVolume);
     3302            hr = IWineD3DResource_SetShRcState((IWineD3DResource*)This->wineD3DVolume, enmState);
    33033303            wined3d_mutex_unlock();
    33043304            break;
     
    33083308            IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl*)iface ;
    33093309            wined3d_mutex_lock();
    3310             hr = IWineD3DResource_SetDontDeleteGl((IWineD3DResource*)This->wineD3DTexture);
     3310            hr = IWineD3DResource_SetShRcState((IWineD3DResource*)This->wineD3DTexture, enmState);
    33113311            wined3d_mutex_unlock();
    33123312            break;
     
    33163316            IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl*)iface ;
    33173317            wined3d_mutex_lock();
    3318             hr = IWineD3DResource_SetDontDeleteGl((IWineD3DResource*)This->wineD3DVolumeTexture);
     3318            hr = IWineD3DResource_SetShRcState((IWineD3DResource*)This->wineD3DVolumeTexture, enmState);
    33193319            wined3d_mutex_unlock();
    33203320            break;
     
    33243324            IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl*)iface ;
    33253325            wined3d_mutex_lock();
    3326             hr = IWineD3DResource_SetDontDeleteGl((IWineD3DResource*)This->wineD3DCubeTexture);
     3326            hr = IWineD3DResource_SetShRcState((IWineD3DResource*)This->wineD3DCubeTexture, enmState);
    33273327            wined3d_mutex_unlock();
    33283328            break;
     
    33323332            IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl*)iface ;
    33333333            wined3d_mutex_lock();
    3334             hr = IWineD3DResource_SetDontDeleteGl((IWineD3DResource*)This->wineD3DVertexBuffer);
     3334            hr = IWineD3DResource_SetShRcState((IWineD3DResource*)This->wineD3DVertexBuffer, enmState);
    33353335            wined3d_mutex_unlock();
    33363336            break;
     
    33403340            IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl*)iface ;
    33413341            wined3d_mutex_lock();
    3342             hr = IWineD3DResource_SetDontDeleteGl((IWineD3DResource*)This->wineD3DIndexBuffer);
     3342            hr = IWineD3DResource_SetShRcState((IWineD3DResource*)This->wineD3DIndexBuffer, enmState);
    33433343            wined3d_mutex_unlock();
    33443344            break;
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/wined3d.h

    r39602 r40388  
    34343434
    34353435#ifdef VBOX_WITH_WDDM
    3436     HRESULT (STDMETHODCALLTYPE *SetDontDeleteGl)(
    3437         IWineD3DResource* This);
     3436    HRESULT (STDMETHODCALLTYPE *SetShRcState)(
     3437        IWineD3DResource* This,
     3438        VBOXWINEEX_SHRC_STATE enmState);
    34383439#endif
    34393440
     
    34613462#define IWineD3DResource_GetType(This) (This)->lpVtbl->GetType(This)
    34623463# ifdef VBOX_WITH_WDDM
    3463 #  define IWineD3DResource_SetDontDeleteGl(This) (This)->lpVtbl->SetDontDeleteGl(This)
     3464#  define IWineD3DResource_SetShRcState(This, enmState) (This)->lpVtbl->SetShRcState(This, enmState)
    34643465# endif
    34653466#endif
     
    40694070
    40704071#ifdef VBOX_WITH_WDDM
    4071     HRESULT (STDMETHODCALLTYPE *SetDontDeleteGl)(
    4072         IWineD3DResource* This);
     4072    HRESULT (STDMETHODCALLTYPE *SetShRcState)(
     4073        IWineD3DResource* This,
     4074        VBOXWINEEX_SHRC_STATE enmState);
    40734075#endif
    40744076
     
    46894691
    46904692#ifdef VBOX_WITH_WDDM
    4691     HRESULT (STDMETHODCALLTYPE *SetDontDeleteGl)(
    4692         IWineD3DResource* This);
     4693    HRESULT (STDMETHODCALLTYPE *SetShRcState)(
     4694        IWineD3DResource* This,
     4695        VBOXWINEEX_SHRC_STATE enmState);
    46934696#endif
    46944697
     
    49084911
    49094912#ifdef VBOX_WITH_WDDM
    4910     HRESULT (STDMETHODCALLTYPE *SetDontDeleteGl)(
    4911         IWineD3DResource* This);
     4913    HRESULT (STDMETHODCALLTYPE *SetShRcState)(
     4914        IWineD3DResource* This,
     4915        VBOXWINEEX_SHRC_STATE enmState);
    49124916#endif
    49134917
     
    51595163
    51605164#ifdef VBOX_WITH_WDDM
    5161     HRESULT (STDMETHODCALLTYPE *SetDontDeleteGl)(
    5162         IWineD3DTexture* This);
     5165    HRESULT (STDMETHODCALLTYPE *SetShRcState)(
     5166        IWineD3DTexture* This,
     5167        VBOXWINEEX_SHRC_STATE enmState);
    51635168#endif
    51645169
     
    54105415
    54115416#ifdef VBOX_WITH_WDDM
    5412     HRESULT (STDMETHODCALLTYPE *SetDontDeleteGl)(
    5413         IWineD3DCubeTexture* This);
     5417    HRESULT (STDMETHODCALLTYPE *SetShRcState)(
     5418        IWineD3DCubeTexture* This,
     5419        VBOXWINEEX_SHRC_STATE enmState);
    54145420#endif
    54155421
     
    56655671
    56665672#ifdef VBOX_WITH_WDDM
    5667     HRESULT (STDMETHODCALLTYPE *SetDontDeleteGl)(
    5668         IWineD3DResource* This);
     5673    HRESULT (STDMETHODCALLTYPE *SetShRcState)(
     5674        IWineD3DResource* This,
     5675        VBOXWINEEX_SHRC_STATE enmState);
    56695676#endif
    56705677
     
    64266433
    64276434#ifdef VBOX_WITH_WDDM
    6428     HRESULT (STDMETHODCALLTYPE *SetDontDeleteGl)(
    6429         IWineD3DResource* This);
     6435    HRESULT (STDMETHODCALLTYPE *SetShRcState)(
     6436        IWineD3DResource* This,
     6437        VBOXWINEEX_SHRC_STATE enmState);
    64306438#endif
    64316439
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/vbox/VBoxWineEx.h

    r38982 r40388  
    1515#ifndef ___VBoxWineEx_h__
    1616#define ___VBoxWineEx_h__
     17
     18typedef enum
     19{
     20    VBOXWINEEX_SHRC_STATE_UNDEFINED = 0,
     21    /* the underlying GL resource can not be used because it can be removed concurrently by other SHRC client */
     22    VBOXWINEEX_SHRC_STATE_GL_DISABLE,
     23    /* the given client is requested to delete the underlying GL resource on SHRC termination */
     24    VBOXWINEEX_SHRC_STATE_GL_DELETE
     25} VBOXWINEEX_SHRC_STATE;
     26
     27#ifndef IN_VBOXLIBWINE
    1728
    1829#define VBOXWINEEX_VERSION 1
     
    4253typedef FNVBOXWINEEXD3DDEV9_UPDATE *PFNVBOXWINEEXD3DDEV9_UPDATE;
    4354
    44 typedef VBOXWINEEX_DECL(HRESULT) FNVBOXWINEEXD3DRC9_SETDONTDELETEGL(IDirect3DResource9 *iface);
    45 typedef FNVBOXWINEEXD3DRC9_SETDONTDELETEGL *PFNVBOXWINEEXD3DRC9_SETDONTDELETEGL;
     55typedef VBOXWINEEX_DECL(HRESULT) FNVBOXWINEEXD3DRC9_SETSHRCSTATE(IDirect3DResource9 *iface, VBOXWINEEX_SHRC_STATE enmState);
     56typedef FNVBOXWINEEXD3DRC9_SETSHRCSTATE *PFNVBOXWINEEXD3DRC9_SETSHRCSTATE;
    4657
    4758typedef VBOXWINEEX_DECL(HRESULT) FNVBOXWINEEXD3DSWAPCHAIN9_PRESENT(IDirect3DSwapChain9 *iface, IDirect3DSurface9 *surf);
     
    6980                                                    IDirect3DDevice9Ex **outIface); /* update device parameters */
    7081
    71 VBOXWINEEX_DECL(HRESULT) VBoxWineExD3DRc9SetDontDeleteGl(IDirect3DResource9 *iface);
     82VBOXWINEEX_DECL(HRESULT) VBoxWineExD3DRc9SetShRcState(IDirect3DResource9 *iface, VBOXWINEEX_SHRC_STATE enmState);
    7283
    7384VBOXWINEEX_DECL(HRESULT) VBoxWineExD3DSwapchain9Present(IDirect3DSwapChain9 *iface,
     
    7788#endif
    7889
     90#endif /* #ifndef IN_VBOXLIBWINE */
     91
    7992#endif
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/vbox/libWineStub/include/wine/wined3d.h

    r39602 r40388  
    66#ifndef __WIDL_WINED3D_H
    77#define __WIDL_WINED3D_H
     8
     9#ifdef VBOX_WITH_WDDM
     10#include "../../../vbox/VBoxWineEx.h"
     11#endif
    812
    913# define DECLSPEC_HIDDEN
     
    34323436
    34333437#ifdef VBOX_WITH_WDDM
    3434     HRESULT (STDMETHODCALLTYPE *SetDontDeleteGl)(
    3435         IWineD3DResource* This);
     3438    HRESULT (STDMETHODCALLTYPE *SetShRcState)(
     3439        IWineD3DResource* This,
     3440        VBOXWINEEX_SHRC_STATE enmState);
    34363441#endif
    34373442
     
    34593464#define IWineD3DResource_GetType(This) (This)->lpVtbl->GetType(This)
    34603465# ifdef VBOX_WITH_WDDM
    3461 #  define IWineD3DResource_SetDontDeleteGl(This) (This)->lpVtbl->SetDontDeleteGl(This)
     3466#  define IWineD3DResource_SetShRcState(This, enmState) (This)->lpVtbl->SetShRcState(This, enmState)
    34623467# endif
    34633468#endif
     
    40674072
    40684073#ifdef VBOX_WITH_WDDM
    4069     HRESULT (STDMETHODCALLTYPE *SetDontDeleteGl)(
    4070         IWineD3DResource* This);
     4074    HRESULT (STDMETHODCALLTYPE *SetShRcState)(
     4075        IWineD3DResource* This,
     4076        VBOXWINEEX_SHRC_STATE enmState);
    40714077#endif
    40724078
     
    46874693
    46884694#ifdef VBOX_WITH_WDDM
    4689     HRESULT (STDMETHODCALLTYPE *SetDontDeleteGl)(
    4690         IWineD3DResource* This);
     4695    HRESULT (STDMETHODCALLTYPE *SetShRcState)(
     4696        IWineD3DResource* This,
     4697        VBOXWINEEX_SHRC_STATE enmState);
    46914698#endif
    46924699
     
    49064913
    49074914#ifdef VBOX_WITH_WDDM
    4908     HRESULT (STDMETHODCALLTYPE *SetDontDeleteGl)(
    4909         IWineD3DResource* This);
     4915    HRESULT (STDMETHODCALLTYPE *SetShRcState)(
     4916        IWineD3DResource* This,
     4917        VBOXWINEEX_SHRC_STATE enmState);
    49104918#endif
    49114919
     
    51575165
    51585166#ifdef VBOX_WITH_WDDM
    5159     HRESULT (STDMETHODCALLTYPE *SetDontDeleteGl)(
    5160         IWineD3DResource* This);
     5167    HRESULT (STDMETHODCALLTYPE *SetShRcState)(
     5168        IWineD3DResource* This,
     5169        VBOXWINEEX_SHRC_STATE enmState);
    51615170#endif
    51625171
     
    54085417
    54095418#ifdef VBOX_WITH_WDDM
    5410     HRESULT (STDMETHODCALLTYPE *SetDontDeleteGl)(
    5411         IWineD3DResource* This);
     5419    HRESULT (STDMETHODCALLTYPE *SetShRcState)(
     5420        IWineD3DResource* This,
     5421        VBOXWINEEX_SHRC_STATE enmState);
    54125422#endif
    54135423
     
    56635673
    56645674#ifdef VBOX_WITH_WDDM
    5665     HRESULT (STDMETHODCALLTYPE *SetDontDeleteGl)(
    5666         IWineD3DResource* This);
     5675    HRESULT (STDMETHODCALLTYPE *SetShRcState)(
     5676        IWineD3DResource* This,
     5677        VBOXWINEEX_SHRC_STATE enmState);
    56675678#endif
    56685679
     
    64246435
    64256436#ifdef VBOX_WITH_WDDM
    6426     HRESULT (STDMETHODCALLTYPE *SetDontDeleteGl)(
    6427         IWineD3DResource* This);
     6437    HRESULT (STDMETHODCALLTYPE *SetShRcState)(
     6438        IWineD3DResource* This,
     6439        VBOXWINEEX_SHRC_STATE enmState);
    64286440#endif
    64296441
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/basetexture.c

    r39899 r40388  
    296296    TRACE("(%p) : About to bind texture\n", This);
    297297
     298#ifdef VBOX_WITH_WDDM
     299    Assert(!VBOXSHRC_IS_DISABLED(This));
     300#endif
     301
    298302    This->baseTexture.is_srgb = srgb; /* SRGB mode cache for PreLoad calls outside drawprim */
    299303    if(srgb) {
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/buffer.c

    r38982 r40388  
    14501450    buffer_GetType,
    14511451#ifdef VBOX_WITH_WDDM
    1452     IWineD3DResourceImpl_SetDontDeleteGl,
     1452    IWineD3DResourceImpl_SetShRcState,
    14531453#endif
    14541454    /* IWineD3DBuffer methods */
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/cubetexture.c

    r38982 r40388  
    246246
    247247#ifdef VBOX_WITH_WDDM
    248 static HRESULT WINAPI IWineD3DCubeTextureImpl_SetDontDeleteGl(IWineD3DCubeTexture *iface) {
     248static HRESULT WINAPI IWineD3DCubeTextureImpl_SetShRcState(IWineD3DCubeTexture *iface, VBOXWINEEX_SHRC_STATE enmState) {
    249249    IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl*)iface;
    250     HRESULT hr = IWineD3DResourceImpl_SetDontDeleteGl((IWineD3DResource*)iface);
     250    HRESULT hr = IWineD3DResourceImpl_SetShRcState((IWineD3DResource*)iface, enmState);
    251251    unsigned int i, j;
    252252
    253253    if (FAILED(hr))
    254254    {
    255         ERR("IWineD3DResource_SetDontDeleteGl failed");
     255        ERR("IWineD3DResource_SetShRcState failed");
    256256        return hr;
    257257    }
     
    260260        for (j = WINED3DCUBEMAP_FACE_POSITIVE_X; j <= WINED3DCUBEMAP_FACE_NEGATIVE_Z; ++j) {
    261261            if (This->surfaces[j][i]) {
    262                 HRESULT tmpHr = IWineD3DResource_SetDontDeleteGl((IWineD3DResource*)This->surfaces[j][i]);
     262                HRESULT tmpHr = IWineD3DResource_SetShRcState((IWineD3DResource*)This->surfaces[j][i], enmState);
    263263                Assert(tmpHr == S_OK);
    264264            }
    265265        }
    266266    }
     267
     268    device_cleanup_durtify_texture_target(This->resource.device, ((IWineD3DSurfaceImpl*)This->surfaces[j][i])->texture_target);
    267269
    268270    return WINED3D_OK;
     
    444446    IWineD3DCubeTextureImpl_GetType,
    445447#ifdef VBOX_WITH_WDDM
    446     IWineD3DCubeTextureImpl_SetDontDeleteGl,
     448    IWineD3DCubeTextureImpl_SetShRcState,
    447449#endif
    448450    /* IWineD3DBaseTexture */
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/device.c

    r39602 r40388  
    70107010    }
    70117011    return WINED3D_OK;
     7012}
     7013
     7014/* context activation is done by the caller */
     7015void device_cleanup_durtify_texture_target(IWineD3DDeviceImpl *This, GLuint texture_target)
     7016{
     7017    const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
     7018    unsigned int i;
     7019    GLint active_texture=GL_TEXTURE0_ARB;
     7020    ENTER_GL();
     7021    glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture);
     7022
     7023    for (i = 0; i < gl_info->limits.textures; ++i)
     7024    {
     7025        /* Make appropriate texture active */
     7026        GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + i));
     7027        checkGLcall("glActiveTextureARB");
     7028
     7029        /* don't do  glGet GL_TEXTURE_BINDING_xxx just ensure nothing is bound to IWineD3DSurfaceImpl::texture_target,
     7030         * and dirtify the state later */
     7031        if (texture_target == GL_TEXTURE_2D)
     7032            glBindTexture(texture_target, This->dummyTextureName[i]);
     7033        else
     7034            glBindTexture(texture_target, 0);
     7035    }
     7036
     7037    /* restore tha active texture unit */
     7038    GL_EXTCALL(glActiveTextureARB(active_texture));
     7039    checkGLcall("glActiveTextureARB");
     7040    LEAVE_GL();
     7041
     7042    /* dirtify */
     7043    for (i = 0; i < gl_info->limits.textures; ++i)
     7044    {
     7045        DWORD active_sampler = This->rev_tex_unit_map[active_texture - GL_TEXTURE0_ARB + i];
     7046
     7047        if (active_sampler != WINED3D_UNMAPPED_STAGE)
     7048        {
     7049            IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(active_sampler));
     7050        }
     7051    }
     7052
     7053    /* do flush to ensure this all goes to host */
     7054    wglFlush();
    70127055}
    70137056#endif
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/resource.c

    r38982 r40388  
    288288
    289289#ifdef VBOX_WITH_WDDM
    290 HRESULT WINAPI IWineD3DResourceImpl_SetDontDeleteGl(IWineD3DResource *iface) {
     290HRESULT WINAPI IWineD3DResourceImpl_SetShRcState(IWineD3DResource *iface, VBOXWINEEX_SHRC_STATE enmState) {
    291291    IWineD3DResourceImpl *This = (IWineD3DResourceImpl*)iface;
    292292    if (!VBOXSHRC_IS_SHARED(This))
     
    296296    }
    297297
    298     VBOXSHRC_SET_DONT_DELETE(This);
    299     return WINED3D_OK;
    300 }
    301 #endif
     298    switch (enmState)
     299    {
     300        case VBOXWINEEX_SHRC_STATE_GL_DISABLE:
     301            VBOXSHRC_SET_DISABLE(This);
     302            break;
     303        case VBOXWINEEX_SHRC_STATE_GL_DELETE:
     304            VBOXSHRC_SET_DELETE(This);
     305            break;
     306        default:
     307            ERR("invalid arg");
     308            return E_INVALIDARG;
     309    }
     310
     311    return WINED3D_OK;
     312}
     313#endif
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/surface.c

    r39899 r40388  
    672672    IWineD3DSurface_BindTexture((IWineD3DSurface *)This, srgb);
    673673}
     674
    674675
    675676/* This function checks if the primary render target uses the 8bit paletted format. */
     
    28682869    IWineD3DBaseTexture *baseTexture = NULL;
    28692870
     2871#ifdef VBOX_WITH_WDDM
     2872    Assert(!VBOXSHRC_IS_DISABLED(This));
     2873#endif
     2874
    28702875    TRACE("(%p)Checking to see if the container is a base texture\n", This);
    28712876    if (IWineD3DSurface_GetContainer(iface, &IID_IWineD3DBaseTexture, (void **)&baseTexture) == WINED3D_OK) {
     
    53445349}
    53455350
     5351#ifdef VBOX_WITH_WDDM
     5352static HRESULT WINAPI IWineD3DSurfaceImpl_SetShRcState(IWineD3DSurface *iface, VBOXWINEEX_SHRC_STATE enmState) {
     5353    IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl*)iface;
     5354    IWineD3DBaseTextureImpl *texture = NULL;
     5355    HRESULT hr;
     5356    unsigned int i;
     5357
     5358    if (SUCCEEDED(IWineD3DSurface_GetContainer(iface, &IID_IWineD3DBaseTexture, (void **)&texture)))
     5359    {
     5360        /* this is a texture, check that the */
     5361        switch (enmState)
     5362        {
     5363            case VBOXWINEEX_SHRC_STATE_GL_DISABLE:
     5364                if (!VBOXSHRC_IS_DISABLED(texture))
     5365                {
     5366                    ERR("directly doing SetShRcState for texture surface not allowed!");
     5367                    return E_FAIL;
     5368                }
     5369                break;
     5370            case VBOXWINEEX_SHRC_STATE_GL_DELETE:
     5371                if (!VBOXSHRC_IS_DELETE(texture))
     5372                {
     5373                    ERR("directly doing SetShRcState for texture surface not allowed!");
     5374                    return E_FAIL;
     5375                }
     5376                break;
     5377            default:
     5378                ERR("invalid arg");
     5379                return E_INVALIDARG;
     5380        }
     5381
     5382        IWineD3DBaseTexture_Release(texture);
     5383    }
     5384
     5385
     5386    hr = IWineD3DResourceImpl_SetShRcState((IWineD3DResource*)iface, enmState);
     5387    if (FAILED(hr))
     5388    {
     5389        ERR("IWineD3DResource_SetShRcState failed");
     5390        return hr;
     5391    }
     5392
     5393    if (!texture)
     5394        device_cleanup_durtify_texture_target(This->resource.device, This->texture_target);
     5395
     5396    return WINED3D_OK;
     5397}
     5398#endif
     5399
    53465400const IWineD3DSurfaceVtbl IWineD3DSurface_Vtbl =
    53475401{
     
    53615415    IWineD3DBaseSurfaceImpl_GetType,
    53625416#ifdef VBOX_WITH_WDDM
    5363     IWineD3DResourceImpl_SetDontDeleteGl,
     5417    IWineD3DSurfaceImpl_SetShRcState,
    53645418#endif
    53655419    /* IWineD3DSurface */
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/surface_gdi.c

    r38982 r40388  
    667667    IWineD3DBaseSurfaceImpl_GetType,
    668668#ifdef VBOX_WITH_WDDM
    669     IWineD3DResourceImpl_SetDontDeleteGl,
     669    IWineD3DResourceImpl_SetShRcState,
    670670#endif
    671671    /* IWineD3DSurface */
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/texture.c

    r39899 r40388  
    232232
    233233#ifdef VBOX_WITH_WDDM
    234 static HRESULT WINAPI IWineD3DTextureImpl_SetDontDeleteGl(IWineD3DTexture *iface) {
     234static HRESULT WINAPI IWineD3DTextureImpl_SetShRcState(IWineD3DTexture *iface, VBOXWINEEX_SHRC_STATE enmState) {
    235235    IWineD3DTextureImpl *This = (IWineD3DTextureImpl*)iface;
    236     HRESULT hr = IWineD3DResourceImpl_SetDontDeleteGl((IWineD3DResource*)iface);
     236    HRESULT hr = IWineD3DResourceImpl_SetShRcState((IWineD3DResource*)iface, enmState);
    237237    unsigned int i;
    238238
    239239    if (FAILED(hr))
    240240    {
    241         ERR("IWineD3DResource_SetDontDeleteGl failed");
     241        ERR("IWineD3DResource_SetShRcState failed");
    242242        return hr;
    243243    }
     
    247247        if (This->surfaces[i])
    248248        {
    249             HRESULT tmpHr = IWineD3DResource_SetDontDeleteGl((IWineD3DResource*)This->surfaces[i]);
     249            HRESULT tmpHr = IWineD3DResource_SetShRcState((IWineD3DResource*)This->surfaces[i], enmState);
    250250            Assert(tmpHr == S_OK);
    251251        }
    252252    }
     253
     254    device_cleanup_durtify_texture_target(This->resource.device, This->target);
    253255
    254256    return WINED3D_OK;
     
    299301
    300302    TRACE("(%p) : relay to BaseTexture\n", This);
     303
     304#ifdef VBOX_WITH_WDDM
     305    Assert(!VBOXSHRC_IS_DISABLED(This));
     306#endif
    301307
    302308    hr = basetexture_bind((IWineD3DBaseTexture *)iface, srgb, &set_gl_texture_desc);
     
    451457    IWineD3DTextureImpl_GetType,
    452458#ifdef VBOX_WITH_WDDM
    453     IWineD3DTextureImpl_SetDontDeleteGl,
     459    IWineD3DTextureImpl_SetShRcState,
    454460#endif
    455461    /* IWineD3DBaseTexture */
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/vboxsharedrc.h

    r39648 r40388  
    1919#define VBOXSHRC_F_SHARED              0x00000001 /* shared rc */
    2020#define VBOXSHRC_F_SHARED_OPENED       0x00000002 /* if set shared rc is opened, otherwise it is created */
    21 #define VBOXSHRC_F_DONT_DELETE         0x00000004 /* don't delete gl resources on d3d resource deletion */
     21#define VBOXSHRC_F_GL_DISABLE          0x00000004 /* don't delete gl resources on d3d resource deletion */
     22#define VBOXSHRC_F_GL_DELETE           0x00000008 /* don't delete gl resources on d3d resource deletion */
    2223
    2324#define VBOXSHRC_GET_SHAREFLAFS(_o) ((_o)->resource.sharerc_flags)
     
    3031#define VBOXSHRC_SET_SHARED(_o) (VBOXSHRC_GET_SHAREFLAFS(_o) |= VBOXSHRC_F_SHARED)
    3132#define VBOXSHRC_SET_SHARED_OPENED(_o) (VBOXSHRC_GET_SHAREFLAFS(_o) |= VBOXSHRC_F_SHARED_OPENED)
    32 #define VBOXSHRC_SET_DONT_DELETE(_o) (VBOXSHRC_GET_SHAREFLAFS(_o) |= VBOXSHRC_F_DONT_DELETE)
     33#define VBOXSHRC_SET_DISABLE(_o) (VBOXSHRC_GET_SHAREFLAFS(_o) |= VBOXSHRC_F_GL_DISABLE)
     34#define VBOXSHRC_SET_DELETE(_o) (VBOXSHRC_GET_SHAREFLAFS(_o) = (VBOXSHRC_GET_SHAREFLAFS(_o) | VBOXSHRC_F_GL_DELETE) & (~VBOXSHRC_F_GL_DISABLE))
    3335
    3436#define VBOXSHRC_IS_SHARED(_o) (!!(VBOXSHRC_GET_SHAREFLAFS(_o) & VBOXSHRC_F_SHARED))
    3537#define VBOXSHRC_IS_SHARED_OPENED(_o) (!!(VBOXSHRC_GET_SHAREFLAFS(_o) & VBOXSHRC_F_SHARED_OPENED))
    3638#define VBOXSHRC_IS_SHARED_UNLOCKED(_o) (VBOXSHRC_IS_SHARED(_o) && !VBOXSHRC_IS_LOCKED(_o))
    37 #define VBOXSHRC_CAN_DELETE(_d, _o) ( \
    38         !VBOXSHRC_IS_SHARED(_o) \
    39         || !(VBOXSHRC_GET_SHAREFLAFS(_o) & VBOXSHRC_F_DONT_DELETE) \
     39#define VBOXSHRC_IS_DISABLED(_o) ( \
     40        VBOXSHRC_IS_SHARED(_o) \
     41        && (VBOXSHRC_GET_SHAREFLAFS(_o) & VBOXSHRC_F_GL_DISABLE) \
    4042    )
     43#define VBOXSHRC_IS_DELETE(_o) ( \
     44        VBOXSHRC_IS_SHARED(_o) \
     45        && (VBOXSHRC_GET_SHAREFLAFS(_o) & VBOXSHRC_F_GL_DELETE) \
     46    )
     47
     48#define VBOXSHRC_CAN_DELETE(_d, _o) (!VBOXSHRC_IS_DISABLED(_o))
    4149
    4250#define VBOXSHRC_LOCK(_o) do{ \
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/volume.c

    r38982 r40388  
    382382    IWineD3DVolumeImpl_GetType,
    383383#ifdef VBOX_WITH_WDDM
    384     IWineD3DResourceImpl_SetDontDeleteGl,
     384    IWineD3DResourceImpl_SetShRcState,
    385385#endif
    386386    /* IWineD3DVolume */
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/volumetexture.c

    r38982 r40388  
    340340    IWineD3DVolumeTextureImpl_GetType,
    341341#ifdef VBOX_WITH_WDDM
    342     IWineD3DResourceImpl_SetDontDeleteGl,
     342    IWineD3DResourceImpl_SetShRcState,
    343343#endif
    344344    /* BaseTexture */
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/wined3d_private.h

    r39899 r40388  
    18111811LRESULT device_process_message(IWineD3DDeviceImpl *device, HWND window,
    18121812        UINT message, WPARAM wparam, LPARAM lparam, WNDPROC proc) DECLSPEC_HIDDEN;
     1813#else
     1814void device_cleanup_durtify_texture_target(IWineD3DDeviceImpl *This, GLuint texture_target);
    18131815#endif
    18141816void device_resource_add(IWineD3DDeviceImpl *This, IWineD3DResource *resource) DECLSPEC_HIDDEN;
     
    19021904
    19031905#ifdef VBOX_WITH_WDDM
    1904 HRESULT WINAPI IWineD3DResourceImpl_SetDontDeleteGl(IWineD3DResource *iface) ;
     1906HRESULT WINAPI IWineD3DResourceImpl_SetShRcState(IWineD3DResource *iface, VBOXWINEEX_SHRC_STATE enmState);
    19051907#endif
    19061908
  • trunk/src/VBox/GuestHost/OpenGL/util/error.c

    r40267 r40388  
    251251        va_end( args );
    252252
    253 #if defined(WINDOWS) && defined(DEBUG)/* && !defined(IN_GUEST) */
     253#if defined(WINDOWS) && defined(DEBUG) && !defined(IN_GUEST)
    254254        DebugBreak();
    255255#endif
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