[Piglit] [PATCH] arb_tessellation_shader: test GL_PATCHES with immediate mode

Timothy Arceri tarceri at itsqueeze.com
Mon Jun 18 04:50:44 UTC 2018


---
 tests/opengl.py                               |   1 +
 .../arb_tessellation_shader/CMakeLists.gl.txt |   1 +
 .../immediate-mode-draw-patches.c             | 111 ++++++++++++++++++
 3 files changed, 113 insertions(+)
 create mode 100644 tests/spec/arb_tessellation_shader/immediate-mode-draw-patches.c

diff --git a/tests/opengl.py b/tests/opengl.py
index 6a6d71fb4..d1f6b99e4 100644
--- a/tests/opengl.py
+++ b/tests/opengl.py
@@ -1517,6 +1517,7 @@ with profile.test_list.group_manager(
     g(['arb_tessellation_shader-get-tcs-params'])
     g(['arb_tessellation_shader-get-tes-params'])
     g(['arb_tessellation_shader-minmax'])
+    g(['arb_tessellation_shader-immediate-mode-draw-patches'])
     g(['arb_tessellation_shader-invalid-get-program-params'])
     g(['arb_tessellation_shader-invalid-patch-vertices-range'])
     g(['arb_tessellation_shader-invalid-primitive'])
diff --git a/tests/spec/arb_tessellation_shader/CMakeLists.gl.txt b/tests/spec/arb_tessellation_shader/CMakeLists.gl.txt
index c87e0d57d..d70b00f3f 100644
--- a/tests/spec/arb_tessellation_shader/CMakeLists.gl.txt
+++ b/tests/spec/arb_tessellation_shader/CMakeLists.gl.txt
@@ -11,6 +11,7 @@ link_libraries (
 
 piglit_add_executable (arb_tessellation_shader-get-tcs-params get-tcs-params.c)
 piglit_add_executable (arb_tessellation_shader-get-tes-params get-tes-params.c)
+piglit_add_executable (arb_tessellation_shader-immediate-mode-draw-patches immediate-mode-draw-patches.c)
 piglit_add_executable (arb_tessellation_shader-invalid-get-program-params invalid-get-program-params.c)
 piglit_add_executable (arb_tessellation_shader-invalid-patch-vertices-range invalid-patch-vertices-range.c)
 piglit_add_executable (arb_tessellation_shader-invalid-primitive invalid-primitive.c)
diff --git a/tests/spec/arb_tessellation_shader/immediate-mode-draw-patches.c b/tests/spec/arb_tessellation_shader/immediate-mode-draw-patches.c
new file mode 100644
index 000000000..a2bdc5157
--- /dev/null
+++ b/tests/spec/arb_tessellation_shader/immediate-mode-draw-patches.c
@@ -0,0 +1,111 @@
+/*
+ * Copyright © 2018 Timothy Arceri
+ *
+ * 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.
+ */
+
+/**
+ * Test immediate mode can draw GL_PATCHES.
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+	config.supports_gl_compat_version = 32;
+	config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
+	config.khr_no_error_support = PIGLIT_NO_ERRORS;
+PIGLIT_GL_TEST_CONFIG_END
+
+unsigned int prog;
+
+static const char *const vs_source =
+"#version 150 compatibility\n"
+"in vec4 piglit_vertex;\n"
+"void main() { gl_Position = piglit_vertex; }\n";
+
+static const char *const tcs_source =
+"#version 150 compatibility\n"
+"#extension GL_ARB_tessellation_shader: require\n"
+"layout(vertices = 3) out;\n"
+"out vec4 color[];\n"
+"void main() {\n"
+"	gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;\n"
+"	gl_TessLevelOuter = float[4](1.0, 1.0, 1.0, 0.0);\n"
+"	gl_TessLevelInner = float[2](0.0, 0.0);\n"
+"	color[gl_InvocationID] = vec4(0, 1, 0, 1);\n"
+"}\n";
+
+static const char *const tes_source =
+"#version 150 compatibility\n"
+"#extension GL_ARB_tessellation_shader: require\n"
+"layout(triangles) in;\n"
+"in vec4 color[];\n"
+"void main() { \n"
+"	gl_Position = gl_in[0].gl_Position * gl_TessCoord[0]\n"
+"	            + gl_in[1].gl_Position * gl_TessCoord[1]\n"
+"	            + gl_in[2].gl_Position * gl_TessCoord[2];\n"
+"\n"
+"	gl_FrontColor = color[0] * gl_TessCoord[0]\n"
+"	           + color[1] * gl_TessCoord[1]\n"
+"	           + color[2] * gl_TessCoord[2];\n"
+"}\n";
+
+enum piglit_result
+piglit_display(void)
+{
+	static const GLfloat green[4] = { 0, 1, 0, 1 };
+	enum piglit_result result;
+
+	glClearColor(0.1, 0.1, 0.1, 0.1);
+	glClear(GL_COLOR_BUFFER_BIT);
+
+	glBegin(GL_PATCHES);
+	glVertex2f(-1.0, -1.0);
+	glVertex2f(1.0, -1.0);
+	glVertex2f(-1.0, 1.0);
+	glVertex2f(-1.0, 1.0);
+	glVertex2f(1.0, -1.0);
+	glVertex2f(1.0, 1.0);
+	glEnd();
+
+	if (piglit_probe_pixel_rgb(piglit_width-1, piglit_height-1, green))
+		result = PIGLIT_PASS;
+	else
+		result = PIGLIT_FAIL;
+
+	if (!piglit_check_gl_error(GL_NO_ERROR))
+		result = PIGLIT_FAIL;
+
+	return result;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+	piglit_require_extension("GL_ARB_tessellation_shader");
+
+	prog = piglit_build_simple_program_multiple_shaders(
+			GL_VERTEX_SHADER, vs_source,
+			GL_TESS_CONTROL_SHADER, tcs_source,
+			GL_TESS_EVALUATION_SHADER, tes_source,
+			0);
+
+	glUseProgram(prog);
+}
-- 
2.17.1



More information about the Piglit mailing list