[Piglit] [PATCH 4/4] util/dispatch: move "to waffle or not to waffle" decision in the caller
Emil Velikov
emil.l.velikov at gmail.com
Fri Nov 21 11:52:51 PST 2014
piglit-dispatch.c is about to get hairy even without this hunk. Also
moving the code in piglit-dispatch-init.c will allow us to have a clear
visual as we start removing the non-waffle (glut) support.
Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
Reviewed-by: Brian Paul <brianp at vmware.com>
Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
tests/util/piglit-dispatch-init.c | 77 ++++++++++++++++++++++++++++++++++++---
tests/util/piglit-dispatch.c | 62 -------------------------------
2 files changed, 72 insertions(+), 67 deletions(-)
diff --git a/tests/util/piglit-dispatch-init.c b/tests/util/piglit-dispatch-init.c
index b27330e..cc8b684 100644
--- a/tests/util/piglit-dispatch-init.c
+++ b/tests/util/piglit-dispatch-init.c
@@ -41,6 +41,12 @@
#endif
+#if defined(PIGLIT_USE_WAFFLE)
+#include <waffle.h>
+#include "piglit-util-waffle.h"
+#include "piglit-framework-gl.h"
+#endif
+
/**
* Generated code calls this function if the test tries to use a GL
* function that is not supported on the current implementation.
@@ -182,6 +188,43 @@ get_core_proc_address(const char *function_name, int gl_10x_version)
#endif
+#ifdef PIGLIT_USE_WAFFLE
+static enum waffle_enum piglit_waffle_dl = WAFFLE_DL_OPENGL;
+
+/**
+ * This function is used to retrieve the address of core GL functions
+ * via the waffle library.
+ */
+static piglit_dispatch_function_ptr
+get_wfl_core_proc(const char *name, int gl_10x_version)
+{
+ piglit_dispatch_function_ptr func;
+
+ func = (piglit_dispatch_function_ptr)waffle_dl_sym(piglit_waffle_dl,
+ name);
+ if (!func)
+ wfl_log_error(__FUNCTION__);
+
+ return func;
+}
+
+/**
+ * This function is used to retrieve the address of functions not part of the
+ * core GL specification via the waffle library.
+ */
+static piglit_dispatch_function_ptr
+get_wfl_ext_proc(const char *name)
+{
+ piglit_dispatch_function_ptr func;
+
+ func = (piglit_dispatch_function_ptr)waffle_get_proc_address(name);
+ if (!func)
+ wfl_log_error(__FUNCTION__);
+
+ return func;
+}
+#endif
+
/**
* Initialize the GL dispatch mechanism to a default configuration.
*
@@ -200,11 +243,35 @@ piglit_dispatch_default_init(piglit_dispatch_api api)
if (already_initialized)
return;
- piglit_dispatch_init(api,
- get_core_proc_address,
- get_ext_proc_address,
- default_unsupported,
- default_get_proc_address_failure);
+#ifdef PIGLIT_USE_WAFFLE
+ switch (api) {
+ case PIGLIT_DISPATCH_GL:
+ piglit_waffle_dl = WAFFLE_DL_OPENGL;
+ break;
+ case PIGLIT_DISPATCH_ES1:
+ piglit_waffle_dl = WAFFLE_DL_OPENGL_ES1;
+ break;
+ case PIGLIT_DISPATCH_ES2:
+ piglit_waffle_dl = WAFFLE_DL_OPENGL_ES2;
+ break;
+ }
+
+ if (gl_fw) {
+ piglit_dispatch_init(api,
+ get_wfl_core_proc,
+ get_wfl_ext_proc,
+ default_unsupported,
+ default_get_proc_address_failure);
+ } else
+#endif
+ {
+
+ piglit_dispatch_init(api,
+ get_core_proc_address,
+ get_ext_proc_address,
+ default_unsupported,
+ default_get_proc_address_failure);
+ }
already_initialized = true;
}
diff --git a/tests/util/piglit-dispatch.c b/tests/util/piglit-dispatch.c
index 4c5c956..90a6dba 100644
--- a/tests/util/piglit-dispatch.c
+++ b/tests/util/piglit-dispatch.c
@@ -23,12 +23,6 @@
#include "piglit-dispatch.h"
#include "piglit-util-gl.h"
-#if defined(PIGLIT_USE_WAFFLE)
-#include <waffle.h>
-#include "piglit-util-waffle.h"
-#include "piglit-framework-gl.h"
-#endif
-
/* Global state maintained by the Piglit dispatch mechanism: */
/**
@@ -86,43 +80,6 @@ check_initialized()
exit(1);
}
-#ifdef PIGLIT_USE_WAFFLE
-static enum waffle_enum piglit_waffle_dl = WAFFLE_DL_OPENGL;
-
-/**
- * Generated code calls this function to retrieve the address of a
- * core function.
- */
-static piglit_dispatch_function_ptr
-get_wfl_core_proc(const char *name, int gl_10x_version)
-{
- piglit_dispatch_function_ptr func;
-
- func = (piglit_dispatch_function_ptr)waffle_dl_sym(piglit_waffle_dl,
- name);
- if (!func)
- wfl_log_error(__FUNCTION__);
-
- return func;
-}
-
-/**
- * Generated code calls this function to retrieve the address of a
- * core function.
- */
-static piglit_dispatch_function_ptr
-get_wfl_ext_proc(const char *name)
-{
- piglit_dispatch_function_ptr func;
-
- func = (piglit_dispatch_function_ptr)waffle_get_proc_address(name);
- if (!func)
- wfl_log_error(__FUNCTION__);
-
- return func;
-}
-#endif
-
/**
* Generated code calls this function to retrieve the address of a
* core function.
@@ -216,25 +173,6 @@ piglit_dispatch_init(piglit_dispatch_api api,
unsupported = unsupported_proc;
get_proc_address_failure = failure_proc;
-#ifdef PIGLIT_USE_WAFFLE
- switch (api) {
- case PIGLIT_DISPATCH_GL:
- piglit_waffle_dl = WAFFLE_DL_OPENGL;
- break;
- case PIGLIT_DISPATCH_ES1:
- piglit_waffle_dl = WAFFLE_DL_OPENGL_ES1;
- break;
- case PIGLIT_DISPATCH_ES2:
- piglit_waffle_dl = WAFFLE_DL_OPENGL_ES2;
- break;
- }
-
- if (gl_fw) {
- get_core_proc_address = get_wfl_core_proc;
- get_ext_proc_address = get_wfl_ext_proc;
- }
-#endif
-
/* No need to reset the dispatch pointers the first time */
if (is_initialized) {
reset_dispatch_pointers();
--
2.1.3
More information about the Piglit
mailing list