ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / arb_separate_shader_objects / compat-builtins.c
blob4c19459079815034c2df40833bc3e146e3e8f7d3
1 /*
2 * Copyright © 2015 Intel Corporation
3 * Copyright © 2015 Advanced Micro Devices, Inc.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22 * IN THE SOFTWARE.
25 /**
26 * Test separate shaders using built-in varyings, which are allowed in the
27 * compatibility profile (or GL 3.0 and earlier).
30 #include "piglit-util-gl.h"
32 PIGLIT_GL_TEST_CONFIG_BEGIN
34 config.supports_gl_compat_version = 21;
35 config.supports_gl_core_version = 0;
36 config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
38 PIGLIT_GL_TEST_CONFIG_END
40 static GLuint pipeline;
42 static const char *vs_code =
43 "#version 110\n"
44 "#extension GL_ARB_separate_shader_objects: require\n"
45 "\n"
46 "varying vec4 gl_TexCoord[2];\n"
47 "\n"
48 "void main()\n"
49 "{\n"
50 " gl_Position = gl_Vertex;\n"
51 " gl_TexCoord[0] = vec4(0.1, 0.2, 0.3, 0.4);\n"
52 " gl_TexCoord[1] = vec4(0.01, 0.02, 0.03, 0.04);\n"
53 "}\n"
56 static const char *fs_code =
57 "#version 110\n"
58 "#extension GL_ARB_separate_shader_objects: require\n"
59 "\n"
60 "varying vec4 gl_TexCoord[2];\n"
61 "\n"
62 "void main()\n"
63 "{\n"
64 " gl_FragColor = gl_TexCoord[0] + gl_TexCoord[1];\n"
65 "}\n"
68 enum piglit_result
69 piglit_display(void)
71 static const float expected[] = {
72 0.11, 0.22, 0.33, 0.44
74 bool pass;
76 glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
77 glClear(GL_COLOR_BUFFER_BIT);
79 glBindProgramPipeline(pipeline);
80 piglit_draw_rect(-1, -1, 2, 2);
82 pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height,
83 expected);
85 piglit_present_results();
86 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
89 void piglit_init(int argc, char **argv)
91 GLuint vs_prog, fs_prog;
93 piglit_require_extension("GL_ARB_separate_shader_objects");
95 vs_prog = glCreateShaderProgramv(GL_VERTEX_SHADER, 1,
96 (const GLchar *const*) &vs_code);
97 piglit_link_check_status(vs_prog);
99 fs_prog = glCreateShaderProgramv(GL_FRAGMENT_SHADER, 1,
100 (const GLchar *const *) &fs_code);
101 piglit_link_check_status(fs_prog);
103 glGenProgramPipelines(1, &pipeline);
104 glUseProgramStages(pipeline, GL_VERTEX_SHADER_BIT, vs_prog);
105 glUseProgramStages(pipeline, GL_FRAGMENT_SHADER_BIT, fs_prog);
106 piglit_program_pipeline_check_status(pipeline);
108 if (!piglit_check_gl_error(0))
109 piglit_report_result(PIGLIT_FAIL);