[Piglit] [PATCH v2 1/2] util: add primitive restart util routines

Jordan Justen jordan.l.justen at intel.com
Mon Jul 2 13:19:01 PDT 2012


Add routines to handle GL 3.1 vs. GL_NV_primitive_restart
differences for detecting & using primitive restart.

Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
---
 tests/util/CMakeLists.gl.txt          |    2 +
 tests/util/piglit-core-ext-wrappers.c |   66 +++++++++++++++++++++++++++++++++
 tests/util/piglit-core-ext-wrappers.h |   49 ++++++++++++++++++++++++
 tests/util/piglit-util.h              |    1 +
 4 files changed, 118 insertions(+)
 create mode 100644 tests/util/piglit-core-ext-wrappers.c
 create mode 100644 tests/util/piglit-core-ext-wrappers.h

diff --git a/tests/util/CMakeLists.gl.txt b/tests/util/CMakeLists.gl.txt
index 7494de3..cfc5e7f 100644
--- a/tests/util/CMakeLists.gl.txt
+++ b/tests/util/CMakeLists.gl.txt
@@ -10,6 +10,7 @@ set(UTIL_SOURCES
 	piglit-shader.c
 	piglit-shader-gl.c
 	piglit-transform-feedback.c
+	piglit-core-ext-wrappers.c
 	piglit-util-gl.c
 	piglit-vbo.cpp
 	sized-internalformats.c
@@ -28,6 +29,7 @@ IF(BUILD_GLX_TESTS)
 		    piglit-shader.c
 		    piglit-shader-gl.c
 		    piglit-transform-feedback.c
+		    piglit-core-ext-wrappers.c
 		    piglit-util.c
 		    piglit-util-enum.c
 		    piglit-util-gl.c
diff --git a/tests/util/piglit-core-ext-wrappers.c b/tests/util/piglit-core-ext-wrappers.c
new file mode 100644
index 0000000..422f1ea
--- /dev/null
+++ b/tests/util/piglit-core-ext-wrappers.c
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2011 Intel Corporation
+ *
+ * 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.
+ */
+
+#ifndef USE_OPENGL
+#   error USE_OPENGL is undefined
+#endif
+
+#if defined(_MSC_VER)
+#include <windows.h>
+#endif
+
+#include "piglit-util.h"
+
+void
+piglit_EnablePrimitiveRestart(GLuint index)
+{
+   if (piglit_get_gl_version() >= 31) {
+      glEnable(GL_PRIMITIVE_RESTART);
+      glPrimitiveRestartIndex(index);
+   } else {
+      glEnableClientState(GL_PRIMITIVE_RESTART_NV);
+      glPrimitiveRestartIndexNV(index);
+   }
+}
+
+void
+piglit_DisablePrimitiveRestart(void)
+{
+   if (piglit_get_gl_version() >= 31) {
+      glDisable(GL_PRIMITIVE_RESTART);
+   } else {
+      glDisableClientState(GL_PRIMITIVE_RESTART_NV);
+   }
+}
+
+void
+piglit_require_primitive_restart(void)
+{
+   if ((piglit_get_gl_version() < 31) &&
+       !piglit_is_extension_supported("GL_NV_primitive_restart")) {
+      printf("Primitive restart not supported.\n");
+      piglit_report_result(PIGLIT_SKIP);
+      exit(1);
+   }
+}
+
diff --git a/tests/util/piglit-core-ext-wrappers.h b/tests/util/piglit-core-ext-wrappers.h
new file mode 100644
index 0000000..b630951
--- /dev/null
+++ b/tests/util/piglit-core-ext-wrappers.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2011 Intel Corporation
+ *
+ * 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.
+ */
+
+#pragma once
+
+/**
+ * Enable primitive restart.
+ *
+ * Primitive restart will be enabled by glEnable for GL 3.1 and/or
+ * by glEnableClientState for GL_NV_primitive_restart.
+ */
+void piglit_EnablePrimitiveRestart(GLuint index);
+
+/**
+ * Disable primitive restart.
+ *
+ * Primitive restart will be enabled by glEnable for GL 3.1 and/or
+ * by glEnableClientState for GL_NV_primitive_restart.
+ */
+void piglit_DisablePrimitiveRestart();
+
+/**
+ * Require primitive restart.
+ *
+ * Primitive restart may either be provided by GL 3.1 or
+ * GL_NV_primitive_restart.
+ */
+extern void piglit_require_primitive_restart(void);
+
diff --git a/tests/util/piglit-util.h b/tests/util/piglit-util.h
index 7764068..320c178 100755
--- a/tests/util/piglit-util.h
+++ b/tests/util/piglit-util.h
@@ -104,6 +104,7 @@ enum piglit_result {
 #include "piglit-framework.h"
 #include "piglit-shader.h"
 #include "piglit-transform-feedback.h"
+#include "piglit-core-ext-wrappers.h"
 
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
 
-- 
1.7.9.5



More information about the Piglit mailing list