[Mesa-dev] [PATCH 06/15] mesa: Add a mutex and refcounting to gl_shader_state

Ian Romanick idr at freedesktop.org
Fri Feb 7 22:00:16 PST 2014


From: Gregory Hainaut <gregory.hainaut at gmail.com>

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
---
 src/mesa/main/mtypes.h    | 4 ++++
 src/mesa/main/shaderapi.c | 8 ++++++++
 2 files changed, 12 insertions(+)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 9786a98..52aeb15 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2749,6 +2749,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 11384df..64bfe08 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);
 }
 
 
-- 
1.8.1.4



More information about the mesa-dev mailing list