perf/pixel-rate: new pixel throughput microbenchmark
[piglit.git] / tests / spec / glx_oml_sync_control / common.c
blobfe56b359050efb3956dd0b0eff7ee0b4a6351c68
1 /*
2 * Copyright © 2012 Intel Corporation
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 (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
23 * Authors:
24 * Eric Anholt <eric@anholt.net>
28 /** @file common.c
30 * Support code for running tests of GLX_OML_sync_control.
33 #include "piglit-util-gl.h"
34 #include "piglit-glx-util.h"
35 #include "common.h"
37 PFNGLXGETSYNCVALUESOMLPROC __piglit_glXGetSyncValuesOML;
38 PFNGLXGETMSCRATEOMLPROC __piglit_glXGetMscRateOML;
39 PFNGLXSWAPBUFFERSMSCOMLPROC __piglit_glXSwapBuffersMscOML;
40 PFNGLXWAITFORMSCOMLPROC __piglit_glXWaitForMscOML;
41 PFNGLXWAITFORSBCOMLPROC __piglit_glXWaitForSbcOML;
43 #define ADD_FUNC(name) PIGLIT_GLX_PROC(__piglit_##name, name)
44 static const struct piglit_glx_proc_reference procs[] = {
45 ADD_FUNC(glXGetSyncValuesOML),
46 ADD_FUNC(glXGetMscRateOML),
47 ADD_FUNC(glXSwapBuffersMscOML),
48 ADD_FUNC(glXWaitForMscOML),
49 ADD_FUNC(glXWaitForSbcOML),
52 Window win;
53 XVisualInfo *visinfo;
55 void
56 piglit_oml_sync_control_test_run(bool fullscreen, enum piglit_result (*draw)(Display *dpy))
58 Display *dpy;
59 GLXContext ctx;
61 dpy = XOpenDisplay(NULL);
62 if (dpy == NULL) {
63 fprintf(stderr, "couldn't open display\n");
64 piglit_report_result(PIGLIT_FAIL);
67 piglit_require_glx_extension(dpy, "GLX_OML_sync_control");
68 piglit_glx_get_all_proc_addresses(procs, ARRAY_SIZE(procs));
70 visinfo = piglit_get_glx_visual(dpy);
71 if (fullscreen)
72 win = piglit_get_glx_window_fullscreen(dpy, visinfo);
73 else
74 win = piglit_get_glx_window(dpy, visinfo);
75 ctx = piglit_get_glx_context(dpy, visinfo);
76 glXMakeCurrent(dpy, win, ctx);
78 piglit_dispatch_default_init(PIGLIT_DISPATCH_GL);
80 piglit_glx_event_loop(dpy, draw);