From: Gregory Hainaut Date: Fri, 28 Jun 2013 20:43:43 +0000 (-0700) Subject: mesa: Add a mutex and refcounting to gl_shader_state X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0f137a1d73c415dc8744d4b9e6c194232715f023;p=mesa.git mesa: Add a mutex and refcounting to gl_shader_state Reviewed-by: Ian Romanick Reviewed-by: Jordan Justen --- diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index a29058badae..48ae519ed57 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2760,6 +2760,10 @@ struct gl_shader_program */ struct gl_shader_state { + GLint RefCount; + + _glthread_Mutex Mutex; + /** * Programs used for rendering * diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index 939e980174e..ac95dc735cf 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -121,6 +121,10 @@ _mesa_init_shader_state(struct gl_context *ctx) memcpy(&ctx->ShaderCompilerOptions[sh], &options, sizeof(options)); ctx->Shader.Flags = _mesa_get_shader_flags(); + + /* Extended for ARB_separate_shader_objects */ + ctx->Shader.RefCount = 1; + _glthread_INIT_MUTEX(ctx->Shader.Mutex); } @@ -138,6 +142,10 @@ _mesa_free_shader_state(struct gl_context *ctx) _mesa_reference_shader_program(ctx, &ctx->Shader._CurrentFragmentProgram, NULL); _mesa_reference_shader_program(ctx, &ctx->Shader.ActiveProgram, NULL); + + /* Extended for ARB_separate_shader_objects */ + assert(ctx->Shader.RefCount == 1); + _glthread_DESTROY_MUTEX(ctx->Shader.Mutex); }