[Piglit] [PATCH v3 19/19] glean: use piglit_get_proc_address().
Paul Berry
stereotype441 at gmail.com
Wed Mar 21 08:58:18 PDT 2012
Previously glean got the address of GL functions by directly calling
an OS-specific function (e.g. glXGetProcAddressARB(), dlsym(), or
wglGetProcAddress()). This patch changes it to use
piglit_get_proc_address(), which uses piglit-dispatch. This will help
pave the way for adapting glean to test using GLES and
forward-compatible contexts.
Reviewed-by: Chad Versace <chad.versace at linux.intel.com>
v2: Changed the return type of glean's getProcAddress to "void
(APIENTRY *)()" so that no type casting is necessary on Windows.
---
tests/glean/glutils.cpp | 28 +++-------------------------
tests/glean/glutils.h | 2 +-
2 files changed, 4 insertions(+), 26 deletions(-)
diff --git a/tests/glean/glutils.cpp b/tests/glean/glutils.cpp
index 70cf0cc..8825aa2 100644
--- a/tests/glean/glutils.cpp
+++ b/tests/glean/glutils.cpp
@@ -43,6 +43,7 @@
#if defined(__AGL__)
# include <cstring>
#endif
+#include "piglit-util.h"
namespace GLEAN {
@@ -118,31 +119,8 @@ getVersion()
// doesn't take a rendering context as an argument.)
///////////////////////////////////////////////////////////////////////////////
void
-(*getProcAddress(const char* name))() {
-#if defined(__X11__)
-# if defined(GLX_ARB_get_proc_address)
- return glXGetProcAddressARB(reinterpret_cast<const GLubyte*>(name));
-# else
- // XXX This isn't guaranteed to work, but it may be the best option
- // we have at the moment.
- void* libHandle = dlopen("libGL.so", RTLD_LAZY);
- if (libHandle) {
- void* funcPointer = dlsym(libHandle, name);
- dlclose(libHandle);
- return funcPointer;
- } else
- return 0;
-# endif
-#elif defined(__WIN__)
- // Gotta be a little more explicit about the cast to please MSVC.
- typedef void (__cdecl* VOID_FUNC_VOID) ();
- return reinterpret_cast<VOID_FUNC_VOID>(wglGetProcAddress(name));
-#elif defined(__BEWIN__)
-# error "Need GetProcAddress (or equivalent) for BeOS"
- return 0;
-#elif defined(__AGL__)
- return reinterpret_cast<void (*)()>(dlsym(RTLD_DEFAULT, name));
-#endif
+(APIENTRY *getProcAddress(const char* name))() {
+ return piglit_get_proc_address(name);
} // getProcAddress
///////////////////////////////////////////////////////////////////////////////
diff --git a/tests/glean/glutils.h b/tests/glean/glutils.h
index bc96b59..34f89da 100644
--- a/tests/glean/glutils.h
+++ b/tests/glean/glutils.h
@@ -57,7 +57,7 @@ inline bool haveExtension(const char* name) {
// Get a pointer to a function (usually, an extension function).
// Like haveExtension, we have to do this here rather than in
// RenderingContext.
-void (*getProcAddress(const char* name))();
+void (APIENTRY *getProcAddress(const char* name))();
// Return GL renderer version as a float (1.1, 2.0, etc)
float getVersion();
--
1.7.7.6
More information about the Piglit
mailing list