1999-11-11 01:22:25 +00:00
|
|
|
/*
|
|
|
|
* Mesa 3-D graphics library
|
|
|
|
*
|
2008-06-17 20:23:32 +01:00
|
|
|
* Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
|
1999-11-11 01:22:25 +00:00
|
|
|
*
|
|
|
|
* 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
|
2013-04-21 21:46:48 +01:00
|
|
|
* 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.
|
1999-11-11 01:22:25 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2004-09-10 01:45:12 +01:00
|
|
|
/**
|
|
|
|
* \mainpage Mesa GL API Module
|
|
|
|
*
|
|
|
|
* \section GLAPIIntroduction Introduction
|
|
|
|
*
|
|
|
|
* The Mesa GL API module is responsible for dispatching all the
|
|
|
|
* gl*() functions. All GL functions are dispatched by jumping through
|
|
|
|
* the current dispatch table (basically a struct full of function
|
|
|
|
* pointers.)
|
|
|
|
*
|
|
|
|
* A per-thread current dispatch table and per-thread current context
|
|
|
|
* pointer are managed by this module too.
|
|
|
|
*
|
|
|
|
* This module is intended to be non-Mesa-specific so it can be used
|
|
|
|
* with the X/DRI libGL also.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
1999-11-11 01:22:25 +00:00
|
|
|
#ifndef _GLAPI_H
|
|
|
|
#define _GLAPI_H
|
|
|
|
|
2015-03-04 00:15:05 +00:00
|
|
|
#include "util/macros.h"
|
2021-05-21 21:23:07 +01:00
|
|
|
#include "util/u_thread.h"
|
2021-12-11 00:54:08 +00:00
|
|
|
#include "util/detect_os.h"
|
2011-11-09 10:20:51 +00:00
|
|
|
|
|
|
|
|
2011-10-04 10:53:45 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2006-03-15 20:31:50 +00:00
|
|
|
|
2011-11-09 10:20:51 +00:00
|
|
|
|
2010-08-23 09:13:12 +01:00
|
|
|
#ifdef _GLAPI_NO_EXPORTS
|
|
|
|
# define _GLAPI_EXPORT
|
|
|
|
#else /* _GLAPI_NO_EXPORTS */
|
|
|
|
# ifdef _WIN32
|
|
|
|
# ifdef _GLAPI_DLL_EXPORTS
|
|
|
|
# define _GLAPI_EXPORT __declspec(dllexport)
|
|
|
|
# else
|
|
|
|
# define _GLAPI_EXPORT __declspec(dllimport)
|
|
|
|
# endif
|
2015-12-01 23:07:08 +00:00
|
|
|
# elif defined(__GNUC__)
|
2010-08-23 09:13:12 +01:00
|
|
|
# define _GLAPI_EXPORT __attribute__((visibility("default")))
|
|
|
|
# else
|
|
|
|
# define _GLAPI_EXPORT
|
|
|
|
# endif
|
|
|
|
#endif /* _GLAPI_NO_EXPORTS */
|
2010-08-21 04:50:22 +01:00
|
|
|
|
|
|
|
|
2010-04-23 09:06:26 +01:00
|
|
|
typedef void (*_glapi_proc)(void);
|
2015-03-13 16:20:29 +00:00
|
|
|
|
|
|
|
typedef void (*_glapi_nop_handler_proc)(const char *name);
|
|
|
|
|
2010-08-21 04:50:22 +01:00
|
|
|
struct _glapi_table;
|
|
|
|
|
2021-12-11 00:54:08 +00:00
|
|
|
#if DETECT_OS_WINDOWS
|
2021-12-04 09:39:09 +00:00
|
|
|
extern __THREAD_INITIAL_EXEC struct _glapi_table * _glapi_tls_Dispatch;
|
|
|
|
extern __THREAD_INITIAL_EXEC void * _glapi_tls_Context;
|
2021-02-19 22:55:57 +00:00
|
|
|
#else
|
2021-05-21 21:23:07 +01:00
|
|
|
_GLAPI_EXPORT extern __THREAD_INITIAL_EXEC struct _glapi_table * _glapi_tls_Dispatch;
|
|
|
|
_GLAPI_EXPORT extern __THREAD_INITIAL_EXEC void * _glapi_tls_Context;
|
2021-02-19 22:55:57 +00:00
|
|
|
#endif
|
2010-08-21 04:50:22 +01:00
|
|
|
|
|
|
|
_GLAPI_EXPORT extern const struct _glapi_table *_glapi_Dispatch;
|
|
|
|
_GLAPI_EXPORT extern const void *_glapi_Context;
|
|
|
|
|
Fix static glapi on Windows
On Linux, the static glapi path sees libGL.so implementing the static
glapi, and the drivers (libgallium_dri.so) updating/reading the TLS
vars.
On Windows, to allow libgallium_wgl.dll to be a full ICD, it's
responsible for implementing the actual static glapi. However, before
this change, OpenGL32.dll was also implementing the static glapi,
meaning that GL API calls from OpenGL32.dll didn't route to the driver
correctly because the TLS vars were never actually set - the driver set
its copy, and OpenGL32.dll read its own copy.
Now, always build a bridge and static version of glapi when not using
shared. The bridge version is linked into OpenGL32.dll, and the static
version is linked into the driver on Windows. GLES only builds with
shared glapi - but after this, shared glapi is not really needed on
Windows for GLES, since the driver has all of the data.
Fixes: f36921ef ("wgl: Refactor drivers to a libgallium_wgl.dll")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6560
Acked-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16713>
2022-05-25 21:50:42 +01:00
|
|
|
#if DETECT_OS_WINDOWS && !defined(MAPI_MODE_UTIL) && !defined(MAPI_MODE_GLAPI)
|
2021-11-02 18:38:02 +00:00
|
|
|
# define GET_DISPATCH() _glapi_get_dispatch()
|
|
|
|
# define GET_CURRENT_CONTEXT(C) struct gl_context *C = (struct gl_context *) _glapi_get_context()
|
|
|
|
#else
|
2010-09-09 23:59:49 +01:00
|
|
|
# define GET_DISPATCH() _glapi_tls_Dispatch
|
2010-10-12 17:26:10 +01:00
|
|
|
# define GET_CURRENT_CONTEXT(C) struct gl_context *C = (struct gl_context *) _glapi_tls_Context
|
2021-11-02 18:38:02 +00:00
|
|
|
#endif
|
2010-08-21 04:50:22 +01:00
|
|
|
|
2018-04-18 16:33:03 +01:00
|
|
|
_GLAPI_EXPORT void
|
2010-08-21 04:50:22 +01:00
|
|
|
_glapi_destroy_multithread(void);
|
1999-11-11 01:22:25 +00:00
|
|
|
|
|
|
|
|
2010-08-21 04:50:22 +01:00
|
|
|
_GLAPI_EXPORT void
|
|
|
|
_glapi_check_multithread(void);
|
|
|
|
|
|
|
|
|
|
|
|
_GLAPI_EXPORT void
|
|
|
|
_glapi_set_context(void *context);
|
|
|
|
|
|
|
|
|
|
|
|
_GLAPI_EXPORT void *
|
|
|
|
_glapi_get_context(void);
|
|
|
|
|
|
|
|
|
|
|
|
_GLAPI_EXPORT void
|
|
|
|
_glapi_set_dispatch(struct _glapi_table *dispatch);
|
|
|
|
|
|
|
|
|
|
|
|
_GLAPI_EXPORT struct _glapi_table *
|
|
|
|
_glapi_get_dispatch(void);
|
|
|
|
|
|
|
|
|
|
|
|
_GLAPI_EXPORT unsigned int
|
1999-11-27 21:30:40 +00:00
|
|
|
_glapi_get_dispatch_table_size(void);
|
|
|
|
|
|
|
|
|
2010-08-21 04:50:22 +01:00
|
|
|
_GLAPI_EXPORT int
|
2005-07-28 01:29:51 +01:00
|
|
|
_glapi_add_dispatch( const char * const * function_names,
|
|
|
|
const char * parameter_signature );
|
1999-11-11 01:22:25 +00:00
|
|
|
|
2010-08-21 04:50:22 +01:00
|
|
|
_GLAPI_EXPORT int
|
1999-11-27 21:30:40 +00:00
|
|
|
_glapi_get_proc_offset(const char *funcName);
|
1999-11-11 01:22:25 +00:00
|
|
|
|
|
|
|
|
2010-08-21 04:50:22 +01:00
|
|
|
_GLAPI_EXPORT _glapi_proc
|
1999-11-11 01:22:25 +00:00
|
|
|
_glapi_get_proc_address(const char *funcName);
|
|
|
|
|
|
|
|
|
2010-08-21 04:50:22 +01:00
|
|
|
_GLAPI_EXPORT const char *
|
2010-02-11 22:04:06 +00:00
|
|
|
_glapi_get_proc_name(unsigned int offset);
|
1999-12-15 15:03:16 +00:00
|
|
|
|
|
|
|
|
2016-07-11 21:38:16 +01:00
|
|
|
#if defined(GLX_USE_APPLEGL) || defined(GLX_USE_WINDOWSGL)
|
2011-06-10 00:59:49 +01:00
|
|
|
_GLAPI_EXPORT struct _glapi_table *
|
|
|
|
_glapi_create_table_from_handle(void *handle, const char *symbol_prefix);
|
2018-01-16 16:26:57 +00:00
|
|
|
|
|
|
|
_GLAPI_EXPORT void
|
|
|
|
_glapi_table_patch(struct _glapi_table *, const char *name, void *wrapper);
|
2015-12-09 12:41:22 +00:00
|
|
|
#endif
|
2011-06-10 00:59:49 +01:00
|
|
|
|
|
|
|
|
2015-03-13 16:20:29 +00:00
|
|
|
_GLAPI_EXPORT void
|
|
|
|
_glapi_set_nop_handler(_glapi_nop_handler_proc func);
|
|
|
|
|
|
|
|
/** Return pointer to new dispatch table filled with no-op functions */
|
|
|
|
_GLAPI_EXPORT struct _glapi_table *
|
|
|
|
_glapi_new_nop_table(unsigned num_entries);
|
|
|
|
|
|
|
|
|
2014-03-14 16:13:16 +00:00
|
|
|
/** Deprecated function */
|
|
|
|
_GLAPI_EXPORT unsigned long
|
|
|
|
_glthread_GetID(void);
|
|
|
|
|
|
|
|
|
2010-08-21 04:50:22 +01:00
|
|
|
/*
|
|
|
|
* These stubs are kept so that the old DRI drivers still load.
|
|
|
|
*/
|
|
|
|
_GLAPI_EXPORT void
|
|
|
|
_glapi_noop_enable_warnings(unsigned char enable);
|
|
|
|
|
|
|
|
|
|
|
|
_GLAPI_EXPORT void
|
|
|
|
_glapi_set_warning_func(_glapi_proc func);
|
|
|
|
|
2011-11-09 10:20:51 +00:00
|
|
|
|
2011-10-04 10:53:45 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2010-08-21 04:50:22 +01:00
|
|
|
|
|
|
|
#endif /* _GLAPI_H */
|