[Piglit] [PATCH 3/3] util/waffle: More wisely handle compat context versions > 1.0

Chad Versace chad.versace at linux.intel.com
Wed Feb 20 15:03:19 PST 2013


The commit below caused many shader_runner tests to skip on drivers that
lack GLX_ARB_create_context and EGL_KHR_create_context.  This patch fixes
those regressions buy changing the way that Piglit handles requests for
compatibility contexts.

    commit 3a92ffa0eb1efff8ccbe65b5c51710cea8ef0c5c
    Author: Paul Berry <stereotype441 at gmail.com>
    Date:   Fri Feb 8 13:04:13 2013 -0800

	shader_runner and glslparsertest: choose GL version more accurately.

The regressing commit set test_config->supports_gl_compat_version to the
least version that is guaranteed to support the GLSL version used by the
test. If supports_gl_compat_version > 10, then a code path is taken in
Waffle that requires the driver to support GLX_ARB_create_context or
EGL_KHR_create_context.

This patch changes piglit_wfl_framework to *not* specify a GL version when
creating a compatibility waffle_context. If context creation succeeds,
Piglit checks that the actual context version satifies the requested
version and skips the test accordingly.

CC: Paul Berry <stereotype441 at gmail.com>
CC: Michel Dänzer <michel at daenzer.net>
Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
---
 tests/util/piglit-framework-gl.h                   | 26 +++------
 .../piglit-framework-gl/piglit_wfl_framework.c     | 68 ++++++++++++++++++----
 2 files changed, 65 insertions(+), 29 deletions(-)

