summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2014-03-28 14:27:29 -0700
committerEric Anholt <eric@anholt.net>2014-03-28 16:33:53 -0700
commit11a946cbf5ebd4ba79915ab06434847ae2581e47 (patch)
tree48b6154e441d1c2c1ea9e3b866837f2d45b77d6c /test
parentea12f935c14351a26a721fc6ffee6c67b53b0e15 (diff)
downloadlibepoxy-11a946cbf5ebd4ba79915ab06434847ae2581e47.tar.gz
Prefer non-aliased functions when resolving.
This increases the size of the library, but avoids some of the concerns that have been brought up with the library silently switching you from glWhateverEXT() to glWhatever() if there might be slight behavior differences between the two that hadn't been identified. The downside is that it means we can't share the resolver functions among aliases.
Diffstat (limited to 'test')
-rw-r--r--test/.gitignore1
-rw-r--r--test/Makefile.am7
-rw-r--r--test/glx_alias_prefer_same_name.c93
3 files changed, 100 insertions, 1 deletions
diff --git a/test/.gitignore b/test/.gitignore
index f280858..4a0d22f 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -4,6 +4,7 @@ egl_and_glx_different_pointers_glx
egl_has_extension_nocontext
egl_gles1_without_glx
egl_gles2_without_glx
+glx_alias_prefer_same_name
glx_beginend
glx_gles2
glx_glxgetprocaddress_nocontext
diff --git a/test/Makefile.am b/test/Makefile.am
index f462fbe..5a8c49a 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -94,10 +94,11 @@ endif
endif
GLX_TESTS = \
- glx_gles2 \
+ glx_alias_prefer_same_name \
glx_beginend \
glx_public_api \
glx_public_api_core \
+ glx_gles2 \
glx_glxgetprocaddress_nocontext \
glx_has_extension_nocontext \
glx_static \
@@ -143,6 +144,10 @@ egl_and_glx_different_pointers_egl_glx_LDADD = libegl_common.la libglx_common.la
egl_and_glx_different_pointers_egl_glx_LDFLAGS = -rdynamic
egl_and_glx_different_pointers_egl_glx_CPPFLAGS = $(AM_CPPFLAGS) -DUSE_EGL -DUSE_GLX
+glx_alias_prefer_same_name_SOURCES = glx_gles2.c dlwrap.c dlwrap.h
+glx_alias_prefer_same_name_LDFLAGS = -rdynamic
+glx_alias_prefer_same_name_LDADD = $(EPOXY) libglx_common.la $(X11_LIBS) -ldl
+
glx_beginend_LDADD = $(EPOXY) libglx_common.la $(GL_LIBS) $(X11_LIBS)
glx_gles2_SOURCES = glx_gles2.c dlwrap.c dlwrap.h
diff --git a/test/glx_alias_prefer_same_name.c b/test/glx_alias_prefer_same_name.c
new file mode 100644
index 0000000..e28db8e
--- /dev/null
+++ b/test/glx_alias_prefer_same_name.c
@@ -0,0 +1,93 @@
+/*
+ * Copyright © 2013 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.
+ */
+
+/**
+ * @file glx_gles2.c
+ *
+ * Catches a bug where a GLES2 context using
+ * GLX_EXT_create_context_es2_profile would try to find the symbols in
+ * libGLESv2.so.2 instead of libGL.so.1.
+ */
+
+#include <stdio.h>
+#include <assert.h>
+#include <err.h>
+#include "epoxy/gl.h"
+#include "epoxy/glx.h"
+#include <X11/Xlib.h>
+
+#include "glx_common.h"
+
+static Display *dpy;
+
+static int last_call;
+
+#define CORE_FUNC_VAL 100
+#define EXT_FUNC_VAL 101
+
+void
+override_GL_glBindTexture(GLenum target, GLenum texture);
+void
+override_GL_glBindTextureEXT(GLenum target, GLenum texture);
+
+void
+override_GL_glBindTexture(GLenum target)
+{
+ last_call = CORE_FUNC_VAL;
+}
+
+void
+override_GL_glBindTexture(GLenum target)
+{
+ last_call = EXT_FUNC_VAL;
+}
+
+int
+main(int argc, char **argv)
+{
+ bool pass = true;
+ XVisualInfo *vis;
+ Window win;
+ GLXContext ctx;
+ GLXFBConfig config;
+ int context_attribs[] = {
+ GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_ES2_PROFILE_BIT_EXT,
+ GLX_CONTEXT_MAJOR_VERSION_ARB, 2,
+ GLX_CONTEXT_MINOR_VERSION_ARB, 0,
+ 0
+ };
+ GLuint shader;
+
+ dpy = get_display_or_skip();
+ make_glx_context_current_or_skip(dpy);
+
+ if (!epoxy_has_gl_extension(dpy, 0, "GLX_EXT_texture_object"))
+ errx(77, "Test requires GLX_EXT_texture_object");
+
+ glBindTexture(GL_TEXTURE_2D, 1);
+ pass = pass && last_call == CORE_VAL;
+ glBindTextureEXT(GL_TEXTURE_2D, 1);
+ pass = pass && last_call == EXT_VAL;
+
+ return pass != true;
+}