VirtualBox

忽略:
時間撮記:
2014-8-8 下午06:34:02 (10 年 以前)
作者:
vboxsync
訊息:

wddm/crOpenGL: prevent shared objects from being deleted till they can be used

位置:
trunk
檔案:
修改 5 筆資料

圖例:

未更動
新增
刪除
  • trunk

  • trunk/src/VBox

  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/state.h

    r44290 r52329  
    7777void crStateGenNames(CRContext *g, CRHashTable *table, GLsizei n, GLuint *names);
    7878void crStateRegNames(CRContext *g, CRHashTable *table, GLsizei n, GLuint *names);
     79void crStateOnTextureUsageRelease(CRSharedState *pS, CRTextureObj *pObj);
    7980#endif
  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_init.c

    r51559 r52329  
    5050}
    5151
    52 
    53 
    5452/**
    5553 * Callback used for crFreeHashtable().
     
    7068} CR_STATE_RELEASEOBJ, *PCR_STATE_RELEASEOBJ;
    7169
     70void crStateOnTextureUsageRelease(CRSharedState *pS, CRTextureObj *pObj)
     71{
     72    if (!pObj->pinned)
     73        crHashtableDelete(pS->textureTable, pObj->id, crStateDeleteTextureCallback);
     74    else
     75        Assert(crHashtableSearch(pS->textureTable, pObj->id));
     76}
     77
     78void crStateReleaseTextureInternal(CRSharedState *pS, CRContext *pCtx, CRTextureObj *pObj)
     79{
     80    Assert(CR_STATE_SHAREDOBJ_USAGE_IS_USED(pObj) || pObj->pinned);
     81    CR_STATE_SHAREDOBJ_USAGE_CLEAR(pObj, pCtx);
     82    if (CR_STATE_SHAREDOBJ_USAGE_IS_USED(pObj))
     83        return;
     84
     85    crStateOnTextureUsageRelease(pS, pObj);
     86}
     87
     88DECLEXPORT(void) crStateReleaseTexture(CRContext *pCtx, CRTextureObj *pObj)
     89{
     90    Assert(CR_STATE_SHAREDOBJ_USAGE_IS_USED(pObj));
     91    CR_STATE_SHAREDOBJ_USAGE_CLEAR(pObj, pCtx);
     92    if (CR_STATE_SHAREDOBJ_USAGE_IS_USED(pObj))
     93        return;
     94
     95    if (!gSharedState)
     96    {
     97        WARN(("no global shared"));
     98        return;
     99    }
     100
     101    crStateOnTextureUsageRelease(gSharedState, pObj);
     102}
     103
     104void crStateReleaseBufferObjectInternal(CRSharedState *pS, CRContext *pCtx, CRBufferObject *pObj)
     105{
     106    Assert(CR_STATE_SHAREDOBJ_USAGE_IS_USED(pObj));
     107    CR_STATE_SHAREDOBJ_USAGE_CLEAR(pObj, pCtx);
     108    if (!CR_STATE_SHAREDOBJ_USAGE_IS_USED(pObj))
     109        crHashtableDelete(pS->buffersTable, pObj->id, crStateFreeBufferObject);
     110}
     111
     112void crStateReleaseFBOInternal(CRSharedState *pS, CRContext *pCtx, CRFramebufferObject *pObj)
     113{
     114    Assert(CR_STATE_SHAREDOBJ_USAGE_IS_USED(pObj));
     115    CR_STATE_SHAREDOBJ_USAGE_CLEAR(pObj, pCtx);
     116    if (!CR_STATE_SHAREDOBJ_USAGE_IS_USED(pObj))
     117        crHashtableDelete(pS->fbTable, pObj->id, crStateFreeFBO);
     118}
     119
     120void crStateReleaseRBOInternal(CRSharedState *pS, CRContext *pCtx, CRRenderbufferObject *pObj)
     121{
     122    Assert(CR_STATE_SHAREDOBJ_USAGE_IS_USED(pObj));
     123    CR_STATE_SHAREDOBJ_USAGE_CLEAR(pObj, pCtx);
     124    if (!CR_STATE_SHAREDOBJ_USAGE_IS_USED(pObj))
     125        crHashtableDelete(pS->rbTable, pObj->id, crStateFreeRBO);
     126}
     127
    72128static void ReleaseTextureCallback(unsigned long key, void *data1, void *data2)
    73129{
    74130    PCR_STATE_RELEASEOBJ pData = (PCR_STATE_RELEASEOBJ)data2;
    75131    CRTextureObj *pObj = (CRTextureObj *)data1;
    76     CR_STATE_SHAREDOBJ_USAGE_CLEAR(pObj, pData->pCtx);
    77     if (!CR_STATE_SHAREDOBJ_USAGE_IS_USED(pObj))
    78         crHashtableDelete(pData->s->textureTable, key, crStateDeleteTextureCallback);
     132    crStateReleaseTextureInternal(pData->s, pData->pCtx, pObj);
    79133}
    80134
     
    83137    PCR_STATE_RELEASEOBJ pData = (PCR_STATE_RELEASEOBJ)data2;
    84138    CRBufferObject *pObj = (CRBufferObject *)data1;
    85     CR_STATE_SHAREDOBJ_USAGE_CLEAR(pObj, pData->pCtx);
    86     if (!CR_STATE_SHAREDOBJ_USAGE_IS_USED(pObj))
    87         crHashtableDelete(pData->s->buffersTable, key, crStateFreeBufferObject);
     139    crStateReleaseBufferObjectInternal(pData->s, pData->pCtx, pObj);
    88140}
    89141
     
    92144    PCR_STATE_RELEASEOBJ pData = (PCR_STATE_RELEASEOBJ)data2;
    93145    CRFramebufferObject *pObj = (CRFramebufferObject *)data1;
    94     CR_STATE_SHAREDOBJ_USAGE_CLEAR(pObj, pData->pCtx);
    95     if (!CR_STATE_SHAREDOBJ_USAGE_IS_USED(pObj))
    96         crHashtableDelete(pData->s->fbTable, key, crStateFreeFBO);
     146    crStateReleaseFBOInternal(pData->s, pData->pCtx, pObj);
    97147}
    98148
     
    101151    PCR_STATE_RELEASEOBJ pData = (PCR_STATE_RELEASEOBJ)data2;
    102152    CRRenderbufferObject *pObj = (CRRenderbufferObject *)data1;
    103     CR_STATE_SHAREDOBJ_USAGE_CLEAR(pObj, pData->pCtx);
    104     if (!CR_STATE_SHAREDOBJ_USAGE_IS_USED(pObj))
    105         crHashtableDelete(pData->s->rbTable, key, crStateFreeRBO);
     153    crStateReleaseRBOInternal(pData->s, pData->pCtx, pObj);
    106154}
    107155
  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_texture.c

    r50041 r52329  
    754754#endif
    755755    }
    756 
    757     CR_STATE_SHAREDOBJ_USAGE_CLEAR(tObj, g);
    758756}
    759757
     
    795793
    796794            crStateCleanupTextureRefs(g, tObj);
     795
     796            CR_STATE_SHAREDOBJ_USAGE_CLEAR(tObj, g);
    797797
    798798            CR_STATE_SHAREDOBJ_USAGE_FOREACH_USED_IDX(tObj, j)
     
    804804                CRContext *ctx = g_pAvailableContexts[j];
    805805                if (j && ctx)
     806                {
    806807                    crStateCleanupTextureRefs(ctx, tObj);
     808                    CR_STATE_SHAREDOBJ_USAGE_CLEAR(tObj, g);
     809                }
    807810                else
    808811                    CR_STATE_SHAREDOBJ_USAGE_CLEAR_IDX(tObj, j);
     
    894897}
    895898
     899#ifndef IN_GUEST
     900# ifdef DEBUG
     901static uint32_t gDbgNumPinned = 0;
     902# endif
     903
     904DECLEXPORT(void) crStatePinTexture(GLuint texture, GLboolean pin)
     905{
     906    CRTextureObj * pTobj;
     907    CRSharedState *pShared = crStateGlobalSharedAcquire();
     908    if (pShared)
     909    {
     910        pTobj = (CRTextureObj*)crHashtableSearch(pShared->textureTable, texture);
     911
     912        if (pTobj)
     913        {
     914# ifdef DEBUG
     915            if (!pTobj->pinned != !pin)
     916            {
     917                if (pin)
     918                    ++gDbgNumPinned;
     919                else
     920                {
     921                    Assert(gDbgNumPinned);
     922                    --gDbgNumPinned;
     923                }
     924            }
     925# endif
     926            pTobj->pinned = !!pin;
     927            if (!pin)
     928            {
     929                if (!CR_STATE_SHAREDOBJ_USAGE_IS_USED(pTobj))
     930                    crStateOnTextureUsageRelease(pShared, pTobj);
     931            }
     932        }
     933        else
     934            WARN(("texture %d not defined", texture));
     935
     936        crStateGlobalSharedRelease();
     937    }
     938    else
     939        WARN(("no global shared"));
     940}
     941#endif
     942
    896943DECLEXPORT(void) crStateSetTextureUsed(GLuint texture, GLboolean used)
    897944{
     
    916963#endif
    917964        {
    918             crWarning("crStateSetTextureUsed: failed to fined a HW name for texture(%d)!", texture);
     965            WARN(("crStateSetTextureUsed: failed to fined a HW name for texture(%d)!", texture));
    919966            return;
    920967        }
     
    931978        crStateCleanupTextureRefs(g, tobj);
    932979
    933         if (!CR_STATE_SHAREDOBJ_USAGE_IS_USED(tobj))
    934         {
    935             /* on the host side, we need to delete an ogl texture object here as well, which crStateDeleteTextureCallback will do
    936              * in addition to calling crStateDeleteTextureObject to delete a state object */
    937             crHashtableDelete(g->shared->textureTable, texture, crStateDeleteTextureCallback);
    938         }
     980        crStateReleaseTexture(g, tobj);
    939981
    940982        DIRTY(tb->dirty, g->neg_bitid);
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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