VirtualBox

Changeset 48079 in vbox for trunk/src


Ignore:
Timestamp:
Aug 27, 2013 12:30:57 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
88452
Message:

crOpenGL: proper default shared context support

Location:
trunk/src/VBox
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/GuestHost/OpenGL/include/chromium.h

    r46783 r48079  
    724724/* guest requests host whether e debug break is needed*/
    725725#define GL_DBG_CHECK_BREAK_CR         0x8B2C
     726/* Tells renderspu the default context id being used by the crserver */
     727#define GL_HH_SET_DEFAULT_SHARED_CTX  0x8B2D
    726728
    727729/**********************************************************************/
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_context.c

    r47566 r48079  
    6363        cr_server.firstCallCreateContext = GL_FALSE;
    6464        fFirst = GL_TRUE;
     65
     66        cr_server.head_spu->dispatch_table.ChromiumParameteriCR(GL_HH_SET_DEFAULT_SHARED_CTX, cr_server.MainContextInfo.SpuContext);
    6567    }
    6668    else {
     
    7173            /* the new context needs new visual attributes */
    7274            cr_server.MainContextInfo.CreateInfo.visualBits |= visualBits;
    73             crDebug("crServerDispatchCreateContext requires new visual (0x%x).",
     75            crWarning("crServerDispatchCreateContext requires new visual (0x%x).",
    7476                    cr_server.MainContextInfo.CreateInfo.visualBits);
    7577
     
    9597                return -1;
    9698            }
     99
     100            /* we do not need to clean up the old default context explicitly, since the above cr_server.head_spu->dispatch_table.DestroyContext call
     101             * will do that for us */
     102            cr_server.head_spu->dispatch_table.ChromiumParameteriCR(GL_HH_SET_DEFAULT_SHARED_CTX, cr_server.MainContextInfo.SpuContext);
    97103        }
    98104    }
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_misc.c

    r46783 r48079  
    274274    case GL_HOST_WND_CREATED_HIDDEN_CR:
    275275        cr_server.bWindowsInitiallyHidden = value ? 1 : 0;
     276        break;
     277    case GL_HH_SET_DEFAULT_SHARED_CTX:
     278        crWarning("Recieved GL_HH_SET_DEFAULT_SHARED_CTX from guest, ignoring");
    276279        break;
    277280    default:
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.c

    r47566 r48079  
    1616#include <iprt/asm.h>
    1717
     18uint32_t renderspuContextRelease(ContextInfo *context);
     19uint32_t renderspuContextRetain(ContextInfo *context);
    1820
    1921static void
     
    183185
    184186    if (sharedContext)
    185         ASMAtomicIncU32(&sharedContext->cRefs);
     187        renderspuContextRetain(sharedContext);
     188
    186189    context->cRefs = 1;
    187190
     
    215218}
    216219
    217 static uint32_t renderspuContextRelease( ContextInfo *context );
    218220static void renderspuDestroyContextTerminate( ContextInfo *context )
    219221{
     
    231233}
    232234
    233 static uint32_t renderspuContextRelease( ContextInfo *context )
     235uint32_t renderspuContextRetain( ContextInfo *context )
     236{
     237    Assert(context->cRefs);
     238    return ASMAtomicIncU32(&context->cRefs);
     239}
     240
     241uint32_t renderspuContextRelease( ContextInfo *context )
    234242{
    235243    uint32_t cRefs = ASMAtomicDecU32(&context->cRefs);
     
    251259}
    252260
     261ContextInfo * renderspuDefaultSharedContextAcquire()
     262{
     263    ContextInfo * pCtx = render_spu.defaultSharedContext;
     264    if (!pCtx)
     265        return NULL;
     266
     267    renderspuContextRetain(pCtx);
     268    return pCtx;
     269}
     270
     271void renderspuDefaultSharedContextRelease(ContextInfo * pCtx)
     272{
     273    renderspuContextRelease(pCtx);
     274}
     275
     276
    253277static void RENDER_APIENTRY
    254278renderspuDestroyContext( GLint ctx )
     
    265289
    266290    context = (ContextInfo *) crHashtableSearch(render_spu.contextTable, ctx);
    267     CRASSERT(context);
    268     {
    269         if (!context)
    270         {
    271             crWarning("request to delete inexistent context");
    272             return;
    273         }
     291
     292    if (!context)
     293    {
     294        crWarning("request to delete inexistent context");
     295        return;
     296    }
     297
     298    if (render_spu.defaultSharedContext == context)
     299    {
     300        renderspuContextRelease(render_spu.defaultSharedContext);
     301        render_spu.defaultSharedContext = NULL;
    274302    }
    275303
     
    748776        {
    749777            int rc;
    750             CR_BLITTER_CONTEXT ctx;
     778            ContextInfo * pDefaultCtxInfo;
     779
    751780            pBlitter = (PCR_BLITTER)crCalloc(sizeof (*pBlitter));
    752781            if (!pBlitter)
     
    756785            }
    757786
    758             /* @todo: this is the assumption that crserverlib uses context 1 as a default one
    759              * need to do it in a more proper way */
    760             ctx.Base.id = 1;
    761             ctx.Base.visualBits = window->visual->visAttribs;
    762             rc = CrBltInit(pBlitter, &ctx, true, true, render_spu.blitterDispatch);
     787            pDefaultCtxInfo = renderspuDefaultSharedContextAcquire();
     788            if (!pDefaultCtxInfo)
     789            {
     790                crWarning("no default ctx info!");
     791                crFree(pBlitter);
     792                return NULL;
     793            }
     794
     795            rc = CrBltInit(pBlitter, &pDefaultCtxInfo->BltInfo, true, true, render_spu.blitterDispatch);
     796
     797            /* we can release it either way, since it will be retained when used as a shared context */
     798            renderspuDefaultSharedContextRelease(pDefaultCtxInfo);
     799
    763800            if (!RT_SUCCESS(rc))
    764801            {
     
    12311268    switch (target)
    12321269    {
     1270        case GL_HH_SET_DEFAULT_SHARED_CTX:
     1271            if (render_spu.defaultSharedContext)
     1272            {
     1273                renderspuContextRelease(render_spu.defaultSharedContext);
     1274                render_spu.defaultSharedContext = NULL;
     1275            }
     1276
     1277            if (value)
     1278            {
     1279                render_spu.defaultSharedContext = (ContextInfo *) crHashtableSearch(render_spu.contextTable, value);
     1280                if (render_spu.defaultSharedContext)
     1281                    renderspuContextRetain(render_spu.defaultSharedContext);
     1282                else
     1283                    crWarning("invalid default shared context id %d", value);
     1284            }
     1285
     1286            break;
    12331287        default:
    12341288//            crWarning("Unhandled target in renderspuChromiumParameteriCR()");
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.h

    r45577 r48079  
    258258    CRHashTable *windowTable;
    259259    CRHashTable *contextTable;
     260
     261    ContextInfo *defaultSharedContext;
    260262
    261263#ifndef CHROMIUM_THREADSAFE
     
    418420extern uint32_t renderspuContextMarkDeletedAndRelease( ContextInfo *context );
    419421
     422ContextInfo * renderspuDefaultSharedContextAcquire();
     423void renderspuDefaultSharedContextRelease(ContextInfo * pCtx);
     424uint32_t renderspuContextRelease(ContextInfo *context);
     425uint32_t renderspuContextRetain(ContextInfo *context);
     426
    420427#ifdef __cplusplus
    421428extern "C" {
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m

    r47566 r48079  
    17811781{
    17821782    NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init];
     1783   
     1784    /* view should not necesserily have a context set
     1785     * @todo: check and set default shared one */
    17831786
    17841787    [(OverlayView*)pView presentComposition:pChangedEntry];
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_init.c

    r45132 r48079  
    446446    }
    447447
     448    if (render_spu.defaultSharedContext)
     449    {
     450        renderspuContextRelease(render_spu.defaultSharedContext);
     451        render_spu.defaultSharedContext = NULL;
     452    }
     453
    448454    crFreeHashtable(render_spu.contextTable, DeleteContextCallback);
    449455    render_spu.contextTable = NULL;
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