mesa: Add a mutex and refcounting to gl_shader_state
authorGregory Hainaut <gregory.hainaut@gmail.com>
Fri, 28 Jun 2013 20:43:43 +0000 (13:43 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 21 Feb 2014 23:41:02 +0000 (15:41 -0800)
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
src/mesa/main/mtypes.h
src/mesa/main/shaderapi.c

index a29058badae0f84ec8bd8a9942371eced13e6ee9..48ae519ed57b808d6a96e7f4c0a913e793ba81c4 100644 (file)
@@ -2760,6 +2760,10 @@ struct gl_shader_program
  */
 struct gl_shader_state
 {
+   GLint RefCount;
+
+   _glthread_Mutex Mutex;
+
    /**
     * Programs used for rendering
     *
index 939e980174e7567a62e9f1af02e219d95fbed52a..ac95dc735cf61b16779968b486aa198b79ec49df 100644 (file)
@@ -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);
 }