VirtualBox

Changeset 52329 in vbox for trunk/src/VBox/GuestHost


Ignore:
Timestamp:
Aug 8, 2014 6:34:02 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
95454
Message:

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

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/VBox

  • trunk/src/VBox/GuestHost/OpenGL/include/chromium.h

    r51559 r52329  
    737737#define GL_SHARE_LISTS_CR             0x8B31
    738738
     739/* ensure the resource is  */
     740#define GL_PIN_TEXTURE_SET_CR         0x8B32
     741#define GL_PIN_TEXTURE_CLEAR_CR       0x8B33
     742
    739743/**********************************************************************/
    740744/*****                Chromium-specific API                       *****/
  • trunk/src/VBox/GuestHost/OpenGL/include/cr_glstate.h

    r52263 r52329  
    283283
    284284
     285DECLEXPORT(void) crStateReleaseTexture(CRContext *pCtx, CRTextureObj *pObj);
     286
    285287#ifndef IN_GUEST
    286288DECLEXPORT(int32_t) crStateSaveContext(CRContext *pContext, PSSMHANDLE pSSM);
     
    298300
    299301DECLEXPORT(void) crStateSetTextureUsed(GLuint texture, GLboolean used);
     302DECLEXPORT(void) crStatePinTexture(GLuint texture, GLboolean pin);
    300303DECLEXPORT(void) crStateDeleteTextureCallback(void *texObj);
    301304
  • trunk/src/VBox/GuestHost/OpenGL/include/state/cr_texture.h

    r48491 r52329  
    9494    GLboolean              generateMipmap;
    9595#endif
     96    GLboolean              pinned; /* <- keep the texture alive if its ctxUsage reaches zero */
    9697    CRbitvalue             dirty[CR_MAX_BITARRAY];
    9798    CRbitvalue             imageBit[CR_MAX_BITARRAY];
  • trunk/src/VBox/GuestHost/OpenGL/packer/packer.py

    r51313 r52329  
    215215
    216216
     217r0_funcs = [ 'ChromiumParameteriCR', 'WindowSize', 'WindowShow', 'WindowPosition' ]
    217218
    218219
     
    259260        pointers_ok = 1
    260261
     262    if not func_name in r0_funcs:
     263        print '#ifndef IN_RING0'
     264       
    261265    PrintFunc( func_name, params, 0, pointers_ok )
    262266    PrintFunc( func_name, params, 1, pointers_ok )
     267   
     268    if not func_name in r0_funcs:
     269        print '#endif'
     270   
  • 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);
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