[Mesa-dev] [PATCH 08/68] glsl: add cache to ctx and add sha1 string fields

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


From: Carl Worth <cworth at cworth.org>

V2: dont leak cache

Signed-off-by: Timothy Arceri <timothy.arceri at collabora.com>
---
 src/mesa/main/context.c | 6 ++++++
 src/mesa/main/mtypes.h  | 5 +++++
 2 files changed, 11 insertions(+)

diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 172c854..2f00c9d 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -143,6 +143,7 @@
 #include "sparc/sparc.h"
 #endif
 
+#include "compiler/glsl/cache.h"
 #include "compiler/glsl/glsl_parser_extras.h"
 #include <stdbool.h>
 
@@ -1224,6 +1225,8 @@ _mesa_initialize_context(struct gl_context *ctx,
    memset(&ctx->TextureFormatSupported, GL_TRUE,
 	  sizeof(ctx->TextureFormatSupported));
 
+   ctx->Cache = cache_create();
+
    switch (ctx->API) {
    case API_OPENGL_COMPAT:
       ctx->BeginEnd = create_beginend_table(ctx);
@@ -1264,6 +1267,7 @@ fail:
    free(ctx->BeginEnd);
    free(ctx->OutsideBeginEnd);
    free(ctx->Save);
+   ralloc_free(ctx->Cache);
    return GL_FALSE;
 }
 
@@ -1369,6 +1373,8 @@ _mesa_free_context_data( struct gl_context *ctx )
    free(ctx->Save);
    free(ctx->ContextLost);
 
+   ralloc_free(ctx->Cache);
+
    /* Shared context state (display lists, textures, etc) */
    _mesa_reference_shared_state(ctx, &ctx->Shared, NULL);
 
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 1a9ef8f..b17d407 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2247,6 +2247,7 @@ struct gl_shader
    GLuint Name;  /**< AKA the handle */
    GLint RefCount;  /**< Reference count */
    GLchar *Label;   /**< GL_KHR_debug */
+   unsigned char sha1[20]; /**< SHA1 hash of pre-processed source */
    GLboolean DeletePending;
    GLboolean CompileStatus;
    bool IsES;              /**< True if this shader uses GLSL ES */
@@ -2660,6 +2661,8 @@ struct gl_shader_program
     * Is the application intending to glGetProgramBinary this program?
     */
    GLboolean BinaryRetreivableHint;
+   unsigned char sha1[20]; /**< SHA1 hash of linked program */
+   bool program_written_to_cache;
 
    /**
     * Indicates whether program can be bound for individual pipeline stages
@@ -4628,6 +4631,8 @@ struct gl_context
     * Once this field becomes true, it is never reset to false.
     */
    GLboolean ShareGroupReset;
+
+   struct program_cache *Cache;
 };
 
 /**
-- 
2.5.5



More information about the mesa-dev mailing list