VirtualBox

Ignore:
Timestamp:
Mar 4, 2013 11:16:25 AM (12 years ago)
Author:
vboxsync
Message:

crOpenGL: work around context destruction ogl driver bug

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

Legend:

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

    r44887 r44908  
    1313#include "renderspu.h"
    1414#include "cr_extstring.h"
     15
     16#include <iprt/asm.h>
    1517
    1618
     
    180182    */
    181183
     184    if (sharedContext)
     185        ASMAtomicIncU32(&sharedContext->cRefs);
     186    context->cRefs = 1;
     187
    182188    return context;
    183189}
     
    209215}
    210216
     217static uint32_t renderspuContextRelease( ContextInfo *context );
     218static void renderspuDestroyContextTerminate( ContextInfo *context )
     219{
     220    CRASSERT(context->BltInfo.Base.id == -1);
     221    renderspu_SystemDestroyContext( context );
     222    if (context->extensionString) {
     223        crFree(context->extensionString);
     224        context->extensionString = NULL;
     225    }
     226
     227    if (context->shared)
     228        renderspuContextRelease( context->shared );
     229
     230    crFree(context);
     231}
     232
     233static uint32_t renderspuContextRelease( ContextInfo *context )
     234{
     235    uint32_t cRefs = ASMAtomicDecU32(&context->cRefs);
     236    if (!cRefs)
     237        renderspuDestroyContextTerminate( context );
     238    else
     239        CRASSERT(cRefs < UINT32_MAX/2);
     240    return cRefs;
     241}
     242
     243uint32_t renderspuContextMarkDeletedAndRelease( ContextInfo *context )
     244{
     245    /* invalidate the context id to mark it as deleted */
     246    context->BltInfo.Base.id = -1;
     247
     248    /* some drivers do not like when the base (shared) context is deleted before its referals,
     249     * this is why we keep a context refference counting the base (shared) context will be destroyed as soon as*/
     250    return renderspuContextRelease( context );
     251}
     252
    211253static void RENDER_APIENTRY
    212254renderspuDestroyContext( GLint ctx )
     
    224266    context = (ContextInfo *) crHashtableSearch(render_spu.contextTable, ctx);
    225267    CRASSERT(context);
     268    {
     269        if (!context)
     270        {
     271            crWarning("request to delete inexistent context");
     272            return;
     273        }
     274    }
    226275
    227276    curCtx = GET_CONTEXT_VAL();
     
    235284    }
    236285
    237     renderspu_SystemDestroyContext( context );
    238     if (context->extensionString) {
    239         crFree(context->extensionString);
    240         context->extensionString = NULL;
    241     }
    242     crHashtableDelete(render_spu.contextTable, ctx, crFree);
     286    crHashtableDelete(render_spu.contextTable, ctx, NULL);
     287
     288    renderspuContextMarkDeletedAndRelease(context);
    243289}
    244290
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.h

    r44887 r44908  
    168168    struct _ContextInfo *shared;
    169169    char *extensionString;
     170    volatile uint32_t cRefs;
    170171} ContextInfo;
    171172
     
    416417extern void RENDER_APIENTRY renderspuSwapBuffers( GLint window, GLint flags );
    417418
     419extern uint32_t renderspuContextMarkDeletedAndRelease( ContextInfo *context );
     420
    418421#ifdef __cplusplus
    419422extern "C" {
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_init.c

    r44887 r44908  
    411411{
    412412    ContextInfo *context = (ContextInfo *) data;
    413     renderspu_SystemDestroyContext(context);
    414     crFree(context);
     413    renderspuContextMarkDeletedAndRelease(context);
    415414}
    416415
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