ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / arb_blend_func_extended / api / output-location.c
blobdbda66f7d187f66335738cd4e941c75c19d2e5a1
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
12 * Software.
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
20 * IN THE SOFTWARE.
23 /**
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;
37 #endif
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 =
45 "#version 150\n"
46 "in vec4 vertex;\n"
47 "void main() { gl_Position = vertex; }\n"
50 static const char *fs_template =
51 "#version 150\n"
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"
55 "void main() {\n"
56 " a = vec4(0.0);\n"
57 " b = vec4(1.0);\n"
58 "}\n"
60 #else // PIGLIT_USE_OPENGLES3
61 static const char *vs_text =
62 "#version 300 es\n"
63 "in vec4 vertex;\n"
64 "void main() { gl_Position = vertex; }\n"
67 static const char *fs_template =
68 "#version 300 es\n"
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"
72 "void main() {\n"
73 " a = vec4(0.0);\n"
74 " b = vec4(1.0);\n"
75 "}\n"
77 #endif
79 enum piglit_result
80 piglit_display(void)
82 return PIGLIT_FAIL;
85 void piglit_init(int argc, char **argv)
87 GLint max_dual_source;
88 GLuint prog;
89 char fs_text[256];
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");
97 #endif
98 glGetIntegerv(GL_MAX_DUAL_SOURCE_DRAW_BUFFERS, &max_dual_source);
100 if (max_dual_source < 1) {
101 fprintf(stderr,
102 "ARB_blend_func_extended requires "
103 "GL_MAX_DUAL_SOURCE_DRAW_BUFFERS >= 1. "
104 "Only got %d!\n",
105 max_dual_source);
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. */
115 glLinkProgram(prog);
117 if (piglit_link_check_status(prog))
118 piglit_report_result(PIGLIT_FAIL);
120 piglit_report_result(PIGLIT_PASS);