[Mesa-dev] [RFC 16/20] glsl: add method to deserialize binary program from given path

Tapani Pälli tapani.palli at intel.com
Mon Jun 2 05:05:57 PDT 2014


Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
---
 src/glsl/shader_cache.h         |  3 +++
 src/glsl/shader_deserialize.cpp | 18 ++++++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/src/glsl/shader_cache.h b/src/glsl/shader_cache.h
index 23d1098..2262a49 100644
--- a/src/glsl/shader_cache.h
+++ b/src/glsl/shader_cache.h
@@ -91,6 +91,9 @@ int
 mesa_program_deserialize(struct gl_shader_program *prog, const GLvoid *data,
                          size_t size);
 
+int
+mesa_program_load(struct gl_shader_program *prog, const char *path);
+
 #ifdef __cplusplus
 } /* extern "C" */
 #endif
diff --git a/src/glsl/shader_deserialize.cpp b/src/glsl/shader_deserialize.cpp
index 84b62cc..f0e3a58 100644
--- a/src/glsl/shader_deserialize.cpp
+++ b/src/glsl/shader_deserialize.cpp
@@ -401,3 +401,21 @@ mesa_program_deserialize(struct gl_shader_program *prog, const GLvoid *data,
    map.map((const void*) data, size);
    return deserialize_program(prog, map);
 }
+
+
+extern "C" int
+mesa_program_load(struct gl_shader_program *prog, const char *path)
+{
+   memory_map map;
+   int result = 0;
+
+   if (map.map(path))
+      return -1;
+   result = deserialize_program(prog, map);
+
+   /* Cache binary produced with a different Mesa, remove it. */
+   if (result == MESA_SHADER_DESERIALIZE_VERSION_ERROR)
+      unlink(path);
+
+   return result;
+}
-- 
1.8.3.1



More information about the mesa-dev mailing list