glx-multithread-texture: Avoid front-buffer rendering.
[piglit.git] / tests / util / piglit-framework-gl / piglit_gl_framework.c
blob37c06773db3d4beca80107bd16a0d6e1151b5721
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.
24 #include <stdio.h>
25 #include <string.h>
27 #include "piglit-util-gl.h"
28 #include "piglit_gl_framework.h"
29 #include "piglit-util-gl.h"
31 #ifdef PIGLIT_USE_WAFFLE
32 # include "piglit_fbo_framework.h"
33 # include "piglit_winsys_framework.h"
34 #else
35 # include "piglit_glut_framework.h"
36 #endif
37 #ifdef HAVE_LIBDRM
38 # include "piglit_drm_dma_buf.h"
39 #endif
41 struct piglit_gl_framework*
42 piglit_gl_framework_factory(const struct piglit_gl_test_config *test_config)
44 #ifdef PIGLIT_USE_WAFFLE
45 struct piglit_gl_framework *gl_fw = NULL;
47 if (piglit_use_fbo && !test_config->requires_displayed_window) {
48 gl_fw = piglit_fbo_framework_create(test_config);
51 if (gl_fw == NULL) {
52 piglit_use_fbo = false;
53 gl_fw = piglit_winsys_framework_factory(test_config);
56 return gl_fw;
57 #else
58 return piglit_glut_framework_create(test_config);
59 #endif
62 static void
63 validate_supported_apis(const struct piglit_gl_test_config *test_config)
65 if (!test_config->supports_gl_core_version &&
66 !test_config->supports_gl_compat_version &&
67 !test_config->supports_gl_es_version) {
68 printf("The test config supports no GL API's.\n");
69 piglit_report_result(PIGLIT_FAIL);
72 if (test_config->supports_gl_core_version > 0 &&
73 test_config->supports_gl_core_version < 31) {
74 printf("Config attribute 'supports_gl_core_version' is %d, "
75 "but must be either 0 or at least 31\n",
76 test_config->supports_gl_core_version);
77 piglit_report_result(PIGLIT_FAIL);
80 #if defined(PIGLIT_USE_OPENGL)
81 if (!test_config->supports_gl_core_version
82 && !test_config->supports_gl_compat_version) {
83 printf("Neither config attribute 'supports_gl_core_version' "
84 "nor 'supports_gl_compat_version' is set\n");
85 piglit_report_result(PIGLIT_SKIP);
87 #elif defined(PIGLIT_USE_OPENGL_ES1) || \
88 defined(PIGLIT_USE_OPENGL_ES2) || \
89 defined(PIGLIT_USE_OPENGL_ES3)
90 if (!test_config->supports_gl_es_version) {
91 printf("Config attribute 'supports_gl_es_version' is not "
92 "set\n");
93 piglit_report_result(PIGLIT_SKIP);
95 #else
96 # error
97 #endif
100 bool
101 piglit_gl_framework_init(struct piglit_gl_framework *gl_fw,
102 const struct piglit_gl_test_config *test_config)
104 validate_supported_apis(test_config);
105 memset(gl_fw, 0, sizeof(*gl_fw));
107 #ifdef HAVE_LIBDRM
108 gl_fw->create_dma_buf = piglit_drm_create_dma_buf;
109 gl_fw->destroy_dma_buf = piglit_drm_destroy_dma_buf;
110 #endif
112 gl_fw->test_config = test_config;
113 return true;
116 void
117 piglit_gl_framework_teardown(struct piglit_gl_framework *gl_fw)
119 return;