glsl: test loop unroll with uint overflow
[piglit.git] / tests / spec / intel_blackhole_render / blackhole_draw.c
blobdd63b6726412d6facae0b042c1a2d37ff6d70fd0
1 /*
2 * Copyright © 2018 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 blackhole_draw.c
27 * Verifies that with GL_INTEL_black_render enabled, rendering operations have
28 * no effect.
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_ES2) || defined(PIGLIT_USE_OPENGL_ES3)
39 config.supports_gl_es_version = 20;
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 static enum piglit_result
49 run(void)
51 float delta = 1.01 / piglit_width;
52 GLuint prog;
54 /* This atom should be disabled by default */
55 if (glIsEnabled(GL_BLACKHOLE_RENDER_INTEL))
56 return PIGLIT_FAIL;
58 prog = piglit_build_simple_program(
59 #if defined(PIGLIT_USE_OPENGL)
60 "#version 330\n"
61 "in vec4 piglit_vertex;\n"
62 #elif defined(PIGLIT_USE_OPENGL_ES2) || defined(PIGLIT_USE_OPENGL_ES3)
63 "#version 100\n"
64 "attribute vec4 piglit_vertex;\n"
65 #endif
66 "void main()\n"
67 "{\n"
68 " gl_Position = piglit_vertex;\n"
69 "}\n",
70 #if defined(PIGLIT_USE_OPENGL)
71 "#version 330\n"
72 #elif defined(PIGLIT_USE_OPENGL_ES2) || defined(PIGLIT_USE_OPENGL_ES3)
73 "#version 100\n"
74 #endif
75 "void main()\n"
76 "{\n"
77 " gl_FragColor = 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 glViewport(0, 0, piglit_width, piglit_height);
85 glClearColor(0.0, 0.0, 0.0, 0.0);
87 glUseProgram(prog);
89 GLuint vao;
90 glGenVertexArrays(1, &vao);
91 glBindVertexArray(vao);
93 GLuint vbo;
94 float vertices[3][2] = {
95 { -0.5, -1 + delta, },
96 { 0, 0.8, },
97 { 0.5, -1 + delta, },
99 glGenBuffers(1, &vbo);
100 glBindBuffer(GL_ARRAY_BUFFER, vbo);
101 glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
102 glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(GLfloat), NULL);
103 glEnableVertexAttribArray(0);
105 glDisable(GL_BLACKHOLE_RENDER_INTEL);
106 glClear(GL_COLOR_BUFFER_BIT);
107 glDrawArrays(GL_TRIANGLES, 0, 3);
109 if(!piglit_check_gl_error(GL_NO_ERROR))
110 return PIGLIT_FAIL;
112 piglit_present_results();
114 const float normal_expected[] = { 1.0, 0.0, 0.0, 1.0 };
115 if (!piglit_probe_pixel_rgba(piglit_width / 2,
116 piglit_height / 2,
117 normal_expected))
118 return PIGLIT_FAIL;
120 glClearColor(0.0, 1.0, 0.0, 1.0);
121 glClear(GL_COLOR_BUFFER_BIT);
123 const float blackhole_draw_expected[] = { 0.0, 1.0, 0.0, 1.0 };
124 if (!piglit_probe_pixel_rgba(piglit_width / 2,
125 piglit_height / 2,
126 blackhole_draw_expected))
127 return PIGLIT_FAIL;
129 glEnable(GL_BLACKHOLE_RENDER_INTEL);
131 if (!glIsEnabled(GL_BLACKHOLE_RENDER_INTEL))
132 return PIGLIT_FAIL;
134 glDrawArrays(GL_TRIANGLES, 0, 3);
136 if(!piglit_check_gl_error(GL_NO_ERROR))
137 return PIGLIT_FAIL;
139 piglit_present_results();
141 glDisable(GL_BLACKHOLE_RENDER_INTEL);
143 if (!piglit_probe_pixel_rgba(piglit_width / 2,
144 piglit_height / 2,
145 blackhole_draw_expected))
146 return PIGLIT_FAIL;
148 glEnable(GL_BLACKHOLE_RENDER_INTEL);
150 glClearColor(1.0, 0.0, 0.0, 1.0);
152 if(!piglit_check_gl_error(GL_NO_ERROR))
153 return PIGLIT_FAIL;
155 piglit_present_results();
157 glDisable(GL_BLACKHOLE_RENDER_INTEL);
159 const float blackhole_clear_expected[] = { 0.0, 1.0, 0.0, 1.0 };
160 if (!piglit_probe_pixel_rgba(piglit_width / 2,
161 piglit_height / 2,
162 blackhole_clear_expected))
163 return PIGLIT_FAIL;
165 glClearColor(1.0, 0.0, 0.0, 1.0);
166 glClear(GL_COLOR_BUFFER_BIT);
168 piglit_present_results();
170 if (!piglit_probe_pixel_rgba(piglit_width / 2,
171 piglit_height / 2,
172 normal_expected))
173 return PIGLIT_FAIL;
175 return PIGLIT_PASS;
178 enum piglit_result
179 piglit_display(void)
181 enum piglit_result result = run();
183 glDisable(GL_BLACKHOLE_RENDER_INTEL);
185 return result;
188 void piglit_init(int argc, char **argv)
190 piglit_require_extension("GL_INTEL_blackhole_render");