| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BENCH_GL_MAIN_H_ | 5 #ifndef BENCH_GL_MAIN_H_ |
| 6 #define BENCH_GL_MAIN_H_ | 6 #define BENCH_GL_MAIN_H_ |
| 7 | 7 |
| 8 #include <gflags/gflags.h> | 8 #include <gflags/gflags.h> |
| 9 #include <sys/time.h> | 9 #include <sys/time.h> |
| 10 | 10 |
| 11 #ifdef USE_GLES | 11 #ifdef USE_EGL |
| 12 #include <GLES2/gl2.h> |
| 12 #include <EGL/egl.h> | 13 #include <EGL/egl.h> |
| 13 #include <GLES/gl.h> | |
| 14 #else | 14 #else |
| 15 #include <GL/gl.h> | 15 #include <GL/gl.h> |
| 16 #include <GL/glx.h> | 16 #include <GL/glx.h> |
| 17 | 17 |
| 18 #define LIST_PROC_FUNCTIONS(F) \ | 18 #define LIST_PROC_FUNCTIONS(F) \ |
| 19 F(glAttachShader, PFNGLATTACHSHADERPROC) \ | 19 F(glAttachShader, PFNGLATTACHSHADERPROC) \ |
| 20 F(glBindBuffer, PFNGLBINDBUFFERPROC) \ | 20 F(glBindBuffer, PFNGLBINDBUFFERPROC) \ |
| 21 F(glBufferData, PFNGLBUFFERDATAPROC) \ | 21 F(glBufferData, PFNGLBUFFERDATAPROC) \ |
| 22 F(glCompileShader, PFNGLCOMPILESHADERPROC) \ | 22 F(glCompileShader, PFNGLCOMPILESHADERPROC) \ |
| 23 F(glCreateProgram, PFNGLCREATEPROGRAMPROC) \ | 23 F(glCreateProgram, PFNGLCREATEPROGRAMPROC) \ |
| 24 F(glCreateShader, PFNGLCREATESHADERPROC) \ | 24 F(glCreateShader, PFNGLCREATESHADERPROC) \ |
| 25 F(glDeleteBuffers, PFNGLDELETEBUFFERSPROC) \ | 25 F(glDeleteBuffers, PFNGLDELETEBUFFERSPROC) \ |
| 26 F(glDeleteProgram, PFNGLDELETEPROGRAMPROC) \ | 26 F(glDeleteProgram, PFNGLDELETEPROGRAMPROC) \ |
| 27 F(glDeleteShader, PFNGLDELETESHADERPROC) \ | 27 F(glDeleteShader, PFNGLDELETESHADERPROC) \ |
| 28 F(glEnableVertexAttribArray, PFNGLENABLEVERTEXATTRIBARRAYPROC) \ | 28 F(glEnableVertexAttribArray, PFNGLENABLEVERTEXATTRIBARRAYPROC) \ |
| 29 F(glGenBuffers, PFNGLGENBUFFERSPROC) \ | 29 F(glGenBuffers, PFNGLGENBUFFERSPROC) \ |
| 30 F(glGetAttribLocation, PFNGLGETATTRIBLOCATIONPROC) \ | 30 F(glGetAttribLocation, PFNGLGETATTRIBLOCATIONPROC) \ |
| 31 F(glGetInfoLogARB, PFNGLGETPROGRAMINFOLOGPROC) \ | 31 F(glGetInfoLogARB, PFNGLGETPROGRAMINFOLOGPROC) \ |
| 32 F(glGetProgramInfoLog, PFNGLGETPROGRAMINFOLOGPROC) \ |
| 33 F(glGetShaderInfoLog, PFNGLGETSHADERINFOLOGPROC) \ |
| 32 F(glGetUniformLocation, PFNGLGETUNIFORMLOCATIONPROC) \ | 34 F(glGetUniformLocation, PFNGLGETUNIFORMLOCATIONPROC) \ |
| 33 F(glLinkProgram, PFNGLLINKPROGRAMPROC) \ | 35 F(glLinkProgram, PFNGLLINKPROGRAMPROC) \ |
| 34 F(glShaderSource, PFNGLSHADERSOURCEPROC) \ | 36 F(glShaderSource, PFNGLSHADERSOURCEPROC) \ |
| 35 F(glUniform1f, PFNGLUNIFORM1FPROC) \ | 37 F(glUniform1f, PFNGLUNIFORM1FPROC) \ |
| 36 F(glUniform1i, PFNGLUNIFORM1IPROC) \ | 38 F(glUniform1i, PFNGLUNIFORM1IPROC) \ |
| 37 F(glUseProgram, PFNGLUSEPROGRAMPROC) \ | 39 F(glUseProgram, PFNGLUSEPROGRAMPROC) \ |
| 38 F(glVertexAttribPointer, PFNGLVERTEXATTRIBPOINTERPROC) \ | 40 F(glVertexAttribPointer, PFNGLVERTEXATTRIBPOINTERPROC) \ |
| 39 F(glXSwapIntervalSGI, PFNGLXSWAPINTERVALSGIPROC) | 41 F(glXSwapIntervalSGI, PFNGLXSWAPINTERVALSGIPROC) \ |
| 42 F(glXBindTexImageEXT, PFNGLXBINDTEXIMAGEEXTPROC) \ |
| 43 F(glXReleaseTexImageEXT, PFNGLXRELEASETEXIMAGEEXTPROC) |
| 40 | 44 |
| 41 #define F(fun, type) extern type fun; | 45 #define F(fun, type) extern type fun; |
| 42 LIST_PROC_FUNCTIONS(F) | 46 LIST_PROC_FUNCTIONS(F) |
| 43 #undef F | 47 #undef F |
| 44 | 48 |
| 45 #endif | 49 #endif |
| 46 | 50 |
| 47 inline uint64_t GetUTime() { | 51 inline uint64_t GetUTime() { |
| 48 struct timeval tv; | 52 struct timeval tv; |
| 49 gettimeofday(&tv, NULL); | 53 gettimeofday(&tv, NULL); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 78 // that: | 82 // that: |
| 79 // time it took to run x iterations = slope * x + bias | 83 // time it took to run x iterations = slope * x + bias |
| 80 // Returns false if one iteration of the test takes longer than | 84 // Returns false if one iteration of the test takes longer than |
| 81 // MAX_ITERATION_LENGTH_MS. The test is then assumed too slow to provide | 85 // MAX_ITERATION_LENGTH_MS. The test is then assumed too slow to provide |
| 82 // meaningful results. | 86 // meaningful results. |
| 83 bool Bench(BenchFunc func, float *slope, int64_t *bias); | 87 bool Bench(BenchFunc func, float *slope, int64_t *bias); |
| 84 | 88 |
| 85 void *MmapFile(const char *name, size_t *length); | 89 void *MmapFile(const char *name, size_t *length); |
| 86 | 90 |
| 87 #endif // BENCH_GL_MAIN_H_ | 91 #endif // BENCH_GL_MAIN_H_ |
| OLD | NEW |