summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/shaderapi.c
diff options
context:
space:
mode:
authorTapani Pälli <[email protected]>2018-07-24 10:41:46 +0300
committerTapani Pälli <[email protected]>2018-08-15 11:03:35 +0300
commit656ccf4ef890b91debbb72b38957723ca04411d0 (patch)
tree646198661955a9c4515a78d71667376453856668 /src/mesa/main/shaderapi.c
parent479a849ad606482c3cf67157b77af94ecd450ace (diff)
mesa: shader dump/read support for ARB programs
Signed-off-by: Tapani Pälli <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106283 Reviewed-by: Alejandro Piñeiro <[email protected]>
Diffstat (limited to 'src/mesa/main/shaderapi.c')
-rw-r--r--src/mesa/main/shaderapi.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index f7080847cc1..2ea8d965aba 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -1795,6 +1795,7 @@ generate_sha1(const char *source, char sha_str[64])
* following format:
*
* <path>/<stage prefix>_<CHECKSUM>.glsl
+ * <path>/<stage prefix>_<CHECKSUM>.arb
*/
static char *
construct_name(const gl_shader_stage stage, const char *source,
@@ -1805,15 +1806,17 @@ construct_name(const gl_shader_stage stage, const char *source,
"VS", "TC", "TE", "GS", "FS", "CS",
};
+ const char *format = strncmp(source, "!!ARB", 5) ? "glsl" : "arb";
+
generate_sha1(source, sha);
- return ralloc_asprintf(NULL, "%s/%s_%s.glsl", path, types[stage], sha);
+ return ralloc_asprintf(NULL, "%s/%s_%s.%s", path, types[stage], sha, format);
}
/**
* Write given shader source to a file in MESA_SHADER_DUMP_PATH.
*/
-static void
-dump_shader(const gl_shader_stage stage, const char *source)
+void
+_mesa_dump_shader_source(const gl_shader_stage stage, const char *source)
{
static bool path_exists = true;
char *dump_path;
@@ -1846,8 +1849,8 @@ dump_shader(const gl_shader_stage stage, const char *source)
* Read shader source code from a file.
* Useful for debugging to override an app's shader.
*/
-static GLcharARB *
-read_shader(const gl_shader_stage stage, const char *source)
+GLcharARB *
+_mesa_read_shader_source(const gl_shader_stage stage, const char *source)
{
char *read_path;
static bool path_exists = true;
@@ -1971,9 +1974,9 @@ shader_source(struct gl_context *ctx, GLuint shaderObj, GLsizei count,
/* Dump original shader source to MESA_SHADER_DUMP_PATH and replace
* if corresponding entry found from MESA_SHADER_READ_PATH.
*/
- dump_shader(sh->Stage, source);
+ _mesa_dump_shader_source(sh->Stage, source);
- replacement = read_shader(sh->Stage, source);
+ replacement = _mesa_read_shader_source(sh->Stage, source);
if (replacement) {
free(source);
source = replacement;