mirror of
https://github.com/reactos/reactos.git
synced 2025-08-04 00:36:30 +00:00
[OPENGL32] Allocate thread data in IntMakeCurrent if it is not allocated yet.
CORE-12232
This commit is contained in:
parent
fa9ce98d8e
commit
64d10228ee
2 changed files with 28 additions and 7 deletions
|
@ -9,6 +9,22 @@
|
||||||
|
|
||||||
#ifdef OPENGL32_USE_TLS
|
#ifdef OPENGL32_USE_TLS
|
||||||
DWORD OglTlsIndex = 0xFFFFFFFF;
|
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
|
#endif
|
||||||
|
|
||||||
BOOL WINAPI
|
BOOL WINAPI
|
||||||
|
@ -30,14 +46,8 @@ DllMain(HINSTANCE hInstance, DWORD Reason, LPVOID Reserved)
|
||||||
/* no break */
|
/* no break */
|
||||||
case DLL_THREAD_ATTACH:
|
case DLL_THREAD_ATTACH:
|
||||||
#ifdef OPENGL32_USE_TLS
|
#ifdef OPENGL32_USE_TLS
|
||||||
ThreadData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ThreadData));
|
if (!init_tls_data())
|
||||||
if(!ThreadData)
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
TlsSetValue(OglTlsIndex, ThreadData);
|
|
||||||
ThreadData->glDispatchTable = &StubTable.glDispatchTable;
|
|
||||||
ThreadData->hglrc = NULL;
|
|
||||||
ThreadData->hdc = NULL;
|
|
||||||
ThreadData->dc_data = NULL;
|
|
||||||
#else
|
#else
|
||||||
NtCurrentTeb()->glTable = &StubTable.glDispatchTable;
|
NtCurrentTeb()->glTable = &StubTable.glDispatchTable;
|
||||||
#endif // defined(OPENGL32_USE_TLS)
|
#endif // defined(OPENGL32_USE_TLS)
|
||||||
|
|
|
@ -121,11 +121,22 @@ struct Opengl32_ThreadData
|
||||||
};
|
};
|
||||||
C_ASSERT(FIELD_OFFSET(struct Opengl32_ThreadData, glDispatchTable) == 0);
|
C_ASSERT(FIELD_OFFSET(struct Opengl32_ThreadData, glDispatchTable) == 0);
|
||||||
|
|
||||||
|
/* dllmain.c */
|
||||||
|
BOOL init_tls_data(void);
|
||||||
|
|
||||||
static inline
|
static inline
|
||||||
void
|
void
|
||||||
IntMakeCurrent(HGLRC hglrc, HDC hdc, struct wgl_dc_data* dc_data)
|
IntMakeCurrent(HGLRC hglrc, HDC hdc, struct wgl_dc_data* dc_data)
|
||||||
{
|
{
|
||||||
struct Opengl32_ThreadData* thread_data = TlsGetValue(OglTlsIndex);
|
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->hglrc = hglrc;
|
||||||
thread_data->hdc = hdc;
|
thread_data->hdc = hdc;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue