2 * Copyright © 2020 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
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
25 * \file compute-and-render-bug-109630
27 * Test verifies that after compute workload geometry renders fine.
28 * This exercises hardware issue in Intel's GEN9 GPU which resulted
29 * in geometry flickering see https://bugs.freedesktop.org/show_bug.cgi?id=109630
30 * There is no guaranteed way to reproduce the issue but to run the
31 * core part of the test many times.
33 * \author Andrii Kryvytskyi <andrii.o.kryvytskyi@globallogic.com>
36 #include "piglit-util-gl.h"
37 PIGLIT_GL_TEST_CONFIG_BEGIN
39 config
.supports_gl_core_version
= 42;
40 config
.window_height
= 1024;
41 config
.window_width
= 1024;
42 config
.window_visual
= PIGLIT_GL_VISUAL_DOUBLE
| PIGLIT_GL_VISUAL_RGBA
;
44 PIGLIT_GL_TEST_CONFIG_END
46 static const char *cs_text
=
48 "#extension GL_ARB_compute_shader: require\n"
50 "layout(local_size_x = 1) in; \n"
56 static const GLchar
* vs_text
=
60 "uniform mat3 transform;\n"
64 " gl_Position = vec4(pos * transform, 1.0f);\n"
67 static const GLchar
* fs_text
=
70 "uniform vec4 color;\n"
71 "out vec4 fragColor;\n"
75 " fragColor = color;\n"
78 static GLuint cs_prog
;
84 piglit_init(int argc
, char **argv
)
86 piglit_require_extension("GL_ARB_compute_shader");
88 cs_prog
= glCreateProgram();
89 GLint compute_shader
=
90 piglit_compile_shader_text(GL_COMPUTE_SHADER
, cs_text
);
92 glAttachShader(cs_prog
, compute_shader
);
93 glLinkProgram(cs_prog
);
95 if (!piglit_link_check_status(cs_prog
))
96 piglit_report_result(PIGLIT_FAIL
);
98 const float vertices
[] = {
105 prog
= piglit_build_simple_program(vs_text
, fs_text
);
107 glGenVertexArrays(1, &vao
);
108 glBindVertexArray(vao
);
109 glGenBuffers(1, &vbo
);
110 glBindBuffer(GL_ARRAY_BUFFER
, vbo
);
111 glBufferData(GL_ARRAY_BUFFER
, sizeof(vertices
), vertices
, GL_STATIC_DRAW
);
113 glVertexAttribPointer(0, 3, GL_FLOAT
, GL_FALSE
, 3 * sizeof(float), (void*)0);
114 glEnableVertexAttribArray(0);
116 if (!piglit_check_gl_error(GL_NO_ERROR
))
117 piglit_report_result(PIGLIT_FAIL
);
121 piglit_display(void) {
122 //Transform matrix is required for reproducing flickers.
123 const float transform_matr
[] = {
131 const float expected
[] = { 0.0f
, 1.0f
, 0.0f
, 1.0f
};
133 glBindBuffer(GL_ARRAY_BUFFER
, vao
);
134 glBindVertexArray(vbo
);
136 GLint transform_loc
= glGetUniformLocation(prog
, "transform");
137 GLint color_loc
= glGetUniformLocation(prog
, "color");
139 for (int i
= 0; i
< 50; i
++) {
140 glClearColor(1.0, 0.0, 0.0, 1.0);
141 glClear(GL_COLOR_BUFFER_BIT
);
143 glUseProgram(cs_prog
);
144 glDispatchCompute(1, 1, 1);
148 glUniformMatrix3fv(transform_loc
, 1, GL_FALSE
, transform_matr
);
149 glUniform4f(color_loc
, 1.0f
, 1.0f
, 0.0f
, 1.0f
);
151 glDrawArraysInstanced(GL_TRIANGLE_STRIP
, 0, 4, 200);
153 glUniform4f(color_loc
, 0.0f
, 1.0f
, 0.0f
, 1.0f
);
155 glDrawArraysInstanced(GL_TRIANGLE_STRIP
, 0, 4, 1);
159 if (!piglit_probe_pixel_rgba(0, 0, expected
)) {
160 printf("Failed on iteration #%d \n", i
);
166 glBindBuffer(GL_ARRAY_BUFFER
, 0);
167 glBindVertexArray(0);
169 piglit_present_results();
171 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;