ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / arb_tessellation_shader / immediate-mode-draw-patches.c
bloba2bdc5157932b861d45bcb0ad693005c290d0680
1 /*
2 * Copyright © 2018 Timothy Arceri
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
13 * Software.
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.
24 /**
25 * Test immediate mode can draw GL_PATCHES.
28 #include "piglit-util-gl.h"
30 PIGLIT_GL_TEST_CONFIG_BEGIN
31 config.supports_gl_compat_version = 32;
32 config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
33 config.khr_no_error_support = PIGLIT_NO_ERRORS;
34 PIGLIT_GL_TEST_CONFIG_END
36 unsigned int prog;
38 static const char *const vs_source =
39 "#version 150 compatibility\n"
40 "in vec4 piglit_vertex;\n"
41 "void main() { gl_Position = piglit_vertex; }\n";
43 static const char *const tcs_source =
44 "#version 150 compatibility\n"
45 "#extension GL_ARB_tessellation_shader: require\n"
46 "layout(vertices = 3) out;\n"
47 "out vec4 color[];\n"
48 "void main() {\n"
49 " gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;\n"
50 " gl_TessLevelOuter = float[4](1.0, 1.0, 1.0, 0.0);\n"
51 " gl_TessLevelInner = float[2](0.0, 0.0);\n"
52 " color[gl_InvocationID] = vec4(0, 1, 0, 1);\n"
53 "}\n";
55 static const char *const tes_source =
56 "#version 150 compatibility\n"
57 "#extension GL_ARB_tessellation_shader: require\n"
58 "layout(triangles) in;\n"
59 "in vec4 color[];\n"
60 "void main() { \n"
61 " gl_Position = gl_in[0].gl_Position * gl_TessCoord[0]\n"
62 " + gl_in[1].gl_Position * gl_TessCoord[1]\n"
63 " + gl_in[2].gl_Position * gl_TessCoord[2];\n"
64 "\n"
65 " gl_FrontColor = color[0] * gl_TessCoord[0]\n"
66 " + color[1] * gl_TessCoord[1]\n"
67 " + color[2] * gl_TessCoord[2];\n"
68 "}\n";
70 enum piglit_result
71 piglit_display(void)
73 static const GLfloat green[4] = { 0, 1, 0, 1 };
74 enum piglit_result result;
76 glClearColor(0.1, 0.1, 0.1, 0.1);
77 glClear(GL_COLOR_BUFFER_BIT);
79 glBegin(GL_PATCHES);
80 glVertex2f(-1.0, -1.0);
81 glVertex2f(1.0, -1.0);
82 glVertex2f(-1.0, 1.0);
83 glVertex2f(-1.0, 1.0);
84 glVertex2f(1.0, -1.0);
85 glVertex2f(1.0, 1.0);
86 glEnd();
88 if (piglit_probe_pixel_rgb(piglit_width-1, piglit_height-1, green))
89 result = PIGLIT_PASS;
90 else
91 result = PIGLIT_FAIL;
93 if (!piglit_check_gl_error(GL_NO_ERROR))
94 result = PIGLIT_FAIL;
96 return result;
99 void
100 piglit_init(int argc, char **argv)
102 piglit_require_extension("GL_ARB_tessellation_shader");
104 prog = piglit_build_simple_program_multiple_shaders(
105 GL_VERTEX_SHADER, vs_source,
106 GL_TESS_CONTROL_SHADER, tcs_source,
107 GL_TESS_EVALUATION_SHADER, tes_source,
110 glUseProgram(prog);