mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
[OPENGL32]
- Get rid of the TLS based implementation CORE-14024
This commit is contained in:
parent
31acac46a1
commit
4067eb1454
3 changed files with 1 additions and 159 deletions
|
@ -7,61 +7,21 @@
|
|||
|
||||
#include "opengl32.h"
|
||||
|
||||
#ifdef OPENGL32_USE_TLS
|
||||
DWORD OglTlsIndex = 0xFFFFFFFF;
|
||||
|
||||
BOOL init_tls_data(void)
|
||||
{
|
||||
struct Opengl32_ThreadData* ThreadData;
|
||||
|
||||
ThreadData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ThreadData));
|
||||
if(!ThreadData)
|
||||
return FALSE;
|
||||
TlsSetValue(OglTlsIndex, ThreadData);
|
||||
ThreadData->glDispatchTable = &StubTable.glDispatchTable;
|
||||
ThreadData->hglrc = NULL;
|
||||
ThreadData->hdc = NULL;
|
||||
ThreadData->dc_data = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
BOOL WINAPI
|
||||
DllMain(HINSTANCE hInstance, DWORD Reason, LPVOID Reserved)
|
||||
{
|
||||
#ifdef OPENGL32_USE_TLS
|
||||
struct Opengl32_ThreadData* ThreadData;
|
||||
#endif
|
||||
switch ( Reason )
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
#ifdef OPENGL32_USE_TLS
|
||||
OglTlsIndex = TlsAlloc();
|
||||
if(OglTlsIndex == TLS_OUT_OF_INDEXES)
|
||||
return FALSE;
|
||||
#endif
|
||||
/* Initialize Context list */
|
||||
InitializeListHead(&ContextListHead);
|
||||
/* no break */
|
||||
case DLL_THREAD_ATTACH:
|
||||
#ifdef OPENGL32_USE_TLS
|
||||
if (!init_tls_data())
|
||||
return FALSE;
|
||||
#endif // defined(OPENGL32_USE_TLS)
|
||||
break;
|
||||
|
||||
case DLL_THREAD_DETACH:
|
||||
/* Set NULL context for this thread */
|
||||
wglMakeCurrent(NULL, NULL);
|
||||
/* Clean up */
|
||||
#ifdef OPENGL32_USE_TLS
|
||||
ThreadData = TlsGetValue(OglTlsIndex);
|
||||
if(ThreadData)
|
||||
HeapFree(GetProcessHeap(), 0, ThreadData);
|
||||
#else
|
||||
NtCurrentTeb()->glTable = NULL;
|
||||
#endif // defined(OPENGL32_USE_TLS)
|
||||
break;
|
||||
case DLL_PROCESS_DETACH:
|
||||
/* Clean up */
|
||||
|
@ -71,15 +31,7 @@ DllMain(HINSTANCE hInstance, DWORD Reason, LPVOID Reserved)
|
|||
wglMakeCurrent(NULL, NULL);
|
||||
IntDeleteAllContexts();
|
||||
IntDeleteAllICDs();
|
||||
#ifdef OPENGL32_USE_TLS
|
||||
ThreadData = TlsGetValue(OglTlsIndex);
|
||||
if(ThreadData)
|
||||
HeapFree(GetProcessHeap(), 0, ThreadData);
|
||||
#endif
|
||||
}
|
||||
#ifdef OPENGL32_USE_TLS
|
||||
TlsFree(OglTlsIndex);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,31 +16,16 @@ ASSUME nothing
|
|||
|
||||
.code
|
||||
|
||||
#ifdef OPENG32_USE_TLS
|
||||
EXTERN _OglTlsIndex:DWORD
|
||||
EXTERN _TlsGetValue@4:PROC
|
||||
#endif
|
||||
|
||||
MACRO(USE_GL_FUNC, name, offset, stack)
|
||||
PUBLIC _gl&name&@&stack
|
||||
.PROC _gl&name&@&stack
|
||||
|
||||
FPO 0, 0, 0, 0, 0, FRAME_FPO
|
||||
|
||||
#ifdef OPENG32_USE_TLS
|
||||
push _OglTlsIndex
|
||||
call _TlsGetValue@4
|
||||
/* If we don't have a thread data, this is a nop */
|
||||
test eax, eax
|
||||
jz name&_fast_ret
|
||||
/* Get the GL table */
|
||||
mov eax, [eax]
|
||||
#else
|
||||
/* Get the TEB */
|
||||
mov eax, fs:[TEB_SELF]
|
||||
/* Get the GL table */
|
||||
mov eax, [eax + TEB_GL_TABLE]
|
||||
#endif
|
||||
|
||||
/* If we don't have a dispatch table, this is a nop */
|
||||
test eax, eax
|
||||
|
|
|
@ -112,99 +112,6 @@ struct wgl_dc_data
|
|||
void IntDeleteAllContexts(void);
|
||||
void IntDeleteAllICDs(void);
|
||||
|
||||
#ifdef OPENGL32_USE_TLS
|
||||
extern DWORD OglTlsIndex;
|
||||
|
||||
struct Opengl32_ThreadData
|
||||
{
|
||||
const GLDISPATCHTABLE* glDispatchTable;
|
||||
HGLRC hglrc;
|
||||
HDC hdc;
|
||||
struct wgl_dc_data* dc_data;
|
||||
PVOID* icdData;
|
||||
};
|
||||
C_ASSERT(FIELD_OFFSET(struct Opengl32_ThreadData, glDispatchTable) == 0);
|
||||
|
||||
/* dllmain.c */
|
||||
BOOL init_tls_data(void);
|
||||
|
||||
FORCEINLINE
|
||||
void
|
||||
IntMakeCurrent(HGLRC hglrc, HDC hdc, struct wgl_dc_data* dc_data)
|
||||
{
|
||||
struct Opengl32_ThreadData* thread_data = TlsGetValue(OglTlsIndex);
|
||||
if (!thread_data)
|
||||
{
|
||||
OutputDebugStringA("Calling init_tls_data from IntMakeCurrent\n");
|
||||
if (!init_tls_data())
|
||||
OutputDebugStringA("init_tls_data failed, brace for impact...\n");
|
||||
|
||||
thread_data = TlsGetValue(OglTlsIndex);
|
||||
}
|
||||
|
||||
thread_data->hglrc = hglrc;
|
||||
thread_data->hdc = hdc;
|
||||
thread_data->dc_data = dc_data;
|
||||
}
|
||||
|
||||
FORCEINLINE
|
||||
HGLRC
|
||||
IntGetCurrentRC(void)
|
||||
{
|
||||
struct Opengl32_ThreadData* data = TlsGetValue(OglTlsIndex);
|
||||
return data ? data->hglrc : NULL;
|
||||
}
|
||||
|
||||
FORCEINLINE
|
||||
HDC
|
||||
IntGetCurrentDC(void)
|
||||
{
|
||||
struct Opengl32_ThreadData* data = TlsGetValue(OglTlsIndex);
|
||||
return data ? data->hdc : NULL;
|
||||
}
|
||||
|
||||
FORCEINLINE
|
||||
struct wgl_dc_data*
|
||||
IntGetCurrentDcData(void)
|
||||
{
|
||||
struct Opengl32_ThreadData* data = TlsGetValue(OglTlsIndex);
|
||||
return data->dc_data;
|
||||
}
|
||||
|
||||
FORCEINLINE
|
||||
const GLDISPATCHTABLE *
|
||||
IntGetCurrentDispatchTable(void)
|
||||
{
|
||||
struct Opengl32_ThreadData* data = TlsGetValue(OglTlsIndex);
|
||||
return data->glDispatchTable;
|
||||
}
|
||||
|
||||
FORCEINLINE
|
||||
void
|
||||
IntSetCurrentDispatchTable(const GLDISPATCHTABLE* table)
|
||||
{
|
||||
struct Opengl32_ThreadData* data = TlsGetValue(OglTlsIndex);
|
||||
data->glDispatchTable = table;
|
||||
}
|
||||
|
||||
FORCEINLINE
|
||||
void
|
||||
IntSetCurrentICDPrivate(void* value)
|
||||
{
|
||||
struct Opengl32_ThreadData* data = TlsGetValue(OglTlsIndex);
|
||||
data->icdData = value;
|
||||
}
|
||||
|
||||
FORCEINLINE
|
||||
void*
|
||||
IntGetCurrentICDPrivate(void)
|
||||
{
|
||||
struct Opengl32_ThreadData* data = TlsGetValue(OglTlsIndex);
|
||||
return data->icdData;
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
FORCEINLINE
|
||||
const GLDISPATCHTABLE*
|
||||
IntGetCurrentDispatchTable(void)
|
||||
|
@ -265,8 +172,6 @@ IntGetCurrentICDPrivate(void)
|
|||
return (void*)NtCurrentTeb()->glReserved1[0];
|
||||
}
|
||||
|
||||
#endif // defined(OPENGL32_USE_TLS)
|
||||
|
||||
FORCEINLINE
|
||||
DHGLRC
|
||||
IntGetCurrentDHGLRC(void)
|
||||
|
|
Loading…
Reference in a new issue