diff --git a/tests/util/piglit-framework-gl.h b/tests/util/piglit-framework-gl.h
index 6ab791a..bc3a3cd 100644
--- a/tests/util/piglit-framework-gl.h
+++ b/tests/util/piglit-framework-gl.h
@@ -126,15 +126,15 @@ struct piglit_gl_test_config {
 	 * compatibility context having at least the given version.
 	 *
 	 * When attempting run a test under a GL compatibility context, Piglit
-	 * chooses a waffle_config with the following attributes set.  (Note
-	 * that Waffle ignores the profile attribute for versions less than
-	 * 3.2).
-	 *     - WAFFLE_CONTEXT_PROFILE       = WAFFLE_CONTEXT_COMPATIBILITY_PROFILE
-	 *     - WAFFLE_CONTEXT_MAJOR_VERSION = supports_gl_core_version / 10
-	 *     - WAFFLE_CONTEXT_MINOR_VERSION = supports_gl_core_version % 10
-	 * If Piglit fails to acquire the waffle_config or to create the
-	 * waffle_context, then it skips its attempt to run the test under
-	 * a GL compatibility context.
+	 * chooses a waffle_config with the following attribute set.
+	 *
+	 *     WAFFLE_CONTEXT_PROFILE = WAFFLE_CONTEXT_COMPATIBILITY_PROFILE
+	 *
+	 * If context creation succeeds, then Piglit verifies with
+	 * glGetString() that the context's actual version is no less than the
+	 * requested version. Otherwise, If the version verification fails,
+	 * then Piglit skips its attempt to run the test under a GL
+	 * compatibility context.
 	 *
 	 * Piglit handles a request for a GL 3.1 compatibility context as
 	 * a special case.  As noted above, Waffle ignores the profile
@@ -146,14 +146,6 @@ struct piglit_gl_test_config {
 	 * skipping the attempt if the context lacks the GL_ARB_compatibility
 	 * extension.
 	 *
-	 * Be aware that, if this field is greater than 10, then the test will
-	 * skip on platforms for which specifying a context version is
-	 * unsupported (that is, GLX that lacks GLX_ARB_create_context and EGL
-	 * that lacks EGL_KHR_create_context). If the test requires a GL
-	 * version greater than 1.0, then consider setting this field to 10
-	 * and checking the GL version from within the test with
-	 * piglit_require_gl_version().
-	 *
 	 * If this field is 0, then the test is not able to run under a GL
 	 * compatibility context of any version.
 	 */
diff --git a/tests/util/piglit-framework-gl/piglit_wfl_framework.c b/tests/util/piglit-framework-gl/piglit_wfl_framework.c
index 77a491b..3975deb 100644
--- a/tests/util/piglit-framework-gl/piglit_wfl_framework.c
+++ b/tests/util/piglit-framework-gl/piglit_wfl_framework.c
@@ -178,21 +178,22 @@ choose_config(struct piglit_wfl_framework *wfl_fw,
 		case CONTEXT_GL_COMPAT:
 			assert(test_config->supports_gl_compat_version);
 
+			/* Don't supply a GL version to Waffle.  When no
+			 * version is specified, GLX and EGL should return the
+			 * latest supported version. Later, we compare the
+			 * actual version, as reported by glGetString, against
+			 * the version required by the test.
+			 *
+			 * If a version != 1.0 is given to
+			 * waffle_choose_config, then a code path in waffle is
+			 * taken that requires GLX_ARB_create_context or
+			 * EGL_KHR_create_context. This trick enables tests
+			 * for which supports_gl_compat_version > 1.0 to run
+			 * on drivers that lack those extensions.
+			 */
 			i = 0;
 			head_attrib_list[i++] = WAFFLE_CONTEXT_API;
 			head_attrib_list[i++] = WAFFLE_CONTEXT_OPENGL;
-
-			if (test_config->supports_gl_compat_version >= 32) {
-				head_attrib_list[i++] = WAFFLE_CONTEXT_PROFILE;
-				head_attrib_list[i++] = WAFFLE_CONTEXT_COMPATIBILITY_PROFILE;
-			}
-
-			head_attrib_list[i++] = WAFFLE_CONTEXT_MAJOR_VERSION;
-			head_attrib_list[i++] = test_config->supports_gl_compat_version / 10;
-
-			head_attrib_list[i++] = WAFFLE_CONTEXT_MINOR_VERSION;
-			head_attrib_list[i++] = test_config->supports_gl_compat_version % 10;
-
 			head_attrib_list[i++] = 0;
 			break;
 
@@ -244,6 +245,45 @@ choose_config(struct piglit_wfl_framework *wfl_fw,
 }
 
 /**
+ * Check that the context's actual version no less than the requested
+ * version for \a flavor.
+ */
+static bool
+check_gl_version(const struct piglit_gl_test_config *test_config,
+                 enum context_flavor flavor)
+{
+	switch (flavor) {
+	case CONTEXT_GL_CORE:
+	case CONTEXT_GL_ES:
+		/* There is no need to check the context version here, because
+		 * Piglit explicitly supplied the desired version to
+		 * waffle_config_choose().
+		 */
+		return true;
+	case CONTEXT_GL_COMPAT: {
+		/* Piglit did not supply a version to
+		 * waffle_config_choose(). We must check the context's
+		 * actual version.
+		 */
+		int actual_version = piglit_get_gl_version();
+		if (actual_version >= test_config->supports_gl_compat_version)
+		   return true;
+
+		printf("piglit: info: Requested a GL %d.%d compatibility "
+		       "context, but actual context version is %d.%d\n",
+		       test_config->supports_gl_compat_version / 10,
+		       test_config->supports_gl_compat_version % 10,
+		       actual_version / 10,
+		       actual_version % 10);
+		return false;
+	  }
+	default:
+	   assert(0);
+	   return false;
+	}
+}
+
+/**
  * Handle the special case when a test requests GL 3.1.
  */
 static bool
@@ -316,6 +356,10 @@ make_context_current_singlepass(struct piglit_wfl_framework *wfl_fw,
 	piglit_dispatch_default_init();
 #endif
 
+	ok = check_gl_version(test_config, flavor);
+	if (!ok)
+	   goto fail;
+
 	ok = special_case_gl_31(test_config, flavor);
 	if (!ok)
 		goto fail;
-- 
1.8.1.1



More information about the Piglit mailing list