[Mesa-dev] [PATCH 08/88] glsl: add cache to ctx and add sha1 string fields
Timothy Arceri
timothy.arceri at collabora.com
Sat Sep 24 05:24: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 f550b0c..358cc01 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>
@@ -1223,6 +1224,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);
@@ -1263,6 +1266,7 @@ fail:
free(ctx->BeginEnd);
free(ctx->OutsideBeginEnd);
free(ctx->Save);
+ ralloc_free(ctx->Cache);
return GL_FALSE;
}
@@ -1330,6 +1334,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 56b0601..23c671e 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2474,6 +2474,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 */
@@ -2702,6 +2703,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
@@ -4689,6 +4692,8 @@ struct gl_context
* Stores the arguments to glPrimitiveBoundingBox
*/
GLfloat PrimitiveBoundingBox[8];
+
+ struct program_cache *Cache;
};
/**
--
2.7.4
More information about the mesa-dev
mailing list