VirtualBox

Ignore:
Timestamp:
Apr 14, 2014 2:21:37 PM (11 years ago)
Author:
vboxsync
Message:

crOpenGL: fix to switch on/off new command submission

Location:
trunk/src/VBox/HostServices/SharedOpenGL/render
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.c

    r50405 r51064  
    599599}
    600600
     601void renderspuWindowTermBase( WindowInfo *window )
     602{
     603    renderspuVBoxCompositorSet(window, NULL);
     604    renderspuVBoxPresentBlitterCleanup(window);
     605    renderspu_SystemDestroyWindow( window );
     606    RTCritSectDelete(&window->CompositorLock);
     607}
     608
    601609void renderspuWindowTerm( WindowInfo *window )
    602610{
     
    605613    CRASSERT(!pOldCtx == !pOldWindow);
    606614    /* ensure no concurrent draws can take place */
    607     renderspuVBoxCompositorSet(window, NULL);
    608     renderspuVBoxPresentBlitterCleanup(window);
    609     renderspu_SystemDestroyWindow( window );
    610     RTCritSectDelete(&window->CompositorLock);
     615    renderspuWindowTermBase(window);
    611616    /* check if this window is bound to some ctx. Note: window pointer is already freed here */
    612617    crHashtableWalk(render_spu.contextTable, renderspuCheckCurrentCtxWindowCB, window);
     
    13671372}
    13681373
    1369 
    13701374static void RENDER_APIENTRY renderspuChromiumParameteriCR(GLenum target, GLint value)
    13711375{
    1372 
    13731376    switch (target)
    13741377    {
     
    13821385
    13831386            renderspuSetDefaultSharedContext(pCtx);
     1387            break;
     1388        }
     1389        case GL_HH_RENDERTHREAD_INFORM:
     1390        {
     1391            if (value)
     1392            {
     1393                int rc = renderspuDefaultCtxInit();
     1394                if (RT_FAILURE(rc))
     1395                {
     1396                    WARN(("renderspuDefaultCtxInit failed"));
     1397                    break;
     1398                }
     1399            }
     1400            else
     1401            {
     1402                renderspuCleanupBase(false);
     1403            }
    13841404            break;
    13851405        }
     
    17531773{
    17541774    WindowInfo *pWindow = (WindowInfo *)data1;
    1755 
    1756     renderspu_SystemReparentWindow(pWindow);
     1775    CRHashTable *pTable = (CRHashTable*)data2;
     1776
     1777    crHashtableDelete(pTable, key, NULL);
     1778
     1779    renderspuWindowTerm(pWindow);
     1780
     1781    crFree(pWindow);
    17571782}
    17581783
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.h

    r50095 r51064  
    424424extern PCR_BLITTER renderspuVBoxPresentBlitterGetAndEnter( WindowInfo *window, int32_t i32MakeCurrentUserData );
    425425extern PCR_BLITTER renderspuVBoxPresentBlitterEnsureCreated( WindowInfo *window, int32_t i32MakeCurrentUserData );
     426void renderspuWindowTermBase( WindowInfo *window );
    426427extern void renderspuWindowTerm( WindowInfo *window );
    427428extern WindowInfo* renderspuGetDummyWindow(GLint visBits);
     
    443444extern uint32_t renderspuContextMarkDeletedAndRelease( ContextInfo *context );
    444445
     446int renderspuDefaultCtxInit();
     447void renderspuCleanupBase(bool fDeleteTables);
     448
    445449ContextInfo * renderspuDefaultSharedContextAcquire();
    446450void renderspuDefaultSharedContextRelease(ContextInfo * pCtx);
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_glx.c

    r50095 r51064  
    673673        if (RT_SUCCESS(rc))
    674674        {
    675             rc = RTSemEventWait(render_spu.hWinCmdCompleteEvent, RT_INDEFINITE_WAIT);
     675            rc = RTSemEventWait(render_spu.hWinCmdCompleteEvent, RT_INDEFINITE_WAIT);
    676676            if (RT_SUCCESS(rc))
    677677            {
    678                 return VINF_SUCCESS;
    679             }
     678                return VINF_SUCCESS;
     679            }
    680680            else
    681681            {
    682                 crWarning("RTSemEventWait failed rc %d", rc);
    683             }
    684 
    685             RTThreadWait(render_spu.hWinCmdThread, RT_INDEFINITE_WAIT, NULL);
     682            crWarning("RTSemEventWait failed rc %d", rc);
     683        }
     684
     685        RTThreadWait(render_spu.hWinCmdThread, RT_INDEFINITE_WAIT, NULL);
    686686        }
    687687        else
     
    689689            crWarning("RTThreadCreate failed rc %d", rc);
    690690        }
    691         RTSemEventDestroy(render_spu.hWinCmdCompleteEvent);
     691            RTSemEventDestroy(render_spu.hWinCmdCompleteEvent);
    692692    }
    693693    else
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_init.c

    r50095 r51064  
    134134#endif
    135135
     136int renderspuDefaultCtxInit()
     137{
     138    GLint defaultWin, defaultCtx;
     139    WindowInfo *windowInfo;
     140
     141    /*
     142     * Create the default window and context.  Their indexes are zero and
     143     * a client can use them without calling CreateContext or WindowCreate.
     144     */
     145    crDebug("Render SPU: Creating default window (visBits=0x%x, id=0)",
     146            render_spu.default_visual);
     147    defaultWin = renderspuWindowCreateEx( NULL, render_spu.default_visual, CR_RENDER_DEFAULT_WINDOW_ID );
     148    if (defaultWin != CR_RENDER_DEFAULT_WINDOW_ID) {
     149        crError("Render SPU: Couldn't get a double-buffered, RGB visual with Z!");
     150        return VERR_GENERAL_FAILURE;
     151    }
     152    crDebug( "Render SPU: WindowCreate returned %d (0=normal)", defaultWin );
     153
     154    crDebug("Render SPU: Creating default context, visBits=0x%x",
     155            render_spu.default_visual );
     156    defaultCtx = renderspuCreateContextEx( NULL, render_spu.default_visual, CR_RENDER_DEFAULT_CONTEXT_ID, 0 );
     157    if (defaultCtx != CR_RENDER_DEFAULT_CONTEXT_ID) {
     158        crError("Render SPU: failed to create default context!");
     159        return VERR_GENERAL_FAILURE;
     160    }
     161
     162    renderspuMakeCurrent( defaultWin, 0, defaultCtx );
     163
     164    /* Get windowInfo for the default window */
     165    windowInfo = (WindowInfo *) crHashtableSearch(render_spu.windowTable, CR_RENDER_DEFAULT_WINDOW_ID);
     166    CRASSERT(windowInfo);
     167    windowInfo->mapPending = GL_TRUE;
     168
     169    return VINF_SUCCESS;
     170}
     171
    136172static SPUFunctions *
    137173renderSPUInit( int id, SPU *child, SPU *self,
     
    139175{
    140176    int numFuncs, numSpecial;
    141     GLint defaultWin, defaultCtx;
    142     WindowInfo *windowInfo;
     177
    143178    const char * pcpwSetting;
    144179    int rc;
     
    267302#endif /* DARWIN */
    268303
    269     /*
    270      * Create the default window and context.  Their indexes are zero and
    271      * a client can use them without calling CreateContext or WindowCreate.
    272      */
    273     crDebug("Render SPU: Creating default window (visBits=0x%x, id=0)",
    274             render_spu.default_visual);
    275     defaultWin = renderspuWindowCreateEx( NULL, render_spu.default_visual, CR_RENDER_DEFAULT_WINDOW_ID );
    276     if (defaultWin != CR_RENDER_DEFAULT_WINDOW_ID) {
    277         crError("Render SPU: Couldn't get a double-buffered, RGB visual with Z!");
     304    rc = renderspuDefaultCtxInit();
     305    if (!RT_SUCCESS(rc))
     306    {
     307        WARN(("renderspuDefaultCtxInit failed %d", rc));
    278308        return NULL;
    279309    }
    280     crDebug( "Render SPU: WindowCreate returned %d (0=normal)", defaultWin );
    281 
    282     crDebug("Render SPU: Creating default context, visBits=0x%x",
    283             render_spu.default_visual );
    284     defaultCtx = renderspuCreateContextEx( NULL, render_spu.default_visual, CR_RENDER_DEFAULT_CONTEXT_ID, 0 );
    285     if (defaultCtx != CR_RENDER_DEFAULT_CONTEXT_ID) {
    286         crError("Render SPU: failed to create default context!");
    287         return NULL;
    288     }
    289 
    290     renderspuMakeCurrent( defaultWin, 0, defaultCtx );
    291 
    292     /* Get windowInfo for the default window */
    293     windowInfo = (WindowInfo *) crHashtableSearch(render_spu.windowTable, CR_RENDER_DEFAULT_WINDOW_ID);
    294     CRASSERT(windowInfo);
    295     windowInfo->mapPending = GL_TRUE;
    296310
    297311    /*
     
    414428{
    415429    WindowInfo *window = (WindowInfo *) data;
    416     renderspu_SystemDestroyWindow(window);
     430    renderspuWindowTermBase(window);
    417431    crFree(window);
    418432}
     
    433447}
    434448
     449
     450static void renderspuDeleteBlitterCB(unsigned long key, void *data1, void *data2)
     451{
     452    CRHashTable *pTbl = (CRHashTable*)data2;
     453
     454    crHashtableDelete( pTbl, key, NULL );
     455
     456    DeleteBlitterCallback(data1);
     457}
     458
     459
     460static void renderspuDeleteWindowCB(unsigned long key, void *data1, void *data2)
     461{
     462    CRHashTable *pTbl = (CRHashTable*)data2;
     463
     464    crHashtableDelete( pTbl, key, NULL );
     465
     466    DeleteWindowCallback(data1);
     467}
     468
     469static void renderspuDeleteBarierCB(unsigned long key, void *data1, void *data2)
     470{
     471    CRHashTable *pTbl = (CRHashTable*)data2;
     472
     473    crHashtableDelete( pTbl, key, NULL );
     474
     475    crFree(data1);
     476}
     477
     478
     479static void renderspuDeleteContextCB(unsigned long key, void *data1, void *data2)
     480{
     481    CRHashTable *pTbl = (CRHashTable*)data2;
     482
     483    crHashtableDelete( pTbl, key, NULL );
     484
     485    DeleteContextCallback(data1);
     486}
     487
     488void renderspuCleanupBase(bool fDeleteTables)
     489{
     490    renderspuVBoxCompositorClearAll();
     491
     492    if (render_spu.blitterTable)
     493    {
     494        if (fDeleteTables)
     495        {
     496            crFreeHashtable(render_spu.blitterTable, DeleteBlitterCallback);
     497            render_spu.blitterTable = NULL;
     498        }
     499        else
     500        {
     501            crHashtableWalk(render_spu.blitterTable, renderspuDeleteBlitterCB, render_spu.contextTable);
     502        }
     503    }
     504    else
     505    {
     506        crHashtableWalk(render_spu.windowTable, renderspuBlitterCleanupCB, NULL);
     507
     508        crHashtableWalk(render_spu.dummyWindowTable, renderspuBlitterCleanupCB, NULL);
     509    }
     510
     511    renderspuSetDefaultSharedContext(NULL);
     512
     513    if (fDeleteTables)
     514    {
     515        crFreeHashtable(render_spu.contextTable, DeleteContextCallback);
     516        render_spu.contextTable = NULL;
     517        crFreeHashtable(render_spu.windowTable, DeleteWindowCallback);
     518        render_spu.windowTable = NULL;
     519        crFreeHashtable(render_spu.dummyWindowTable, DeleteWindowCallback);
     520        render_spu.dummyWindowTable = NULL;
     521        crFreeHashtable(render_spu.barrierHash, crFree);
     522        render_spu.barrierHash = NULL;
     523    }
     524    else
     525    {
     526        crHashtableWalk(render_spu.contextTable, renderspuDeleteContextCB, render_spu.contextTable);
     527        crHashtableWalk(render_spu.windowTable, renderspuDeleteWindowCB, render_spu.windowTable);
     528        crHashtableWalk(render_spu.dummyWindowTable, renderspuDeleteWindowCB, render_spu.dummyWindowTable);
     529        crHashtableWalk(render_spu.barrierHash, renderspuDeleteBarierCB, render_spu.barrierHash);
     530    }
     531}
     532
    435533static int renderSPUCleanup(void)
    436534{
    437     renderspuVBoxCompositorClearAll();
    438 
    439     if (render_spu.blitterTable)
    440     {
    441         crFreeHashtable(render_spu.blitterTable, DeleteBlitterCallback);
    442         render_spu.blitterTable = NULL;
    443     }
    444     else
    445     {
    446         crHashtableWalk(render_spu.windowTable, renderspuBlitterCleanupCB, NULL);
    447 
    448         crHashtableWalk(render_spu.dummyWindowTable, renderspuBlitterCleanupCB, NULL);
    449     }
    450 
    451     renderspuSetDefaultSharedContext(NULL);
    452 
    453     crFreeHashtable(render_spu.contextTable, DeleteContextCallback);
    454     render_spu.contextTable = NULL;
    455     crFreeHashtable(render_spu.windowTable, DeleteWindowCallback);
    456     render_spu.windowTable = NULL;
    457     crFreeHashtable(render_spu.dummyWindowTable, DeleteWindowCallback);
    458     render_spu.dummyWindowTable = NULL;
    459     crFreeHashtable(render_spu.barrierHash, crFree);
    460     render_spu.barrierHash = NULL;
     535    renderspuCleanupBase(true);
    461536
    462537#ifdef RT_OS_DARWIN
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