diff options
author | Brian <[email protected]> | 2007-08-23 08:53:43 +0100 |
---|---|---|
committer | Brian <[email protected]> | 2007-08-23 08:53:43 +0100 |
commit | 4b654d41da08b3b5475144c027e97a3ae7ab5696 (patch) | |
tree | 2b19565434268fad9c767e6f39553fffafca7fcf /src/mesa/main/context.c | |
parent | dbef6158c6c19a28dc96a96357c9ed9bd9422b88 (diff) |
For _mesa_share_state(), update the context's references to the new share group's objects (Shane Blackett)
Diffstat (limited to 'src/mesa/main/context.c')
-rw-r--r-- | src/mesa/main/context.c | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index bb481093170..d988ef2d215 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -999,6 +999,28 @@ init_attrib_groups(GLcontext *ctx) /** + * Update default objects in a GL context with respect to shared state. + * + * \param ctx GL context. + * + * Removes references to old default objects, (texture objects, program + * objects, etc.) and changes to reference those from the current shared + * state. + */ +static GLboolean +update_default_objects(GLcontext *ctx) +{ + assert(ctx); + + _mesa_update_default_objects_program(ctx); + _mesa_update_default_objects_texture(ctx); + _mesa_update_default_objects_buffer_objects(ctx); + + return GL_TRUE; +} + + +/** * This is the default function we plug into all dispatch table slots * This helps prevents a segfault when someone calls a GL function without * first checking if the extension's supported. @@ -1605,12 +1627,18 @@ GLboolean _mesa_share_state(GLcontext *ctx, GLcontext *ctxToShare) { if (ctx && ctxToShare && ctx->Shared && ctxToShare->Shared) { - ctx->Shared->RefCount--; - if (ctx->Shared->RefCount == 0) { - free_shared_state(ctx, ctx->Shared); - } + struct gl_shared_state *oldSharedState = ctx->Shared; + ctx->Shared = ctxToShare->Shared; ctx->Shared->RefCount++; + + update_default_objects(ctx); + + oldSharedState->RefCount--; + if (oldSharedState->RefCount == 0) { + free_shared_state(ctx, oldSharedState); + } + return GL_TRUE; } else { |