1 /* Copyright © 2015 Intel Corporation
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and associated documentation files (the "Software"),
5 * to deal in the Software without restriction, including without limitation
6 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 * and/or sell copies of the Software, and to permit persons to whom the
8 * Software is furnished to do so, subject to the following conditions:
10 * The above copyright notice and this permission notice (including the next
11 * paragraph) shall be included in all copies or substantial portions of the
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 * \file output-location.c
26 * \author Tapani Pälli
27 * heavily inspired by getfragdataindex.c from Dave Airlie
29 #include "piglit-util-gl.h"
31 PIGLIT_GL_TEST_CONFIG_BEGIN
33 #ifdef PIGLIT_USE_OPENGL
34 config
.supports_gl_core_version
= 31;
35 #else // PIGLIT_USE_OPENGLES3
36 config
.supports_gl_es_version
= 30;
38 config
.window_visual
= PIGLIT_GL_VISUAL_RGB
| PIGLIT_GL_VISUAL_DOUBLE
;
39 config
.khr_no_error_support
= PIGLIT_NO_ERRORS
;
41 PIGLIT_GL_TEST_CONFIG_END
43 #ifdef PIGLIT_USE_OPENGL
44 static const char *vs_text
=
47 "void main() { gl_Position = vertex; }\n"
50 static const char *fs_template
=
52 "#extension GL_ARB_explicit_attrib_location : require\n"
53 "layout(location = 0, index = 0) out vec4 a;\n"
54 "layout(location = %d, index = 1) out vec4 b;\n"
60 #else // PIGLIT_USE_OPENGLES3
61 static const char *vs_text
=
64 "void main() { gl_Position = vertex; }\n"
67 static const char *fs_template
=
69 "#extension GL_EXT_blend_func_extended : enable\n"
70 "layout(location = 0, index = 0) out highp vec4 a;\n"
71 "layout(location = %d, index = 1) out highp vec4 b;\n"
85 void piglit_init(int argc
, char **argv
)
87 GLint max_dual_source
;
92 #ifdef PIGLIT_USE_OPENGL
93 piglit_require_GLSL_version(150);
94 piglit_require_extension("GL_ARB_blend_func_extended");
95 #else // PIGLIT_USE_OPENGLES3
96 piglit_require_extension("GL_EXT_blend_func_extended");
98 glGetIntegerv(GL_MAX_DUAL_SOURCE_DRAW_BUFFERS
, &max_dual_source
);
100 if (max_dual_source
< 1) {
102 "ARB_blend_func_extended requires "
103 "GL_MAX_DUAL_SOURCE_DRAW_BUFFERS >= 1. "
106 piglit_report_result(PIGLIT_FAIL
);
109 /* Set >= GL_MAX_DUAL_SOURCE_DRAW_BUFFERS location for 'b' */
110 snprintf(fs_text
, 256, fs_template
, max_dual_source
);
112 prog
= piglit_build_simple_program_unlinked(vs_text
, fs_text
);
114 /* Linking should fail as the location set is too big. */
117 if (piglit_link_check_status(prog
))
118 piglit_report_result(PIGLIT_FAIL
);
120 piglit_report_result(PIGLIT_PASS
);