Mesa (master): mesa: new _mesa_append_uniforms_to_file() debug/ logging function

Brian Paul brianp at kemper.freedesktop.org
Fri Aug 14 17:31:39 UTC 2009


Module: Mesa
Branch: master
Commit: db598b899868ba6db8f3f525a22a45331589592e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=db598b899868ba6db8f3f525a22a45331589592e

Author: Brian Paul <brianp at vmware.com>
Date:   Fri Aug 14 11:26:20 2009 -0600

mesa: new _mesa_append_uniforms_to_file() debug/logging function

---

 src/mesa/shader/prog_print.c |   31 +++++++++++++++++++++++++++++++
 src/mesa/shader/prog_print.h |    3 +++
 2 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/src/mesa/shader/prog_print.c b/src/mesa/shader/prog_print.c
index 20d3fde..1bc2109 100644
--- a/src/mesa/shader/prog_print.c
+++ b/src/mesa/shader/prog_print.c
@@ -958,3 +958,34 @@ _mesa_write_shader_to_file(const struct gl_shader *shader)
 }
 
 
+/**
+ * Append the shader's uniform info/values to the shader log file.
+ * The log file will typically have been created by the
+ * _mesa_write_shader_to_file function.
+ */
+void
+_mesa_append_uniforms_to_file(const struct gl_shader *shader)
+{
+   const char *type;
+   char filename[100];
+   FILE *f;
+
+   if (shader->Type == GL_FRAGMENT_SHADER)
+      type = "frag";
+   else
+      type = "vert";
+
+   _mesa_snprintf(filename, sizeof(filename), "shader_%u.%s", shader->Name, type);
+   f = fopen(filename, "a"); /* append */
+   if (!f) {
+      fprintf(stderr, "Unable to open %s for appending\n", filename);
+      return;
+   }
+
+   fprintf(f, "/* First-draw parameters / constants */\n");
+   fprintf(f, "/*\n");
+   _mesa_fprint_parameter_list(f, shader->Program->Parameters);
+   fprintf(f, "*/\n");
+
+   fclose(f);
+}
diff --git a/src/mesa/shader/prog_print.h b/src/mesa/shader/prog_print.h
index 3da3e76..460426f 100644
--- a/src/mesa/shader/prog_print.h
+++ b/src/mesa/shader/prog_print.h
@@ -86,5 +86,8 @@ _mesa_print_parameter_list(const struct gl_program_parameter_list *list);
 extern void
 _mesa_write_shader_to_file(const struct gl_shader *shader);
 
+extern void
+_mesa_append_uniforms_to_file(const struct gl_shader *shader);
+
 
 #endif /* PROG_PRINT_H */




More information about the mesa-commit mailing list