[Mesa-dev] [PATCH 04/37] glsl: add cache to ctx and add sha1 string fields
Timothy Arceri
t_arceri at yahoo.com.au
Mon Jan 23 23:12:43 UTC 2017
From: Carl Worth <cworth at cworth.org>
We also add a flag for detecting shaders written to shader cache.
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 | 9 +++++++++
2 files changed, 15 insertions(+)
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index bd4551e..7ecd241 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -121,6 +121,7 @@
#include "shared.h"
#include "shaderobj.h"
#include "shaderimage.h"
+#include "util/disk_cache.h"
#include "util/strtod.h"
#include "stencil.h"
#include "texcompress_s3tc.h"
@@ -1229,6 +1230,8 @@ _mesa_initialize_context(struct gl_context *ctx,
memset(&ctx->TextureFormatSupported, GL_TRUE,
sizeof(ctx->TextureFormatSupported));
+ ctx->Cache = disk_cache_create();
+
switch (ctx->API) {
case API_OPENGL_COMPAT:
ctx->BeginEnd = create_beginend_table(ctx);
@@ -1269,6 +1272,7 @@ fail:
free(ctx->BeginEnd);
free(ctx->OutsideBeginEnd);
free(ctx->Save);
+ ralloc_free(ctx->Cache);
return GL_FALSE;
}
@@ -1336,6 +1340,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 4ac7531..1cc8322 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1927,6 +1927,9 @@ struct gl_program
bool is_arb_asm; /** Is this an ARB assembly-style program */
+ /** Is this program written to on disk shader cache */
+ bool program_written_to_cache;
+
GLbitfield64 SecondaryOutputsWritten; /**< Subset of OutputsWritten outputs written with non-zero index. */
GLbitfield TexturesUsed[MAX_COMBINED_TEXTURE_IMAGE_UNITS]; /**< TEXTURE_x_BIT bitmask */
GLbitfield SamplersUsed; /**< Bitfield of which samplers are used */
@@ -2384,6 +2387,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 */
@@ -2649,6 +2653,9 @@ struct gl_shader_program_data
{
GLint RefCount; /**< Reference count */
+ /** SHA1 hash of linked shader program */
+ unsigned char sha1[20];
+
unsigned NumUniformStorage;
unsigned NumHiddenUniforms;
struct gl_uniform_storage *UniformStorage;
@@ -4645,6 +4652,8 @@ struct gl_context
* Stores the arguments to glPrimitiveBoundingBox
*/
GLfloat PrimitiveBoundingBox[8];
+
+ struct disk_cache *Cache;
};
/**
--
2.9.3
More information about the mesa-dev
mailing list