diff options
author | Brian Paul <[email protected]> | 2009-08-20 14:29:26 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2009-08-20 14:43:32 -0600 |
commit | f300db379e49c39418c4f05cc377ee7733d90163 (patch) | |
tree | fdb1067256d4973b977df4e7ccc46cb1afd841e8 /progs/util/shaderutil.c | |
parent | 8a883d165783d016923ea4b29a9e1e198b578a7a (diff) |
progs/util: added GetShaderCompile/LinkTime() to get compilation/link times
Diffstat (limited to 'progs/util/shaderutil.c')
-rw-r--r-- | progs/util/shaderutil.c | 33 |
1 files changed, 33 insertions, 0 deletions
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 <GL/glut.h> #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[]) { |