1 /*
2 * Copyright © 2018 Intel Corporation
3 *
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:
10 *
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.
14 *
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.
22 */
23
24 /**
25 * @file
26 * Test that vertex attribute aliasing is disallowed.
27 *
28 * From OpenGL ES 3.0.5 spec "2.12.5 Vertex Attributes":
29 *
30 * "Binding more than one attribute name to the same location is referred
31 * to as aliasing, and is not permitted in OpenGL ES Shading Language 3.00
32 * vertex shaders. LinkProgram will fail when this condition exists."
33 *
34 * From OpenGL ES SL 3.10/3.20 spec:
35 *
36 * "The existence of aliasing is determined by declarations present
37 * after preprocessing."
38 */
39
40 #include "piglit-util-gl.h"
41
42 PIGLIT_GL_TEST_CONFIG_BEGIN
43 config.supports_gl_es_version = 30;
44 PIGLIT_GL_TEST_CONFIG_END
45
46 static const char vs_source[] =
47 "#version 300 es\n"
48 "in highp float a;\n"
49 "in highp float b;\n"
50 "void main()\n"
51 "{\n"
52 " gl_Position = vec4(0.0);\n"
53 "}\n";
54
55 static const char fs_source[] =
56 "#version 300 es\n"
57 "out highp vec4 color;\n"
58 "void main()\n"
59 "{\n"
60 " color = vec4(0.0);\n"
61 "}\n";
62
63 enum piglit_result
piglit_display(void)64 piglit_display(void)
65 {
66 return PIGLIT_FAIL;
67 }
68
69 void
piglit_init(int argc,char ** argv)70 piglit_init(int argc, char **argv)
71 {
72 GLuint vs, fs, prog;
73
74 prog = glCreateProgram();
75
76 /* Bind 2 attributes to the same location. */
77 glBindAttribLocation(prog, 0, "a");
78 glBindAttribLocation(prog, 0, "b");
79
80 vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_source);
81 fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_source);
82
83 glAttachShader(prog, vs);
84 glAttachShader(prog, fs);
85
86 glLinkProgram(prog);
87
88 if (piglit_link_check_status_quiet(prog))
89 piglit_report_result(PIGLIT_FAIL);
90
91 glDeleteShader(vs);
92 glDeleteShader(fs);
93 glDeleteProgram(prog);
94
95 piglit_report_result(PIGLIT_PASS);
96 }
97