2 * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * VMWARE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 * Measure SwapBuffers.
33 int WinWidth
= 100, WinHeight
= 100;
34 int real_WinWidth
, real_WinHeight
; /* don't know whats going on here */
43 static const struct vertex vertices
[4] = {
51 /** Called from test harness/main */
55 /* setup VBO w/ vertex data */
56 glGenBuffersARB(1, &VBO
);
57 glBindBufferARB(GL_ARRAY_BUFFER_ARB
, VBO
);
58 glBufferDataARB(GL_ARRAY_BUFFER_ARB
,
59 sizeof(vertices
), vertices
, GL_STATIC_DRAW_ARB
);
60 glVertexPointer(2, GL_FLOAT
, sizeof(struct vertex
), (void *) 0);
61 glEnableClientState(GL_VERTEX_ARRAY
);
64 glAlphaFunc(GL_ALWAYS
, 0.0);
68 SwapNaked(unsigned count
)
71 for (i
= 0; i
< count
; i
++) {
78 SwapClear(unsigned count
)
81 for (i
= 0; i
< count
; i
++) {
82 glClear(GL_COLOR_BUFFER_BIT
);
88 SwapClearPoint(unsigned count
)
91 for (i
= 0; i
< count
; i
++) {
92 glClear(GL_COLOR_BUFFER_BIT
);
93 glDrawArrays(GL_POINTS
, 0, 4);
115 if (i
< sizeof(sizes
) / sizeof(sizes
[0]) &&
116 PerfReshapeWindow( sizes
[i
].w
, sizes
[i
].h
))
118 perf_printf("Reshape %dx%d\n", sizes
[i
].w
, sizes
[i
].h
);
119 real_WinWidth
= sizes
[i
].w
;
120 real_WinHeight
= sizes
[i
].h
;
131 /** Called from test harness/main */
137 rate0
= PerfMeasureRate(SwapNaked
);
138 perf_printf(" Swapbuffers %dx%d: %s swaps/second",
139 real_WinWidth
, real_WinHeight
,
140 PerfHumanFloat(rate0
));
141 perf_printf(" %s pixels/second\n",
142 PerfHumanFloat(rate0
* real_WinWidth
* real_WinHeight
));
146 rate0
= PerfMeasureRate(SwapClear
);
147 perf_printf(" Swap/Clear %dx%d: %s swaps/second",
148 real_WinWidth
, real_WinHeight
,
149 PerfHumanFloat(rate0
));
150 perf_printf(" %s pixels/second\n",
151 PerfHumanFloat(rate0
* real_WinWidth
* real_WinHeight
));
154 rate0
= PerfMeasureRate(SwapClearPoint
);
155 perf_printf(" Swap/Clear/Draw %dx%d: %s swaps/second",
156 real_WinWidth
, real_WinHeight
,
157 PerfHumanFloat(rate0
));
158 perf_printf(" %s pixels/second\n",
159 PerfHumanFloat(rate0
* real_WinWidth
* real_WinHeight
));