From: Brian Paul Date: Thu, 20 Aug 2009 20:29:26 +0000 (-0600) Subject: progs/util: added GetShaderCompile/LinkTime() to get compilation/link times X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f300db379e49c39418c4f05cc377ee7733d90163;p=mesa.git progs/util: added GetShaderCompile/LinkTime() to get compilation/link times --- diff --git a/progs/util/shaderutil.c b/progs/util/shaderutil.c index 489e71cc30c..c58c249831e 100644 --- a/progs/util/shaderutil.c +++ b/progs/util/shaderutil.c @@ -14,6 +14,12 @@ #include #include "shaderutil.h" +/** time to compile previous shader */ +static GLdouble CompileTime = 0.0; + +/** time to linke previous program */ +static GLdouble LinkTime = 0.0; + GLboolean ShadersSupported(void) @@ -37,10 +43,17 @@ CompileShaderText(GLenum shaderType, const char *text) { GLuint shader; GLint stat; + GLdouble t0, t1; shader = glCreateShader(shaderType); glShaderSource(shader, 1, (const GLchar **) &text, NULL); + + t0 = glutGet(GLUT_ELAPSED_TIME) * 0.001; glCompileShader(shader); + t1 = glutGet(GLUT_ELAPSED_TIME) * 0.001; + + CompileTime = t1 - t0; + glGetShaderiv(shader, GL_COMPILE_STATUS, &stat); if (!stat) { GLchar log[1000]; @@ -95,6 +108,7 @@ GLuint LinkShaders(GLuint vertShader, GLuint fragShader) { GLuint program = glCreateProgram(); + GLdouble t0, t1; assert(vertShader || fragShader); @@ -102,7 +116,12 @@ LinkShaders(GLuint vertShader, GLuint fragShader) glAttachShader(program, fragShader); if (vertShader) glAttachShader(program, vertShader); + + t0 = glutGet(GLUT_ELAPSED_TIME) * 0.001; glLinkProgram(program); + t1 = glutGet(GLUT_ELAPSED_TIME) * 0.001; + + LinkTime = t1 - t0; /* check link */ { @@ -121,6 +140,20 @@ LinkShaders(GLuint vertShader, GLuint fragShader) } +GLdouble +GetShaderCompileTime(void) +{ + return CompileTime; +} + + +GLdouble +GetShaderLinkTime(void) +{ + return LinkTime; +} + + void SetUniformValues(GLuint program, struct uniform_info uniforms[]) { diff --git a/progs/util/shaderutil.h b/progs/util/shaderutil.h index 0a6be026759..91c0d4094f8 100644 --- a/progs/util/shaderutil.h +++ b/progs/util/shaderutil.h @@ -36,6 +36,12 @@ CompileShaderFile(GLenum shaderType, const char *filename); extern GLuint LinkShaders(GLuint vertShader, GLuint fragShader); +extern GLdouble +GetShaderCompileTime(void); + +extern GLdouble +GetShaderLinkTime(void); + extern void SetUniformValues(GLuint program, struct uniform_info uniforms[]);