Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(529)

Side by Side Diff: client/deps/glbench/src/main.h

Issue 894003: Teartest with -o flag to specify override redirect window and -r number to specify refresh rate. (Closed)
Patch Set: Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <sys/time.h> 8 #include <sys/time.h>
9 9
10 #ifdef USE_GLES 10 #ifdef USE_GLES
11 #include <EGL/egl.h> 11 #include <EGL/egl.h>
12 #include <GLES/gl.h> 12 #include <GLES/gl.h>
13 #else 13 #else
14 #include <GL/gl.h> 14 #include <GL/gl.h>
15 #include <GL/glx.h>
15 16
16 #define LIST_PROC_FUNCTIONS(F) \ 17 #define LIST_PROC_FUNCTIONS(F) \
17 F(glAttachShader, PFNGLATTACHSHADERPROC) \ 18 F(glAttachShader, PFNGLATTACHSHADERPROC) \
18 F(glBindBuffer, PFNGLBINDBUFFERPROC) \ 19 F(glBindBuffer, PFNGLBINDBUFFERPROC) \
19 F(glBufferData, PFNGLBUFFERDATAPROC) \ 20 F(glBufferData, PFNGLBUFFERDATAPROC) \
20 F(glCompileShader, PFNGLCOMPILESHADERPROC) \ 21 F(glCompileShader, PFNGLCOMPILESHADERPROC) \
21 F(glCreateProgram, PFNGLCREATEPROGRAMPROC) \ 22 F(glCreateProgram, PFNGLCREATEPROGRAMPROC) \
22 F(glCreateShader, PFNGLCREATESHADERPROC) \ 23 F(glCreateShader, PFNGLCREATESHADERPROC) \
23 F(glDeleteBuffers, PFNGLDELETEBUFFERSPROC) \ 24 F(glDeleteBuffers, PFNGLDELETEBUFFERSPROC) \
24 F(glDeleteProgram, PFNGLDELETEPROGRAMPROC) \ 25 F(glDeleteProgram, PFNGLDELETEPROGRAMPROC) \
25 F(glDeleteShader, PFNGLDELETESHADERPROC) \ 26 F(glDeleteShader, PFNGLDELETESHADERPROC) \
26 F(glEnableVertexAttribArray, PFNGLENABLEVERTEXATTRIBARRAYPROC) \ 27 F(glEnableVertexAttribArray, PFNGLENABLEVERTEXATTRIBARRAYPROC) \
27 F(glGenBuffers, PFNGLGENBUFFERSPROC) \ 28 F(glGenBuffers, PFNGLGENBUFFERSPROC) \
28 F(glGetAttribLocation, PFNGLGETATTRIBLOCATIONPROC) \ 29 F(glGetAttribLocation, PFNGLGETATTRIBLOCATIONPROC) \
29 F(glGetInfoLogARB, PFNGLGETPROGRAMINFOLOGPROC) \ 30 F(glGetInfoLogARB, PFNGLGETPROGRAMINFOLOGPROC) \
30 F(glGetUniformLocation, PFNGLGETUNIFORMLOCATIONPROC) \ 31 F(glGetUniformLocation, PFNGLGETUNIFORMLOCATIONPROC) \
31 F(glLinkProgram, PFNGLLINKPROGRAMPROC) \ 32 F(glLinkProgram, PFNGLLINKPROGRAMPROC) \
32 F(glShaderSource, PFNGLSHADERSOURCEPROC) \ 33 F(glShaderSource, PFNGLSHADERSOURCEPROC) \
33 F(glUniform1f, PFNGLUNIFORM1FPROC) \ 34 F(glUniform1f, PFNGLUNIFORM1FPROC) \
34 F(glUniform1i, PFNGLUNIFORM1IPROC) \ 35 F(glUniform1i, PFNGLUNIFORM1IPROC) \
35 F(glUseProgram, PFNGLUSEPROGRAMPROC) \ 36 F(glUseProgram, PFNGLUSEPROGRAMPROC) \
36 F(glVertexAttribPointer, PFNGLVERTEXATTRIBPOINTERPROC) 37 F(glVertexAttribPointer, PFNGLVERTEXATTRIBPOINTERPROC) \
38 F(glXSwapIntervalSGI, PFNGLXSWAPINTERVALSGIPROC)
37 39
38 #define F(fun, type) extern type fun; 40 #define F(fun, type) extern type fun;
39 LIST_PROC_FUNCTIONS(F) 41 LIST_PROC_FUNCTIONS(F)
40 #undef F 42 #undef F
41 43
42 #endif 44 #endif
43 45
44 inline uint64_t GetUTime() { 46 inline uint64_t GetUTime() {
45 struct timeval tv; 47 struct timeval tv;
46 gettimeofday(&tv, NULL); 48 gettimeofday(&tv, NULL);
47 return static_cast<uint64_t>(tv.tv_usec) + 49 return static_cast<uint64_t>(tv.tv_usec) +
48 1000000ULL*static_cast<uint64_t>(tv.tv_sec); 50 1000000ULL*static_cast<uint64_t>(tv.tv_sec);
49 } 51 }
50 52
51 extern GLint g_width; 53 extern GLint g_width;
52 extern GLint g_height; 54 extern GLint g_height;
55 extern bool g_override_redirect;
53 56
54 bool Init(); 57 bool Init();
55 bool InitContext(); 58 bool InitContext();
56 void DestroyContext(); 59 void DestroyContext();
57 void SwapBuffers(); 60 void SwapBuffers();
61 bool SwapInterval(int interval);
58 62
59 // BenchFunc functions are assumed to execute an operation iter times. See 63 // BenchFunc functions are assumed to execute an operation iter times. See
60 // Bench for a detailed explanation. 64 // Bench for a detailed explanation.
61 typedef void (*BenchFunc)(int iter); 65 typedef void (*BenchFunc)(int iter);
62 66
63 uint64_t TimeBench(BenchFunc func, int iter); 67 uint64_t TimeBench(BenchFunc func, int iter);
64 68
65 #define MAX_ITERATION_DURATION_MS 100000 69 #define MAX_ITERATION_DURATION_MS 100000
66 // Runs func passing it sequential powers of two (8, 16, 32,...) recording time 70 // Runs func passing it sequential powers of two (8, 16, 32,...) recording time
67 // it took. The data is then fitted linearly, obtaining slope and bias such 71 // it took. The data is then fitted linearly, obtaining slope and bias such
68 // that: 72 // that:
69 // time it took to run x iterations = slope * x + bias 73 // time it took to run x iterations = slope * x + bias
70 // Returns false if one iteration of the test takes longer than 74 // Returns false if one iteration of the test takes longer than
71 // MAX_ITERATION_LENGTH_MS. The test is then assumed too slow to provide 75 // MAX_ITERATION_LENGTH_MS. The test is then assumed too slow to provide
72 // meaningful results. 76 // meaningful results.
73 bool Bench(BenchFunc func, float *slope, int64_t *bias); 77 bool Bench(BenchFunc func, float *slope, int64_t *bias);
74 78
75 void *MmapFile(const char *name, size_t *length); 79 void *MmapFile(const char *name, size_t *length);
76 80
77 #endif // BENCH_GL_MAIN_H_ 81 #endif // BENCH_GL_MAIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698