ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / intel_conservative_rasterization / invalid.c
blob7ae43f6643da1505feb20d0cc0107079c3fdbd13
1 /*
2 * Copyright © 2016 Intel Corporation
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.
25 /** @file invalid.c
27 * Verifies that with GL_INTEL_conservative_rasterization enabled, we
28 * get specified errors when using invalid modes for that extension.
31 #include "piglit-util-gl.h"
32 #include "piglit-matrix.h"
34 PIGLIT_GL_TEST_CONFIG_BEGIN
36 #if defined(PIGLIT_USE_OPENGL)
37 config.supports_gl_core_version = 42;
38 #elif defined(PIGLIT_USE_OPENGL_ES3)
39 config.supports_gl_es_version = 31;
40 #endif
42 PIGLIT_GL_TEST_CONFIG_END
44 enum piglit_result
45 piglit_display(void)
47 return PIGLIT_FAIL;
50 void piglit_init(int argc, char **argv)
52 piglit_require_extension("GL_INTEL_conservative_rasterization");
54 GLuint prog = piglit_build_simple_program(
55 #if defined(PIGLIT_USE_OPENGL)
56 "#version 330\n"
57 #elif defined(PIGLIT_USE_OPENGL_ES3)
58 "#version 310 es\n"
59 "precision highp float;\n"
60 #endif
61 "in vec4 piglit_vertex;\n"
62 "void main()\n"
63 "{\n"
64 " gl_Position = piglit_vertex;\n"
65 "}\n",
66 #if defined(PIGLIT_USE_OPENGL)
67 "#version 330\n"
68 #elif defined(PIGLIT_USE_OPENGL_ES3)
69 "#version 310 es\n"
70 "precision highp float;\n"
71 #endif
72 "\n"
73 "out vec4 color;\n"
74 "\n"
75 "void main()\n"
76 "{\n"
77 " color = vec4(1.0, 0.0, 0.0, 1.0);\n"
78 "}\n");
79 if (!prog)
80 piglit_report_result(PIGLIT_FAIL);
82 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, piglit_winsys_fbo);
83 glUseProgram(prog);
85 GLuint vao;
86 glGenVertexArrays(1, &vao);
87 glBindVertexArray(vao);
89 GLuint vbo;
90 float vertices[3][2] = {
91 { -0.5, -1, },
92 { 0, 0.8, },
93 { 0.5, -1, },
95 glGenBuffers(1, &vbo);
96 glBindBuffer(GL_ARRAY_BUFFER, vbo);
97 glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
98 glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(GLfloat), NULL);
99 glEnableVertexAttribArray(0);
101 glEnable(GL_CONSERVATIVE_RASTERIZATION_INTEL);
102 #ifdef PIGLIT_USE_OPENGL
103 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
104 #endif
105 glClear(GL_COLOR_BUFFER_BIT);
107 glDrawArrays(GL_POINTS, 0, 3);
108 if (!piglit_check_gl_error(GL_INVALID_OPERATION))
109 piglit_report_result(PIGLIT_FAIL);
111 glDrawArrays(GL_LINES, 0, 3);
112 if (!piglit_check_gl_error(GL_INVALID_OPERATION))
113 piglit_report_result(PIGLIT_FAIL);
115 #ifdef PIGLIT_USE_OPENGL
116 glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
117 glDrawArrays(GL_LINES, 0, 3);
118 if (!piglit_check_gl_error(GL_INVALID_OPERATION))
119 piglit_report_result(PIGLIT_FAIL);
121 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
122 glDrawArrays(GL_LINES, 0, 3);
123 if (!piglit_check_gl_error(GL_INVALID_OPERATION))
124 piglit_report_result(PIGLIT_FAIL);
125 #endif
127 piglit_report_result(PIGLIT_PASS);