[Mesa-dev] [PATCH V2] glsl: add cache to ctx and add sha1 string fields
Timothy Arceri
timothy.arceri at collabora.com
Sat Apr 30 04:53:59 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 6af02d1..48e4e74 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>
@@ -1222,6 +1223,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);
@@ -1262,6 +1265,7 @@ fail:
free(ctx->BeginEnd);
free(ctx->OutsideBeginEnd);
free(ctx->Save);
+ ralloc_free(ctx->Cache);
return GL_FALSE;
}
@@ -1366,6 +1370,8 @@ _mesa_free_context_data( struct gl_context *ctx )
free(ctx->OutsideBeginEnd);
free(ctx->Save);
+ 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 17100e4..3eced51 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2246,6 +2246,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 */
@@ -2619,6 +2620,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
@@ -4565,6 +4568,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