Commit c8124ef1 authored by Emil Velikov's avatar Emil Velikov
Browse files

util/dispatch: move "to waffle or not to waffle" decision in the caller



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's avatarEmil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Brian Paul's avatarBrian Paul <brianp@vmware.com>
parent 18caea37
......@@ -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;
}
......@@ -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();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment