2 * Copyright © 2018 Advanced Micro Devices, Inc.
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
24 #include "piglit-util-gl.h"
26 PIGLIT_GL_TEST_CONFIG_BEGIN
28 config
.supports_gl_compat_version
= 10;
29 config
.supports_gl_es_version
= 30;
31 config
.window_visual
= PIGLIT_GL_VISUAL_RGB
| PIGLIT_GL_VISUAL_DOUBLE
;
32 config
.khr_no_error_support
= PIGLIT_NO_ERRORS
;
34 PIGLIT_GL_TEST_CONFIG_END
37 create_program(float f
)
39 char vscode
[4096], fscode
[4096];
41 snprintf(vscode
, sizeof(vscode
),
42 "void main() { gl_Position = vec4(%f); }", f
);
43 snprintf(fscode
, sizeof(fscode
),
44 "void main() { gl_FragColor = vec4(%f); }", f
);
46 piglit_build_simple_program(vscode
, fscode
);
50 check_max_shader_compiler_threads(unsigned expected
)
53 glGetIntegerv(GL_MAX_SHADER_COMPILER_THREADS_KHR
, &threads
);
54 if (!piglit_check_gl_error(GL_NO_ERROR
))
55 piglit_report_result(PIGLIT_FAIL
);
57 if (threads
!= expected
)
58 piglit_report_result(PIGLIT_FAIL
);
62 piglit_init(int argc
, char **argv
)
64 piglit_require_extension("GL_KHR_parallel_shader_compile");
67 check_max_shader_compiler_threads(0xffffffff);
69 /* Test the initial compilation completion status. */
71 GLuint shader
= glCreateShader(GL_VERTEX_SHADER
);
72 glGetShaderiv(shader
, GL_COMPLETION_STATUS_KHR
, &status
);
73 if (!piglit_check_gl_error(GL_NO_ERROR
))
74 piglit_report_result(PIGLIT_FAIL
);
75 if (status
!= GL_TRUE
) {
76 puts("glGetShaderiv incorrect initial completion status");
77 piglit_report_result(PIGLIT_FAIL
);
80 GLuint program
= glCreateProgram();
81 glGetProgramiv(program
, GL_COMPLETION_STATUS_KHR
, &status
);
82 if (!piglit_check_gl_error(GL_NO_ERROR
))
83 piglit_report_result(PIGLIT_FAIL
);
84 if (status
!= GL_TRUE
) {
85 puts("glGetProgramiv incorrect initial completion status");
86 piglit_report_result(PIGLIT_FAIL
);
89 /* Change the thread count to test that the driver doesn't crash.
90 * Drivers are not required to obey this.
93 for (unsigned i
= 0; i
< 40; i
++)
94 create_program(counter
++);
95 glMaxShaderCompilerThreadsKHR(1);
96 check_max_shader_compiler_threads(1);
98 for (unsigned i
= 0; i
< 40; i
++)
99 create_program(counter
++);
100 glMaxShaderCompilerThreadsKHR(20);
101 check_max_shader_compiler_threads(20);
103 for (unsigned i
= 0; i
< 40; i
++)
104 create_program(counter
++);
105 glMaxShaderCompilerThreadsKHR(2);
106 check_max_shader_compiler_threads(2);
108 piglit_report_result(PIGLIT_PASS
);