mirror of
https://github.com/reactos/reactos.git
synced 2025-05-29 05:58:13 +00:00
[OPENGL32]
- Implement storing thread data into the TEB CORE-14024
This commit is contained in:
parent
1bfbdb6123
commit
6aaf217b10
7 changed files with 437 additions and 357 deletions
|
@ -48,6 +48,7 @@
|
||||||
# endif /* _STATIC_MESA support */
|
# endif /* _STATIC_MESA support */
|
||||||
#endif /* WIN32 / CYGWIN bracket */
|
#endif /* WIN32 / CYGWIN bracket */
|
||||||
|
|
||||||
|
#define WIN32_NO_STATUS
|
||||||
|
|
||||||
#define GL_GLEXT_PROTOTYPES
|
#define GL_GLEXT_PROTOTYPES
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -48,9 +48,8 @@ DllMain(HINSTANCE hInstance, DWORD Reason, LPVOID Reserved)
|
||||||
#ifdef OPENGL32_USE_TLS
|
#ifdef OPENGL32_USE_TLS
|
||||||
if (!init_tls_data())
|
if (!init_tls_data())
|
||||||
return FALSE;
|
return FALSE;
|
||||||
#else
|
|
||||||
NtCurrentTeb()->glTable = &StubTable.glDispatchTable;
|
|
||||||
#endif // defined(OPENGL32_USE_TLS)
|
#endif // defined(OPENGL32_USE_TLS)
|
||||||
|
IntSetCurrentDispatchTable(&StubTable.glDispatchTable);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DLL_THREAD_DETACH:
|
case DLL_THREAD_DETACH:
|
||||||
|
|
|
@ -7,9 +7,11 @@
|
||||||
|
|
||||||
/* X86 opengl API entry points, fast forward to the current thread's dispatch table */
|
/* X86 opengl API entry points, fast forward to the current thread's dispatch table */
|
||||||
#include <asm.inc>
|
#include <asm.inc>
|
||||||
|
#include <ks386.inc>
|
||||||
|
|
||||||
.code
|
.code
|
||||||
|
|
||||||
|
#ifdef OPENG32_USE_TLS
|
||||||
EXTERN _OglTlsIndex:DWORD
|
EXTERN _OglTlsIndex:DWORD
|
||||||
EXTERN _TlsGetValue@4:PROC
|
EXTERN _TlsGetValue@4:PROC
|
||||||
|
|
||||||
|
@ -22,6 +24,23 @@ PUBLIC _gl&name&@&stack
|
||||||
jmp dword ptr [eax+4*VAL(offset)]
|
jmp dword ptr [eax+4*VAL(offset)]
|
||||||
.ENDP
|
.ENDP
|
||||||
ENDM
|
ENDM
|
||||||
|
#else
|
||||||
|
MACRO(USE_GL_FUNC, name, offset, stack)
|
||||||
|
EXTERN _nop_&name@&stack:PROC
|
||||||
|
PUBLIC _gl&name&@&stack
|
||||||
|
.PROC _gl&name&@&stack
|
||||||
|
/* Get the TEB */
|
||||||
|
mov eax, fs:[TEB_SELF]
|
||||||
|
/* Get the GL table */
|
||||||
|
mov eax, [eax + TEB_GL_TABLE]
|
||||||
|
/* If we don't have a dispatch table, call the nop */
|
||||||
|
test eax, eax
|
||||||
|
jz _nop_&name&@&stack
|
||||||
|
/* Jump into the ICD */
|
||||||
|
jmp dword ptr [eax+4*VAL(offset)]
|
||||||
|
.ENDP
|
||||||
|
ENDM
|
||||||
|
#endif
|
||||||
|
|
||||||
USE_GL_FUNC Accum, 213, 8
|
USE_GL_FUNC Accum, 213, 8
|
||||||
USE_GL_FUNC AlphaFunc, 240, 8
|
USE_GL_FUNC AlphaFunc, 240, 8
|
||||||
|
|
|
@ -17,6 +17,10 @@
|
||||||
#include <winddi.h>
|
#include <winddi.h>
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
|
|
||||||
|
#ifndef OPENGL32_USE_TLS
|
||||||
|
#include <pstypes.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <wine/debug.h>
|
#include <wine/debug.h>
|
||||||
|
|
||||||
#include "icd.h"
|
#include "icd.h"
|
||||||
|
@ -124,7 +128,7 @@ C_ASSERT(FIELD_OFFSET(struct Opengl32_ThreadData, glDispatchTable) == 0);
|
||||||
/* dllmain.c */
|
/* dllmain.c */
|
||||||
BOOL init_tls_data(void);
|
BOOL init_tls_data(void);
|
||||||
|
|
||||||
static inline
|
FORCEINLINE
|
||||||
void
|
void
|
||||||
IntMakeCurrent(HGLRC hglrc, HDC hdc, struct wgl_dc_data* dc_data)
|
IntMakeCurrent(HGLRC hglrc, HDC hdc, struct wgl_dc_data* dc_data)
|
||||||
{
|
{
|
||||||
|
@ -143,7 +147,7 @@ IntMakeCurrent(HGLRC hglrc, HDC hdc, struct wgl_dc_data* dc_data)
|
||||||
thread_data->dc_data = dc_data;
|
thread_data->dc_data = dc_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline
|
FORCEINLINE
|
||||||
HGLRC
|
HGLRC
|
||||||
IntGetCurrentRC(void)
|
IntGetCurrentRC(void)
|
||||||
{
|
{
|
||||||
|
@ -151,16 +155,7 @@ IntGetCurrentRC(void)
|
||||||
return data ? data->hglrc : NULL;
|
return data ? data->hglrc : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline
|
FORCEINLINE
|
||||||
DHGLRC
|
|
||||||
IntGetCurrentDHGLRC(void)
|
|
||||||
{
|
|
||||||
struct wgl_context* ctx = (struct wgl_context*)IntGetCurrentRC();
|
|
||||||
if(!ctx) return NULL;
|
|
||||||
return ctx->dhglrc;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline
|
|
||||||
HDC
|
HDC
|
||||||
IntGetCurrentDC(void)
|
IntGetCurrentDC(void)
|
||||||
{
|
{
|
||||||
|
@ -168,7 +163,7 @@ IntGetCurrentDC(void)
|
||||||
return data ? data->hdc : NULL;
|
return data ? data->hdc : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline
|
FORCEINLINE
|
||||||
struct wgl_dc_data*
|
struct wgl_dc_data*
|
||||||
IntGetCurrentDcData(void)
|
IntGetCurrentDcData(void)
|
||||||
{
|
{
|
||||||
|
@ -176,7 +171,7 @@ IntGetCurrentDcData(void)
|
||||||
return data->dc_data;
|
return data->dc_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline
|
FORCEINLINE
|
||||||
const GLDISPATCHTABLE *
|
const GLDISPATCHTABLE *
|
||||||
IntGetCurrentDispatchTable(void)
|
IntGetCurrentDispatchTable(void)
|
||||||
{
|
{
|
||||||
|
@ -184,7 +179,7 @@ IntGetCurrentDispatchTable(void)
|
||||||
return data->glDispatchTable;
|
return data->glDispatchTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline
|
FORCEINLINE
|
||||||
void
|
void
|
||||||
IntSetCurrentDispatchTable(const GLDISPATCHTABLE* table)
|
IntSetCurrentDispatchTable(const GLDISPATCHTABLE* table)
|
||||||
{
|
{
|
||||||
|
@ -192,7 +187,7 @@ IntSetCurrentDispatchTable(const GLDISPATCHTABLE* table)
|
||||||
data->glDispatchTable = table;
|
data->glDispatchTable = table;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline
|
FORCEINLINE
|
||||||
void
|
void
|
||||||
IntSetCurrentICDPrivate(void* value)
|
IntSetCurrentICDPrivate(void* value)
|
||||||
{
|
{
|
||||||
|
@ -200,7 +195,7 @@ IntSetCurrentICDPrivate(void* value)
|
||||||
data->icdData = value;
|
data->icdData = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline
|
FORCEINLINE
|
||||||
void*
|
void*
|
||||||
IntGetCurrentICDPrivate(void)
|
IntGetCurrentICDPrivate(void)
|
||||||
{
|
{
|
||||||
|
@ -210,14 +205,77 @@ IntGetCurrentICDPrivate(void)
|
||||||
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
static inline
|
FORCEINLINE
|
||||||
const GLDISPATCHTABLE*
|
const GLDISPATCHTABLE*
|
||||||
IntGetCurrentDispatchTable(void)
|
IntGetCurrentDispatchTable(void)
|
||||||
{
|
{
|
||||||
return (GLDISPATCHTABLE*)NtCurrentTeb()->glTable;
|
return (GLDISPATCHTABLE*)NtCurrentTeb()->glTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FORCEINLINE
|
||||||
|
void
|
||||||
|
IntSetCurrentDispatchTable(const GLDISPATCHTABLE* table)
|
||||||
|
{
|
||||||
|
NtCurrentTeb()->glTable = (void*)table;
|
||||||
|
}
|
||||||
|
|
||||||
|
FORCEINLINE
|
||||||
|
void
|
||||||
|
IntMakeCurrent(HGLRC hglrc, HDC hdc, struct wgl_dc_data* dc_data)
|
||||||
|
{
|
||||||
|
TEB* CurrentTeb = NtCurrentTeb();
|
||||||
|
|
||||||
|
CurrentTeb->glCurrentRC = hglrc;
|
||||||
|
CurrentTeb->glReserved2 = hdc;
|
||||||
|
CurrentTeb->glContext = dc_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
FORCEINLINE
|
||||||
|
HGLRC
|
||||||
|
IntGetCurrentRC(void)
|
||||||
|
{
|
||||||
|
return NtCurrentTeb()->glCurrentRC;
|
||||||
|
}
|
||||||
|
|
||||||
|
FORCEINLINE
|
||||||
|
HDC
|
||||||
|
IntGetCurrentDC(void)
|
||||||
|
{
|
||||||
|
return NtCurrentTeb()->glReserved2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline
|
||||||
|
struct wgl_dc_data*
|
||||||
|
IntGetCurrentDcData(void)
|
||||||
|
{
|
||||||
|
return NtCurrentTeb()->glContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
FORCEINLINE
|
||||||
|
void
|
||||||
|
IntSetCurrentICDPrivate(void* value)
|
||||||
|
{
|
||||||
|
NtCurrentTeb()->glReserved1[0] = (ULONG_PTR)value;
|
||||||
|
}
|
||||||
|
|
||||||
|
FORCEINLINE
|
||||||
|
void*
|
||||||
|
IntGetCurrentICDPrivate(void)
|
||||||
|
{
|
||||||
|
return (void*)NtCurrentTeb()->glReserved1[0];
|
||||||
|
}
|
||||||
|
|
||||||
#endif // defined(OPENGL32_USE_TLS)
|
#endif // defined(OPENGL32_USE_TLS)
|
||||||
|
|
||||||
|
FORCEINLINE
|
||||||
|
DHGLRC
|
||||||
|
IntGetCurrentDHGLRC(void)
|
||||||
|
{
|
||||||
|
struct wgl_context* ctx = (struct wgl_context*)IntGetCurrentRC();
|
||||||
|
if(!ctx) return NULL;
|
||||||
|
return ctx->dhglrc;
|
||||||
|
}
|
||||||
|
|
||||||
/* Software implementation functions */
|
/* Software implementation functions */
|
||||||
INT sw_DescribePixelFormat(HDC hdc, INT format, UINT size, PIXELFORMATDESCRIPTOR* descr);
|
INT sw_DescribePixelFormat(HDC hdc, INT format, UINT size, PIXELFORMATDESCRIPTOR* descr);
|
||||||
BOOL sw_SetPixelFormat(HDC hdc, struct wgl_dc_data*, INT format);
|
BOOL sw_SetPixelFormat(HDC hdc, struct wgl_dc_data*, INT format);
|
||||||
|
|
|
@ -736,6 +736,7 @@ OFFSET(TEB_SELF, TEB, NtTib.Self),
|
||||||
OFFSET(TEB_PEB, TEB, ProcessEnvironmentBlock),
|
OFFSET(TEB_PEB, TEB, ProcessEnvironmentBlock),
|
||||||
OFFSET(TEB_EXCEPTION_CODE, TEB, ExceptionCode),
|
OFFSET(TEB_EXCEPTION_CODE, TEB, ExceptionCode),
|
||||||
OFFSET(TEB_ACTIVATION_CONTEXT_STACK_POINTER, TEB, ActivationContextStackPointer),
|
OFFSET(TEB_ACTIVATION_CONTEXT_STACK_POINTER, TEB, ActivationContextStackPointer),
|
||||||
|
OFFSET(TEB_GL_TABLE, TEB, glTable),
|
||||||
OFFSET(TEB_DEALLOCATION_STACK, TEB, DeallocationStack),
|
OFFSET(TEB_DEALLOCATION_STACK, TEB, DeallocationStack),
|
||||||
OFFSET(TEB_GDI_BATCH_COUNT, TEB, GdiBatchCount),
|
OFFSET(TEB_GDI_BATCH_COUNT, TEB, GdiBatchCount),
|
||||||
OFFSET(TEB_GUARANTEED_STACK_BYTES, TEB, GuaranteedStackBytes),
|
OFFSET(TEB_GUARANTEED_STACK_BYTES, TEB, GuaranteedStackBytes),
|
||||||
|
|
|
@ -414,6 +414,7 @@ Author:
|
||||||
#define TEB_PEB 0x30
|
#define TEB_PEB 0x30
|
||||||
#define TEB_EXCEPTION_CODE 0x1A4
|
#define TEB_EXCEPTION_CODE 0x1A4
|
||||||
#define TEB_ACTIVATION_CONTEXT_STACK_POINTER 0x1A8
|
#define TEB_ACTIVATION_CONTEXT_STACK_POINTER 0x1A8
|
||||||
|
#define TEB_GL_TABLE 0xBE8
|
||||||
#define TEB_DEALLOCATION_STACK 0xE0C
|
#define TEB_DEALLOCATION_STACK 0xE0C
|
||||||
#define TEB_GDI_BATCH_COUNT 0xF70
|
#define TEB_GDI_BATCH_COUNT 0xF70
|
||||||
#define TEB_GUARANTEED_STACK_BYTES 0xF78
|
#define TEB_GUARANTEED_STACK_BYTES 0xF78
|
||||||
|
|
Loading…
Reference in a new issue