aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mapi/mapi_glapi.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2013-06-04 09:07:26 +0200
committermarha <marha@users.sourceforge.net>2013-06-04 09:48:59 +0200
commitfd2b28971a2afbf54b6cb641aa6a2d5e940a1450 (patch)
tree1b103a8b2114125ffa8d79827d931aba3744a0d2 /mesalib/src/mapi/mapi_glapi.c
parent62a1ce0583cf41c173f4edb91511430b552e04da (diff)
downloadvcxsrv-fd2b28971a2afbf54b6cb641aa6a2d5e940a1450.tar.gz
vcxsrv-fd2b28971a2afbf54b6cb641aa6a2d5e940a1450.tar.bz2
vcxsrv-fd2b28971a2afbf54b6cb641aa6a2d5e940a1450.zip
xwininfo fontconfig libX11 libXau libXdmcp libXext mesa libXinerama libxcb libxcb/xcb-proto libfontenc pixman xkbcomp mkfontscale xkeyboard-config git update 4 Jun 2013
xserver commit c21344add2fc589df83b29be5831c36a372201bd libxcb commit 9ae84ad187e2ba440c40f44b8eb21c82c2fdbf12 libxcb/xcb-proto commit bdfedfa57a13ff805580cfacafc70f9cc55df363 xkeyboard-config commit dad9ade4e83d1ef5a517fcc4cc9ad3a79b47acce libX11 commit 8496122eb00ce6cd5d2308ee54f64b68c378e455 libXdmcp commit 0b443c1b769b9c9a3b45b4252afe07e18b709ff4 libXext commit d8366afbb0d2e4fbb1e419b1187f490522270bea libfontenc commit 3acba630d8b57084f7e92c15732408711ed5137a libXinerama commit 6e1d1dc328ba8162bba2f4694e7f3c706a1491ff libXau commit 899790011304c4029e15abf410e49ce7cec17e0a xkbcomp commit ed582f4fccd4e23abcfba8b3b03649fea6414f44 pixman commit 2acfac5f8e097ee2ae225d986f981b55d65dd152 mkfontscale commit 19e2cb7c6a3ec2c5b1bc0d24866fa685eef0ee13 xwininfo commit ba0d1b0da21d2dbdd81098ed5778f3792b472e13 fontconfig commit cd9b1033a68816a7acfbba1718ba0aa5888f6ec7 mesa commit 7bafd88c153e395274b632e7eae4bc9fc3aec1d2
Diffstat (limited to 'mesalib/src/mapi/mapi_glapi.c')
-rw-r--r--mesalib/src/mapi/mapi_glapi.c240
1 files changed, 240 insertions, 0 deletions
diff --git a/mesalib/src/mapi/mapi_glapi.c b/mesalib/src/mapi/mapi_glapi.c
new file mode 100644
index 000000000..a6838ce61
--- /dev/null
+++ b/mesalib/src/mapi/mapi_glapi.c
@@ -0,0 +1,240 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 7.9
+ *
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
+ * Copyright (C) 2010 LunarG Inc.
+ *
+ * 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 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.
+ *
+ * Authors:
+ * Chia-I Wu <olv@lunarg.com>
+ */
+
+#include <string.h>
+#include "glapi/glapi.h"
+#include "u_current.h"
+#include "table.h" /* for MAPI_TABLE_NUM_SLOTS */
+#include "stub.h"
+
+/*
+ * Global variables, _glapi_get_context, and _glapi_get_dispatch are defined in
+ * u_current.c.
+ */
+
+#ifdef GLX_USE_TLS
+/* not used, but defined for compatibility */
+const struct _glapi_table *_glapi_Dispatch;
+const void *_glapi_Context;
+#endif /* GLX_USE_TLS */
+
+void
+_glapi_destroy_multithread(void)
+{
+ u_current_destroy();
+}
+
+void
+_glapi_check_multithread(void)
+{
+ u_current_init();
+}
+
+void
+_glapi_set_context(void *context)
+{
+ u_current_set_user((const void *) context);
+}
+
+void
+_glapi_set_dispatch(struct _glapi_table *dispatch)
+{
+ u_current_set((const struct mapi_table *) dispatch);
+}
+
+/**
+ * Return size of dispatch table struct as number of functions (or
+ * slots).
+ */
+unsigned int
+_glapi_get_dispatch_table_size(void)
+{
+ return MAPI_TABLE_NUM_SLOTS;
+}
+
+/**
+ * Fill-in the dispatch stub for the named function.
+ *
+ * This function is intended to be called by a hardware driver. When called,
+ * a dispatch stub may be created created for the function. A pointer to this
+ * dispatch function will be returned by glXGetProcAddress.
+ *
+ * \param function_names Array of pointers to function names that should
+ * share a common dispatch offset.
+ * \param parameter_signature String representing the types of the parameters
+ * passed to the named function. Parameter types
+ * are converted to characters using the following
+ * rules:
+ * - 'i' for \c GLint, \c GLuint, and \c GLenum
+ * - 'p' for any pointer type
+ * - 'f' for \c GLfloat and \c GLclampf
+ * - 'd' for \c GLdouble and \c GLclampd
+ *
+ * \returns
+ * The offset in the dispatch table of the named function. A pointer to the
+ * driver's implementation of the named function should be stored at
+ * \c dispatch_table[\c offset]. Return -1 if error/problem.
+ *
+ * \sa glXGetProcAddress
+ *
+ * \warning
+ * This function can only handle up to 8 names at a time. As far as I know,
+ * the maximum number of names ever associated with an existing GL function is
+ * 4 (\c glPointParameterfSGIS, \c glPointParameterfEXT,
+ * \c glPointParameterfARB, and \c glPointParameterf), so this should not be
+ * too painful of a limitation.
+ *
+ * \todo
+ * Check parameter_signature.
+ */
+int
+_glapi_add_dispatch( const char * const * function_names,
+ const char * parameter_signature )
+{
+ const struct mapi_stub *function_stubs[8];
+ const struct mapi_stub *alias = NULL;
+ unsigned i;
+
+ (void) memset(function_stubs, 0, sizeof(function_stubs));
+
+ /* find the missing stubs, and decide the alias */
+ for (i = 0; function_names[i] != NULL && i < 8; i++) {
+ const char * funcName = function_names[i];
+ const struct mapi_stub *stub;
+ int slot;
+
+ if (!funcName || funcName[0] != 'g' || funcName[1] != 'l')
+ return -1;
+ funcName += 2;
+
+ stub = stub_find_public(funcName);
+ if (!stub)
+ stub = stub_find_dynamic(funcName, 0);
+
+ slot = (stub) ? stub_get_slot(stub) : -1;
+ if (slot >= 0) {
+ if (alias && stub_get_slot(alias) != slot)
+ return -1;
+ /* use the first existing stub as the alias */
+ if (!alias)
+ alias = stub;
+
+ function_stubs[i] = stub;
+ }
+ }
+
+ /* generate missing stubs */
+ for (i = 0; function_names[i] != NULL && i < 8; i++) {
+ const char * funcName = function_names[i] + 2;
+ struct mapi_stub *stub;
+
+ if (function_stubs[i])
+ continue;
+
+ stub = stub_find_dynamic(funcName, 1);
+ if (!stub)
+ return -1;
+
+ stub_fix_dynamic(stub, alias);
+ if (!alias)
+ alias = stub;
+ }
+
+ return (alias) ? stub_get_slot(alias) : -1;
+}
+
+static const struct mapi_stub *
+_glapi_get_stub(const char *name, int generate)
+{
+ const struct mapi_stub *stub;
+
+#ifdef USE_MGL_NAMESPACE
+ if (name)
+ name++;
+#endif
+
+ if (!name || name[0] != 'g' || name[1] != 'l')
+ return NULL;
+ name += 2;
+
+ stub = stub_find_public(name);
+ if (!stub)
+ stub = stub_find_dynamic(name, generate);
+
+ return stub;
+}
+
+/**
+ * Return offset of entrypoint for named function within dispatch table.
+ */
+int
+_glapi_get_proc_offset(const char *funcName)
+{
+ const struct mapi_stub *stub = _glapi_get_stub(funcName, 0);
+ return (stub) ? stub_get_slot(stub) : -1;
+}
+
+/**
+ * Return pointer to the named function. If the function name isn't found
+ * in the name of static functions, try generating a new API entrypoint on
+ * the fly with assembly language.
+ */
+_glapi_proc
+_glapi_get_proc_address(const char *funcName)
+{
+ const struct mapi_stub *stub = _glapi_get_stub(funcName, 1);
+ return (stub) ? (_glapi_proc) stub_get_addr(stub) : NULL;
+}
+
+/**
+ * Return the name of the function at the given dispatch offset.
+ * This is only intended for debugging.
+ */
+const char *
+_glapi_get_proc_name(unsigned int offset)
+{
+ const struct mapi_stub *stub = stub_find_by_slot(offset);
+ return stub ? stub_get_name(stub) : NULL;
+}
+
+unsigned long
+_glthread_GetID(void)
+{
+ return u_thread_self();
+}
+
+void
+_glapi_noop_enable_warnings(unsigned char enable)
+{
+}
+
+void
+_glapi_set_warning_func(_glapi_proc func)
+{
+}