VirtualBox

Ignore:
Timestamp:
Mar 28, 2012 3:48:51 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
77147
Message:

crOpenGL: basics for using multiple contexts on host

Location:
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server.h

    r39603 r40691  
    8282} CRServerProgram;
    8383
    84 typedef struct {
    85     char   *pszDpyName;
    86     GLint   visualBits;
    87     int32_t internalID;
    88 } CRCreateInfo_t;
    89 
    9084void crServerSetVBoxConfiguration();
    9185void crServerSetVBoxConfigurationHGCM();
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_boundsinfo.c

    r27889 r40691  
    265265
    266266        if (!mural->viewportValidated) {
    267                 crServerComputeViewportBounds(&(cr_server.curClient->currentCtx->viewport),
     267                crServerComputeViewportBounds(&(cr_server.curClient->currentCtxInfo->pContext->viewport),
    268268                                                                                                                                        mural);
    269269        }
     
    292292                                {
    293293                                        mural->curExtent = p->id;
    294                                         if (cr_server.run_queue->client->currentCtx) {
     294                                        if (cr_server.run_queue->client->currentCtxInfo && cr_server.run_queue->client->currentCtxInfo->pContext) {
    295295                                                crServerSetOutputBounds( mural, mural->curExtent );
    296296                                        }
     
    315315                        {
    316316                                mural->curExtent = i;
    317                                 if (cr_server.run_queue->client->currentCtx) {
     317                                if (cr_server.run_queue->client->currentCtxInfo && cr_server.run_queue->client->currentCtxInfo->pContext) {
    318318                                        crServerSetOutputBounds( mural, i );
    319319                                }
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_config.c

    r36843 r40691  
    4141    cr_server.num_overlap_intens = 0;
    4242    cr_server.overlap_intens = 0;
    43     cr_server.SpuContext = 0;
     43    crMemset(&cr_server.MainContextInfo, 0, sizeof (cr_server.MainContextInfo));
    4444
    4545    crMatrixInit(&cr_server.viewMatrix[0]);
     
    219219                                            cr_server.tcpip_port,
    220220                                            cr_server.mtu, 0);
    221         newClient->currentCtx = cr_server.DummyContext;
     221        newClient->currentCtxInfo = &cr_server.MainContextInfo;
    222222        crServerAddToRunQueue(newClient);
    223223
     
    293293                                            cr_server.tcpip_port,
    294294                                            cr_server.mtu, 0);
    295         newClient->currentCtx = cr_server.DummyContext;
     295        newClient->currentCtxInfo = &cr_server.MainContextInfo;
    296296        crServerAddToRunQueue(newClient);
    297297
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_lists.c

    r34725 r40691  
    8080    list = TranslateListID( list );
    8181
    82     if (cr_server.curClient->currentCtx->lists.mode == 0) {
     82    if (cr_server.curClient->currentCtxInfo->pContext->lists.mode == 0) {
    8383        /* we're not compiling, so execute the list now */
    8484        /* Issue the list as-is */
     
    208208    }
    209209
    210     if (cr_server.curClient->currentCtx->lists.mode == 0) {
     210    if (cr_server.curClient->currentCtxInfo->pContext->lists.mode == 0) {
    211211        /* we're not compiling, so execute the list now */
    212212        /* Issue the list as-is */
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_main.c

    r40318 r40691  
    109109
    110110
    111 static void deleteContextCallback( void *data )
    112 {
    113     CRContext *c = (CRContext *) data;
    114     crStateDestroyContext(c);
     111static void deleteContextInfoCallback( void *data )
     112{
     113    CRContextInfo *c = (CRContextInfo *) data;
     114    crStateDestroyContext(c->pContext);
     115    if (c->CreateInfo.pszDpyName)
     116        crFree(c->CreateInfo.pszDpyName);
     117    crFree(c);
    115118}
    116119
     
    144147
    145148    /* Free all context info */
    146     crFreeHashtable(cr_server.contextTable, deleteContextCallback);
     149    crFreeHashtable(cr_server.contextTable, deleteContextInfoCallback);
    147150
    148151    /* Free context/window creation info */
    149     crFreeHashtable(cr_server.pContextCreateInfoTable, crServerCreateInfoDeleteCB);
    150152    crFreeHashtable(cr_server.pWindowCreateInfoTable, crServerCreateInfoDeleteCB);
    151153
     
    275277#endif
    276278
     279#ifndef DEBUG_misha
     280    cr_server.bUseMultipleContexts = GL_FALSE;
     281#else
     282    cr_server.bUseMultipleContexts = GL_FALSE;
     283#endif
     284
     285    if (cr_server.bUseMultipleContexts)
     286    {
     287        crInfo("Info: using multiple contexts!");
     288        crDebug("Debug: using multiple contexts!");
     289    }
     290
    277291    cr_server.firstCallCreateContext = GL_TRUE;
    278292    cr_server.firstCallMakeCurrent = GL_TRUE;
     
    298312     */
    299313    cr_server.contextTable = crAllocHashtable();
    300     cr_server.DummyContext = crStateCreateContext( &cr_server.limits,
     314    cr_server.MainContextInfo.pContext = crStateCreateContext( &cr_server.limits,
    301315                                                   CR_RGB_BIT | CR_DEPTH_BIT, NULL );
    302     cr_server.curClient->currentCtx = cr_server.DummyContext;
     316    cr_server.curClient->currentCtxInfo = &cr_server.MainContextInfo;
    303317
    304318    crServerInitDispatch();
     
    334348#endif
    335349
     350#ifndef DEBUG_misha
     351    cr_server.bUseMultipleContexts = GL_FALSE;
     352#else
     353    cr_server.bUseMultipleContexts = GL_FALSE;
     354#endif
     355
     356    if (cr_server.bUseMultipleContexts)
     357    {
     358        crInfo("Info: using multiple contexts!");
     359        crDebug("Debug: using multiple contexts!");
     360    }
     361
    336362    crNetInit(crServerRecv, crServerClose);
    337363
     
    341367    cr_server.bIsInLoadingState = GL_FALSE;
    342368    cr_server.bIsInSavingState  = GL_FALSE;
     369
    343370
    344371    cr_server.pCleanupClient = NULL;
     
    367394     */
    368395    cr_server.contextTable = crAllocHashtable();
    369     cr_server.DummyContext = crStateCreateContext( &cr_server.limits,
     396    cr_server.MainContextInfo.pContext = crStateCreateContext( &cr_server.limits,
    370397                                                   CR_RGB_BIT | CR_DEPTH_BIT, NULL );
    371     cr_server.pContextCreateInfoTable = crAllocHashtable();
     398//    cr_server.pContextCreateInfoTable = crAllocHashtable();
    372399    cr_server.pWindowCreateInfoTable = crAllocHashtable();
    373400
     
    402429
    403430    newClient->spu_id = 0;
    404     newClient->currentCtx = cr_server.DummyContext;
     431    newClient->currentCtxInfo = &cr_server.MainContextInfo;
    405432    newClient->currentContextNumber = -1;
    406433    newClient->conn = crNetAcceptClient(cr_server.protocol, NULL,
     
    686713static void crVBoxServerSaveCreateInfoCB(unsigned long key, void *data1, void *data2)
    687714{
    688     CRCreateInfo_t *pCreateInfo = (CRCreateInfo_t *) data1;
     715    CRCreateInfo_t *pCreateInfo = (CRCreateInfo_t *)data1;
    689716    PSSMHANDLE pSSM = (PSSMHANDLE) data2;
    690717    int32_t rc;
     
    705732}
    706733
     734static void crVBoxServerSaveCreateInfoFromCtxInfoCB(unsigned long key, void *data1, void *data2)
     735{
     736    CRContextInfo *pContextInfo = (CRContextInfo *)data1;
     737    CRCreateInfo_t *pCreateInfo = &pContextInfo->CreateInfo;
     738    crVBoxServerSaveCreateInfoCB(key, pCreateInfo, data2);
     739}
     740
    707741static void crVBoxServerSyncTextureCB(unsigned long key, void *data1, void *data2)
    708742{
     
    716750static void crVBoxServerSaveContextStateCB(unsigned long key, void *data1, void *data2)
    717751{
    718     CRContext *pContext = (CRContext *) data1;
     752    CRContextInfo *pContextInfo = (CRContextInfo *) data1;
     753    CRContext *pContext = pContextInfo->pContext;
    719754    PSSMHANDLE pSSM = (PSSMHANDLE) data2;
    720755    int32_t rc;
     
    732767    {
    733768        unsigned long id;
    734         if (!crHashtableGetDataKey(cr_server.contextTable, pContext, &id))
     769        if (!crHashtableGetDataKey(cr_server.contextTable, pContextInfo, &id))
    735770        {
    736771            crWarning("No client id for server ctx %d", pContext->id);
     
    786821
    787822    /* Save rendering contexts creation info */
    788     ui32 = crHashtableNumElements(cr_server.pContextCreateInfoTable);
     823    ui32 = crHashtableNumElements(cr_server.contextTable);
    789824    rc = SSMR3PutU32(pSSM, (uint32_t) ui32);
    790825    AssertRCReturn(rc, rc);
    791     crHashtableWalk(cr_server.pContextCreateInfoTable, crVBoxServerSaveCreateInfoCB, pSSM);
     826    crHashtableWalk(cr_server.contextTable, crVBoxServerSaveCreateInfoFromCtxInfoCB, pSSM);
    792827
    793828#ifdef CR_STATE_NO_TEXTURE_IMAGE_STORE
     
    855890            AssertRCReturn(rc, rc);
    856891
    857             if (pClient->currentCtx && pClient->currentContextNumber>=0)
     892            if (pClient->currentCtxInfo && pClient->currentCtxInfo->pContext && pClient->currentContextNumber>=0)
    858893            {
    859                 b = crHashtableGetDataKey(cr_server.contextTable, pClient->currentCtx, &key);
     894                b = crHashtableGetDataKey(cr_server.contextTable, pClient->currentCtxInfo, &key);
    860895                CRASSERT(b);
    861896                rc = SSMR3PutMem(pSSM, &key, sizeof(key));
     
    878913}
    879914
     915static DECLCALLBACK(CRContext*) crVBoxServerGetContextCB(void* pvData)
     916{
     917    CRContextInfo* pContextInfo = (CRContextInfo*)pvData;
     918    CRASSERT(pContextInfo);
     919    CRASSERT(pContextInfo->pContext);
     920    return pContextInfo->pContext;
     921}
     922
    880923DECLEXPORT(int32_t) crVBoxServerLoadState(PSSMHANDLE pSSM, uint32_t version)
    881924{
     
    915958        char psz[200];
    916959        GLint ctxID;
     960        CRContextInfo* pContextInfo;
    917961        CRContext* pContext;
    918962
     
    932976        CRASSERT((int64_t)ctxID == (int64_t)key);
    933977
    934         pContext = (CRContext*) crHashtableSearch(cr_server.contextTable, key);
    935         CRASSERT(pContext);
     978        pContextInfo = (CRContextInfo*) crHashtableSearch(cr_server.contextTable, key);
     979        CRASSERT(pContextInfo);
     980        CRASSERT(pContextInfo->pContext);
     981        pContext = pContextInfo->pContext;
    936982        pContext->shared->id=-1;
    937983    }
     
    940986    for (ui=0; ui<uiNumElems; ++ui)
    941987    {
     988        CRContextInfo* pContextInfo;
    942989        CRContext *pContext;
    943990
     
    945992        AssertRCReturn(rc, rc);
    946993
    947         pContext = (CRContext*) crHashtableSearch(cr_server.contextTable, key);
    948         CRASSERT(pContext);
    949 
    950         rc = crStateLoadContext(pContext, cr_server.contextTable, pSSM);
     994        pContextInfo = (CRContextInfo*) crHashtableSearch(cr_server.contextTable, key);
     995        CRASSERT(pContextInfo);
     996        CRASSERT(pContextInfo->pContext);
     997        pContext = pContextInfo->pContext;
     998
     999        rc = crStateLoadContext(pContext, cr_server.contextTable, crVBoxServerGetContextCB, pSSM);
    9511000        AssertRCReturn(rc, rc);
    9521001    }
     
    10561105
    10571106            pClient->currentContextNumber = -1;
    1058             pClient->currentCtx = cr_server.DummyContext;
     1107            pClient->currentCtxInfo = &cr_server.MainContextInfo;
    10591108            pClient->currentMural = NULL;
    10601109            pClient->currentWindow = -1;
     
    10621111            cr_server.curClient = pClient;
    10631112
    1064             if (client.currentCtx && client.currentContextNumber>=0)
     1113            if (client.currentCtxInfo && client.currentContextNumber>=0)
    10651114            {
    10661115                rc = SSMR3GetMem(pSSM, &ctxID, sizeof(ctxID));
    10671116                AssertRCReturn(rc, rc);
    1068                 client.currentCtx = (CRContext*) crHashtableSearch(cr_server.contextTable, ctxID);
    1069                 CRASSERT(client.currentCtx);
     1117                client.currentCtxInfo = (CRContextInfo*) crHashtableSearch(cr_server.contextTable, ctxID);
     1118                CRASSERT(client.currentCtxInfo);
     1119                CRASSERT(client.currentCtxInfo->pContext);
    10701120                //pClient->currentCtx = client.currentCtx;
    10711121                //pClient->currentContextNumber = ctxID;
     
    10941144            crServerDispatchMakeCurrent(winID, 0, ctxID);
    10951145
    1096             crHashtableWalk(client.currentCtx->shared->textureTable, crVBoxServerSyncTextureCB, client.currentCtx);
    1097 
    1098             crStateTextureObjectDiff(client.currentCtx, NULL, NULL, &client.currentCtx->texture.base1D, GL_TRUE);
    1099             crStateTextureObjectDiff(client.currentCtx, NULL, NULL, &client.currentCtx->texture.base2D, GL_TRUE);
    1100             crStateTextureObjectDiff(client.currentCtx, NULL, NULL, &client.currentCtx->texture.base3D, GL_TRUE);
     1146            crHashtableWalk(client.currentCtxInfo->pContext->shared->textureTable, crVBoxServerSyncTextureCB, client.currentCtxInfo->pContext);
     1147
     1148            crStateTextureObjectDiff(client.currentCtxInfo->pContext, NULL, NULL, &client.currentCtxInfo->pContext->texture.base1D, GL_TRUE);
     1149            crStateTextureObjectDiff(client.currentCtxInfo->pContext, NULL, NULL, &client.currentCtxInfo->pContext->texture.base2D, GL_TRUE);
     1150            crStateTextureObjectDiff(client.currentCtxInfo->pContext, NULL, NULL, &client.currentCtxInfo->pContext->texture.base3D, GL_TRUE);
    11011151#ifdef CR_ARB_texture_cube_map
    1102             crStateTextureObjectDiff(client.currentCtx, NULL, NULL, &client.currentCtx->texture.baseCubeMap, GL_TRUE);
     1152            crStateTextureObjectDiff(client.currentCtxInfo->pContext, NULL, NULL, &client.currentCtxInfo->pContext->texture.baseCubeMap, GL_TRUE);
    11031153#endif
    11041154#ifdef CR_NV_texture_rectangle
    11051155            //@todo this doesn't work as expected
    1106             //crStateTextureObjectDiff(client.currentCtx, NULL, NULL, &client.currentCtx->texture.baseRect, GL_TRUE);
     1156            //crStateTextureObjectDiff(client.currentCtxInfo->pContext, NULL, NULL, &client.currentCtxInfo->pContext->texture.baseRect, GL_TRUE);
    11071157#endif
    11081158            /*cr_server.head_spu->dispatch_table.Materialfv(GL_FRONT_AND_BACK, GL_AMBIENT, amb);
     
    11411191                tmpCtx = crStateCreateContext(NULL, createInfo->visualBits, NULL);
    11421192                CRASSERT(tmpCtx);
    1143                 crStateDiffContext(tmpCtx, client.currentCtx);
     1193                crStateDiffContext(tmpCtx, client.currentCtxInfo->pContext);
    11441194                crStateDestroyContext(tmpCtx);*/
    11451195            }
     
    12641314        {
    12651315            cr_server.curClient = cr_server.clients[i];
    1266             if (cr_server.curClient->currentCtx
    1267                 && (cr_server.curClient->currentCtx->buffer.pFrontImg || cr_server.curClient->currentCtx->buffer.pBackImg)
     1316            if (cr_server.curClient->currentCtxInfo
     1317                && cr_server.curClient->currentCtxInfo->pContext
     1318                && (cr_server.curClient->currentCtxInfo->pContext->buffer.pFrontImg || cr_server.curClient->currentCtxInfo->pContext->buffer.pBackImg)
    12681319                && cr_server.curClient->currentMural
    12691320                && cr_server.curClient->currentMural->screenId == sIndex
    1270                 && cr_server.curClient->currentCtx->buffer.storedHeight == h
    1271                 && cr_server.curClient->currentCtx->buffer.storedWidth == w)
     1321                && cr_server.curClient->currentCtxInfo->pContext->buffer.storedHeight == h
     1322                && cr_server.curClient->currentCtxInfo->pContext->buffer.storedWidth == w)
    12721323            {
    12731324                int clientWindow = cr_server.curClient->currentWindow;
     
    12791330                }
    12801331
    1281                 crStateApplyFBImage(cr_server.curClient->currentCtx);
     1332                crStateApplyFBImage(cr_server.curClient->currentCtxInfo->pContext);
    12821333            }
    12831334        }
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_misc.c

    r33601 r40691  
    263263    if (pCreateInfo->pszDpyName)
    264264        crFree(pCreateInfo->pszDpyName);
     265    crFree(pCreateInfo);
    265266}
    266267
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_projmatrix.c

    r33540 r40691  
    3232    else {
    3333        /* we have a quad-buffered window and we're watching glDrawBuffer */
    34         GLenum drawBuffer = cr_server.curClient->currentCtx->buffer.drawBuffer;
     34        GLenum drawBuffer = cr_server.curClient->currentCtxInfo->pContext->buffer.drawBuffer;
    3535        int eye = drawBuffer == GL_BACK_RIGHT || drawBuffer == GL_FRONT_RIGHT
    3636            || drawBuffer == GL_RIGHT;
     
    4242void SERVER_DISPATCH_APIENTRY crServerDispatchLoadMatrixf( const GLfloat *m )
    4343{
    44     const GLenum matMode = cr_server.curClient->currentCtx->transform.matrixMode;
     44    const GLenum matMode = cr_server.curClient->currentCtxInfo->pContext->transform.matrixMode;
    4545    const CRMuralInfo *mural = cr_server.curClient->currentMural;
    4646
     
    5959void SERVER_DISPATCH_APIENTRY crServerDispatchLoadMatrixd( const GLdouble *m )
    6060{
    61     const GLenum matMode = cr_server.curClient->currentCtx->transform.matrixMode;
     61    const GLenum matMode = cr_server.curClient->currentCtxInfo->pContext->transform.matrixMode;
    6262    const CRMuralInfo *mural = cr_server.curClient->currentMural;
    6363
     
    7676void SERVER_DISPATCH_APIENTRY crServerDispatchMultMatrixf( const GLfloat *m )
    7777{
    78     const GLenum matMode = cr_server.curClient->currentCtx->transform.matrixMode;
     78    const GLenum matMode = cr_server.curClient->currentCtxInfo->pContext->transform.matrixMode;
    7979
    8080    if (matMode == GL_PROJECTION && cr_server.projectionOverride) {
     
    9393void SERVER_DISPATCH_APIENTRY crServerDispatchMultMatrixd( const GLdouble *m )
    9494{
    95     const GLenum matMode = cr_server.curClient->currentCtx->transform.matrixMode;
     95    const GLenum matMode = cr_server.curClient->currentCtxInfo->pContext->transform.matrixMode;
    9696
    9797    if (matMode == GL_PROJECTION && cr_server.projectionOverride) {
     
    111111void SERVER_DISPATCH_APIENTRY crServerDispatchLoadIdentity( void )
    112112{
    113     const GLenum matMode = cr_server.curClient->currentCtx->transform.matrixMode;
     113    const GLenum matMode = cr_server.curClient->currentCtxInfo->pContext->transform.matrixMode;
    114114    const CRMuralInfo *mural = cr_server.curClient->currentMural;
    115115
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_stream.c

    r40318 r40691  
    2626                                                                                 cr_server.mtu, 1 );
    2727
    28         newClient->currentCtx = cr_server.DummyContext;
     28        newClient->currentCtxInfo = &cr_server.MainContextInfo;
    2929
    3030        /* add to array */
     
    293293crServerClientInBeginEnd(const CRClient *client)
    294294{
    295     if (client->currentCtx &&
    296             (client->currentCtx->lists.currentIndex != 0 ||
    297              client->currentCtx->current.inBeginEnd ||
    298              client->currentCtx->occlusion.currentQueryObject)) {
     295    if (client->currentCtxInfo
     296            && client->currentCtxInfo->pContext
     297            && (client->currentCtxInfo->pContext->lists.currentIndex != 0 ||
     298             client->currentCtxInfo->pContext->current.inBeginEnd ||
     299             client->currentCtxInfo->pContext->occlusion.currentQueryObject)) {
    299300        return GL_TRUE;
    300301    }
     
    543544             int clientWindow = cr_server.curClient->currentWindow;
    544545             int clientContext = cr_server.curClient->currentContextNumber;
    545              if (clientWindow && clientWindow != cr_server.currentWindow) {
     546             CRContextInfo *clientCtxInfo = cr_server.curClient->currentCtxInfo;
     547             if (clientCtxInfo != cr_server.currentCtxInfo) {
    546548                 crServerDispatchMakeCurrent(clientWindow, 0, clientContext);
    547549                 /*
     
    550552             }
    551553        }
    552 
    553         crStateMakeCurrent( cr_server.curClient->currentCtx );
    554554#endif
    555555
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_viewport.c

    r33540 r40691  
    240240        }
    241241        else
    242                 projMatrix = cr_server.curClient->currentCtx->transform.projectionStack.top;
     242                projMatrix = cr_server.curClient->currentCtxInfo->pContext->transform.projectionStack.top;
    243243
    244244        cr_server.head_spu->dispatch_table.PushAttrib( GL_TRANSFORM_BIT );
     
    254254crServerApplyViewMatrix(const CRmatrix *view)
    255255{
    256         const CRmatrix *modelview = cr_server.curClient->currentCtx->transform.modelViewStack.top;
     256        const CRmatrix *modelview = cr_server.curClient->currentCtxInfo->pContext->transform.modelViewStack.top;
    257257
    258258        cr_server.head_spu->dispatch_table.PushAttrib( GL_TRANSFORM_BIT );
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