VirtualBox

Changeset 40692 in vbox


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

crOpenGL: missing file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_context.c

    r39815 r40692  
    2525    GLint retVal = -1;
    2626    CRContext *newCtx;
    27     CRCreateInfo_t *pCreateInfo;
     27    CRContextInfo *pContextInfo;
     28    GLboolean fFirst = GL_FALSE;
    2829
    2930    if (shareCtx > 0) {
     
    3132        shareCtx = 0;
    3233    }
     34
     35    pContextInfo = (CRContextInfo *) crAlloc(sizeof (CRContextInfo));
     36    if (!pContextInfo)
     37    {
     38        crWarning("failed to alloc context info!");
     39        return -1;
     40    }
     41
     42    pContextInfo->CreateInfo.visualBits = visualBits;
    3343
    3444    /* Since the Cr server serialized all incoming clients/contexts into
     
    3747     */
    3848    if (cr_server.firstCallCreateContext) {
    39         cr_server.SpuContextVisBits = visualBits;
    40         cr_server.SpuContext = cr_server.head_spu->dispatch_table.
    41             CreateContext(dpyName, cr_server.SpuContextVisBits, shareCtx);
    42         if (cr_server.SpuContext < 0) {
     49        cr_server.MainContextInfo.CreateInfo.visualBits = visualBits;
     50        cr_server.MainContextInfo.SpuContext = cr_server.head_spu->dispatch_table.
     51            CreateContext(dpyName, cr_server.MainContextInfo.CreateInfo.visualBits, shareCtx);
     52        if (cr_server.MainContextInfo.SpuContext < 0) {
    4353            crWarning("crServerDispatchCreateContext() failed.");
     54            crFree(pContextInfo);
    4455            return -1;
    4556        }
    4657        cr_server.firstCallCreateContext = GL_FALSE;
     58        fFirst = GL_TRUE;
    4759    }
    4860    else {
    4961        /* second or third or ... context */
    50         if ((visualBits & cr_server.SpuContextVisBits) != visualBits) {
     62        if (!cr_server.bUseMultipleContexts && ((visualBits & cr_server.MainContextInfo.CreateInfo.visualBits) != visualBits)) {
    5163            int oldSpuContext;
    5264
    5365            /* the new context needs new visual attributes */
    54             cr_server.SpuContextVisBits |= visualBits;
     66            cr_server.MainContextInfo.CreateInfo.visualBits |= visualBits;
    5567            crDebug("crServerDispatchCreateContext requires new visual (0x%x).",
    56                     cr_server.SpuContextVisBits);
     68                    cr_server.MainContextInfo.CreateInfo.visualBits);
    5769
    5870            /* Here, we used to just destroy the old rendering context.
     
    6779
    6880            /* create new rendering context with suitable visual */
    69             oldSpuContext = cr_server.SpuContext;
    70             cr_server.SpuContext = cr_server.head_spu->dispatch_table.
    71                 CreateContext(dpyName, cr_server.SpuContextVisBits, cr_server.SpuContext);
     81            oldSpuContext = cr_server.MainContextInfo.SpuContext;
     82            cr_server.MainContextInfo.SpuContext = cr_server.head_spu->dispatch_table.
     83                CreateContext(dpyName, cr_server.MainContextInfo.CreateInfo.visualBits, cr_server.MainContextInfo.SpuContext);
    7284            /* destroy old rendering context */
    7385            cr_server.head_spu->dispatch_table.DestroyContext(oldSpuContext);
    74             if (cr_server.SpuContext < 0) {
     86            if (cr_server.MainContextInfo.SpuContext < 0) {
    7587                crWarning("crServerDispatchCreateContext() failed.");
     88                crFree(pContextInfo);
    7689                return -1;
    7790            }
    7891        }
     92    }
     93
     94    if (cr_server.bUseMultipleContexts) {
     95        pContextInfo->SpuContext = cr_server.head_spu->dispatch_table.
     96                CreateContext(dpyName, cr_server.MainContextInfo.CreateInfo.visualBits, cr_server.MainContextInfo.SpuContext);
     97        if (pContextInfo->SpuContext < 0) {
     98            crWarning("crServerDispatchCreateContext() failed.");
     99            crStateEnableDiffOnMakeCurrent(GL_TRUE);
     100            cr_server.bUseMultipleContexts = GL_FALSE;
     101            if (!fFirst)
     102                crError("creating shared context failed, while it is expected to work!");
     103        }
     104        else if (fFirst)
     105        {
     106            crStateEnableDiffOnMakeCurrent(GL_FALSE);
     107        }
     108    }
     109    else
     110    {
     111        pContextInfo->SpuContext = -1;
    79112    }
    80113
     
    87120        crStateResetCurrentPointers(&(cr_server.current));
    88121        retVal = preloadCtxID<0 ? crServerGenerateID(&cr_server.idsPool.freeContextID) : preloadCtxID;
    89         crHashtableAdd(cr_server.contextTable, retVal, newCtx);
    90 
    91         pCreateInfo = (CRCreateInfo_t *) crAlloc(sizeof(CRCreateInfo_t));
    92         pCreateInfo->pszDpyName = dpyName ? crStrdup(dpyName) : NULL;
    93         pCreateInfo->visualBits = visualBits;
    94         pCreateInfo->internalID = newCtx->id;
    95         crHashtableAdd(cr_server.pContextCreateInfoTable, retVal, pCreateInfo);
     122
     123        pContextInfo->pContext = newCtx;
     124        pContextInfo->CreateInfo.visualBits = visualBits;
     125        pContextInfo->CreateInfo.internalID = newCtx->id;
     126        pContextInfo->CreateInfo.pszDpyName = dpyName ? crStrdup(dpyName) : NULL;
     127        crHashtableAdd(cr_server.contextTable, retVal, pContextInfo);
    96128    }
    97129
     
    149181crServerDispatchDestroyContext( GLint ctx )
    150182{
     183    CRContextInfo *crCtxInfo;
    151184    CRContext *crCtx;
    152185    int32_t client;
     
    154187    int found=false;
    155188
    156     crCtx = (CRContext *) crHashtableSearch(cr_server.contextTable, ctx);
    157     if (!crCtx) {
     189    crCtxInfo = (CRContextInfo *) crHashtableSearch(cr_server.contextTable, ctx);
     190    if (!crCtxInfo) {
    158191        crWarning("CRServer: DestroyContext invalid context %d", ctx);
    159192        return;
    160193    }
     194    crCtx = crCtxInfo->pContext;
     195    CRASSERT(crCtx);
    161196
    162197    crDebug("CRServer: DestroyContext context %d", ctx);
     
    164199    crHashtableDelete(cr_server.contextTable, ctx, NULL);
    165200    crStateDestroyContext( crCtx );
    166     crHashtableDelete(cr_server.pContextCreateInfoTable, ctx, crServerCreateInfoDeleteCB);
     201
     202    if (crCtxInfo->CreateInfo.pszDpyName)
     203        crFree(crCtxInfo->CreateInfo.pszDpyName);
     204
     205    if (crCtxInfo->SpuContext >= 0)
     206        cr_server.head_spu->dispatch_table.DestroyContext(crCtxInfo->SpuContext);
     207
     208    crFree(crCtxInfo);
    167209
    168210    if (cr_server.curClient)
    169211    {
    170212        /* If we delete our current context, default back to the null context */
    171         if (cr_server.curClient->currentCtx == crCtx) {
     213        if (cr_server.curClient->currentCtxInfo == crCtxInfo) {
    172214            cr_server.curClient->currentContextNumber = -1;
    173             cr_server.curClient->currentCtx = cr_server.DummyContext;
     215            cr_server.curClient->currentCtxInfo = &cr_server.MainContextInfo;
    174216        }
    175217
     
    207249    for (client=0; client<cr_server.numClients; ++client)
    208250    {
    209         if (cr_server.clients[client]->currentCtx == crCtx)
     251        if (cr_server.clients[client]->currentCtxInfo == crCtxInfo)
    210252        {
    211253            cr_server.clients[client]->currentContextNumber = -1;
    212             cr_server.clients[client]->currentCtx = cr_server.DummyContext;
     254            cr_server.clients[client]->currentCtxInfo = &cr_server.MainContextInfo;
    213255        }
    214256    }
     
    217259    while (pNode)
    218260    {
    219         if (pNode->pClient->currentCtx == crCtx)
     261        if (pNode->pClient->currentCtxInfo == crCtxInfo)
    220262        {
    221263            pNode->pClient->currentContextNumber = -1;
    222             pNode->pClient->currentCtx = cr_server.DummyContext;
     264            pNode->pClient->currentCtxInfo = &cr_server.MainContextInfo;
    223265        }
    224266        pNode = pNode->next;
     
    231273{
    232274    CRMuralInfo *mural, *oldMural;
     275    CRContextInfo *ctxInfo = NULL;
    233276    CRContext *ctx, *oldCtx;
    234277
     
    242285
    243286        /* Update the state tracker's current context */
    244         ctx = (CRContext *) crHashtableSearch(cr_server.contextTable, context);
    245         if (!ctx) {
     287        ctxInfo = (CRContextInfo *) crHashtableSearch(cr_server.contextTable, context);
     288        if (!ctxInfo) {
    246289            crWarning("CRserver: NULL context in MakeCurrent %d", context);
    247290            return;
     
    262305        }
    263306
    264         ctx = cr_server.DummyContext;
     307        ctxInfo = &cr_server.MainContextInfo;
    265308        window = -1;
    266309        mural = NULL;
    267310        return;
    268311    }
     312
     313    ctx = ctxInfo->pContext;
     314    CRASSERT(ctx);
    269315
    270316    /* Ubuntu 11.04 hosts misbehave if context window switch is
     
    273319     * crStateSwichPrepare restores the FBO state to its default values before the context window switch,
    274320     * while crStateSwichPostprocess restores it back to the original values */
    275     oldCtx = crStateSwichPrepare(ctx);
     321    if (!cr_server.bUseMultipleContexts)
     322        oldCtx = crStateSwichPrepare(ctx);
    276323
    277324    /*
     
    280327    */
    281328    cr_server.curClient->currentContextNumber = context;
    282     cr_server.curClient->currentCtx = ctx;
     329    cr_server.curClient->currentCtxInfo = ctxInfo;
    283330    cr_server.curClient->currentMural = mural;
    284331    cr_server.curClient->currentWindow = window;
    285332
    286     CRASSERT(cr_server.curClient->currentCtx);
     333    CRASSERT(cr_server.curClient->currentCtxInfo);
     334    CRASSERT(cr_server.curClient->currentCtxInfo->pContext);
    287335
    288336    /* This is a hack to force updating the 'current' attribs */
     
    324372        cr_server.head_spu->dispatch_table.MakeCurrent( mural->spuWindow,
    325373                                                        nativeWindow,
    326                                                         cr_server.SpuContext );
     374                                                        ctxInfo->SpuContext >= 0
     375                                                            ? ctxInfo->SpuContext
     376                                                              : cr_server.MainContextInfo.SpuContext);
    327377        cr_server.firstCallMakeCurrent = GL_FALSE;
     378        cr_server.currentCtxInfo = ctxInfo;
    328379        cr_server.currentWindow = window;
    329380        cr_server.currentNativeWindow = nativeWindow;
     
    333384    crStateMakeCurrent( ctx );
    334385
    335     crStateSwichPostprocess(oldCtx);
     386
     387    if (!cr_server.bUseMultipleContexts)
     388        crStateSwichPostprocess(oldCtx);
    336389
    337390    if (oldMural != mural && crServerSupportRedirMuralFBO())
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