glsl: test loop unroll with uint overflow
[piglit.git] / tests / spec / intel_conservative_rasterization / tri.c
blob56624453e7eabfaae17516b6bf6d8c6f1a21993d
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 tri.c
27 * Verifies that with GL_INTEL_conservative_rasterization enabled,
28 * partially covered pixels are rasterized.
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 config.window_width = 400;
43 config.window_height = 400;
44 config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
46 PIGLIT_GL_TEST_CONFIG_END
48 enum piglit_result
49 piglit_display(void)
51 float delta = 1.01 / piglit_width;
52 GLuint prog;
53 enum piglit_result result = PIGLIT_PASS;
55 prog = piglit_build_simple_program(
56 #if defined(PIGLIT_USE_OPENGL)
57 "#version 330\n"
58 #elif defined(PIGLIT_USE_OPENGL_ES3)
59 "#version 300 es\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 "out vec4 color;\n"
69 #elif defined(PIGLIT_USE_OPENGL_ES3)
70 "#version 300 es\n"
71 "out highp vec4 color;\n"
72 #endif
73 "void main()\n"
74 "{\n"
75 " color = vec4(1.0, 0.0, 0.0, 1.0);\n"
76 "}\n");
77 if (!prog)
78 piglit_report_result(PIGLIT_FAIL);
80 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, piglit_winsys_fbo);
81 glViewport(0, 0, piglit_width, piglit_height);
83 glClearColor(0.0, 0.0, 0.0, 0.0);
85 glUseProgram(prog);
87 GLuint vao;
88 glGenVertexArrays(1, &vao);
89 glBindVertexArray(vao);
91 GLuint vbo;
92 float vertices[3][2] = {
93 { -0.5, -1 + delta, },
94 { 0, 0.8, },
95 { 0.5, -1 + delta, },
97 glGenBuffers(1, &vbo);
98 glBindBuffer(GL_ARRAY_BUFFER, vbo);
99 glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
100 glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(GLfloat), NULL);
101 glEnableVertexAttribArray(0);
103 glEnable(GL_CONSERVATIVE_RASTERIZATION_INTEL);
104 glClear(GL_COLOR_BUFFER_BIT);
105 glDrawArrays(GL_TRIANGLES, 0, 3);
107 if(!piglit_check_gl_error(GL_NO_ERROR))
108 return PIGLIT_FAIL;
110 piglit_present_results();
112 const float conservative_expected[] = { 1.0, 0.0, 0.0, 1.0 };
113 if (!piglit_probe_pixel_rgba(piglit_width / 2, 0, conservative_expected))
114 result = PIGLIT_FAIL;
116 glDisable(GL_CONSERVATIVE_RASTERIZATION_INTEL);
117 glClear(GL_COLOR_BUFFER_BIT);
118 glDrawArrays(GL_TRIANGLES, 0, 3);
120 if(!piglit_check_gl_error(GL_NO_ERROR))
121 return PIGLIT_FAIL;
123 piglit_present_results();
125 const float expected[] = { 0.0, 0.0, 0.0, 0.0 };
126 if (!piglit_probe_pixel_rgba(piglit_width / 2, 0, expected))
127 result = PIGLIT_FAIL;
129 return result;
132 void piglit_init(int argc, char **argv)
134 piglit_require_extension("GL_INTEL_conservative_rasterization");