VirtualBox

Changeset 37986 in vbox for trunk/src


Ignore:
Timestamp:
Jul 15, 2011 3:14:35 PM (13 years ago)
Author:
vboxsync
Message:

Wddm/3d: fix thread sync issues

Location:
trunk/src/VBox
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/crOpenGL/context.c

    r34295 r37986  
    497497
    498498void
    499 stubGetWindowGeometry( const WindowInfo *window, int *x, int *y,
    500                                              unsigned int *w, unsigned int *h )
     499stubGetWindowGeometry(const WindowInfo *window, int *x, int *y,
     500                      unsigned int *w, unsigned int *h )
    501501{
    502502    RECT rect;
     
    11331133        return;
    11341134    }
     1135
     1136    crHashtableLock(stub.contextTable);
     1137
    11351138    context = (ContextInfo *) crHashtableSearch(stub.contextTable, contextId);
    11361139
     
    11671170    crMemZero(context, sizeof(ContextInfo));  /* just to be safe */
    11681171    crHashtableDelete(stub.contextTable, contextId, crFree);
    1169 }
    1170 
     1172
     1173    crHashtableUnlock(stub.contextTable);
     1174}
    11711175
    11721176void
  • trunk/src/VBox/Additions/common/crOpenGL/glx.c

    r37030 r37986  
    682682    }
    683683
    684     if (ctx && drawable) {
     684    if (ctx && drawable)
     685    {
     686        crHashtableLock(stub.windowTable);
     687        crHashtableLock(stub.contextTable);
     688
    685689        context = (ContextInfo *) crHashtableSearch(stub.contextTable, (unsigned long) ctx);
    686690        window = stubGetWindowInfo(dpy, drawable);
     
    692696        }
    693697    }
    694     else {
     698    else
     699    {
    695700        dpy = NULL;
    696701        window = NULL;
     
    702707
    703708    retVal = stubMakeCurrent(window, context);
     709
     710    if (ctx && drawable)
     711    {
     712        crHashtableUnlock(stub.contextTable);
     713        crHashtableUnlock(stub.windowTable);
     714    }
     715
    704716    return retVal;
    705717}
  • trunk/src/VBox/Additions/common/crOpenGL/icd_drv.c

    r37216 r37986  
    9595    ContextInfo *context;
    9696    WindowInfo *window;
     97    BOOL ret;
    9798
    9899    /*crDebug( "DrvSetContext called(0x%x, 0x%x)", hdc, hglrc );*/
    99100    (void) (callback);
    100101
     102    crHashtableLock(stub.windowTable);
     103    crHashtableLock(stub.contextTable);
     104
    101105    context = (ContextInfo *) crHashtableSearch(stub.contextTable, (unsigned long) hglrc);
    102106    window = stubGetWindowInfo(hdc);
    103107
    104     if (stubMakeCurrent( window, context )) {
    105         return &icdTable;
    106     }
    107     else {
    108         return NULL;
    109     }
     108    ret = stubMakeCurrent(window, context);
     109
     110    crHashtableUnlock(stub.contextTable);
     111    crHashtableUnlock(stub.windowTable);
     112
     113    return ret ? &icdTable:NULL;
    110114}
    111115
  • trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_misc.c

    r37760 r37986  
    104104}
    105105
     106#define PACK_FORCED_SYNC
     107
    106108void PACKSPU_APIENTRY packspu_Flush( void )
    107109{
    108110    GET_THREAD(thread);
    109111    int writeback = 1;
     112    int found=0;
    110113
    111114    if (!thread->bInjectThread)
     
    126129        crLockMutex(&_PackMutex);
    127130
    128         /*Make sure we process commands in order they should appear, so flush thread being injected first*/
     131        /*Make sure we process commands in order they should appear, so flush other threads first*/
    129132        for (i=0; i<MAX_THREADS; ++i)
    130133        {
    131134            if (pack_spu.thread[i].inUse
    132135                && (thread != &pack_spu.thread[i]) && pack_spu.thread[i].netServer.conn
    133                 && (pack_spu.thread[i].netServer.conn->u32ClientID == thread->netServer.conn->u32InjectClientID)
    134136                && pack_spu.thread[i].packer && pack_spu.thread[i].packer->currentBuffer)
    135137            {
     138#ifdef PACK_FORCED_SYNC
     139                CRPackContext *pc = pack_spu.thread[i].packer;
     140                unsigned char *data_ptr;
     141
     142                CR_GET_BUFFERED_POINTER( pc, 16 );
     143                WRITE_DATA( 0, GLint, 16 );
     144                WRITE_DATA( 4, GLenum, CR_WRITEBACK_EXTEND_OPCODE );
     145                WRITE_NETWORK_POINTER( 8, (void *) &writeback );
     146                WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
     147                CR_UNLOCK_PACKER_CONTEXT(pc);
     148#endif
    136149                packspuFlush((void *) &pack_spu.thread[i]);
    137                 break;
     150
     151                if (pack_spu.thread[i].netServer.conn->u32ClientID == thread->netServer.conn->u32InjectClientID)
     152                {
     153                    found=1;
     154                }
     155
     156#ifdef PACK_FORCED_SYNC
     157                while (writeback)
     158                    crNetRecv();
     159#endif
    138160            }
    139161        }
    140162
    141         if (i>=MAX_THREADS)
     163        if (!found)
    142164        {
    143165            /*Thread we're supposed to inject commands for has been detached,
     
    147169        }
    148170
     171#ifdef PACK_FORCED_SYNC
     172        writeback = 1;
     173        crPackWriteback(&writeback);
     174#endif
     175        packspuFlush((void *) thread);
     176
     177#ifdef PACK_FORCED_SYNC
     178        while (writeback)
     179            crNetRecv();
     180#endif
    149181        crUnlockMutex(&_PackMutex);
    150 
    151         packspuFlush((void *) thread);
    152182    }
    153183}
  • trunk/src/VBox/Additions/common/crOpenGL/stub.c

    r34295 r37986  
    127127    if (winInfo && winInfo->type == CHROMIUM && stub.spu)
    128128    {
     129        crHashtableLock(stub.windowTable);
     130
    129131        stub.spu->dispatch_table.WindowDestroy( winInfo->spuWindow );
    130 #ifdef CR_NEWWINTRACK
    131         crLockMutex(&stub.mutex);
    132 #endif
     132
    133133#ifdef WINDOWS
    134134        if (winInfo->hVisibleRegion != INVALID_HANDLE_VALUE)
     
    147147        }
    148148# endif
    149 #endif
    150 #ifdef CR_NEWWINTRACK
    151         crUnlockMutex(&stub.mutex);
    152149#endif
    153150        crForcedFlush();
    154151        crHashtableDelete(stub.windowTable, window, crFree);
     152
     153        crHashtableUnlock(stub.windowTable);
    155154    }
    156155}
  • trunk/src/VBox/GuestHost/OpenGL/include/cr_hash.h

    r15532 r37986  
    3636/*Returns GL_TRUE if given hashtable hold the data, pKey is updated with key value for data in this case*/
    3737DECLEXPORT(GLboolean) crHashtableGetDataKey(CRHashTable *pHash, void *pData, unsigned long *pKey);
     38DECLEXPORT(void) crHashtableLock(CRHashTable *h);
     39DECLEXPORT(void) crHashtableUnlock(CRHashTable *h);
    3840
    3941#ifdef __cplusplus
  • trunk/src/VBox/GuestHost/OpenGL/util/hash.c

    r31808 r37986  
    353353}
    354354
     355void crHashtableLock(CRHashTable *h)
     356{
     357#ifdef CHROMIUM_THREADSAFE
     358    crLockMutex(&h->mutex);
     359#endif
     360}
     361
     362void crHashtableUnlock(CRHashTable *h)
     363{
     364#ifdef CHROMIUM_THREADSAFE
     365    crUnlockMutex(&h->mutex);
     366#endif
     367}
    355368
    356369void crHashtableWalk( CRHashTable *hash, CRHashtableWalkCallback walkFunc , void *dataPtr2)
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