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
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
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"
35 # include "piglit_glut_framework.h"
38 # include "piglit_drm_dma_buf.h"
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
);
52 piglit_use_fbo
= false;
53 gl_fw
= piglit_winsys_framework_factory(test_config
);
58 return piglit_glut_framework_create(test_config
);
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 "
93 piglit_report_result(PIGLIT_SKIP
);
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
));
108 gl_fw
->create_dma_buf
= piglit_drm_create_dma_buf
;
109 gl_fw
->destroy_dma_buf
= piglit_drm_destroy_dma_buf
;
112 gl_fw
->test_config
= test_config
;
117 piglit_gl_framework_teardown(struct piglit_gl_framework
*gl_fw
)