VirtualBox

Changeset 46966 in vbox for trunk/src


Ignore:
Timestamp:
Jul 4, 2013 6:08:11 AM (11 years ago)
Author:
vboxsync
Message:

wddm/crOpenGL: some bugfixes, more TexPresent fixes

Location:
trunk/src/VBox
Files:
29 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/common/wddm/VBoxMPIf.h

    r46783 r46966  
    3535
    3636/* One would increase this whenever definitions in this file are changed */
    37 #define VBOXVIDEOIF_VERSION 18
     37#define VBOXVIDEOIF_VERSION 19
    3838
    3939#define VBOXWDDM_NODE_ID_SYSTEM           0
     
    424424    VBOXDISP_KMHANDLE hSwapchainKm; /* in, NULL if new is being created */
    425425    VBOXDISP_UMHANDLE hSwapchainUm; /* in, UMD private data */
    426     DWORD winHostID;
     426    int32_t winHostID;
    427427    RECT Rect;
    428428    UINT u32Reserved;
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxD3DIf.cpp

    r46783 r46966  
    831831
    832832    HRESULT hr = pAdapter->D3D.pD3D9If->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, NULL, fFlags, &Params.Base, &pDevice9If);
    833     if (!SUCCEEDED(hr))
    834     {
     833    if (SUCCEEDED(hr))
     834    {
     835        int32_t hostId = 0;
     836        hr = pAdapter->D3D.D3D.pfnVBoxWineExD3DDev9GetHostId((IDirect3DDevice9Ex*)pDevice9If, &hostId);
     837        if (SUCCEEDED(hr))
     838        {
     839            Assert(hostId);
     840
     841            VBOXDISPIFESCAPE Data;
     842            Data.escapeCode = VBOXESC_SETCTXHOSTID;
     843            Data.u32CmdSpecific = (uint32_t)hostId;
     844            D3DDDICB_ESCAPE DdiEscape = {0};
     845            DdiEscape.hContext = pDevice->DefaultContext.ContextInfo.hContext;
     846            DdiEscape.hDevice = pDevice->hDevice;
     847        //    DdiEscape.Flags.Value = 0;
     848            DdiEscape.pPrivateDriverData = &Data;
     849            DdiEscape.PrivateDriverDataSize = sizeof (Data);
     850            hr = pDevice->RtCallbacks.pfnEscapeCb(pDevice->pAdapter->hAdapter, &DdiEscape);
     851            if (SUCCEEDED(hr))
     852            {
     853                pDevice->pDevice9If = pDevice9If;
     854                return S_OK;
     855            }
     856            else
     857                WARN(("pfnEscapeCb VBOXESC_SETCTXHOSTID failed hr 0x%x", hr));
     858        }
     859        else
     860            WARN(("pfnVBoxWineExD3DDev9GetHostId failed hr 0x%x", hr));
     861
     862        pDevice->pAdapter->D3D.D3D.pfnVBoxWineExD3DDev9Term((IDirect3DDevice9Ex *)pDevice9If);
     863    }
     864    else
    835865        WARN(("CreateDevice failed hr 0x%x", hr));
    836         return hr;
    837     }
    838 
    839     pDevice->pDevice9If = pDevice9If;
    840     return S_OK;
    841 }
    842 
     866
     867    return hr;
     868}
     869
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispD3DIf.cpp

    r46783 r46966  
    160160        {
    161161            WARN(("no VBoxWineExD3DSwapchain9GetHostWinID"));
     162            break;
     163        }
     164
     165        pD3D->pfnVBoxWineExD3DDev9GetHostId = (PFNVBOXWINEEXD3DDEV9_GETHOSTID)GetProcAddress(pD3D->hD3DLib, "VBoxWineExD3DDev9GetHostId");
     166        if (!pD3D->pfnVBoxWineExD3DDev9GetHostId)
     167        {
     168            WARN(("no VBoxWineExD3DDev9GetHostId"));
    162169            break;
    163170        }
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispD3DIf.h

    r46783 r46966  
    8585    PFNVBOXWINEEXD3DSWAPCHAIN9_GETHOSTWINID pfnVBoxWineExD3DSwapchain9GetHostWinID;
    8686
     87    PFNVBOXWINEEXD3DDEV9_GETHOSTID pfnVBoxWineExD3DDev9GetHostId;
     88
    8789    /* module handle */
    8890    HMODULE hD3DLib;
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPMisc.cpp

    r46876 r46966  
    394394NTSTATUS vboxWddmSwapchainCtxEscape(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_CONTEXT pContext, PVBOXDISPIFESCAPE_SWAPCHAININFO pSwapchainInfo, UINT cbSize)
    395395{
    396     Assert((cbSize >= RT_OFFSETOF(VBOXDISPIFESCAPE_SWAPCHAININFO, SwapchainInfo.ahAllocs[0])));
    397396    if (cbSize < RT_OFFSETOF(VBOXDISPIFESCAPE_SWAPCHAININFO, SwapchainInfo.ahAllocs[0]))
     397    {
     398        WARN(("invalid cbSize1 %d", cbSize));
    398399        return STATUS_INVALID_PARAMETER;
    399     Assert(cbSize >= RT_OFFSETOF(VBOXDISPIFESCAPE_SWAPCHAININFO, SwapchainInfo.ahAllocs[pSwapchainInfo->SwapchainInfo.cAllocs]));
     400    }
     401
    400402    if (cbSize < RT_OFFSETOF(VBOXDISPIFESCAPE_SWAPCHAININFO, SwapchainInfo.ahAllocs[pSwapchainInfo->SwapchainInfo.cAllocs]))
     403    {
    401404        return STATUS_INVALID_PARAMETER;
     405        WARN(("invalid cbSize2 %d", cbSize));
     406    }
    402407
    403408    if (!pSwapchainInfo->SwapchainInfo.winHostID)
    404409    {
    405410        WARN(("Zero winHostID specified!"));
     411        return STATUS_INVALID_PARAMETER;
     412    }
     413
     414    if (!pContext)
     415    {
     416        WARN(("vboxWddmSwapchainCtxEscape: no context specified"));
    406417        return STATUS_INVALID_PARAMETER;
    407418    }
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPTypes.h

    r46757 r46966  
    228228    VBOXDISP_UMHANDLE hSwapchainUm;
    229229    VBOXDISP_KMHANDLE hSwapchainKm;
    230     UINT winHostID;
     230    int32_t winHostID;
    231231    BOOLEAN fExposed;
    232232    POINT Pos;
     
    244244    UINT  EngineAffinity;
    245245    BOOLEAN fRenderFromShadowDisabled;
     246    int32_t hostID;
    246247    uint32_t u32CrConClientID;
    247248    VBOXMP_CRPACKER CrPacker;
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPWddm.cpp

    r46885 r46966  
    41104110                break;
    41114111            }
     4112            case VBOXESC_SETCTXHOSTID:
     4113            {
     4114                /* set swapchain information */
     4115                PVBOXWDDM_CONTEXT pContext = (PVBOXWDDM_CONTEXT)pEscape->hContext;
     4116                if (!pContext)
     4117                {
     4118                    WARN(("VBOXESC_SETCTXHOSTID: no context specified"));
     4119                    Status = STATUS_INVALID_PARAMETER;
     4120                    break;
     4121                }
     4122
     4123                if (pEscape->PrivateDriverDataSize != sizeof (VBOXDISPIFESCAPE))
     4124                {
     4125                    WARN(("VBOXESC_SETCTXHOSTID: invalid data size %d", pEscape->PrivateDriverDataSize));
     4126                    Status = STATUS_INVALID_PARAMETER;
     4127                    break;
     4128                }
     4129
     4130                int32_t hostID = (int32_t)pEscapeHdr->u32CmdSpecific;
     4131                if (hostID <= 0)
     4132                {
     4133                    WARN(("VBOXESC_SETCTXHOSTID: invalid hostID %d", hostID));
     4134                    Status = STATUS_INVALID_PARAMETER;
     4135                    break;
     4136                }
     4137
     4138                if (pContext->hostID)
     4139                {
     4140                    WARN(("VBOXESC_SETCTXHOSTID: context already has hostID specified"));
     4141                    Status = STATUS_INVALID_PARAMETER;
     4142                    break;
     4143                }
     4144
     4145                pContext->hostID = hostID;
     4146                Status = STATUS_SUCCESS;
     4147                break;
     4148            }
    41124149            case VBOXESC_SWAPCHAININFO:
    41134150            {
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine_new/d3d9/d3d9wddm.def

    r46783 r46966  
    1313  Direct3DCreate9Ex
    1414  VBoxWineExD3DDev9Flush
    15   VBoxWineExD3DDev9FlushToHost
     15  VBoxWineExD3DDev9GetHostId
    1616  VBoxWineExD3DDev9Finish
    1717  VBoxWineExD3DDev9CreateTexture
     
    2525  VBoxWineExD3DSwapchain9GetHostWinID
    2626  VBoxWineExD3DSurf9SyncToHost
     27  VBoxWineExD3DDev9FlushToHost
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine_new/d3d9/device.c

    r46885 r46966  
    817817    wined3d_mutex_lock();
    818818    hr = wined3d_device_finish(device->wined3d_device);
     819    wined3d_mutex_unlock();
     820
     821    return hr;
     822}
     823
     824VBOXWINEEX_DECL(HRESULT) VBoxWineExD3DDev9GetHostId(IDirect3DDevice9Ex *iface, int32_t *pi32Id)
     825{
     826    struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
     827    HRESULT hr;
     828
     829    TRACE("iface %p, FlushToHost\n", iface);
     830
     831    wined3d_mutex_lock();
     832    hr = wined3d_device_get_host_id(device->wined3d_device, pi32Id);
    819833    wined3d_mutex_unlock();
    820834
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine_new/d3d9/swapchain.c

    r46757 r46966  
    307307}
    308308
    309 VBOXWINEEX_DECL(HRESULT) VBoxWineExD3DSwapchain9GetHostWinID(IDirect3DSwapChain9 *iface, DWORD *pID)
    310 {
    311     struct d3d9_swapchain *swapchain = impl_from_IDirect3DSwapChain9(iface);
    312     HRESULT hr;
    313     wined3d_mutex_lock();
    314     hr = wined3d_swapchain_get_host_win_id(swapchain->wined3d_swapchain, pID);
     309VBOXWINEEX_DECL(HRESULT) VBoxWineExD3DSwapchain9GetHostWinID(IDirect3DSwapChain9 *iface, int32_t *pi32Id)
     310{
     311    struct d3d9_swapchain *swapchain = impl_from_IDirect3DSwapChain9(iface);
     312    HRESULT hr;
     313    wined3d_mutex_lock();
     314    hr = wined3d_swapchain_get_host_win_id(swapchain->wined3d_swapchain, pi32Id);
    315315    wined3d_mutex_unlock();
    316316    return hr;
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine_new/vbox/VBoxWineEx.h

    r46783 r46966  
    7272typedef FNVBOXWINEEXD3DDEV9_FLUSHTOHOST *PFNVBOXWINEEXD3DDEV9_FLUSHTOHOST;
    7373
     74typedef VBOXWINEEX_DECL(HRESULT) FNVBOXWINEEXD3DDEV9_GETHOSTID(IDirect3DDevice9Ex *iface, int32_t *pi32Id);
     75typedef FNVBOXWINEEXD3DDEV9_GETHOSTID *PFNVBOXWINEEXD3DDEV9_GETHOSTID;
     76
    7477typedef VBOXWINEEX_DECL(HRESULT) FNVBOXWINEEXD3DDEV9_FINISH(IDirect3DDevice9Ex *iface);
    7578typedef FNVBOXWINEEXD3DDEV9_FINISH *PFNVBOXWINEEXD3DDEV9_FINISH;
     
    8790typedef FNVBOXWINEEXD3DSWAPCHAIN9_PRESENT *PFNVBOXWINEEXD3DSWAPCHAIN9_PRESENT;
    8891
    89 typedef VBOXWINEEX_DECL(HRESULT) FNVBOXWINEEXD3DSWAPCHAIN9_GETHOSTWINID(IDirect3DSwapChain9 *iface, DWORD *pID);
     92typedef VBOXWINEEX_DECL(HRESULT) FNVBOXWINEEXD3DSWAPCHAIN9_GETHOSTWINID(IDirect3DSwapChain9 *iface, int32_t *pID);
    9093typedef FNVBOXWINEEXD3DSWAPCHAIN9_GETHOSTWINID *PFNVBOXWINEEXD3DSWAPCHAIN9_GETHOSTWINID;
    9194
     
    127130VBOXWINEEX_DECL(HRESULT) VBoxWineExD3DDev9FlushToHost(IDirect3DDevice9Ex *iface); /* flash data to host */
    128131
     132VBOXWINEEX_DECL(HRESULT) VBoxWineExD3DDev9GetHostId(IDirect3DDevice9Ex *iface, int32_t *pi32Id);
     133
    129134VBOXWINEEX_DECL(HRESULT) VBoxWineExD3DDev9Term(IDirect3DDevice9Ex *iface);
    130135
     
    139144                                IDirect3DSurface9 *surf); /* use the given surface as a frontbuffer content source */
    140145
    141 VBOXWINEEX_DECL(HRESULT) VBoxWineExD3DSwapchain9GetHostWinID(IDirect3DSwapChain9 *iface, DWORD *pID);
     146VBOXWINEEX_DECL(HRESULT) VBoxWineExD3DSwapchain9GetHostWinID(IDirect3DSwapChain9 *iface, int32_t *pi32Id);
    142147
    143148typedef struct VBOXWINEEX_D3DPRESENT_PARAMETERS
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine_new/vbox/libWineStub/include/wine/wined3d.h

    r46783 r46966  
    24792479HRESULT __cdecl wined3d_device_blt_vol(struct wined3d_device *device, struct wined3d_volume *src, struct wined3d_volume *dst, const struct wined3d_box *pSrcBoxArg, const struct VBOXPOINT3D *pDstPoin3D);
    24802480HRESULT __cdecl wined3d_device_blt_voltex(struct wined3d_device *device, struct wined3d_texture *src, struct wined3d_texture *dst, const struct wined3d_box *pSrcBoxArg, const struct VBOXPOINT3D *pDstPoin3D);
     2481HRESULT __cdecl wined3d_device_get_host_id(struct wined3d_device *device, int32_t *pid);
     2482
    24812483HRESULT __cdecl wined3d_surface_get_host_id(struct wined3d_surface *surface, uint32_t *id);
    24822484HRESULT __cdecl wined3d_surface_sync_to_host(struct wined3d_surface *surface);
    24832485
    24842486HRESULT __cdecl wined3d_swapchain_present_rt(struct wined3d_swapchain *swapchain, struct wined3d_surface *rt);
     2487HRESULT __cdecl wined3d_swapchain_get_host_win_id(struct wined3d_swapchain *swapchain, int32_t *pi32Id);
    24852488#endif
    24862489
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine_new/wined3d/device.c

    r46602 r46966  
    56885688
    56895689}
     5690
     5691HRESULT CDECL wined3d_device_get_host_id(struct wined3d_device *device, int32_t *pid)
     5692{
     5693    int32_t id = pVBoxGetContextId(device->contexts[0]->glCtx);
     5694    if (!id)
     5695    {
     5696        *pid = 0;
     5697        ERR("pVBoxGetContextId to get id for context 0x%x", device->contexts[0]->glCtx);
     5698        return E_FAIL;
     5699    }
     5700
     5701    *pid = id;
     5702    return WINED3D_OK;
     5703}
    56905704#endif
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine_new/wined3d/swapchain.c

    r46757 r46966  
    15361536}
    15371537
    1538 HRESULT CDECL wined3d_swapchain_get_host_win_id(struct wined3d_swapchain *swapchain, DWORD *pID)
    1539 {
    1540     DWORD id = (DWORD)pVBoxGetWindowId(swapchain->hDC);
     1538HRESULT CDECL wined3d_swapchain_get_host_win_id(struct wined3d_swapchain *swapchain, int32_t *pi32Id)
     1539{
     1540    int32_t id = pVBoxGetWindowId(swapchain->hDC);
    15411541    if (!id)
    15421542    {
     1543        *pi32Id = 0;
    15431544        ERR("failed to get id for hdc 0x%x", swapchain->hDC);
    15441545        return E_FAIL;
    15451546    }
    1546     *pID = id;
     1547    *pi32Id = id;
    15471548    return S_OK;
    15481549}
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine_new/wined3d/wined3d_gl.h

    r46783 r46966  
    185185void (WINAPI *pVBoxFlushToHost)(HGLRC) DECLSPEC_HIDDEN;
    186186GLint (WINAPI *pVBoxGetWindowId)(HDC)  DECLSPEC_HIDDEN;
     187GLint (WINAPI *pVBoxGetContextId)(HGLRC)  DECLSPEC_HIDDEN;
    187188
    188189
     
    192193        VBOX_USE_FUNC(VBoxCreateContext) \
    193194        VBOX_USE_FUNC(VBoxFlushToHost) \
    194         VBOX_USE_FUNC(VBoxGetWindowId)
     195        VBOX_USE_FUNC(VBoxGetWindowId) \
     196        VBOX_USE_FUNC(VBoxGetContextId)
    195197
    196198# define VBOX_GL_EXT_FUNCS_GEN \
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine_new/wined3d/wined3dwddm.def

    r46783 r46966  
    261261  wined3d_surface_sync_to_host
    262262  wined3d_swapchain_get_host_win_id
     263  wined3d_device_get_host_id
  • trunk/src/VBox/Additions/WINNT/include/VBoxDisplay.h

    r44557 r46966  
    3737# define VBOXESC_REINITVIDEOMODESBYMASK     0xABCD9010
    3838# define VBOXESC_ADJUSTVIDEOMODES           0xABCD9011
     39# define VBOXESC_SETCTXHOSTID               0xABCD9012
    3940#endif /* #ifdef VBOX_WITH_WDDM */
    4041
  • trunk/src/VBox/Additions/common/crOpenGL/defs.py

    r46227 r46966  
    498498VBoxCreateContext
    499499VBoxGetWindowId
     500VBoxGetContextId
    500501VBoxFlushToHost"""
    501502#print "DllMain"
  • trunk/src/VBox/Additions/common/crOpenGL/defs64.py

    r46227 r46966  
    479479VBoxCreateContext
    480480VBoxGetWindowId
     481VBoxGetContextId
    481482VBoxFlushToHost"""
    482483#print "DllMain"
  • trunk/src/VBox/Additions/common/crOpenGL/wgl.c

    r45484 r46966  
    329329DECLEXPORT(GLint) WINAPI VBoxGetWindowId( HDC hdc )
    330330{
    331     WindowInfo *window = stubGetWindowInfo(hdc);
     331    WindowInfo *window;
     332    GLint winid = 0;
     333
     334    CR_DDI_PROLOGUE();
     335
     336    crHashtableLock(stub.windowTable);
     337
     338    window = stubGetWindowInfo(hdc);
    332339    if (!window)
    333340    {
    334         CRASSERT(0);
    335341        crWarning("stubGetWindowInfo: window not found!");
    336         return 0;
     342        goto end;
    337343    }
    338344    if (!window->spuWindow)
    339345    {
    340         CRASSERT(0);
    341346        crWarning("stubGetWindowInfo: window is null!");
    342         return 0;
    343     }
    344     return window->spuWindow;
    345 }
     347        goto end;
     348    }
     349
     350    winid = window->spuWindow;
     351
     352end:
     353    crHashtableUnlock(stub.windowTable);
     354    return winid;
     355}
     356
     357DECLEXPORT(GLint) WINAPI VBoxGetContextId( HGLRC hglrc )
     358{
     359    ContextInfo *context;
     360    GLint ctxid = 0;
     361
     362    CR_DDI_PROLOGUE();
     363
     364//    crHashtableLock(stub.windowTable);
     365    crHashtableLock(stub.contextTable);
     366
     367    context = (ContextInfo *) crHashtableSearch(stub.contextTable, (unsigned long) hglrc);
     368    if (!context)
     369    {
     370        crWarning("crHashtableSearch: context not found!");
     371        goto end;
     372    }
     373
     374    if (context->type != CHROMIUM)
     375    {
     376        crWarning("unexpected context type %d", context->type);
     377        goto end;
     378    }
     379
     380    if (context->spuContext <= 0)
     381    {
     382        crWarning("no spuSontext defined");
     383        goto end;
     384    }
     385
     386    ctxid = context->spuContext;
     387
     388end:
     389    crHashtableUnlock(stub.contextTable);
     390    return ctxid;
     391}
     392
    346393
    347394DECLEXPORT(HGLRC) WINAPI wglCreateContext_prox( HDC hdc )
  • trunk/src/VBox/GuestHost/OpenGL/include/cr_glstate.h

    r46173 r46966  
    287287DECLEXPORT(int32_t) crStateLoadGlobals(PSSMHANDLE pSSM, uint32_t u32Version);
    288288DECLEXPORT(int32_t) crStateSaveGlobals(PSSMHANDLE pSSM);
     289
     290DECLEXPORT(CRSharedState *) crStateGlobalSharedAcquire();
     291DECLEXPORT(void) crStateGlobalSharedRelease();
    289292#endif
    290293
  • trunk/src/VBox/GuestHost/OpenGL/include/cr_protocol.h

    r46885 r46966  
    3333#define CR_PRESENT_DEFINE_FLAG(_f) (1 << (CR_PRESENT_FLAGS_OFFSET + _f))
    3434
    35 #define CR_PRESENT_FLAG_CLEAR_RECTS     CR_PRESENT_DEFINE_FLAG(0)
    36 //#define CR_PRESENT_FLAG_TEX_UPSIDEDOWN  CR_PRESENT_DEFINE_FLAG(1)
     35#define CR_PRESENT_FLAG_CLEAR_RECTS            CR_PRESENT_DEFINE_FLAG(0)
     36#define CR_PRESENT_FLAG_TEX_NONINVERT_YCOORD   CR_PRESENT_DEFINE_FLAG(1)
    3737
    3838#define CR_PRESENT_GET_SCREEN(_cfg) ((_cfg) & CR_PRESENT_SCREEN_MASK)
  • trunk/src/VBox/GuestHost/OpenGL/include/cr_server.h

    r46885 r46966  
    209209    VBOXVR_SCR_COMPOSITOR_ENTRY CEntry;
    210210    VBOXVR_SCR_COMPOSITOR_ENTRY RootVrCEntry;
     211    void *pvUserData1;
     212    void *pvUserData2;
    211213} CR_DISPLAY_ENTRY, *PCR_DISPLAY_ENTRY;
    212214/**/
     
    358360void CrDpTerm(PCR_DISPLAY pDisplay);
    359361void CrDpResize(PCR_DISPLAY pDisplay, int32_t xPos, int32_t yPos, uint32_t width, uint32_t height);
    360 void CrDpEntryInit(PCR_DISPLAY_ENTRY pEntry, const VBOXVR_TEXTURE *pTextureData);
     362void CrDpEntryInit(PCR_DISPLAY_ENTRY pEntry, const VBOXVR_TEXTURE *pTextureData, void *pvUserData);
    361363void CrDpEntryCleanup(PCR_DISPLAY pDisplay, PCR_DISPLAY_ENTRY pEntry);
    362364int CrDpEntryRegionsSet(PCR_DISPLAY pDisplay, PCR_DISPLAY_ENTRY pEntry, const RTPOINT *pPos, uint32_t cRegions, const RTRECT *paRegions);
     
    380382int CrDemInit(PCR_DISPLAY_ENTRY_MAP pMap);
    381383void CrDemTerm(PCR_DISPLAY_ENTRY_MAP pMap);
    382 PCR_DISPLAY_ENTRY CrDemEntryGetCreate(PCR_DISPLAY_ENTRY_MAP pMap, GLuint idTexture, CRContextInfo *pCtxInfo);
    383 void CrDemEntryDestroy(PCR_DISPLAY_ENTRY_MAP pMap, GLuint idTexture);
     384PCR_DISPLAY_ENTRY CrDemEntryAcquire(PCR_DISPLAY_ENTRY_MAP pMap, GLuint idTexture);
     385void CrDemEntryRelease(PCR_DISPLAY_ENTRY pEntry);
     386//void CrDemEntryDestroy(PCR_DISPLAY_ENTRY_MAP pMap, GLuint idTexture);
    384387
    385388/* */
  • trunk/src/VBox/GuestHost/OpenGL/include/cr_vreg.h

    r46885 r46966  
    195195    RTLISTNODE Node;
    196196    VBOXVR_LIST Vr;
     197    uint32_t cRefs;
    197198} VBOXVR_COMPOSITOR_ENTRY, *PVBOXVR_COMPOSITOR_ENTRY;
    198199
    199200struct VBOXVR_COMPOSITOR;
    200201
    201 typedef DECLCALLBACK(void) FNVBOXVRCOMPOSITOR_ENTRY_REMOVED(const struct VBOXVR_COMPOSITOR *pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, PVBOXVR_COMPOSITOR_ENTRY pReplacingEntry);
    202 typedef FNVBOXVRCOMPOSITOR_ENTRY_REMOVED *PFNVBOXVRCOMPOSITOR_ENTRY_REMOVED;
     202typedef DECLCALLBACK(void) FNVBOXVRCOMPOSITOR_ENTRY_RELEASED(const struct VBOXVR_COMPOSITOR *pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, PVBOXVR_COMPOSITOR_ENTRY pReplacingEntry);
     203typedef FNVBOXVRCOMPOSITOR_ENTRY_RELEASED *PFNVBOXVRCOMPOSITOR_ENTRY_RELEASED;
    203204
    204205typedef struct VBOXVR_COMPOSITOR
    205206{
    206207    RTLISTNODE List;
    207     PFNVBOXVRCOMPOSITOR_ENTRY_REMOVED pfnEntryRemoved;
     208    PFNVBOXVRCOMPOSITOR_ENTRY_RELEASED pfnEntryReleased;
    208209} VBOXVR_COMPOSITOR, *PVBOXVR_COMPOSITOR;
    209210
     
    211212typedef FNVBOXVRCOMPOSITOR_VISITOR *PFNVBOXVRCOMPOSITOR_VISITOR;
    212213
    213 VBOXVREGDECL(void) VBoxVrCompositorInit(PVBOXVR_COMPOSITOR pCompositor, PFNVBOXVRCOMPOSITOR_ENTRY_REMOVED pfnEntryRemoved);
     214VBOXVREGDECL(void) VBoxVrCompositorInit(PVBOXVR_COMPOSITOR pCompositor, PFNVBOXVRCOMPOSITOR_ENTRY_RELEASED pfnEntryReleased);
    214215VBOXVREGDECL(void) VBoxVrCompositorClear(PVBOXVR_COMPOSITOR pCompositor);
    215216VBOXVREGDECL(void) VBoxVrCompositorRegionsClear(PVBOXVR_COMPOSITOR pCompositor, bool *pfChanged);
     
    297298} VBOXVR_TEXTURE, *PVBOXVR_TEXTURE;
    298299
     300struct VBOXVR_SCR_COMPOSITOR_ENTRY;
     301struct VBOXVR_SCR_COMPOSITOR;
     302
     303typedef DECLCALLBACK(void) FNVBOXVRSCRCOMPOSITOR_ENTRY_RELEASED(const struct VBOXVR_SCR_COMPOSITOR *pCompositor, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pReplacingEntry);
     304typedef FNVBOXVRSCRCOMPOSITOR_ENTRY_RELEASED *PFNVBOXVRSCRCOMPOSITOR_ENTRY_RELEASED;
     305
     306
    299307typedef struct VBOXVR_SCR_COMPOSITOR_ENTRY
    300308{
     
    308316    PRTRECT paDstRects;
    309317    PRTRECT paDstUnstretchedRects;
     318    PFNVBOXVRSCRCOMPOSITOR_ENTRY_RELEASED pfnEntryReleased;
    310319} VBOXVR_SCR_COMPOSITOR_ENTRY, *PVBOXVR_SCR_COMPOSITOR_ENTRY;
    311320
     
    325334} VBOXVR_SCR_COMPOSITOR, *PVBOXVR_SCR_COMPOSITOR;
    326335
     336
    327337typedef DECLCALLBACK(bool) FNVBOXVRSCRCOMPOSITOR_VISITOR(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, void *pvVisitor);
    328338typedef FNVBOXVRSCRCOMPOSITOR_VISITOR *PFNVBOXVRSCRCOMPOSITOR_VISITOR;
    329339
    330 DECLINLINE(void) CrVrScrCompositorEntryInit(PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, const VBOXVR_TEXTURE *pTex)
     340DECLINLINE(void) CrVrScrCompositorEntryInit(PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, const VBOXVR_TEXTURE *pTex, PFNVBOXVRSCRCOMPOSITOR_ENTRY_RELEASED pfnEntryReleased)
    331341{
    332342    VBoxVrCompositorEntryInit(&pEntry->Ce);
    333343    pEntry->Tex = *pTex;
    334344    memset(&pEntry->Pos, 0, sizeof (VBOXVR_SCR_COMPOSITOR_ENTRY) - RT_OFFSETOF(VBOXVR_SCR_COMPOSITOR_ENTRY, Pos));
     345    pEntry->pfnEntryReleased = pfnEntryReleased;
    335346}
    336347
  • trunk/src/VBox/GuestHost/OpenGL/packer/pack_misc.c

    r46757 r46966  
    126126    WRITE_DATA( 0, GLint, size );
    127127    WRITE_DATA( 4, GLenum, CR_VBOXTEXPRESENT_EXTEND_OPCODE );
    128     WRITE_DATA( 8, GLint, texture );
    129     WRITE_DATA( 12, GLint, cfg );
     128    WRITE_DATA( 8, GLuint, texture );
     129    WRITE_DATA( 12, GLuint, cfg );
    130130    WRITE_DATA( 16, GLint, xPos );
    131131    WRITE_DATA( 20, GLint, yPos );
  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_init.c

    r46395 r46966  
    112112{
    113113    s->refCount--;
     114    Assert(s->refCount >= 0);
    114115    if (s->refCount <= 0) {
    115116        if (s==gSharedState)
     
    125126    }
    126127#ifndef IN_GUEST
    127     else
     128    else if (pContext)
    128129    {
    129130        /* evaluate usage bits*/
     
    137138    }
    138139#endif
     140}
     141
     142DECLEXPORT(CRSharedState *) crStateGlobalSharedAcquire()
     143{
     144    if (!gSharedState)
     145    {
     146        crWarning("No Global Shared State!");
     147        return NULL;
     148    }
     149    gSharedState->refCount++;
     150    return gSharedState;
     151}
     152
     153DECLEXPORT(void) crStateGlobalSharedRelease()
     154{
     155    crStateFreeShared(NULL, gSharedState);
    139156}
    140157
  • trunk/src/VBox/GuestHost/OpenGL/util/vreg.cpp

    r46885 r46966  
    11651165}
    11661166
    1167 VBOXVREGDECL(void) VBoxVrCompositorInit(PVBOXVR_COMPOSITOR pCompositor, PFNVBOXVRCOMPOSITOR_ENTRY_REMOVED pfnEntryRemoved)
     1167VBOXVREGDECL(void) VBoxVrCompositorInit(PVBOXVR_COMPOSITOR pCompositor, PFNVBOXVRCOMPOSITOR_ENTRY_RELEASED pfnEntryReleased)
    11681168{
    11691169    RTListInit(&pCompositor->List);
    1170     pCompositor->pfnEntryRemoved = pfnEntryRemoved;
     1170    pCompositor->pfnEntryReleased = pfnEntryReleased;
    11711171}
    11721172
     
    11901190}
    11911191
     1192DECLINLINE(void) vboxVrCompositorEntryRelease(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, PVBOXVR_COMPOSITOR_ENTRY pReplacingEntry)
     1193{
     1194    if (--pEntry->cRefs)
     1195    {
     1196        Assert(pEntry->cRefs < UINT32_MAX/2);
     1197        return;
     1198    }
     1199
     1200    Assert(!VBoxVrCompositorEntryIsInList(pEntry));
     1201
     1202    if (pCompositor->pfnEntryReleased)
     1203        pCompositor->pfnEntryReleased(pCompositor, pEntry, pReplacingEntry);
     1204}
     1205
     1206DECLINLINE(void) vboxVrCompositorEntryAcquire(PVBOXVR_COMPOSITOR_ENTRY pEntry)
     1207{
     1208    ++pEntry->cRefs;
     1209}
     1210
    11921211DECLINLINE(void) vboxVrCompositorEntryAdd(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry)
    11931212{
    11941213    RTListPrepend(&pCompositor->List, &pEntry->Node);
     1214    vboxVrCompositorEntryAcquire(pEntry);
    11951215}
    11961216
     
    11981218{
    11991219    RTListNodeRemove(&pEntry->Node);
    1200     if (pCompositor->pfnEntryRemoved)
    1201         pCompositor->pfnEntryRemoved(pCompositor, pEntry, pReplacingEntry);
     1220    vboxVrCompositorEntryRelease(pCompositor, pEntry, pReplacingEntry);
    12021221}
    12031222
     
    12051224{
    12061225    VBoxVrListInit(&pEntry->Vr);
     1226    pEntry->cRefs = 0;
    12071227}
    12081228
    12091229VBOXVREGDECL(bool) VBoxVrCompositorEntryRemove(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry)
    12101230{
     1231    vboxVrCompositorEntryAcquire(pEntry);
     1232
    12111233    if (!VBoxVrCompositorEntryIsInList(pEntry))
     1234    {
     1235        vboxVrCompositorEntryRelease(pCompositor, pEntry, NULL);
    12121236        return false;
     1237    }
    12131238    VBoxVrListClear(&pEntry->Vr);
    12141239    vboxVrCompositorEntryRemove(pCompositor, pEntry, NULL);
     1240    vboxVrCompositorEntryRelease(pCompositor, pEntry, NULL);
    12151241    return true;
    12161242}
     
    12191245{
    12201246    bool fChanged;
     1247    vboxVrCompositorEntryAcquire(pEntry);
     1248
    12211249    int rc = VBoxVrListRectsSubst(&pEntry->Vr, cRects, paRects, &fChanged);
    12221250    if (RT_SUCCESS(rc))
     
    12291257        if (pfChanged)
    12301258            *pfChanged = false;
    1231         return VINF_SUCCESS;
    1232     }
    1233 
    1234     WARN(("VBoxVrListRectsSubst failed, rc %d", rc));
     1259    }
     1260    else
     1261        WARN(("VBoxVrListRectsSubst failed, rc %d", rc));
     1262
     1263    vboxVrCompositorEntryRelease(pCompositor, pEntry, NULL);
    12351264    return rc;
    12361265}
     
    12421271    int rc = VINF_SUCCESS;
    12431272
     1273    if (pEntry)
     1274        vboxVrCompositorEntryAcquire(pEntry);
     1275
    12441276    if (!cRects)
    12451277    {
    12461278        if (pfChangeFlags)
    12471279            *pfChangeFlags = 0;
     1280        if (pEntry)
     1281            vboxVrCompositorEntryRelease(pCompositor, pEntry, NULL);
    12481282        return VINF_SUCCESS;
    12491283    }
     
    12601294                if (pfChangeFlags)
    12611295                    *pfChangeFlags = 0;
     1296                vboxVrCompositorEntryRelease(pCompositor, pEntry, NULL);
    12621297                return VINF_SUCCESS;
    12631298            }
     
    12661301        {
    12671302            WARN(("VBoxVrListRectsAdd failed, rc %d", rc));
     1303            vboxVrCompositorEntryRelease(pCompositor, pEntry, NULL);
    12681304            return rc;
    12691305        }
     
    13101346    AssertRC(rc);
    13111347
    1312     if (pEntry && !fEntryWasInList)
    1313     {
    1314         Assert(!VBoxVrListIsEmpty(&pEntry->Vr));
    1315         vboxVrCompositorEntryAdd(pCompositor, pEntry);
     1348    if (pEntry)
     1349    {
     1350        if (!fEntryWasInList)
     1351        {
     1352            Assert(!VBoxVrListIsEmpty(&pEntry->Vr));
     1353            vboxVrCompositorEntryAdd(pCompositor, pEntry);
     1354        }
     1355        vboxVrCompositorEntryRelease(pCompositor, pEntry, NULL);
    13161356    }
    13171357
     
    13481388    }
    13491389
     1390    vboxVrCompositorEntryAcquire(pEntry);
     1391
    13501392    if (VBoxVrListIsEmpty(&pEntry->Vr))
    13511393    {
    13521394        if (pfChanged)
    13531395            *pfChanged = false;
     1396        vboxVrCompositorEntryRelease(pCompositor, pEntry, NULL);
    13541397        return VINF_SUCCESS;
    13551398
     
    13571400
    13581401    int rc = vboxVrCompositorEntryRegionsSubst(pCompositor, pEntry, cRects, paRects, pfChanged);
    1359     if (RT_SUCCESS(rc))
    1360         return VINF_SUCCESS;
    1361 
    1362     WARN(("pfChanged failed, rc %d", rc));
     1402    if (!RT_SUCCESS(rc))
     1403        WARN(("pfChanged failed, rc %d", rc));
     1404
     1405    vboxVrCompositorEntryRelease(pCompositor, pEntry, NULL);
     1406
    13631407    return rc;
    13641408}
     
    13731417        return VERR_INVALID_PARAMETER;
    13741418    }
     1419
     1420    vboxVrCompositorEntryAcquire(pEntry);
    13751421
    13761422    bool fChanged = false, fCurChanged = false;
     
    13821428    rc = VBoxVrCompositorEntryRegionsAdd(pCompositor, pEntry, cRects, paRects, NULL, &fChangeFlags);
    13831429    if (RT_SUCCESS(rc))
     1430    {
    13841431        fChanged |= !!fChangeFlags;
     1432        if (pfChanged)
     1433            *pfChanged = fChanged;
     1434    }
    13851435    else
    1386     {
    13871436        WARN(("VBoxVrCompositorEntryRegionsAdd failed, rc %d", rc));
    1388         return rc;
    1389     }
    1390 
    1391     AssertRC(rc);
     1437
     1438    vboxVrCompositorEntryRelease(pCompositor, pEntry, NULL);
     1439
     1440    return VINF_SUCCESS;
     1441}
     1442
     1443VBOXVREGDECL(int) VBoxVrCompositorEntryListIntersect(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, const VBOXVR_LIST *pList2, bool *pfChanged)
     1444{
     1445    int rc = VINF_SUCCESS;
     1446    bool fChanged = false;
     1447
     1448    vboxVrCompositorEntryAcquire(pEntry);
     1449
     1450    if (VBoxVrCompositorEntryIsInList(pEntry))
     1451    {
     1452        rc = VBoxVrListIntersect(&pEntry->Vr, pList2, &fChanged);
     1453        if (RT_SUCCESS(rc))
     1454        {
     1455            if (VBoxVrListIsEmpty(&pEntry->Vr))
     1456            {
     1457                Assert(fChanged);
     1458                vboxVrCompositorEntryRemove(pCompositor, pEntry, NULL);
     1459            }
     1460        }
     1461        else
     1462        {
     1463            WARN(("VBoxVrListRectsIntersect failed, rc %d", rc));
     1464        }
     1465    }
    13921466
    13931467    if (pfChanged)
    13941468        *pfChanged = fChanged;
    1395     return VINF_SUCCESS;
    1396 }
    1397 
    1398 VBOXVREGDECL(int) VBoxVrCompositorEntryListIntersect(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, const VBOXVR_LIST *pList2, bool *pfChanged)
     1469
     1470    vboxVrCompositorEntryRelease(pCompositor, pEntry, NULL);
     1471
     1472    return rc;
     1473}
     1474
     1475VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsIntersect(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, uint32_t cRects, const RTRECT *paRects, bool *pfChanged)
    13991476{
    14001477    int rc = VINF_SUCCESS;
    14011478    bool fChanged = false;
     1479
     1480    vboxVrCompositorEntryAcquire(pEntry);
     1481
    14021482    if (VBoxVrCompositorEntryIsInList(pEntry))
    14031483    {
    1404         rc = VBoxVrListIntersect(&pEntry->Vr, pList2, &fChanged);
     1484        rc = VBoxVrListRectsIntersect(&pEntry->Vr, cRects, paRects, &fChanged);
    14051485        if (RT_SUCCESS(rc))
    14061486        {
     
    14201500        *pfChanged = fChanged;
    14211501
    1422     return rc;
    1423 }
    1424 
    1425 VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsIntersect(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, uint32_t cRects, const RTRECT *paRects, bool *pfChanged)
    1426 {
    1427     int rc = VINF_SUCCESS;
    1428     bool fChanged = false;
    1429     if (VBoxVrCompositorEntryIsInList(pEntry))
    1430     {
    1431         rc = VBoxVrListRectsIntersect(&pEntry->Vr, cRects, paRects, &fChanged);
    1432         if (RT_SUCCESS(rc))
    1433         {
    1434             if (VBoxVrListIsEmpty(&pEntry->Vr))
    1435             {
    1436                 Assert(fChanged);
    1437                 vboxVrCompositorEntryRemove(pCompositor, pEntry, NULL);
    1438             }
    1439         }
    1440         else
    1441         {
    1442             WARN(("VBoxVrListRectsIntersect failed, rc %d", rc));
    1443         }
    1444     }
    1445 
    1446     if (pfChanged)
    1447         *pfChanged = fChanged;
     1502    vboxVrCompositorEntryRelease(pCompositor, pEntry, NULL);
    14481503
    14491504    return rc;
     
    15181573    }
    15191574
     1575    vboxVrCompositorEntryAcquire(pEntry);
     1576
    15201577    if ((!x && !y)
    15211578            || !VBoxVrCompositorEntryIsInList(pEntry))
     
    15231580        if (pfChanged)
    15241581            *pfChanged = false;
     1582
     1583        vboxVrCompositorEntryRelease(pCompositor, pEntry, NULL);
    15251584        return VINF_SUCCESS;
    15261585    }
     
    15741633    if (paRects)
    15751634        RTMemFree(paRects);
     1635
     1636    vboxVrCompositorEntryRelease(pCompositor, pEntry, NULL);
    15761637
    15771638    return rc;
     
    22622323}
    22632324
     2325static DECLCALLBACK(void) crVrScrCompositorEntryReleasedCB(const struct VBOXVR_COMPOSITOR *pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, PVBOXVR_COMPOSITOR_ENTRY pReplacingEntry)
     2326{
     2327    PVBOXVR_SCR_COMPOSITOR_ENTRY pCEntry = VBOXVR_SCR_COMPOSITOR_ENTRY_FROM_ENTRY(pEntry);
     2328    CrVrScrCompositorEntrySetChanged(pCEntry, true);
     2329
     2330    if (pCEntry->pfnEntryReleased)
     2331    {
     2332        PVBOXVR_SCR_COMPOSITOR_ENTRY pCReplacingEntry = pReplacingEntry ? VBOXVR_SCR_COMPOSITOR_ENTRY_FROM_ENTRY(pReplacingEntry) : NULL;
     2333        PVBOXVR_SCR_COMPOSITOR pCConpositor = VBOXVR_SCR_COMPOSITOR_FROM_COMPOSITOR(pCompositor);
     2334        pCEntry->pfnEntryReleased(pCConpositor, pCEntry, pCReplacingEntry);
     2335    }
     2336}
     2337
    22642338VBOXVREGDECL(void) CrVrScrCompositorInit(PVBOXVR_SCR_COMPOSITOR pCompositor)
    22652339{
    22662340    memset(pCompositor, 0, sizeof (*pCompositor));
    2267     VBoxVrCompositorInit(&pCompositor->Compositor, NULL);
     2341    VBoxVrCompositorInit(&pCompositor->Compositor, crVrScrCompositorEntryReleasedCB);
    22682342    pCompositor->fFlags = CRBLT_F_LINEAR | CRBLT_F_INVERT_YCOORDS;
    22692343#ifndef IN_RING0
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_presenter.cpp

    r46885 r46966  
    140140}
    141141
    142 void CrDpEntryInit(PCR_DISPLAY_ENTRY pEntry, const VBOXVR_TEXTURE *pTextureData)
    143 {
    144     CrVrScrCompositorEntryInit(&pEntry->CEntry, pTextureData);
     142#define PCR_DISPLAY_ENTRY_FROM_CENTRY(_pe) ((PCR_DISPLAY_ENTRY)((uint8_t*)(_pe) - RT_OFFSETOF(CR_DISPLAY_ENTRY, CEntry)))
     143static DECLCALLBACK(void) crDpEntryCEntryReleaseCB(const struct VBOXVR_SCR_COMPOSITOR *pCompositor, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pReplacingEntry)
     144{
     145    PCR_DISPLAY_ENTRY pCEntry = PCR_DISPLAY_ENTRY_FROM_CENTRY(pEntry);
     146    CrDemEntryRelease(pCEntry);
     147}
     148
     149void CrDpEntryInit(PCR_DISPLAY_ENTRY pEntry, const VBOXVR_TEXTURE *pTextureData, void *pvUserData1, void *pvUserData2)
     150{
     151    CrVrScrCompositorEntryInit(&pEntry->CEntry, pTextureData, crDpEntryCEntryReleaseCB);
    145152    CrVrScrCompositorEntryFlagsSet(&pEntry->CEntry, CRBLT_F_INVERT_SRC_YCOORDS);
    146     CrVrScrCompositorEntryInit(&pEntry->RootVrCEntry, pTextureData);
     153    CrVrScrCompositorEntryInit(&pEntry->RootVrCEntry, pTextureData, NULL);
    147154    CrVrScrCompositorEntryFlagsSet(&pEntry->RootVrCEntry, CRBLT_F_INVERT_SRC_YCOORDS);
     155    pEntry->pvUserData1 = pvUserData1;
     156    pEntry->pvUserData2 = pvUserData2;
    148157}
    149158
     
    175184}
    176185
     186void crDemEntryRelease(PCR_DISPLAY_ENTRY_MAP pMap, PCR_DISPLAY_ENTRY pEntry, bool fForceDelete)
     187{
     188    CRTextureObj *pTobj = (CRTextureObj *)pEntry->pvUserData2;
     189    if (!pTobj)
     190    {
     191        crWarning("Trying to release entry that does not have tobj specified");
     192        return;
     193    }
     194
     195    CR_STATE_SHAREDOBJ_USAGE_CLEAR(pTobj, cr_server.MainContextInfo.pContext);
     196
     197    bool fDeleteEntry = fForceDelete;
     198    GLuint idTexture = pTobj->id;
     199
     200    if (!CR_STATE_SHAREDOBJ_USAGE_IS_USED(pTobj))
     201    {
     202        CRSharedState *pShared = crStateGlobalSharedAcquire();
     203
     204        CRASSERT(pShared);
     205        /* on the host side, we need to delete an ogl texture object here as well, which crStateDeleteTextureCallback will do
     206         * in addition to calling crStateDeleteTextureObject to delete a state object */
     207        crHashtableDelete(pShared->textureTable, idTexture, crStateDeleteTextureCallback);
     208
     209        crStateGlobalSharedRelease();
     210
     211        fDeleteEntry = true;
     212    }
     213    else
     214    {
     215        /* this is something we would not generally expect */
     216        CRASSERT(!fForceDelete);
     217    }
     218
     219    if (fDeleteEntry)
     220    {
     221        if (pMap)
     222            crHashtableDelete(pMap->pTextureMap, idTexture, crFree);
     223        else
     224            crFree(pEntry); /* <- when called from crDemTermEntryCb */
     225
     226        crStateGlobalSharedRelease();
     227    }
     228}
     229
     230void crDemTermEntryCb(void *pvEntry)
     231{
     232    crDemEntryRelease(NULL, (PCR_DISPLAY_ENTRY)pvEntry, true);
     233}
     234
    177235void CrDemTerm(PCR_DISPLAY_ENTRY_MAP pMap)
    178236{
    179     crFreeHashtable(pMap->pTextureMap, crFree);
    180 }
    181 
    182 PCR_DISPLAY_ENTRY CrDemEntryGetCreate(PCR_DISPLAY_ENTRY_MAP pMap, GLuint idTexture, CRContextInfo *pCtxInfo)
     237    crFreeHashtable(pMap->pTextureMap, crDemTermEntryCb);
     238}
     239
     240void CrDemEntryRelease(PCR_DISPLAY_ENTRY pEntry)
     241{
     242    PCR_DISPLAY_ENTRY_MAP pMap = (PCR_DISPLAY_ENTRY_MAP)pEntry->pvUserData1;
     243    Assert(pMap);
     244    crDemEntryRelease(pMap, pEntry, false);
     245}
     246
     247PCR_DISPLAY_ENTRY CrDemEntryAcquire(PCR_DISPLAY_ENTRY_MAP pMap, GLuint idTexture)
    183248{
    184249    PCR_DISPLAY_ENTRY pEntry = (PCR_DISPLAY_ENTRY)crHashtableSearch(pMap->pTextureMap, idTexture);
     
    186251        return pEntry;
    187252
    188     CRContext *pContext = pCtxInfo->pContext;
    189     if (!pContext)
    190     {
    191         crWarning("pContext is null!");
     253    CRSharedState *pShared = crStateGlobalSharedAcquire();
     254    if (!pShared)
     255    {
     256        crWarning("pShared is null!");
    192257        return NULL;
    193258    }
    194259
    195     CRTextureObj *pTobj = (CRTextureObj*)crHashtableSearch(pContext->shared->textureTable, idTexture);
     260    CRTextureObj *pTobj = (CRTextureObj*)crHashtableSearch(pShared->textureTable, idTexture);
    196261    if (!pTobj)
    197262    {
    198263        crWarning("pTobj is null!");
     264        crStateGlobalSharedRelease();
    199265        return NULL;
    200266    }
     267
     268    Assert(pTobj->id == idTexture);
    201269
    202270    GLuint hwId = crStateGetTextureObjHWID(pTobj);
     
    204272    {
    205273        crWarning("hwId is null!");
     274        crStateGlobalSharedRelease();
    206275        return NULL;
    207276    }
     
    217286    {
    218287        crWarning("crAlloc failed allocating CR_DISPLAY_ENTRY");
     288        crStateGlobalSharedRelease();
    219289        return NULL;
    220290    }
    221291
    222     CrDpEntryInit(pEntry, &TextureData);
     292    CrDpEntryInit(pEntry, &TextureData, pMap, pTobj);
     293
     294    /* just use main context info's context to hold the texture reference */
     295    CR_STATE_SHAREDOBJ_USAGE_SET(pTobj, cr_server.MainContextInfo.pContext);
    223296
    224297    crHashtableAdd(pMap->pTextureMap, idTexture, pEntry);
     
    226299
    227300}
    228 
     301#if 0
    229302void CrDemEntryDestroy(PCR_DISPLAY_ENTRY_MAP pMap, GLuint idTexture)
    230303{
     
    243316    crHashtableDelete(pMap->pTextureMap, idTexture, crFree);
    244317}
    245 
     318#endif
    246319PCR_DISPLAY crServerDisplayGetInitialized(uint32_t idScreen)
    247320{
     
    412485    if (texture)
    413486    {
    414         pEntry = CrDemEntryGetCreate(&cr_server.PresentTexturepMap, texture, cr_server.currentCtxInfo);
     487        pEntry = CrDemEntryAcquire(&cr_server.PresentTexturepMap, texture);
    415488        if (!pEntry)
    416489        {
    417             crWarning("CrDemEntryGetCreate Failed");
     490            crWarning("CrDemEntryAcquire Failed");
    418491            return;
    419492        }
     
    428501        if (!RT_SUCCESS(rc))
    429502        {
    430             crWarning("CrDpEntrySetRegions Failed rc %d", rc);
     503            crWarning("CrDpEntryRegionsAdd Failed rc %d", rc);
     504//            if (pEntry)
     505//                CrDemEntryRelease(pEntry);
    431506            return;
    432507        }
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_window.c

    r46885 r46966  
    5555        Tex.target = GL_TEXTURE_2D;
    5656        Tex.hwid = 0;
    57         CrVrScrCompositorEntryInit(&mural->DefaultDEntry.CEntry, &Tex);
     57        CrVrScrCompositorEntryInit(&mural->DefaultDEntry.CEntry, &Tex, NULL);
    5858
    5959        if (cr_server.fRootVrOn)
    6060        {
    61             CrVrScrCompositorEntryInit(&mural->DefaultDEntry.RootVrCEntry, &Tex);
     61            CrVrScrCompositorEntryInit(&mural->DefaultDEntry.RootVrCEntry, &Tex, NULL);
    6262            mural->fRootVrOn = GL_TRUE;
    6363        }
     
    407407{
    408408    CR_DISPLAY_ENTRY *pDEntry = CR_DENTRY_FROM_CENTRY(pEntry);
    409     CrVrScrCompositorEntryInit(&pDEntry->RootVrCEntry, CrVrScrCompositorEntryTexGet(pEntry));
     409    CrVrScrCompositorEntryInit(&pDEntry->RootVrCEntry, CrVrScrCompositorEntryTexGet(pEntry), NULL);
    410410    return &pDEntry->RootVrCEntry;
    411411}
     
    416416
    417417    crServerVBoxRootVrTranslateForMural(mural);
     418
     419    /* ensure the rootvr compositor does not hold any data,
     420     * i.e. cleanup all rootvr entries data */
     421    CrVrScrCompositorClear(&mural->RootVrCompositor);
    418422
    419423    rc = CrVrScrCompositorIntersectedList(&mural->Compositor, &cr_server.RootVr, &mural->RootVrCompositor, crServerMuralGetRootVrCEntry, NULL, NULL);
     
    468472                goto end;
    469473            }
    470             CrVrScrCompositorEntryInit(&mural->DefaultDEntry.CEntry, &Tex);
     474            CrVrScrCompositorEntryInit(&mural->DefaultDEntry.CEntry, &Tex, NULL);
    471475            /* initially set regions to all visible since this is what some guest assume
    472476             * and will not post any more visible regions command */
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