VirtualBox

Changeset 41109 in vbox for trunk/src/VBox/Additions/WINNT


Ignore:
Timestamp:
May 2, 2012 8:37:46 AM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
77709
Message:

crOpenGL,wined3d,wddm: second part of fixing resource leakage, basics for cr commands submission from r0 miniport driver (for r0 visible region reporting, WPF 3D rendering fixes w/o Aero, etc.)

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

Legend:

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

    r41058 r41109  
    24692469    return hr;
    24702470}
    2471 
    2472 static HRESULT vboxWddmShRcRefAlloc(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_ALLOCATION pAlloc, BOOL fAddRef, DWORD *pcRefs)
    2473 {
    2474     D3DDDICB_ESCAPE DdiEscape = {0};
    2475     VBOXDISPIFESCAPE_SHRC_REF Data = {0};
    2476     DdiEscape.hContext = pDevice->DefaultContext.ContextInfo.hContext;
    2477     DdiEscape.hDevice = pDevice->hDevice;
    2478     DdiEscape.Flags.HardwareAccess = 1;
    2479     DdiEscape.pPrivateDriverData = &Data;
    2480     DdiEscape.PrivateDriverDataSize = sizeof (Data);
    2481     Data.EscapeHdr.escapeCode = fAddRef ? VBOXESC_SHRC_ADDREF : VBOXESC_SHRC_RELEASE;
    2482     Data.hAlloc = (uint64_t)pAlloc->hAllocation;
    2483     HRESULT hr = pDevice->RtCallbacks.pfnEscapeCb(pDevice->pAdapter->hAdapter, &DdiEscape);
    2484     if (FAILED(hr))
    2485     {
    2486         WARN(("pfnEscapeCb, hr (0x%x)", hr));
    2487         return TRUE;
    2488     }
    2489 
    2490     LOG(("shrc(0x%p) refs(%d)", (void*)pAlloc->hSharedHandle, Data.EscapeHdr.u32CmdSpecific));
    2491     if (pcRefs)
    2492         *pcRefs = Data.EscapeHdr.u32CmdSpecific;
    2493 
    2494     return hr;
    2495 }
    2496 
    2497 static HRESULT vboxWddmShRcRefRc(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_RESOURCE pRc, BOOL fAddRef, DWORD *pcRefs)
    2498 {
    2499     Assert(pRc->RcDesc.fFlags.SharedResource);
    2500     DWORD cTotalRefs = 0;
    2501     HRESULT hr = S_OK;
    2502     for (DWORD i = 0; i < pRc->cAllocations; ++i)
    2503     {
    2504         DWORD cRefs = 0;
    2505         PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[i];
    2506         if(!pAlloc->hSharedHandle)
    2507             continue;
    2508 
    2509         hr = vboxWddmShRcRefAlloc(pDevice, pAlloc, fAddRef, &cRefs);
    2510 
    2511         if (FAILED(hr))
    2512         {
    2513             WARN(("vboxWddmShRcRefAlloc failed, hr()0x%x", hr));
    2514             for (DWORD j = 0; j < i; ++j)
    2515             {
    2516                 PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[i];
    2517                 if(!pAlloc->hSharedHandle)
    2518                     continue;
    2519                 HRESULT tmpHr = vboxWddmShRcRefAlloc(pDevice, pAlloc, !fAddRef, NULL);
    2520                 Assert(SUCCEEDED(tmpHr));
    2521             }
    2522             return hr;
    2523         }
    2524 
    2525         /* success! */
    2526         cTotalRefs += cRefs;
    2527     }
    2528 
    2529     Assert(cTotalRefs || !fAddRef);
    2530 
    2531     /* success! */
    2532     if (pcRefs)
    2533         *pcRefs = cTotalRefs;
    2534 
    2535     return S_OK;
    2536 }
    2537 
    25382471
    25392472static HRESULT vboxWddmSwapchainChkCreateIf(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain)
     
    56815614                    if (pResource->Flags.SharedResource)
    56825615                    {
    5683                         if (pAllocation->hSharedHandle)
    5684                         {
    5685                             vboxWddmShRcRefAlloc(pDevice, pAllocation, TRUE, NULL);
    5686                         }
    56875616#ifdef DEBUG_misha
    56885617                        Assert(VBOXWDDMDISP_IS_TEXTURE(pResource->Flags));
     
    57475676        for (UINT i = 0; i < pRc->cAllocations; ++i)
    57485677        {
    5749             BOOL fSetDelete = FALSE;
    57505678            PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[i];
    57515679            if (pAlloc->hSharedHandle)
    57525680            {
    5753                 /* using one and the same shared resource by different clients could lead to the situation where one client can still refer to the resource
    5754                  * while another one has deleted it
    5755                  * this could lead to gl state corruption on both host and guest side.
    5756                  * This is why we take extra care to avoid it.
    5757                  * Until we do a vboxWddmShRcRefAlloc call below the resource is guarantied to be present, however it can be removed any time after the call
    5758                  * if cShRcRefs is non-zero, i.e. the current cliet is not the one deleting it.
    5759                  * We first explicitely say to wine that resource must NOT be accessed any more and that all references to it should be cleaned */
    5760                 pAdapter->D3D.pfnVBoxWineExD3DRc9SetShRcState((IDirect3DResource9*)pAlloc->pD3DIf, VBOXWINEEX_SHRC_STATE_GL_DISABLE);
    5761 
    5762                 DWORD cShRcRefs;
    5763                 HRESULT tmpHr = vboxWddmShRcRefAlloc(pDevice, pAlloc, FALSE, &cShRcRefs);
    5764                 if (!cShRcRefs)
    5765                 {
    5766                     /* the current client IS the one deleting this resource */
    5767                     fSetDelete = TRUE;
    5768                 }
    57695681#ifdef DEBUG_misha
    57705682                vboxVDbgPrint(("\n\n********\n(0x%x:0n%d)Shared DESTROYED pAlloc(0x%p), hRc(0x%p), hAl(0x%p), "
     
    57755687                            ));
    57765688#endif
    5777             }
    5778 
    5779             if (fSetDelete)
    5780             {
    5781                 Assert(pAlloc->pD3DIf);
    5782                 pAdapter->D3D.pfnVBoxWineExD3DRc9SetShRcState((IDirect3DResource9*)pAlloc->pD3DIf, VBOXWINEEX_SHRC_STATE_GL_DELETE);
    57835689            }
    57845690
     
    70916997                    Assert(pAllocation->hSharedHandle);
    70926998#endif
    7093 
    7094                     vboxWddmShRcRefAlloc(pDevice, pAllocation, TRUE, NULL);
    7095 
    70966999                    vboxVDbgPrint(("\n\n********\n(0x%x:0n%d)Shared OPENNED pAlloc(0x%p), hRc(0x%p), hAl(0x%p), "
    70977000                                    "Handle(0x%x), (0n%d) \n***********\n\n",
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/Makefile.kmk

    r40897 r41109  
    8787 endif
    8888 VBoxVideoWddm_DEFS       += LOG_TO_BACKDOOR
    89  VBoxVideoWddm_INCS       += ../../../include .. . ../../../../common/VBoxGuestLib $(VBOX_PATH_CROGL_INCLUDE)
     89 VBoxVideoWddm_INCS       += ../../../include .. . ../../../../common/VBoxGuestLib $(VBOX_PATH_CROGL_INCLUDE) $(VBOX_PATH_CROGL_GENFILES)
    9090 VBoxVideoWddm_LDFLAGS.x86 += /Entry:DriverEntry@8
    9191 VBoxVideoWddm_LDFLAGS.amd64 += /Entry:DriverEntry
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPCr.cpp

    r40897 r41109  
    2020#include "VBoxMPCr.h"
    2121
     22#include <VBox/HostServices/VBoxCrOpenGLSvc.h>
     23
    2224#include <cr_protocol.h>
    2325
    24 #include <VBox/HostServices/VBoxCrOpenGLSvc.h>
     26#if 0
     27#include <cr_pack.h>
     28
     29typedef struct PVBOXMP_SHGSMIPACKER
     30{
     31    PVBOXMP_DEVEXT pDevExt;
     32    CRPackContext CrPacker;
     33    CRPackBuffer CrBuffer;
     34} PVBOXMP_SHGSMIPACKER, *PPVBOXMP_SHGSMIPACKER;
     35
     36static void* vboxMpCrShgsmiBufferAlloc(PVBOXMP_DEVEXT pDevExt, HGSMISIZE cbData)
     37{
     38    return VBoxSHGSMIHeapBufferAlloc(&VBoxCommonFromDeviceExt(pDevExt)->guestCtx.heapCtx, cbData);
     39}
     40
     41static void vboxMpCrShgsmiBufferFree(PVBOXMP_DEVEXT pDevExt, void *pvBuffer)
     42{
     43    VBoxSHGSMIHeapBufferFree(&VBoxCommonFromDeviceExt(pDevExt)->guestCtx.heapCtx, pvBuffer);
     44}
     45
     46static void vboxMpCrShgsmiPackerCbFlush(void *pvFlush)
     47{
     48    PPVBOXMP_SHGSMIPACKER pPacker = (PPVBOXMP_SHGSMIPACKER)pvFlush;
     49
     50    crPackReleaseBuffer(&pPacker->CrPacker);
     51
     52    if (pPacker->CrBuffer.opcode_current != pPacker->CrBuffer.opcode_start)
     53    {
     54        CRMessageOpcodes *pHdr;
     55        unsigned int len;
     56        pHdr = vboxMpCrPackerPrependHeader(&pPacker->CrBuffer, &len, 0);
     57
     58        /*Send*/
     59    }
     60
     61
     62    crPackSetBuffer(&pPacker->CrPacker, &pPacker->CrBuffer);
     63    crPackResetPointers(&pPacker->CrPacker);
     64}
     65
     66static int vboxMpCrShgsmiPackerInit(PPVBOXMP_SHGSMIPACKER pPacker, PVBOXMP_DEVEXT pDevExt)
     67{
     68    memset(pPacker, 0, sizeof (*pPacker));
     69
     70    static const cbBuffer = 1000;
     71    void *pvBuffer = vboxMpCrShgsmiBufferAlloc(pDevExt, cbBuffer);
     72    if (!pvBuffer)
     73    {
     74        WARN(("vboxMpCrShgsmiBufferAlloc failed"));
     75        return VERR_NO_MEMORY;
     76    }
     77    crPackInitBuffer(&pPacker->CrBuffer, pvBuffer, cbBuffer, cbBuffer);
     78    crPackSetBuffer(&pPacker->CrPacker, &pPacker->CrBuffer);
     79    crPackFlushFunc(&pPacker->CrPacker, vboxMpCrShgsmiPackerCbFlush);
     80    crPackFlushArg(&pPacker->CrPacker, pPacker);
     81//    crPackSendHugeFunc( thread->packer, packspuHuge );
     82    return VINF_SUCCESS;
     83}
     84#endif
    2585
    2686static int vboxMpCrCtlAddRef(PVBOXMP_CRCTLCON pCrCtlCon)
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPShgsmi.cpp

    r40387 r41109  
    161161    KeAcquireSpinLock(&pHeap->HeapLock, &OldIrql);
    162162    HGSMIHeapFree(&pHeap->Heap, pvBuffer);
     163    KeReleaseSpinLock(&pHeap->HeapLock, OldIrql);
     164}
     165
     166void* VBoxSHGSMIHeapBufferAlloc(PVBOXSHGSMI pHeap, HGSMISIZE cbData)
     167{
     168    KIRQL OldIrql;
     169    void* pvData;
     170    Assert(KeGetCurrentIrql() <= DISPATCH_LEVEL);
     171    KeAcquireSpinLock(&pHeap->HeapLock, &OldIrql);
     172    pvData = HGSMIHeapBufferAlloc(&pHeap->Heap, cbData);
     173    KeReleaseSpinLock(&pHeap->HeapLock, OldIrql);
     174    if (!pvData)
     175        WARN(("HGSMIHeapAlloc failed!"));
     176    return pvData;
     177}
     178
     179void VBoxSHGSMIHeapBufferFree(PVBOXSHGSMI pHeap, void *pvBuffer)
     180{
     181    KIRQL OldIrql;
     182    Assert(KeGetCurrentIrql() <= DISPATCH_LEVEL);
     183    KeAcquireSpinLock(&pHeap->HeapLock, &OldIrql);
     184    HGSMIHeapBufferFree(&pHeap->Heap, pvBuffer);
    163185    KeReleaseSpinLock(&pHeap->HeapLock, OldIrql);
    164186}
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPShgsmi.h

    r40387 r41109  
    5858void* VBoxSHGSMIHeapAlloc(PVBOXSHGSMI pHeap, HGSMISIZE cbData, uint8_t u8Channel, uint16_t u16ChannelInfo);
    5959void VBoxSHGSMIHeapFree(PVBOXSHGSMI pHeap, void *pvBuffer);
     60void* VBoxSHGSMIHeapBufferAlloc(PVBOXSHGSMI pHeap, HGSMISIZE cbData);
     61void VBoxSHGSMIHeapBufferFree(PVBOXSHGSMI pHeap, void *pvBuffer);
    6062void* VBoxSHGSMICommandAlloc(PVBOXSHGSMI pHeap, HGSMISIZE cbData, uint8_t u8Channel, uint16_t u16ChannelInfo);
    6163void VBoxSHGSMICommandFree(PVBOXSHGSMI pHeap, void *pvBuffer);
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/basetexture.c

    r40388 r41109  
    3535#include "wined3d_private.h"
    3636
     37#define GLINFO_LOCATION      (This->resource.device->adapter->gl_info)
     38
    3739WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture);
    3840
     
    100102
    101103/* A GL context is provided by the caller */
    102 static void gltexture_delete(struct gl_texture *tex)
     104static void gltexture_delete(IWineD3DTextureImpl *This, struct gl_texture *tex)
    103105{
    104106    ENTER_GL();
    105     glDeleteTextures(1, &tex->name);
     107    texture_gl_delete(This, tex->name);
    106108    LEAVE_GL();
    107109    tex->name = 0;
     
    112114    IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
    113115    IWineD3DDeviceImpl *device = This->resource.device;
    114 
    115 #ifdef VBOX_WITH_WDDM
    116     if (!VBOXSHRC_CAN_DELETE(device, This))
    117     {
    118         This->baseTexture.texture_rgb.name = 0;
    119         This->baseTexture.texture_srgb.name = 0;
    120     }
    121     else
    122 #endif
    123     {
    124         struct wined3d_context *context = NULL;
    125         if (This->baseTexture.texture_rgb.name || This->baseTexture.texture_srgb.name)
    126         {
    127             context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
    128         }
    129 
    130         if(This->baseTexture.texture_rgb.name) {
    131             gltexture_delete(&This->baseTexture.texture_rgb);
    132         }
    133         if(This->baseTexture.texture_srgb.name) {
    134             gltexture_delete(&This->baseTexture.texture_srgb);
    135         }
    136 
    137         if (context) context_release(context);
    138     }
     116    struct wined3d_context *context = NULL;
     117    if (This->baseTexture.texture_rgb.name || This->baseTexture.texture_srgb.name)
     118    {
     119        context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
     120    }
     121
     122    if(This->baseTexture.texture_rgb.name) {
     123        gltexture_delete(This, &This->baseTexture.texture_rgb);
     124    }
     125    if(This->baseTexture.texture_srgb.name) {
     126        gltexture_delete(This, &This->baseTexture.texture_srgb);
     127    }
     128
     129    if (context) context_release(context);
    139130
    140131    This->baseTexture.texture_rgb.dirty = TRUE;
     
    296287    TRACE("(%p) : About to bind texture\n", This);
    297288
    298 #ifdef VBOX_WITH_WDDM
    299     Assert(!VBOXSHRC_IS_DISABLED(This));
    300 #endif
    301 
    302289    This->baseTexture.is_srgb = srgb; /* SRGB mode cache for PreLoad calls outside drawprim */
    303290    if(srgb) {
     
    317304            ERR("should not be here!");
    318305            gl_tex->name = (GLuint)VBOXSHRC_GET_SHAREHANDLE(This);
     306            GL_EXTCALL(glChromiumParameteriCR(GL_RCUSAGE_TEXTURE_SET_CR, gl_tex->name));
    319307            TRACE("Assigned shared texture %d\n", gl_tex->name);
    320308        }
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/device.c

    r41028 r41109  
    62796279    if (surface->texture_name)
    62806280    {
    6281 #ifdef VBOX_WITH_WDDM
    6282 # ifdef DEBUG_misha
    6283         /* shared case needs testing! */
    6284         Assert(!VBOXSHRC_IS_SHARED(surface));
    6285 # endif
    6286         if (VBOXSHRC_CAN_DELETE(device, surface))
    6287 #endif
    6288         {
    6289             struct wined3d_context *context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
    6290             ENTER_GL();
    6291             glDeleteTextures(1, &surface->texture_name);
    6292             LEAVE_GL();
    6293             context_release(context);
    6294         }
     6281        IWineD3DDeviceImpl *This = device; /* <- to make the below texture_gl_delete macro work and avoid other modifications */
     6282        struct wined3d_context *context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
     6283        ENTER_GL();
     6284        texture_gl_delete(surface, surface->texture_name);
     6285        LEAVE_GL();
     6286        context_release(context);
    62956287        surface->texture_name = 0;
    62966288        surface->Flags &= ~SFLAG_CLIENT;
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/resource.c

    r40388 r41109  
    296296    }
    297297
    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
     298    return WINED3D_OK;
     299}
     300#endif
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/surface.c

    r40962 r41109  
    9898    ENTER_GL();
    9999
    100     if (This->texture_name
    101 #ifdef VBOX_WITH_WDDM
    102             && VBOXSHRC_CAN_DELETE(device, This)
    103 #endif
    104             )
     100    if (This->texture_name)
    105101    {
    106102        /* Release the OpenGL texture. */
    107103        TRACE("Deleting texture %u.\n", This->texture_name);
    108         glDeleteTextures(1, &This->texture_name);
     104        texture_gl_delete(This, This->texture_name);
    109105    }
    110106
     
    528524    if (VBOXSHRC_IS_SHARED(surface))
    529525    {
     526        struct wined3d_context * context;
    530527        Assert(shared_handle);
    531         surface_shrc_unlock(surface);
    532528        if (!VBOXSHRC_IS_SHARED_OPENED(surface))
    533529        {
    534             struct wined3d_context * context;
    535 
     530            surface_shrc_unlock(surface);
    536531            Assert(!(*shared_handle));
    537532            *shared_handle = VBOXSHRC_GET_SHAREHANDLE(surface);
    538 
    539             Assert(!device->isInDraw);
    540 
    541             /* flush to ensure the texture is allocated before it is used by another
    542              * process opening it */
    543             context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
    544             if (context->valid)
    545             {
    546                 wglFlush();
    547             }
    548             else
    549             {
    550                 ERR("invalid context!");
    551             }
    552             context_release(context);
    553533        }
    554534        else
    555535        {
     536            VBOXSHRC_UNLOCK(surface);
     537            Assert(!VBOXSHRC_IS_LOCKED(surface));
     538#ifdef DEBUG_misha
     539            ERR("test this!");
     540#endif
     541            surface_setup_location_onopen(surface);
    556542            Assert(*shared_handle);
    557543            Assert(*shared_handle == VBOXSHRC_GET_SHAREHANDLE(surface));
    558544        }
     545
     546        Assert(!device->isInDraw);
     547
     548        /* flush to ensure the texture is allocated/referenced before it is used/released by another
     549         * process opening/creating it */
     550        context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
     551        if (context->valid)
     552        {
     553            wglFlush();
     554        }
     555        else
     556        {
     557            ERR("invalid context!");
     558        }
     559        context_release(context);
    559560    }
    560561    else
     
    14591460    if(!texture) {
    14601461        ENTER_GL();
    1461 #ifdef VBOX_WITH_WDDM
    1462         if (VBOXSHRC_CAN_DELETE(device, This))
    1463 #endif
    1464         {
    1465             glDeleteTextures(1, &This->texture_name);
    1466             glDeleteTextures(1, &This->texture_name_srgb);
    1467         }
     1462        texture_gl_delete(This, This->texture_name);
     1463        texture_gl_delete(This, This->texture_name_srgb);
    14681464        This->texture_name = 0;
    14691465        This->texture_name_srgb = 0;
     
    18281824    struct wined3d_format_desc desc;
    18291825    IWineD3DBaseTexture *baseTexture = NULL;
     1826    struct wined3d_context *context;
    18301827
    18311828    d3dfmt_get_conv(This, TRUE, TRUE, &desc, &convert);
     
    18401837            /* @todo: this is not entirely correct: need to share this state among all instances of the given shared resource */
    18411838            texture_state_init((IWineD3DTexture*)baseTexture, &pTex->baseTexture.texture_rgb);
     1839            context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
     1840            ENTER_GL();
     1841            GL_EXTCALL(glChromiumParameteriCR(GL_RCUSAGE_TEXTURE_SET_CR, pTex->baseTexture.texture_rgb.name));
     1842            ENTER_GL();
     1843            context_release(context);
    18421844        }
    18431845        IWineD3DBaseTexture_Release(baseTexture);
    18441846    }
     1847    else
     1848    {
     1849        context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
     1850        ENTER_GL();
     1851        GL_EXTCALL(glChromiumParameteriCR(GL_RCUSAGE_TEXTURE_SET_CR, (GLuint)VBOXSHRC_GET_SHAREHANDLE(This)));
     1852        ENTER_GL();
     1853        context_release(context);
     1854    }
    18451855    This->Flags |= alloc_flag;
    1846 
    18471856    This->texture_name = (GLuint)VBOXSHRC_GET_SHAREHANDLE(This);
    18481857
     
    22582267
    22592268#ifdef VBOX_WITH_WDDM
    2260         surface_shrc_unlock(This);
     2269    surface_shrc_unlock(This);
    22612270#endif
    22622271
     
    22692278    struct wined3d_context *context;
    22702279
     2280#ifdef VBOX_WITH_WDDM
     2281    if (VBOXSHRC_IS_SHARED(This))
     2282    {
     2283        ERR("surface_release_client_storage for shared resource! ignoring..");
     2284        return;
     2285    }
     2286#endif
     2287
    22712288    context = context_acquire(This->resource.device, NULL, CTXUSAGE_RESOURCELOAD);
    22722289
    22732290    ENTER_GL();
    22742291    glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE);
    2275 #ifdef VBOX_WITH_WDDM
    2276     if (!VBOXSHRC_IS_SHARED_OPENED(This))
    2277 #endif
    2278     {
    2279         if(This->texture_name)
    2280         {
    2281             surface_bind_and_dirtify(This, FALSE);
    2282             glTexImage2D(This->texture_target, This->texture_level,
    2283                          GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
    2284         }
    2285         if(This->texture_name_srgb)
    2286         {
    2287             surface_bind_and_dirtify(This, TRUE);
    2288             glTexImage2D(This->texture_target, This->texture_level,
    2289                          GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
    2290         }
     2292    if(This->texture_name)
     2293    {
     2294        surface_bind_and_dirtify(This, FALSE);
     2295        glTexImage2D(This->texture_target, This->texture_level,
     2296                     GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
     2297    }
     2298    if(This->texture_name_srgb)
     2299    {
     2300        surface_bind_and_dirtify(This, TRUE);
     2301        glTexImage2D(This->texture_target, This->texture_level,
     2302                     GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
    22912303    }
    22922304    glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);
     
    28692881    IWineD3DBaseTexture *baseTexture = NULL;
    28702882
    2871 #ifdef VBOX_WITH_WDDM
    2872     Assert(!VBOXSHRC_IS_DISABLED(This));
    2873 #endif
    2874 
    28752883    TRACE("(%p)Checking to see if the container is a base texture\n", This);
    28762884    if (IWineD3DSurface_GetContainer(iface, &IID_IWineD3DBaseTexture, (void **)&baseTexture) == WINED3D_OK) {
     
    28952903                if (VBOXSHRC_IS_SHARED_OPENED(This))
    28962904                {
     2905                    struct wined3d_gl_info *gl_info = &This->resource.device->adapter->gl_info;
    28972906                    ERR("should not be here!");
    28982907                    *name = (GLuint)VBOXSHRC_GET_SHAREHANDLE(This);
     2908                    GL_EXTCALL(glChromiumParameteriCR(GL_RCUSAGE_TEXTURE_SET_CR, name));
    28992909                }
    29002910                else
     
    53545364#ifdef VBOX_WITH_WDDM
    53555365static HRESULT WINAPI IWineD3DSurfaceImpl_SetShRcState(IWineD3DSurface *iface, VBOXWINEEX_SHRC_STATE enmState) {
    5356     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl*)iface;
    5357     IWineD3DBaseTextureImpl *texture = NULL;
    5358     struct wined3d_context *context = NULL;
    53595366    HRESULT hr;
    5360     unsigned int i;
    5361 
    5362     if (SUCCEEDED(IWineD3DSurface_GetContainer(iface, &IID_IWineD3DBaseTexture, (void **)&texture)))
    5363     {
    5364         /* this is a texture, check that the */
    5365         switch (enmState)
    5366         {
    5367             case VBOXWINEEX_SHRC_STATE_GL_DISABLE:
    5368                 if (!VBOXSHRC_IS_DISABLED(texture))
    5369                 {
    5370                     ERR("directly doing SetShRcState for texture surface not allowed!");
    5371                     return E_FAIL;
    5372                 }
    5373                 break;
    5374             case VBOXWINEEX_SHRC_STATE_GL_DELETE:
    5375                 if (!VBOXSHRC_IS_DELETE(texture))
    5376                 {
    5377                     ERR("directly doing SetShRcState for texture surface not allowed!");
    5378                     return E_FAIL;
    5379                 }
    5380                 break;
    5381             default:
    5382                 ERR("invalid arg");
    5383                 return E_INVALIDARG;
    5384         }
    5385 
    5386         IWineD3DBaseTexture_Release((IWineD3DBaseTexture*)texture);
    5387     }
    5388 
    53895367
    53905368    hr = IWineD3DResourceImpl_SetShRcState((IWineD3DResource*)iface, enmState);
     
    53935371        ERR("IWineD3DResource_SetShRcState failed");
    53945372        return hr;
    5395     }
    5396 
    5397     if (!texture)
    5398     {
    5399         if (!This->resource.device->isInDraw)
    5400         {
    5401             context = context_acquire(This->resource.device, NULL, CTXUSAGE_RESOURCELOAD);
    5402             if (!context)
    5403             {
    5404                 ERR("zero context!");
    5405                 return E_FAIL;
    5406             }
    5407 
    5408             if (!context->valid)
    5409             {
    5410                 ERR("context invalid!");
    5411                 context_release(context);
    5412                 return E_FAIL;
    5413             }
    5414         }
    5415 
    5416         device_cleanup_durtify_texture_target(This->resource.device, This->texture_target);
    5417 
    5418         if (context)
    5419             context_release(context);
    54205373    }
    54215374
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/texture.c

    r40481 r41109  
    323323    TRACE("(%p) : relay to BaseTexture\n", This);
    324324
    325 #ifdef VBOX_WITH_WDDM
    326     Assert(!VBOXSHRC_IS_DISABLED(This));
    327 #endif
    328 
    329325    hr = basetexture_bind((IWineD3DBaseTexture *)iface, srgb, &set_gl_texture_desc);
    330326    if (set_gl_texture_desc && SUCCEEDED(hr)) {
     
    727723#endif
    728724
    729         if (!VBOXSHRC_IS_SHARED_OPENED(texture))
     725        if (!VBOXSHRC_IS_SHARED(texture))
    730726        {
    731727            struct wined3d_context * context;
     
    733729            Assert(!device->isInDraw);
    734730
    735             /* flush to ensure the texture is allocated before it is used by another
    736              * process opening it */
     731            /* flush to ensure the texture is allocated/referenced before it is used/released by another
     732             * process opening/creating it */
    737733            context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
    738734            if (context->valid)
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/vboxsharedrc.h

    r40388 r41109  
    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_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 */
    2321
    2422#define VBOXSHRC_GET_SHAREFLAFS(_o) ((_o)->resource.sharerc_flags)
     
    3129#define VBOXSHRC_SET_SHARED(_o) (VBOXSHRC_GET_SHAREFLAFS(_o) |= VBOXSHRC_F_SHARED)
    3230#define VBOXSHRC_SET_SHARED_OPENED(_o) (VBOXSHRC_GET_SHAREFLAFS(_o) |= VBOXSHRC_F_SHARED_OPENED)
    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))
    3531
    3632#define VBOXSHRC_IS_SHARED(_o) (!!(VBOXSHRC_GET_SHAREFLAFS(_o) & VBOXSHRC_F_SHARED))
    3733#define VBOXSHRC_IS_SHARED_OPENED(_o) (!!(VBOXSHRC_GET_SHAREFLAFS(_o) & VBOXSHRC_F_SHARED_OPENED))
    3834#define VBOXSHRC_IS_SHARED_UNLOCKED(_o) (VBOXSHRC_IS_SHARED(_o) && !VBOXSHRC_IS_LOCKED(_o))
    39 #define VBOXSHRC_IS_DISABLED(_o) ( \
    40         VBOXSHRC_IS_SHARED(_o) \
    41         && (VBOXSHRC_GET_SHAREFLAFS(_o) & VBOXSHRC_F_GL_DISABLE) \
    42     )
    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))
    4935
    5036#define VBOXSHRC_LOCK(_o) do{ \
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/wined3d_gl.h

    r39602 r41109  
    37743774        const PIXELFORMATDESCRIPTOR *ppfd);
    37753775
     3776/*Global resource ids sharing*/
    37763777#define GL_SHARE_CONTEXT_RESOURCES_CR 0x8B27
     3778/*do flush for the command buffer of a thread the context was previusly current for*/
    37773779#define GL_FLUSH_ON_THREAD_SWITCH_CR  0x8B28
     3780/*report that the shared resource is used by this context, the parameter value is a texture name*/
     3781#define GL_RCUSAGE_TEXTURE_SET_CR     0x8B29
     3782/*report that the shared resource is no longer used by this context, the parameter value is a texture name*/
     3783#define GL_RCUSAGE_TEXTURE_CLEAR_CR   0x8B2A
     3784
    37783785typedef void (WINE_GLAPI *PGLFNCHROMIUMPARAMETERUCR)(GLenum param, GLint value);
    37793786
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/wined3d_private.h

    r40962 r41109  
    20122012void basetexture_unload(IWineD3DBaseTexture *iface) DECLSPEC_HIDDEN;
    20132013
     2014#ifdef VBOX_WITH_WDDM
     2015#define texture_gl_delete(_o, _t) do { \
     2016        if (VBOXSHRC_IS_SHARED(_o)) GL_EXTCALL(glChromiumParameteriCR(GL_RCUSAGE_TEXTURE_CLEAR_CR, _t)); \
     2017        else glDeleteTextures(1, &_t);  \
     2018    } while (0)
     2019#else
     2020#define texture_gl_delete(_o, _t) do { \
     2021        glDeleteTextures(1, &_t);  \
     2022    } while (0)
     2023
     2024#endif
    20142025/*****************************************************************************
    20152026 * IWineD3DTexture implementation structure (extends IWineD3DBaseTextureImpl)
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette