[Piglit] [PATCH] KHR_parallel_shader_compiler: new test

Marek Olšák maraeo at gmail.com
Thu Nov 29 02:55:27 UTC 2018


From: Marek Olšák <marek.olsak at amd.com>

---
 tests/opengl.py                               |   6 +
 tests/spec/CMakeLists.txt                     |   1 +
 .../CMakeLists.gl.txt                         |   7 ++
 .../CMakeLists.gles2.txt                      |   4 +
 .../CMakeLists.txt                            |   1 +
 .../spec/khr_parallel_shader_compile/basic.c  | 105 ++++++++++++++++++
 6 files changed, 124 insertions(+)
 create mode 100644 tests/spec/khr_parallel_shader_compile/CMakeLists.gl.txt
 create mode 100644 tests/spec/khr_parallel_shader_compile/CMakeLists.gles2.txt
 create mode 100644 tests/spec/khr_parallel_shader_compile/CMakeLists.txt
 create mode 100644 tests/spec/khr_parallel_shader_compile/basic.c

diff --git a/tests/opengl.py b/tests/opengl.py
index b2e5cf7fd..06f323378 100644
--- a/tests/opengl.py
+++ b/tests/opengl.py
@@ -4388,20 +4388,26 @@ with profile.test_list.group_manager(
 with profile.test_list.group_manager(
         PiglitGLTest, grouptools.join('spec', 'oes_draw_texture')) as g:
     g(['oes_draw_texture'])
 
 with profile.test_list.group_manager(
         PiglitGLTest,
         grouptools.join('spec', 'oes_compressed_etc1_rgb8_texture')) as g:
     g(['oes_compressed_etc1_rgb8_texture-basic'], 'basic')
     g(['oes_compressed_etc1_rgb8_texture-miptree'], 'miptree')
 
+with profile.test_list.group_manager(
+         PiglitGLTest,
+         grouptools.join('spec', 'khr_parallel_shader_compile')) as g:
+    g(['khr_parallel_shader_compile-basic'], 'basic')
+    g(['khr_parallel_shader_compile-basic_gles2'], 'basic_gles2')
+
 with profile.test_list.group_manager(
          PiglitGLTest,
          grouptools.join('spec', 'khr_texture_compression_astc')) as g:
     g(['arb_texture_compression-invalid-formats', 'astc'], 'invalid formats')
     g(['khr_compressed_astc-array_gl'], 'array-gl')
     g(['khr_compressed_astc-array_gles3'], 'array-gles')
     g(['khr_compressed_astc-basic_gl'], 'basic-gl')
     g(['khr_compressed_astc-basic_gles2'], 'basic-gles')
     g(['void-extent-dl-bug'], 'void-extent-dl-bug')
 
diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
index 74edc5f24..093deb77b 100644
--- a/tests/spec/CMakeLists.txt
+++ b/tests/spec/CMakeLists.txt
@@ -179,10 +179,11 @@ add_subdirectory (arb_texture_barrier)
 add_subdirectory (intel_conservative_rasterization)
 add_subdirectory (arb_post_depth_coverage)
 add_subdirectory (arb_fragment_shader_interlock)
 add_subdirectory (ext_occlusion_query_boolean)
 add_subdirectory (ext_disjoint_timer_query)
 add_subdirectory (intel_blackhole_render)
 add_subdirectory (ext_texture_norm16)
 add_subdirectory (ext_render_snorm)
 add_subdirectory (ext_texture_compression_bptc)
 add_subdirectory (ext_texture_compression_rgtc)
+add_subdirectory (khr_parallel_shader_compile)
diff --git a/tests/spec/khr_parallel_shader_compile/CMakeLists.gl.txt b/tests/spec/khr_parallel_shader_compile/CMakeLists.gl.txt
new file mode 100644
index 000000000..aeb5719a1
--- /dev/null
+++ b/tests/spec/khr_parallel_shader_compile/CMakeLists.gl.txt
@@ -0,0 +1,7 @@
+link_libraries (
+	piglitutil_${piglit_target_api}
+)
+
+piglit_add_executable(khr_parallel_shader_compile-basic basic.c)
+
+# vim: ft=cmake:
diff --git a/tests/spec/khr_parallel_shader_compile/CMakeLists.gles2.txt b/tests/spec/khr_parallel_shader_compile/CMakeLists.gles2.txt
new file mode 100644
index 000000000..7b2f68f20
--- /dev/null
+++ b/tests/spec/khr_parallel_shader_compile/CMakeLists.gles2.txt
@@ -0,0 +1,4 @@
+link_libraries(piglitutil_${piglit_target_api})
+piglit_add_executable(khr_parallel_shader_compile-basic_gles2 basic.c)
+
+# vim: ft=cmake:
diff --git a/tests/spec/khr_parallel_shader_compile/CMakeLists.txt b/tests/spec/khr_parallel_shader_compile/CMakeLists.txt
new file mode 100644
index 000000000..144a306f4
--- /dev/null
+++ b/tests/spec/khr_parallel_shader_compile/CMakeLists.txt
@@ -0,0 +1 @@
+piglit_include_target_api()
diff --git a/tests/spec/khr_parallel_shader_compile/basic.c b/tests/spec/khr_parallel_shader_compile/basic.c
new file mode 100644
index 000000000..a1258fb91
--- /dev/null
+++ b/tests/spec/khr_parallel_shader_compile/basic.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright © 2018 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_compat_version = 10;
+	config.supports_gl_es_version = 30;
+
+	config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
+	config.khr_no_error_support = PIGLIT_NO_ERRORS;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static void
+create_program(float f)
+{
+	char vscode[4096], fscode[4096];
+
+	snprintf(vscode, sizeof(vscode),
+		 "void main() { gl_Position = vec4(%f); }", f);
+	snprintf(fscode, sizeof(fscode),
+		 "void main() { gl_FragColor = vec4(%f); }", f);
+
+	piglit_build_simple_program(vscode, fscode);
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+	piglit_require_extension("GL_KHR_parallel_shader_compile");
+
+	/* Test the query. */
+	GLint threads;
+	glGetIntegerv(GL_MAX_SHADER_COMPILER_THREADS_KHR, &threads);
+	if (!piglit_check_gl_error(GL_NO_ERROR))
+		piglit_report_result(PIGLIT_FAIL);
+
+	/* Test the initial compilation completion status. */
+	GLint status;
+	GLuint shader = glCreateShader(GL_VERTEX_SHADER);
+	glGetShaderiv(shader, GL_COMPLETION_STATUS_KHR, &status);
+	if (!piglit_check_gl_error(GL_NO_ERROR))
+		piglit_report_result(PIGLIT_FAIL);
+	if (status != GL_TRUE) {
+		puts("glGetShaderiv incorrect initial completion status");
+		piglit_report_result(PIGLIT_FAIL);
+	}
+
+	GLuint program = glCreateProgram();
+	glGetProgramiv(program, GL_COMPLETION_STATUS_KHR, &status);
+	if (!piglit_check_gl_error(GL_NO_ERROR))
+		piglit_report_result(PIGLIT_FAIL);
+	if (status != GL_TRUE) {
+		puts("glGetProgramiv incorrect initial completion status");
+		piglit_report_result(PIGLIT_FAIL);
+	}
+
+	/* Change the thread count to test that the driver doesn't crash.
+	 * Drivers are not required to obey this.
+	 */
+	unsigned counter = 0;
+        for (unsigned i = 0; i < 40; i++)
+		create_program(counter++);
+	glMaxShaderCompilerThreadsKHR(1);
+
+	for (unsigned i = 0; i < 40; i++)
+		create_program(counter++);
+	glMaxShaderCompilerThreadsKHR(20);
+
+	for (unsigned i = 0; i < 40; i++)
+		create_program(counter++);
+	glMaxShaderCompilerThreadsKHR(2);
+
+	if (!piglit_check_gl_error(GL_NO_ERROR))
+		piglit_report_result(PIGLIT_FAIL);
+	piglit_report_result(PIGLIT_PASS);
+}
+
+enum piglit_result
+piglit_display(void)
+{
+	return PIGLIT_FAIL;
+}
-- 
2.17.1



More information about the Piglit mailing list