[Mesa-dev] [PATCH 15/68] glsl: call _mesa_reference_program rather than bumping ref manually

Timothy Arceri timothy.arceri at collabora.com
Wed Jun 1 06:22:56 UTC 2016


---
 src/compiler/glsl/shader_cache.cpp           | 5 +++--
 src/compiler/glsl/standalone_scaffolding.cpp | 8 ++++++++
 src/compiler/glsl/standalone_scaffolding.h   | 4 ++++
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/compiler/glsl/shader_cache.cpp b/src/compiler/glsl/shader_cache.cpp
index 888daee..ec83797 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -48,6 +48,7 @@
 extern "C" {
 #include "main/shaderobj.h"
 #include "main/enums.h"
+#include "program/program.h"
 }
 
 static void
@@ -478,7 +479,7 @@ shader_cache_read_program_metadata(struct gl_context *ctx,
 
    glprog = ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, prog->Name);
    read_shader_metadata(&metadata, glprog, linked);
-   glprog->RefCount++;
+   _mesa_reference_program(ctx, &linked->Program, glprog);
    _mesa_reference_shader(ctx, &prog->_LinkedShaders[MESA_SHADER_VERTEX],
                           linked);
 
@@ -490,7 +491,7 @@ shader_cache_read_program_metadata(struct gl_context *ctx,
 
    glprog = ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, prog->Name);
    read_shader_metadata(&metadata, glprog, linked);
-   glprog->RefCount++;
+   _mesa_reference_program(ctx, &linked->Program, glprog);
    _mesa_reference_shader(ctx, &prog->_LinkedShaders[MESA_SHADER_FRAGMENT],
                           linked);
 
diff --git a/src/compiler/glsl/standalone_scaffolding.cpp b/src/compiler/glsl/standalone_scaffolding.cpp
index 49abe92..5fd3809 100644
--- a/src/compiler/glsl/standalone_scaffolding.cpp
+++ b/src/compiler/glsl/standalone_scaffolding.cpp
@@ -62,6 +62,14 @@ _mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr,
 }
 
 void
+_mesa_reference_program_(struct gl_context *ctx, struct gl_program **ptr,
+                         struct gl_program *prog)
+{
+   (void) ctx;
+   *ptr = prog;
+}
+
+void
 _mesa_shader_debug(struct gl_context *, GLenum, GLuint *,
                    const char *)
 {
diff --git a/src/compiler/glsl/standalone_scaffolding.h b/src/compiler/glsl/standalone_scaffolding.h
index 31c69a3..38bd76a 100644
--- a/src/compiler/glsl/standalone_scaffolding.h
+++ b/src/compiler/glsl/standalone_scaffolding.h
@@ -42,6 +42,10 @@ extern "C" void
 _mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr,
                        struct gl_shader *sh);
 
+extern "C" void
+_mesa_reference_program_(struct gl_context *ctx, struct gl_program **ptr,
+                         struct gl_program *prog);
+
 extern "C" struct gl_shader *
 _mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type);
 
-- 
2.5.5



More information about the mesa-dev mailing list