windows: Use TLS context/dispatch with shared-glapi
However they have to be called via _glapi_get_dispatch/context. This would be safe to do on any platform, but the extra indirection is only necessary on Windows since TLS vars can't be exported from a DLL. Reviewed-by: Emma Anholt <emma@anholt.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13634>
This commit is contained in:
parent
58aad3f403
commit
c47fd3dc00
11
meson.build
11
meson.build
|
@ -508,10 +508,8 @@ foreach platform : _platforms
|
|||
pre_args += '-DHAVE_@0@_PLATFORM'.format(platform.to_upper())
|
||||
endforeach
|
||||
|
||||
use_elf_tls = false
|
||||
if not with_platform_windows or not with_shared_glapi
|
||||
pre_args += '-DUSE_ELF_TLS'
|
||||
use_elf_tls = true
|
||||
pre_args += '-DUSE_ELF_TLS'
|
||||
|
||||
if with_platform_android and get_option('platform-sdk-version') >= 29
|
||||
# By default the NDK compiler, at least, emits emutls references instead of
|
||||
|
@ -544,6 +542,13 @@ if not with_platform_windows or not with_shared_glapi
|
|||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
if with_platform_windows and with_shared_glapi
|
||||
# Windows doesn't support DLL exports/imports being TLS variables. When using shared
|
||||
# glapi, libglapi.dll hosts the TLS, but other DLLs need to use them. Instead of falling
|
||||
# all the way back to using globals and manual per-thread data, keep using TLS but just
|
||||
# put accesses to it behind a function so the variable doesn't need to be exported.
|
||||
pre_args += '-DUSE_TLS_BEHIND_FUNCTIONS'
|
||||
endif
|
||||
|
||||
if with_glx != 'disabled'
|
||||
|
|
|
@ -91,8 +91,13 @@ _GLAPI_EXPORT extern __THREAD_INITIAL_EXEC void * _glapi_tls_Context;
|
|||
_GLAPI_EXPORT extern const struct _glapi_table *_glapi_Dispatch;
|
||||
_GLAPI_EXPORT extern const void *_glapi_Context;
|
||||
|
||||
#if defined (USE_TLS_BEHIND_FUNCTIONS)
|
||||
# define GET_DISPATCH() _glapi_get_dispatch()
|
||||
# define GET_CURRENT_CONTEXT(C) struct gl_context *C = (struct gl_context *) _glapi_get_context()
|
||||
#else
|
||||
# define GET_DISPATCH() _glapi_tls_Dispatch
|
||||
# define GET_CURRENT_CONTEXT(C) struct gl_context *C = (struct gl_context *) _glapi_tls_Context
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
|
|
Loading…
Reference in New Issue